3 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include <Elementary.h>
9 * @defgroup WebView WebView
14 typedef struct _Widget_Data Widget_Data;
21 static const char *widtype = NULL;
22 static void _del_hook(Evas_Object *obj);
23 static void _sizing_eval(Evas_Object *obj);
24 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
25 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
28 _del_pre_hook(Evas_Object *obj)
30 Widget_Data *wd = elm_widget_data_get(obj);
32 /*evas_object_event_callback_del_full
33 (wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
34 evas_object_box_remove_all(wd->box, 0);
39 _del_hook(Evas_Object *obj)
41 Widget_Data *wd = elm_widget_data_get(obj);
43 //_els_webview_del(wd->webkit);
48 _sizing_eval(Evas_Object *obj)
51 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
52 printf("sizing eval : %d, %d\n", w, h);
53 //evas_object_resize(obj, w, h);
57 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
63 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
69 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
71 Widget_Data *wd = data;
73 //_els_box_layout(o, priv, wd->horizontal, wd->homogeneous);
77 * Add a new box to the parent
79 * @param parent The parent object
80 * @return The new object or NULL if it cannot be created
86 elm_webview_add(Evas_Object *parent, Eina_Bool tiled)
92 wd = ELM_NEW(Widget_Data);
93 e = evas_object_evas_get(parent);
94 obj = elm_widget_add(e);
95 ELM_SET_WIDTYPE(widtype, "webview");
96 elm_widget_type_set(obj, "webview");
97 elm_widget_sub_object_add(parent, obj);
98 elm_widget_data_set(obj, wd);
99 elm_widget_del_hook_set(obj, _del_hook);
101 wd->webkit = _elm_smart_webview_add(e, tiled);
102 _elm_smart_webview_widget_set(wd->webkit, obj);
103 //TODO:evas_object_box_layout_set(wd->box, _layout, wd, NULL);
104 evas_object_event_callback_add(wd->webkit, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
105 _changed_size_hints, obj);
107 elm_widget_resize_object_set(obj, wd->webkit);
108 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
113 elm_webview_webkit_get(Evas_Object *obj)
115 Widget_Data *wd = elm_widget_data_get(obj);
121 elm_webview_events_feed_set(Evas_Object *obj, Eina_Bool feed)
123 Widget_Data *wd = elm_widget_data_get(obj);
125 _elm_smart_webview_events_feed_set(wd->webkit, feed);
129 elm_webview_events_feed_get(Evas_Object *obj)
131 Widget_Data *wd = elm_widget_data_get(obj);
132 if (!wd) return EINA_FALSE;
133 return _elm_smart_webview_events_feed_get(wd->webkit);
137 elm_webview_auto_fitting_set(Evas_Object *obj, Eina_Bool enable)
139 Widget_Data *wd = elm_widget_data_get(obj);
141 _elm_smart_webview_auto_fitting_set(wd->webkit, enable);
145 elm_webview_auto_fitting_get(Evas_Object *obj)
147 Widget_Data *wd = elm_widget_data_get(obj);
148 if (!wd) return EINA_FALSE;
149 return _elm_smart_webview_auto_fitting_get(wd->webkit);
153 elm_webview_minimap_get(Evas_Object *obj)
155 Widget_Data *wd = elm_widget_data_get(obj);
156 if (!wd) return EINA_FALSE;
157 return _elm_smart_webview_minimap_get(wd->webkit);
161 elm_webview_uri_set(Evas_Object *obj, const char *uri)
163 Widget_Data *wd = elm_widget_data_get(obj);
165 _elm_smart_webview_uri_set(wd->webkit, uri);
169 * Set bouncing behavior(Not supported yet)
171 * When scrolling, the WebView may "bounce" when reaching an edge of contents
172 * This is a visual way to indicate the end has been reached. This is enabled
173 * by default for both axes. This will set if it is enabled for that axis with
174 * the boolean parameers for each axis.
176 * @param obj The WebView object
177 * @param h_bounce Will the WebView bounce horizontally or not
178 * @param v_bounce Will the WebView bounce vertically or not
183 elm_webview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
185 Widget_Data *wd = elm_widget_data_get(obj);
187 _elm_smart_webview_bounce_allow_set(wd->webkit, h_bounce, v_bounce);
191 * Add callback to treat mime type
193 * When user click link, the WebView may have different action by mime type.
194 * This is a way to choose proper action each mime type.
196 * @param obj The WebView object
197 * @param mime mime type string
198 * @param mime_callback callback when user choose link which involved @mime
203 elm_webview_mime_callback_set(Evas_Object *obj, const char *mime, Elm_WebView_Mime_Cb func)
205 Widget_Data *wd = elm_widget_data_get(obj);
207 _elm_smart_webview_mime_callback_set(wd->webkit, mime, func);
211 * Set default layout width
213 * If you want to load webpage with specific layout width, you can set it using this API.
214 * If you do not set it, the default layout width will be 1024.
216 * @param obj Webview object
217 * @param width width size that you want to set
223 elm_webview_default_layout_width_set(Evas_Object *obj, int width)
225 Widget_Data *wd = elm_widget_data_get(obj);
227 _elm_smart_webview_default_layout_width_set(wd->webkit, width);