1 #include <Elementary.h>
3 #include "elm_widget_web.h"
5 #if defined(HAVE_ELEMENTARY_WEB) && defined(USE_WEBKIT2)
8 EAPI const char ELM_WEB_SMART_NAME[] = "elm_web";
10 static Ewk_View_Smart_Class _ewk_view_parent_sc =
11 EWK_VIEW_SMART_CLASS_INIT_NULL;
13 static const Evas_Smart_Cb_Description _elm_web_smart_callbacks[] = {
14 { "url,changed", "s" },
18 EVAS_SMART_SUBCLASS_NEW
19 (ELM_WEB_SMART_NAME, _elm_web, Elm_Web_Smart_Class, Elm_Widget_Smart_Class,
20 elm_widget_smart_class_get, _elm_web_smart_callbacks);
23 _view_smart_add(Evas_Object *obj)
27 sd = calloc(1, sizeof(View_Smart_Data));
28 evas_object_smart_data_set(obj, sd);
30 _ewk_view_parent_sc.sc.add(obj);
34 _view_smart_del(Evas_Object *obj)
36 _ewk_view_parent_sc.sc.del(obj);
40 * Creates a new view object given the parent.
42 * @param parent object to use as parent.
44 * @return newly added Evas_Object or @c NULL on errors.
47 _view_add(Evas_Object *parent)
49 Evas *canvas = evas_object_evas_get(parent);
50 static Evas_Smart *smart = NULL;
55 static Ewk_View_Smart_Class api =
56 EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("EWK_View_Elementary");
58 ewk_view_smart_class_set(&api);
59 ewk_view_smart_class_set(&_ewk_view_parent_sc);
61 // TODO: check every api method and provide overrides with hooks!
62 // TODO: hooks should provide extension points
63 // TODO: extension should have some kind of "default implementation",
64 // TODO: that can be replaced or controlled by hooks.
65 // TODO: ie: run_javascript_alert() should present an elm_win
66 // TODO: by default, but user could override it to show as inwin.
67 api.sc.add = _view_smart_add;
68 api.sc.del = _view_smart_del;
70 smart = evas_smart_class_new(&api.sc);
73 CRITICAL("Could not create smart class");
78 view = ewk_view_smart_add(canvas, smart, ewk_context_default_get());
81 ERR("Could not create smart object object for view");
88 static int _elm_need_web = 0;
93 if (_elm_need_web++) return EINA_TRUE;
99 _elm_web_smart_add(Evas_Object *obj)
101 EVAS_SMART_DATA_ALLOC(obj, Elm_Web_Smart_Data);
103 ELM_WIDGET_DATA(priv)->resize_obj = _view_add(obj);
105 _elm_web_parent_sc->base.add(obj);
107 elm_widget_can_focus_set(obj, EINA_TRUE);
111 _elm_web_smart_del(Evas_Object *obj)
113 _elm_web_parent_sc->base.del(obj); /* handles freeing sd */
117 _elm_web_smart_set_user(Elm_Web_Smart_Class *sc)
119 ELM_WIDGET_CLASS(sc)->base.add = _elm_web_smart_add;
120 ELM_WIDGET_CLASS(sc)->base.del = _elm_web_smart_del;
123 EAPI const Elm_Web_Smart_Class *
124 elm_web_smart_class_get(void)
126 static Elm_Web_Smart_Class _sc =
127 ELM_WEB_SMART_CLASS_INIT_NAME_VERSION(ELM_WEB_SMART_NAME);
128 static const Elm_Web_Smart_Class *class = NULL;
129 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
131 if (class) return class;
133 _elm_web_smart_set(&_sc);
134 esc->callbacks = _elm_web_smart_callbacks;
141 elm_web_add(Evas_Object *parent)
145 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
147 obj = elm_widget_add(_elm_web_smart_class_new(), parent);
148 if (!obj) return NULL;
150 if (!elm_widget_sub_object_add(parent, obj))
151 ERR("could not add %p as sub object of %p", obj, parent);
157 elm_web_webkit_view_get(const Evas_Object *obj)
159 ELM_WEB_CHECK(obj) NULL;
161 ELM_WEB_DATA_GET(obj, sd);
163 return ELM_WIDGET_DATA(sd)->resize_obj;
167 elm_web_window_create_hook_set(Evas_Object *obj,
168 Elm_Web_Window_Open func,
178 elm_web_dialog_alert_hook_set(Evas_Object *obj,
179 Elm_Web_Dialog_Alert func,
189 elm_web_dialog_confirm_hook_set(Evas_Object *obj,
190 Elm_Web_Dialog_Confirm func,
200 elm_web_dialog_prompt_hook_set(Evas_Object *obj,
201 Elm_Web_Dialog_Prompt func,
211 elm_web_dialog_file_selector_hook_set(Evas_Object *obj,
212 Elm_Web_Dialog_File_Selector func,
222 elm_web_console_message_hook_set(Evas_Object *obj,
223 Elm_Web_Console_Message func,
233 elm_web_useragent_set(Evas_Object *obj,
234 const char *user_agent)
238 // FIXME : need to implement
243 elm_web_useragent_get(const Evas_Object *obj)
245 ELM_WEB_CHECK(obj) NULL;
247 // FIXME : need to implement
252 elm_web_uri_set(Evas_Object *obj,
255 ELM_WEB_CHECK(obj) EINA_FALSE;
257 ELM_WEB_DATA_GET(obj, sd);
259 return ewk_view_url_set(ELM_WIDGET_DATA(sd)->resize_obj, uri);
263 elm_web_uri_get(const Evas_Object *obj)
265 ELM_WEB_CHECK(obj) NULL;
267 ELM_WEB_DATA_GET(obj, sd);
269 return ewk_view_url_get(ELM_WIDGET_DATA(sd)->resize_obj);
273 elm_web_title_get(const Evas_Object *obj)
275 ELM_WEB_CHECK(obj) NULL;
277 ELM_WEB_DATA_GET(obj, sd);
279 return ewk_view_title_get(ELM_WIDGET_DATA(sd)->resize_obj);
283 elm_web_bg_color_set(Evas_Object *obj,
298 elm_web_bg_color_get(const Evas_Object *obj,
313 elm_web_selection_get(const Evas_Object *obj)
315 ELM_WEB_CHECK(obj) NULL;
321 elm_web_popup_selected_set(Evas_Object *obj,
330 elm_web_popup_destroy(Evas_Object *obj)
332 ELM_WEB_CHECK(obj) EINA_FALSE;
338 elm_web_text_search(const Evas_Object *obj,
340 Eina_Bool case_sensitive,
344 ELM_WEB_CHECK(obj) EINA_FALSE;
347 (void)case_sensitive;
354 elm_web_text_matches_mark(Evas_Object *obj,
356 Eina_Bool case_sensitive,
360 ELM_WEB_CHECK(obj) 0;
363 (void)case_sensitive;
370 elm_web_text_matches_unmark_all(Evas_Object *obj)
372 ELM_WEB_CHECK(obj) EINA_FALSE;
378 elm_web_text_matches_highlight_set(Evas_Object *obj,
381 ELM_WEB_CHECK(obj) EINA_FALSE;
388 elm_web_text_matches_highlight_get(const Evas_Object *obj)
390 ELM_WEB_CHECK(obj) EINA_FALSE;
396 elm_web_load_progress_get(const Evas_Object *obj)
398 ELM_WEB_CHECK(obj) - 1.0;
404 elm_web_stop(Evas_Object *obj)
406 ELM_WEB_CHECK(obj) EINA_FALSE;
412 elm_web_reload(Evas_Object *obj)
414 ELM_WEB_CHECK(obj) EINA_FALSE;
420 elm_web_reload_full(Evas_Object *obj)
422 ELM_WEB_CHECK(obj) EINA_FALSE;
428 elm_web_back(Evas_Object *obj)
430 ELM_WEB_CHECK(obj) EINA_FALSE;
436 elm_web_forward(Evas_Object *obj)
438 ELM_WEB_CHECK(obj) EINA_FALSE;
444 elm_web_navigate(Evas_Object *obj,
447 ELM_WEB_CHECK(obj) EINA_FALSE;
454 elm_web_back_possible_get(Evas_Object *obj)
456 ELM_WEB_CHECK(obj) EINA_FALSE;
462 elm_web_forward_possible_get(Evas_Object *obj)
464 ELM_WEB_CHECK(obj) EINA_FALSE;
470 elm_web_navigate_possible_get(Evas_Object *obj,
473 ELM_WEB_CHECK(obj) EINA_FALSE;
480 elm_web_history_enabled_get(const Evas_Object *obj)
482 ELM_WEB_CHECK(obj) EINA_FALSE;
488 elm_web_history_enabled_set(Evas_Object *obj,
497 elm_web_zoom_set(Evas_Object *obj,
506 elm_web_zoom_get(const Evas_Object *obj)
508 ELM_WEB_CHECK(obj) - 1.0;
514 elm_web_zoom_mode_set(Evas_Object *obj,
515 Elm_Web_Zoom_Mode mode)
522 EAPI Elm_Web_Zoom_Mode
523 elm_web_zoom_mode_get(const Evas_Object *obj)
525 ELM_WEB_CHECK(obj) ELM_WEB_ZOOM_MODE_LAST;
527 return ELM_WEB_ZOOM_MODE_LAST;
531 elm_web_region_show(Evas_Object *obj,
544 elm_web_region_bring_in(Evas_Object *obj,
557 elm_web_inwin_mode_set(Evas_Object *obj,
566 elm_web_inwin_mode_get(const Evas_Object *obj)
568 ELM_WEB_CHECK(obj) EINA_FALSE;
574 elm_web_window_features_ref(Elm_Web_Window_Features *wf)
576 // FIXME : need to implement
581 elm_web_window_features_unref(Elm_Web_Window_Features *wf)
583 // FIXME : need to implement
588 elm_web_window_features_property_get(const Elm_Web_Window_Features *wf,
589 Elm_Web_Window_Feature_Flag flag)
591 // FIXME : need to implement
598 elm_web_window_features_region_get(const Elm_Web_Window_Features *wf,
604 // FIXME : need to implement