| 32 #include "webview.h" |
32 #include "webview.h" |
| 33 |
33 |
| 34 #ifdef UI_WEBVIEW |
34 #ifdef UI_WEBVIEW |
| 35 |
35 |
| 36 UIWIDGET ui_webview_create(UiObject *obj, UiWebviewArgs *args) { |
36 UIWIDGET ui_webview_create(UiObject *obj, UiWebviewArgs *args) { |
| 37 UiObject* current = uic_current_obj(obj); |
|
| 38 |
|
| 39 GtkWidget *webview = webkit_web_view_new(); |
37 GtkWidget *webview = webkit_web_view_new(); |
| 40 |
38 |
| 41 ui_set_name_and_style(webview, args->name, args->style_class); |
39 ui_set_name_and_style(webview, args->name, args->style_class); |
| 42 |
40 |
| 43 UiVar *var = uic_widget_var(obj->ctx, current->ctx, args->value, args->varname, UI_VAR_GENERIC); |
41 UiVar *var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_GENERIC); |
| 44 if(var) { |
42 if(var) { |
| 45 WebViewData *data = malloc(sizeof(WebViewData)); |
43 WebViewData *data = malloc(sizeof(WebViewData)); |
| 46 memset(data, 0, sizeof(WebViewData)); |
44 memset(data, 0, sizeof(WebViewData)); |
| 47 data->webview = WEBKIT_WEB_VIEW(webview); |
45 data->webview = WEBKIT_WEB_VIEW(webview); |
| 48 WebKitSettings *settings = webkit_web_view_get_settings(data->webview); |
46 WebKitSettings *settings = webkit_web_view_get_settings(data->webview); |
| 58 ui_webview_set(value, value->value, UI_WEBVIEW_OBJECT_TYPE); |
56 ui_webview_set(value, value->value, UI_WEBVIEW_OBJECT_TYPE); |
| 59 } |
57 } |
| 60 } |
58 } |
| 61 |
59 |
| 62 ui_set_widget_groups(obj->ctx, webview, args->groups); |
60 ui_set_widget_groups(obj->ctx, webview, args->groups); |
| 63 UI_APPLY_LAYOUT2(current, args); |
61 UiContainerPrivate *ct = (UiContainerPrivate*)obj->container_end; |
| 64 current->container->add(current->container, webview); |
62 UiLayout layout = UI_ARGS2LAYOUT(args); |
| |
63 ct->add(ct, webview, &layout); |
| 65 |
64 |
| 66 return webview; |
65 return webview; |
| 67 } |
66 } |
| 68 |
67 |
| 69 void* ui_webview_get(UiGeneric *g) { |
68 void* ui_webview_get(UiGeneric *g) { |
| 95 GBytes *bytes = g_bytes_new(data->content, data->contentlength); |
94 GBytes *bytes = g_bytes_new(data->content, data->contentlength); |
| 96 webkit_web_view_load_bytes(obj->webview, bytes, data->mimetype, data->encoding, data->uri); |
95 webkit_web_view_load_bytes(obj->webview, bytes, data->mimetype, data->encoding, data->uri); |
| 97 } |
96 } |
| 98 |
97 |
| 99 ui_webview_enable_javascript(g, data->javascript); |
98 ui_webview_enable_javascript(g, data->javascript); |
| 100 webkit_web_view_set_zoom_level(data->webview, data->zoom); |
99 ui_webview_set_zoom(g, data->zoom); |
| 101 |
100 |
| 102 return 0; |
101 return 0; |
| 103 } |
102 } |
| 104 |
103 |
| 105 void ui_webview_load_url(UiGeneric *g, const char *url) { |
104 void ui_webview_load_url(UiGeneric *g, const char *url) { |