summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--legacy/elementary/configure.ac33
-rw-r--r--legacy/elementary/doc/Makefile.am3
-rw-r--r--legacy/elementary/doc/index.doxy4
-rw-r--r--legacy/elementary/doc/widgets/Makefile.am4
-rw-r--r--legacy/elementary/doc/widgets/widget_preview_web.c12
-rw-r--r--legacy/elementary/src/bin/Makefile.am11
-rw-r--r--legacy/elementary/src/bin/test.c8
-rw-r--r--legacy/elementary/src/bin/test_web.c370
-rw-r--r--legacy/elementary/src/lib/Elementary.h.in800
-rw-r--r--legacy/elementary/src/lib/Makefile.am3
-rw-r--r--legacy/elementary/src/lib/elm_main.c1
-rw-r--r--legacy/elementary/src/lib/elm_priv.h1
-rw-r--r--legacy/elementary/src/lib/elm_web.c1566
13 files changed, 2811 insertions, 5 deletions
diff --git a/legacy/elementary/configure.ac b/legacy/elementary/configure.ac
index c06bdf5e9c..7247235353 100644
--- a/legacy/elementary/configure.ac
+++ b/legacy/elementary/configure.ac
@@ -511,6 +511,38 @@ if test "x$want_elementary_ethumb" = "xyes" -a "x$have_elementary_ethumb" = "xno
511fi 511fi
512AC_SUBST(ELM_ETHUMB_DEF) 512AC_SUBST(ELM_ETHUMB_DEF)
513 513
514ELM_WEB_DEF="#undef"
515have_elementary_web="no"
516want_elementary_web="auto"
517AC_ARG_ENABLE([web],
518 [AC_HELP_STRING([--disable-web], [disable web (WebKit) support. @<:@default=detect@:>@])],
519 [want_elementary_web=$enableval], [])
520
521if test "x$want_elementary_web" != "xno"; then
522 PKG_CHECK_MODULES([ELEMENTARY_WEB],
523 [
524 ewebkit
525 ],
526 [
527 AC_DEFINE(HAVE_ELEMENTARY_WEB, 1, [Web support for Elementary])
528 webkit_datadir=$($PKG_CONFIG ewebkit --variable=datadir)
529 AC_DEFINE_UNQUOTED(WEBKIT_DATADIR,
530 "$webkit_datadir",
531 "WebKit's data dir")
532 have_elementary_web="yes"
533 ELM_WEB_DEF="#define"
534 requirement_elm="web_client ${requirement_elm}"
535 ],
536 [have_elementary_web="no"]
537 )
538else
539 have_elementary_web="no"
540fi
541if test "x$want_elementary_web" = "xyes" -a "x$have_elementary_web" = "xno"; then
542 AC_MSG_ERROR([Web support requested, but no ewebkit found by pkg-config.])
543fi
544AC_SUBST(ELM_WEB_DEF)
545
514ELM_DEBUG_DEF="#undef" 546ELM_DEBUG_DEF="#undef"
515want_elementary_debug="no" 547want_elementary_debug="no"
516AC_ARG_ENABLE([debug], 548AC_ARG_ENABLE([debug],
@@ -625,6 +657,7 @@ echo " EFreet.................: ${have_elementary_efreet}"
625echo " EWeather...............: ${have_elementary_eweather}" 657echo " EWeather...............: ${have_elementary_eweather}"
626echo " EMap...................: ${have_elementary_emap}" 658echo " EMap...................: ${have_elementary_emap}"
627echo " Ethumb.................: ${have_elementary_ethumb}" 659echo " Ethumb.................: ${have_elementary_ethumb}"
660echo " Web (WebKit)...........: ${have_elementary_web}"
628echo " Quick Launch...........: ${have_fork}" 661echo " Quick Launch...........: ${have_fork}"
629echo " EIO....................: ${have_eio}" 662echo " EIO....................: ${have_eio}"
630echo " Emotion................: ${have_emotion}" 663echo " Emotion................: ${have_emotion}"
diff --git a/legacy/elementary/doc/Makefile.am b/legacy/elementary/doc/Makefile.am
index f304a1f80b..e59ad9f5b0 100644
--- a/legacy/elementary/doc/Makefile.am
+++ b/legacy/elementary/doc/Makefile.am
@@ -80,7 +80,8 @@ WGT_PREVIEW = \
80 win:preview-00.png:widget_preview_win:200:200 \ 80 win:preview-00.png:widget_preview_win:200:200 \
81 table:preview-00.png:widget_preview_table:100:100 \ 81 table:preview-00.png:widget_preview_table:100:100 \
82 menu:preview-00.png:widget_preview_menu:100:100 \ 82 menu:preview-00.png:widget_preview_menu:100:100 \
83 thumb:preview-00.png:widget_preview_thumb:100:100 83 thumb:preview-00.png:widget_preview_thumb:100:100 \
84 web:preview-00.png:widget_preview_web:300:300
84 85
85widget-build: 86widget-build:
86 @$(MAKE) -C widgets 87 @$(MAKE) -C widgets
diff --git a/legacy/elementary/doc/index.doxy b/legacy/elementary/doc/index.doxy
index caebcd79fd..0f73202bc6 100644
--- a/legacy/elementary/doc/index.doxy
+++ b/legacy/elementary/doc/index.doxy
@@ -238,6 +238,10 @@
238 * @image latex img/toolbar.eps 238 * @image latex img/toolbar.eps
239 * @li @ref Tooltips 239 * @li @ref Tooltips
240 * @li @ref Video 240 * @li @ref Video
241 * @li @ref Web
242 *
243 * @image html img/widget/web/preview-00.png
244 * @image latex img/widget/web/preview-00.eps
241 * @li @ref Win 245 * @li @ref Win
242 * 246 *
243 * @image html img/widget/win/preview-00.png 247 * @image html img/widget/win/preview-00.png
diff --git a/legacy/elementary/doc/widgets/Makefile.am b/legacy/elementary/doc/widgets/Makefile.am
index 86343c80b9..33e02a003e 100644
--- a/legacy/elementary/doc/widgets/Makefile.am
+++ b/legacy/elementary/doc/widgets/Makefile.am
@@ -91,7 +91,8 @@ widget_preview_scroller \
91widget_preview_table \ 91widget_preview_table \
92widget_preview_win \ 92widget_preview_win \
93widget_preview_menu \ 93widget_preview_menu \
94widget_preview_thumb 94widget_preview_thumb \
95widget_preview_web
95 96
96LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@ @ELEMENTARY_EDBUS_LIBS@ @ELEMENTARY_EFREET_LIBS@ @ELEMENTARY_EMAP_LIBS@ @ELEMENTARY_LIBS@ @EIO_LIBS@ @my_libs@ 97LDADD = $(top_builddir)/src/lib/libelementary.la @ELEMENTARY_EWEATHER_LIBS@ @ELEMENTARY_EDBUS_LIBS@ @ELEMENTARY_EFREET_LIBS@ @ELEMENTARY_EMAP_LIBS@ @ELEMENTARY_LIBS@ @EIO_LIBS@ @my_libs@
97 98
@@ -168,5 +169,6 @@ EXTRA_DIST = \
168 widget_preview_win.c \ 169 widget_preview_win.c \
169 widget_preview_menu.c \ 170 widget_preview_menu.c \
170 widget_preview_thumb.c \ 171 widget_preview_thumb.c \
172 widget_preview_web.c \
171 widget_preview_tmpl_foot.c \ 173 widget_preview_tmpl_foot.c \
172 widget_preview_tmpl_head.c 174 widget_preview_tmpl_head.c
diff --git a/legacy/elementary/doc/widgets/widget_preview_web.c b/legacy/elementary/doc/widgets/widget_preview_web.c
new file mode 100644
index 0000000000..11690740da
--- /dev/null
+++ b/legacy/elementary/doc/widgets/widget_preview_web.c
@@ -0,0 +1,12 @@
1#include "widget_preview_tmpl_head.c"
2
3elm_need_web();
4
5Evas_Object *o = elm_web_add(win);
6evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
7elm_win_resize_object_add(win, o);
8evas_object_show(o);
9
10elm_web_uri_set(o, "http://www.enlightenment.org");
11
12#include "widget_preview_tmpl_foot.c"
diff --git a/legacy/elementary/src/bin/Makefile.am b/legacy/elementary/src/bin/Makefile.am
index 43fa6c3174..8833197b84 100644
--- a/legacy/elementary/src/bin/Makefile.am
+++ b/legacy/elementary/src/bin/Makefile.am
@@ -19,7 +19,8 @@ AM_CPPFLAGS = \
19@ELEMENTARY_EWEATHER_CFLAGS@ \ 19@ELEMENTARY_EWEATHER_CFLAGS@ \
20@ELEMENTARY_ETHUMB_CFLAGS@ \ 20@ELEMENTARY_ETHUMB_CFLAGS@ \
21@ELEMENTARY_EMAP_CFLAGS@ \ 21@ELEMENTARY_EMAP_CFLAGS@ \
22@EIO_CFLAGS@ 22@EIO_CFLAGS@ \
23@ELEMENTARY_WEB_CFLAGS@
23 24
24bin_PROGRAMS = @ELEMENTARY_TEST_PRG@ @ELEMENTARY_CONFIG_PRG@ 25bin_PROGRAMS = @ELEMENTARY_TEST_PRG@ @ELEMENTARY_CONFIG_PRG@
25if BUILD_QUICKLAUNCH 26if BUILD_QUICKLAUNCH
@@ -103,6 +104,7 @@ test_toolbar.c \
103test_tooltip.c \ 104test_tooltip.c \
104test_transit.c \ 105test_transit.c \
105test_weather.c \ 106test_weather.c \
107test_web.c \
106test_win_inline.c \ 108test_win_inline.c \
107test_win_state.c 109test_win_state.c
108 110
@@ -117,6 +119,7 @@ elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \
117 @ELEMENTARY_EMAP_LIBS@ \ 119 @ELEMENTARY_EMAP_LIBS@ \
118 @ELEMENTARY_LIBS@ \ 120 @ELEMENTARY_LIBS@ \
119 @EIO_LIBS@ \ 121 @EIO_LIBS@ \
122 @ELEMENTARY_WEB_LIBS@ \
120 @my_libs@ 123 @my_libs@
121elementary_test_LDFLAGS = 124elementary_test_LDFLAGS =
122 125
@@ -159,7 +162,8 @@ elementary_testql_LTLIBRARIES = elementary_testql.la
159elementary_testql_la_SOURCES = $(elementary_test_SOURCES) 162elementary_testql_la_SOURCES = $(elementary_test_SOURCES)
160elementary_testql_la_LIBADD = $(top_builddir)/src/lib/libelementary.la \ 163elementary_testql_la_LIBADD = $(top_builddir)/src/lib/libelementary.la \
161 @ELEMENTARY_EWEATHER_LIBS@ \ 164 @ELEMENTARY_EWEATHER_LIBS@ \
162 @EIO_LIBS@ 165 @EIO_LIBS@ \
166 @ELEMENTARY_WEB_LIBS@
163 167
164elementary_testql_la_CFLAGS = 168elementary_testql_la_CFLAGS =
165elementary_testql_la_LDFLAGS = -module -avoid-version -no-undefined 169elementary_testql_la_LDFLAGS = -module -avoid-version -no-undefined
@@ -170,7 +174,8 @@ elementary_testql_LDADD = $(top_builddir)/src/lib/libelementary.la \
170 @ELEMENTARY_EFREET_LIBS@ \ 174 @ELEMENTARY_EFREET_LIBS@ \
171 @ELEMENTARY_EMAP_LIBS@ \ 175 @ELEMENTARY_EMAP_LIBS@ \
172 @ELEMENTARY_LIBS@ \ 176 @ELEMENTARY_LIBS@ \
173 @EIO_LIBS@ 177 @EIO_LIBS@ \
178 @ELEMENTARY_WEB_LIBS@ \
174 @my_libs@ 179 @my_libs@
175 180
176elementary_testql_CFLAGS = -DELM_LIB_QUICKLAUNCH=1 181elementary_testql_CFLAGS = -DELM_LIB_QUICKLAUNCH=1
diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c
index 8bb1c42f66..3bf5f53ea4 100644
--- a/legacy/elementary/src/bin/test.c
+++ b/legacy/elementary/src/bin/test.c
@@ -147,6 +147,9 @@ void test_factory(void *data, Evas_Object *obj, void *event_info);
147#ifdef HAVE_EIO 147#ifdef HAVE_EIO
148void test_eio(void *data, Evas_Object *obj, void *event_info); 148void test_eio(void *data, Evas_Object *obj, void *event_info);
149#endif 149#endif
150#ifdef HAVE_ELEMENTARY_WEB
151void test_web(void *data, Evas_Object *obj, void *event_info);
152#endif
150 153
151struct elm_test 154struct elm_test
152{ 155{
@@ -429,6 +432,9 @@ add_tests:
429 ADD_TEST("Gesture Layer", test_gesture_layer); 432 ADD_TEST("Gesture Layer", test_gesture_layer);
430 ADD_TEST("Naviframe", test_naviframe); 433 ADD_TEST("Naviframe", test_naviframe);
431 ADD_TEST("Factory", test_factory); 434 ADD_TEST("Factory", test_factory);
435#ifdef HAVE_ELEMENTARY_WEB
436 ADD_TEST("Web", test_web);
437#endif
432#undef ADD_TEST 438#undef ADD_TEST
433 439
434 if (autorun) 440 if (autorun)
@@ -477,6 +483,8 @@ elm_main(int argc, char **argv)
477 Eina_Bool test_win_only = EINA_FALSE; 483 Eina_Bool test_win_only = EINA_FALSE;
478 char *autorun = NULL; 484 char *autorun = NULL;
479 485
486 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
487
480 /* tell elm about our app so it can figure out where to get files */ 488 /* tell elm about our app so it can figure out where to get files */
481 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); 489 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
482 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); 490 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
diff --git a/legacy/elementary/src/bin/test_web.c b/legacy/elementary/src/bin/test_web.c
new file mode 100644
index 0000000000..ebbf297c25
--- /dev/null
+++ b/legacy/elementary/src/bin/test_web.c
@@ -0,0 +1,370 @@
1#include <Elementary.h>
2#ifdef HAVE_CONFIG_H
3# include "elementary_config.h"
4#endif
5#ifndef ELM_LIB_QUICKLAUNCH
6
7typedef struct
8{
9 Evas_Object *web;
10 Evas_Object *btn_back;
11 Evas_Object *btn_fwd;
12 Evas_Object *url_entry;
13 Eina_List *sub_wins;
14 Eina_Bool js_hooks : 1;
15} Web_Test;
16
17static void
18_btn_back_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
19{
20 Evas_Object *web = data;
21
22 elm_web_back(web);
23}
24
25static void
26_btn_fwd_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
27{
28 Evas_Object *web = data;
29
30 elm_web_forward(web);
31}
32
33static void
34_btn_reload_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
35{
36 Evas_Object *web = data;
37
38 elm_web_reload(web);
39}
40
41static void
42_url_change_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
43{
44 Evas_Object *web = data;
45 const char *uri = elm_object_text_get(obj);
46
47 elm_web_uri_set(web, uri);
48}
49
50static void
51_toggle_inwin_mode_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
52{
53 elm_web_inwin_mode_set(data, !elm_web_inwin_mode_get(data));
54}
55
56static void
57_title_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
58{
59 char buf[512];
60 snprintf(buf, sizeof(buf), "Web - %s", (const char *)event_info);
61 elm_win_title_set(data, buf);
62}
63
64static void
65_uri_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
66{
67 Web_Test *wt = data;
68
69 elm_entry_entry_set(wt->url_entry, event_info);
70
71 elm_object_disabled_set(wt->btn_back, !elm_web_back_possible(wt->web));
72 elm_object_disabled_set(wt->btn_fwd, !elm_web_forward_possible(wt->web));
73}
74
75static void
76_new_win_del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
77{
78 Web_Test *wt = data;
79 wt->sub_wins = eina_list_remove(wt->sub_wins, obj);
80}
81
82static void
83_web_win_close_request_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
84{
85 evas_object_del(data);
86}
87
88static Evas_Object *
89_new_window_hook(void *data, Evas_Object *obj __UNUSED__, Eina_Bool js __UNUSED__, const Elm_Web_Window_Features *wf __UNUSED__)
90{
91 Web_Test *wt = data;
92 Evas_Object *new_win, *new_web, *bg;
93
94 new_win = elm_win_add(NULL, "elm-web-test-popup", ELM_WIN_BASIC);
95 elm_win_autodel_set(new_win, EINA_TRUE);
96 evas_object_resize(new_win, 300, 300);
97 evas_object_show(new_win);
98
99 bg = elm_bg_add(new_win);
100 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
101 elm_win_resize_object_add(new_win, bg);
102 evas_object_show(bg);
103
104 new_web = elm_web_add(new_win);
105 evas_object_size_hint_weight_set(new_web, EVAS_HINT_EXPAND,
106 EVAS_HINT_EXPAND);
107 elm_win_resize_object_add(new_win, new_web);
108 evas_object_show(new_web);
109
110 evas_object_smart_callback_add(new_win, "delete,request", _new_win_del_cb,
111 wt);
112 evas_object_smart_callback_add(new_web, "windows,close,request",
113 _web_win_close_request_cb, new_win);
114 wt->sub_wins = eina_list_append(wt->sub_wins, new_win);
115
116 return new_web;
117}
118
119static void
120_alert_del(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
121{
122 evas_object_del(obj);
123}
124
125static Evas_Object *
126_alert_hook(void *data __UNUSED__, Evas_Object *obj, const char *message)
127{
128 Evas_Object *popup, *label;
129
130 popup = elm_notify_add(obj);
131 elm_notify_orient_set(popup, ELM_NOTIFY_ORIENT_CENTER);
132 // Using the timeout doesn't seem to go well with the second main loop
133 //elm_notify_timeout_set(popup, 2.0);
134 elm_notify_repeat_events_set(popup, EINA_FALSE);
135 evas_object_show(popup);
136
137 evas_object_smart_callback_add(popup, "block,clicked", _alert_del, NULL);
138
139 label = elm_label_add(obj);
140 elm_object_text_set(label, message);
141 elm_notify_content_set(popup, label);
142 evas_object_show(label);
143
144 return popup;
145}
146
147static void
148_confirm_ok_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
149{
150 Eina_Bool *response = data;
151 *response = EINA_TRUE;
152}
153
154static void
155_confirm_cancel_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
156{
157 Eina_Bool *response = data;
158 *response = EINA_FALSE;
159}
160
161static void
162_confirm_dismiss_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
163{
164 evas_object_del(data);
165}
166
167static Evas_Object *
168_confirm_hook(void *data __UNUSED__, Evas_Object *obj, const char *message, Eina_Bool *response)
169{
170 Evas_Object *popup, *box, *box2, *label, *btn_ok, *btn_cancel;
171
172 popup = elm_notify_add(obj);
173 elm_notify_orient_set(popup, ELM_NOTIFY_ORIENT_CENTER);
174 elm_notify_repeat_events_set(popup, EINA_FALSE);
175 evas_object_show(popup);
176
177 box = elm_box_add(obj);
178 elm_notify_content_set(popup, box);
179 evas_object_show(box);
180
181 label = elm_label_add(obj);
182 elm_object_text_set(label, message);
183 elm_box_pack_end(box, label);
184 evas_object_show(label);
185
186 box2 = elm_box_add(obj);
187 elm_box_horizontal_set(box2, EINA_TRUE);
188 elm_box_pack_end(box, box2);
189 evas_object_show(box2);
190
191 btn_ok = elm_button_add(obj);
192 elm_object_text_set(btn_ok, "Ok");
193 elm_box_pack_end(box2, btn_ok);
194 evas_object_show(btn_ok);
195
196 btn_cancel = elm_button_add(obj);
197 elm_object_text_set(btn_cancel, "Cancel");
198 elm_box_pack_end(box2, btn_cancel);
199 evas_object_show(btn_cancel);
200
201 evas_object_smart_callback_add(btn_ok, "clicked", _confirm_dismiss_cb,
202 popup);
203 evas_object_smart_callback_add(btn_cancel, "clicked", _confirm_dismiss_cb,
204 popup);
205 evas_object_smart_callback_add(btn_ok, "clicked", _confirm_ok_cb, response);
206 evas_object_smart_callback_add(btn_cancel, "clicked", _confirm_cancel_cb,
207 response);
208
209 return popup;
210}
211
212static Evas_Object *
213_prompt_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *message __UNUSED__, const char *default_value, char **value, Eina_Bool *response)
214{
215 *response = EINA_TRUE;
216 *value = default_value ? strdup(default_value) : "No default!";
217 return NULL;
218}
219
220static Evas_Object *
221_file_selector_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Eina_Bool allow_multiple __UNUSED__, const char *accept_types __UNUSED__, Eina_List **selected_files, Eina_Bool *response)
222{
223 *selected_files = eina_list_append(NULL,
224 strdup("/path/to/non_existing_file"));
225 *response = EINA_TRUE;
226 return NULL;
227}
228
229static void
230_js_popup_hooks_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
231{
232 Web_Test *wt = data;
233
234 wt->js_hooks = !wt->js_hooks;
235 if (wt->js_hooks)
236 {
237 elm_web_dialog_alert_hook_set(wt->web, _alert_hook, NULL);
238 elm_web_dialog_confirm_hook_set(wt->web, _confirm_hook, NULL);
239 elm_web_dialog_prompt_hook_set(wt->web, _prompt_hook, NULL);
240 elm_web_dialog_file_selector_hook_set(wt->web, _file_selector_hook,
241 NULL);
242 }
243 else
244 {
245 elm_web_dialog_alert_hook_set(wt->web, NULL, NULL);
246 elm_web_dialog_confirm_hook_set(wt->web, NULL, NULL);
247 elm_web_dialog_prompt_hook_set(wt->web, NULL, NULL);
248 elm_web_dialog_file_selector_hook_set(wt->web, NULL, NULL);
249 }
250}
251
252static void
253_main_web_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
254{
255 Web_Test *wt = data;
256 Evas_Object *sub_win;
257
258 EINA_LIST_FREE(wt->sub_wins, sub_win)
259 evas_object_del(sub_win);
260
261 free(wt);
262}
263
264void
265test_web(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
266{
267 Evas_Object *win, *bg, *bx, *bx2, *bt, *web, *url;
268 Web_Test *wt;
269
270 elm_need_web();
271
272 wt = calloc(1, sizeof(*wt));
273
274 win = elm_win_add(NULL, "web", ELM_WIN_BASIC);
275 elm_win_title_set(win, "Web");
276 elm_win_autodel_set(win, EINA_TRUE);
277
278 bg = elm_bg_add(win);
279 elm_win_resize_object_add(win, bg);
280 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
281 evas_object_show(bg);
282
283 bx = elm_box_add(win);
284 elm_win_resize_object_add(win, bx);
285 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
286 evas_object_show(bx);
287
288 bx2 = elm_box_add(win);
289 elm_box_horizontal_set(bx2, EINA_TRUE);
290 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0);
291 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, 0.0);
292 elm_box_pack_end(bx, bx2);
293 evas_object_show(bx2);
294
295 web = elm_web_add(win);
296 evas_object_size_hint_weight_set(web, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
297 evas_object_size_hint_align_set(web, EVAS_HINT_FILL, EVAS_HINT_FILL);
298 elm_box_pack_end(bx, web);
299 evas_object_show(web);
300
301 bt = elm_button_add(win);
302 elm_object_text_set(bt, "<");
303 elm_box_pack_end(bx2, bt);
304 evas_object_show(bt);
305
306 evas_object_smart_callback_add(bt, "clicked", _btn_back_cb, web);
307 wt->btn_back = bt;
308
309 bt = elm_button_add(win);
310 elm_object_text_set(bt, "R");
311 elm_box_pack_end(bx2, bt);
312 evas_object_show(bt);
313
314 evas_object_smart_callback_add(bt, "clicked", _btn_reload_cb, web);
315
316 bt = elm_button_add(win);
317 elm_object_text_set(bt, ">");
318 elm_box_pack_end(bx2, bt);
319 evas_object_show(bt);
320
321 evas_object_smart_callback_add(bt, "clicked", _btn_fwd_cb, web);
322 wt->btn_fwd = bt;
323
324 url = elm_entry_add(win);
325 elm_entry_single_line_set(url, EINA_TRUE);
326 elm_entry_scrollable_set(url, EINA_TRUE);
327 evas_object_size_hint_weight_set(url, EVAS_HINT_EXPAND, 0);
328 evas_object_size_hint_align_set(url, EVAS_HINT_FILL, EVAS_HINT_FILL);
329 elm_box_pack_end(bx2, url);
330 evas_object_show(url);
331
332 evas_object_smart_callback_add(url, "activated", _url_change_cb, web);
333 wt->url_entry = url;
334
335 bx2 = elm_box_add(win);
336 elm_box_horizontal_set(bx2, EINA_TRUE);
337 evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0);
338 evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, 0);
339 elm_box_pack_end(bx, bx2);
340 evas_object_show(bx2);
341
342 bt = elm_button_add(win);
343 elm_object_text_set(bt, "Inwin Mode");
344 elm_box_pack_end(bx2, bt);
345 evas_object_show(bt);
346
347 evas_object_smart_callback_add(bt, "clicked", _toggle_inwin_mode_cb, web);
348
349 bt = elm_button_add(win);
350 elm_object_text_set(bt, "Custom Hooks");
351 elm_box_pack_end(bx2, bt);
352 evas_object_show(bt);
353
354 evas_object_smart_callback_add(bt, "clicked", _js_popup_hooks_set, wt);
355
356 evas_object_smart_callback_add(web, "title,changed", _title_changed_cb, win);
357 evas_object_smart_callback_add(web, "uri,changed", _uri_changed_cb, wt);
358
359 evas_object_event_callback_add(web, EVAS_CALLBACK_DEL, _main_web_del_cb, wt);
360
361 wt->web = web;
362
363 elm_web_uri_set(web, "http://www.enlightenment.org");
364
365 elm_web_window_create_hook_set(web, _new_window_hook, wt);
366
367 evas_object_resize(win, 320, 480);
368 evas_object_show(win);
369}
370#endif
diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in
index aa5cc0cef1..984e4a17c8 100644
--- a/legacy/elementary/src/lib/Elementary.h.in
+++ b/legacy/elementary/src/lib/Elementary.h.in
@@ -321,6 +321,7 @@ contact with the developers and maintainers.
321@ELM_EDBUS_DEF@ ELM_EDBUS 321@ELM_EDBUS_DEF@ ELM_EDBUS
322@ELM_EFREET_DEF@ ELM_EFREET 322@ELM_EFREET_DEF@ ELM_EFREET
323@ELM_ETHUMB_DEF@ ELM_ETHUMB 323@ELM_ETHUMB_DEF@ ELM_ETHUMB
324@ELM_WEB_DEF@ ELM_WEB
324@ELM_EMAP_DEF@ ELM_EMAP 325@ELM_EMAP_DEF@ ELM_EMAP
325@ELM_DEBUG_DEF@ ELM_DEBUG 326@ELM_DEBUG_DEF@ ELM_DEBUG
326@ELM_ALLOCA_H_DEF@ ELM_ALLOCA_H 327@ELM_ALLOCA_H_DEF@ ELM_ALLOCA_H
@@ -906,6 +907,14 @@ extern "C" {
906 EAPI Eina_Bool elm_need_ethumb(void); 907 EAPI Eina_Bool elm_need_ethumb(void);
907 908
908 /** 909 /**
910 * This must be called before any other function that handle with
911 * elm_web objects or ewk_view instances.
912 *
913 * @ingroup Web
914 */
915 EAPI Eina_Bool elm_need_web(void);
916
917 /**
909 * Set a new policy's value (for a given policy group/identifier). 918 * Set a new policy's value (for a given policy group/identifier).
910 * 919 *
911 * @param policy policy identifier, as in @ref Elm_Policy. 920 * @param policy policy identifier, as in @ref Elm_Policy.
@@ -12847,6 +12856,797 @@ extern "C" {
12847 */ 12856 */
12848 12857
12849 /** 12858 /**
12859 * @defgroup Web Web
12860 *
12861 * @image html img/widget/web/preview-00.png
12862 * @image latex img/widget/web/preview-00.eps
12863 *
12864 * A web object is used for displaying web pages (HTML/CSS/JS)
12865 * using WebKit-EFL. You must have compiled Elementary with
12866 * ewebkit support.
12867 *
12868 * Signals that you can add callbacks for are:
12869 * @li "download,request": A file download has been requested. Event info is
12870 * a pointer to a Elm_Web_Download
12871 * @li "editorclient,contents,changed": Editor client's contents changed
12872 * @li "editorclient,selection,changed": Editor client's selection changed
12873 * @li "frame,created": A new frame was created. Event info is an
12874 * Evas_Object which can be handled with WebKit's ewk_frame API
12875 * @li "icon,received": An icon was received by the main frame
12876 * @li "inputmethod,changed": Input method changed. Event info is an
12877 * Eina_Bool indicating whether it's enabled or not
12878 * @li "js,windowobject,clear": JS window object has been cleared
12879 * @li "link,hover,in": Mouse cursor is hovering over a link. Event info
12880 * is a char *link[2], where the first string contains the URL the link
12881 * points to, and the second one the title of the link
12882 * @li "link,hover,out": Mouse cursor left the link
12883 * @li "load,document,finished": Loading of a document finished. Event info
12884 * is the frame that finished loading
12885 * @li "load,error": Load failed. Event info is a pointer to
12886 * Elm_Web_Frame_Load_Error
12887 * @li "load,finished": Load finished. Event info is NULL on success, on
12888 * error it's a pointer to Elm_Web_Frame_Load_Error
12889 * @li "load,newwindow,show": A new window was created and is ready to be
12890 * shown
12891 * @li "load,progress": Overall load progress. Event info is a pointer to
12892 * a double containing a value between 0.0 and 1.0
12893 * @li "load,provisional": Started provisional load
12894 * @li "load,started": Loading of a document started
12895 * @li "menubar,visible,get": Queries if the menubar is visible. Event info
12896 * is a pointer to Eina_Bool where the callback should set EINA_TRUE if
12897 * the menubar is visible, or EINA_FALSE in case it's not
12898 * @li "menubar,visible,set": Informs menubar visibility. Event info is
12899 * an Eina_Bool indicating the visibility
12900 * @li "popup,created": A dropdown widget was activated, requesting its
12901 * popup menu to be created. Event info is a pointer to Elm_Web_Menu
12902 * @li "popup,willdelete": The web object is ready to destroy the popup
12903 * object created. Event info is a pointer to Elm_Web_Menu
12904 * @li "ready": Page is fully loaded
12905 * @li "scrollbars,visible,get": Queries visibility of scrollbars. Event
12906 * info is a pointer to Eina_Bool where the visibility state should be set
12907 * @li "scrollbars,visible,set": Informs scrollbars visibility. Event info
12908 * is an Eina_Bool with the visibility state set
12909 * @li "statusbar,text,set": Text of the statusbar changed. Even info is
12910 * a string with the new text
12911 * @li "statusbar,visible,get": Queries visibility of the status bar.
12912 * Event info is a pointer to Eina_Bool where the visibility state should be
12913 * set.
12914 * @li "statusbar,visible,set": Informs statusbar visibility. Event info is
12915 * an Eina_Bool with the visibility value
12916 * @li "title,changed": Title of the main frame changed. Event info is a
12917 * string with the new title
12918 * @li "toolbars,visible,get": Queries visibility of toolbars. Event info
12919 * is a pointer to Eina_Bool where the visibility state should be set
12920 * @li "toolbars,visible,set": Informs the visibility of toolbars. Event
12921 * info is an Eina_Bool with the visibility state
12922 * @li "tooltip,text,set": Show and set text of a tooltip. Event info is
12923 * a string with the text to show
12924 * @li "uri,changed": URI of the main frame changed. Event info is a string
12925 * with the new URI
12926 * @li "view,resized": The web object internal's view changed sized
12927 * @li "windows,close,request": A JavaScript request to close the current
12928 * window was requested
12929 * @li "zoom,animated,end": Animated zoom finished
12930 *
12931 * available styles:
12932 * - default
12933 *
12934 * An example of use of web:
12935 *
12936 * - @ref web_example_01 TBD
12937 */
12938
12939 /**
12940 * @addtogroup Web
12941 * @{
12942 */
12943
12944 /**
12945 * Structure used to report load errors.
12946 *
12947 * Load errors are reported as signal by elm_web. All the strings are
12948 * temporary references and should @b not be used after the signal
12949 * callback returns. If it's required, make copies with strdup() or
12950 * eina_stringshare_add() (they are not even guaranteed to be
12951 * stringshared, so must use eina_stringshare_add() and not
12952 * eina_stringshare_ref()).
12953 */
12954 typedef struct _Elm_Web_Frame_Load_Error Elm_Web_Frame_Load_Error;
12955 /**
12956 * Structure used to report load errors.
12957 *
12958 * Load errors are reported as signal by elm_web. All the strings are
12959 * temporary references and should @b not be used after the signal
12960 * callback returns. If it's required, make copies with strdup() or
12961 * eina_stringshare_add() (they are not even guaranteed to be
12962 * stringshared, so must use eina_stringshare_add() and not
12963 * eina_stringshare_ref()).
12964 */
12965 struct _Elm_Web_Frame_Load_Error
12966 {
12967 int code; /**< Numeric error code */
12968 Eina_Bool is_cancellation; /**< Error produced by cancelling a request */
12969 const char *domain; /**< Error domain name */
12970 const char *description; /**< Error description (already localized) */
12971 const char *failing_url; /**< The URL that failed to load */
12972 Evas_Object *frame; /**< Frame object that produced the error */
12973 };
12974
12975 /**
12976 * The possibles types that the items in a menu can be
12977 */
12978 typedef enum _Elm_Web_Menu_Item_Type Elm_Web_Menu_Item_Type;
12979 /**
12980 * The possibles types that the items in a menu can be
12981 */
12982 enum _Elm_Web_Menu_Item_Type
12983 {
12984 ELM_WEB_MENU_SEPARATOR,
12985 ELM_WEB_MENU_GROUP,
12986 ELM_WEB_MENU_OPTION
12987 };
12988
12989 /**
12990 * Structure describing the items in a menu
12991 */
12992 typedef struct _Elm_Web_Menu_Item Elm_Web_Menu_Item;
12993 /**
12994 * Structure describing the items in a menu
12995 */
12996 struct _Elm_Web_Menu_Item
12997 {
12998 const char *text; /**< The text for the item */
12999 Elm_Web_Menu_Item_Type type; /**< The type of the item */
13000 };
13001
13002 /**
13003 * Structure describing the menu of a popup
13004 *
13005 * This structure will be passed as the @c event_info for the "popup,create"
13006 * signal, which is emitted when a dropdown menu is opened. Users wanting
13007 * to handle these popups by themselves should listen to this signal and
13008 * set the @c handled property of the struct to @c EINA_TRUE. Leaving this
13009 * property as @c EINA_FALSE means that the user will not handle the popup
13010 * and the default implementation will be used.
13011 *
13012 * When the popup is ready to be dismissed, a "popup,willdelete" signal
13013 * will be emitted to notify the user that it can destroy any objects and
13014 * free all data related to it.
13015 *
13016 * @see elm_web_popup_selected_set()
13017 * @see elm_web_popup_destroy()
13018 */
13019 typedef struct _Elm_Web_Menu Elm_Web_Menu;
13020 /**
13021 * Structure describing the menu of a popup
13022 *
13023 * This structure will be passed as the @c event_info for the "popup,create"
13024 * signal, which is emitted when a dropdown menu is opened. Users wanting
13025 * to handle these popups by themselves should listen to this signal and
13026 * set the @c handled property of the struct to @c EINA_TRUE. Leaving this
13027 * property as @c EINA_FALSE means that the user will not handle the popup
13028 * and the default implementation will be used.
13029 *
13030 * When the popup is ready to be dismissed, a "popup,willdelete" signal
13031 * will be emitted to notify the user that it can destroy any objects and
13032 * free all data related to it.
13033 *
13034 * @see elm_web_popup_selected_set()
13035 * @see elm_web_popup_destroy()
13036 */
13037 struct _Elm_Web_Menu
13038 {
13039 Eina_List *items; /**< List of #Elm_Web_Menu_Item */
13040 int x; /**< The X position of the popup, relative to the elm_web object */
13041 int y; /**< The Y position of the popup, relative to the elm_web object */
13042 int width; /**< Width of the popup menu */
13043 int height; /**< Height of the popup menu */
13044
13045 Eina_Bool handled : 1; /**< Set to @c EINA_TRUE by the user to indicate that the popup has been handled and the default implementation should be ignored. Leave as @c EINA_FALSE otherwise. */
13046 };
13047
13048 typedef struct _Elm_Web_Download Elm_Web_Download;
13049 struct _Elm_Web_Download
13050 {
13051 const char *url;
13052 };
13053
13054 /**
13055 * Opaque handler containing the features (such as statusbar, menubar, etc)
13056 * that are to be set on a newly requested window.
13057 */
13058 typedef struct _Elm_Web_Window_Features Elm_Web_Window_Features;
13059 /**
13060 * Callback type for the create_window hook.
13061 *
13062 * The function parameters are:
13063 * @li @p data User data pointer set when setting the hook function
13064 * @li @p obj The elm_web object requesting the new window
13065 * @li @p js Set to @c EINA_TRUE if the request was originated from
13066 * JavaScript. @c EINA_FALSE otherwise.
13067 * @li @p window_features A pointer of #Elm_Web_Window_Features indicating
13068 * the features requested for the new window.
13069 *
13070 * The returned value of the function should be the @c elm_web widget where
13071 * the request will be loaded. That is, if a new window or tab is created,
13072 * the elm_web widget in it should be returned, and @b NOT the window
13073 * object.
13074 * Returning @c NULL should cancel the request.
13075 *
13076 * @see elm_web_window_create_hook_set()
13077 */
13078 typedef Evas_Object *(*Elm_Web_Window_Open)(void *data, Evas_Object *obj, Eina_Bool js, const Elm_Web_Window_Features *window_features);
13079 /**
13080 * Callback type for the JS alert hook.
13081 *
13082 * The function parameters are:
13083 * @li @p data User data pointer set when setting the hook function
13084 * @li @p obj The elm_web object requesting the new window
13085 * @li @p message The message to show in the alert dialog
13086 *
13087 * The function should return the object representing the alert dialog.
13088 * Elm_Web will run a second main loop to handle the dialog and normal
13089 * flow of the application will be restored when the object is deleted, so
13090 * the user should handle the popup properly in order to delete the object
13091 * when the action is finished.
13092 * If the function returns @c NULL the popup will be ignored.
13093 *
13094 * @see elm_web_dialog_alert_hook_set()
13095 */
13096 typedef Evas_Object *(*Elm_Web_Dialog_Alert)(void *data, Evas_Object *obj, const char *message);
13097 /**
13098 * Callback type for the JS confirm hook.
13099 *
13100 * The function parameters are:
13101 * @li @p data User data pointer set when setting the hook function
13102 * @li @p obj The elm_web object requesting the new window
13103 * @li @p message The message to show in the confirm dialog
13104 * @li @p ret Pointer where to store the user selection. @c EINA_TRUE if
13105 * the user selected @c Ok, @c EINA_FALSE otherwise.
13106 *
13107 * The function should return the object representing the confirm dialog.
13108 * Elm_Web will run a second main loop to handle the dialog and normal
13109 * flow of the application will be restored when the object is deleted, so
13110 * the user should handle the popup properly in order to delete the object
13111 * when the action is finished.
13112 * If the function returns @c NULL the popup will be ignored.
13113 *
13114 * @see elm_web_dialog_confirm_hook_set()
13115 */
13116 typedef Evas_Object *(*Elm_Web_Dialog_Confirm)(void *data, Evas_Object *obj, const char *message, Eina_Bool *ret);
13117 /**
13118 * Callback type for the JS prompt hook.
13119 *
13120 * The function parameters are:
13121 * @li @p data User data pointer set when setting the hook function
13122 * @li @p obj The elm_web object requesting the new window
13123 * @li @p message The message to show in the prompt dialog
13124 * @li @p def_value The default value to present the user in the entry
13125 * @li @p value Pointer where to store the value given by the user. Must
13126 * be a malloc'ed string or @c NULL if the user cancelled the popup.
13127 * @li @p ret Pointer where to store the user selection. @c EINA_TRUE if
13128 * the user selected @c Ok, @c EINA_FALSE otherwise.
13129 *
13130 * The function should return the object representing the prompt dialog.
13131 * Elm_Web will run a second main loop to handle the dialog and normal
13132 * flow of the application will be restored when the object is deleted, so
13133 * the user should handle the popup properly in order to delete the object
13134 * when the action is finished.
13135 * If the function returns @c NULL the popup will be ignored.
13136 *
13137 * @see elm_web_dialog_prompt_hook_set()
13138 */
13139 typedef Evas_Object *(*Elm_Web_Dialog_Prompt)(void *data, Evas_Object *obj, const char *message, const char *def_value, char **value, Eina_Bool *ret);
13140 /**
13141 * Callback type for the JS file selector hook.
13142 *
13143 * The function parameters are:
13144 * @li @p data User data pointer set when setting the hook function
13145 * @li @p obj The elm_web object requesting the new window
13146 * @li @p allows_multiple @c EINA_TRUE if multiple files can be selected.
13147 * @li @p accept_types Mime types accepted
13148 * @li @p selected Pointer where to store the list of malloc'ed strings
13149 * containing the path to each file selected. Must be @c NULL if the file
13150 * dialog is cancelled
13151 * @li @p ret Pointer where to store the user selection. @c EINA_TRUE if
13152 * the user selected @c Ok, @c EINA_FALSE otherwise.
13153 *
13154 * The function should return the object representing the file selector
13155 * dialog.
13156 * Elm_Web will run a second main loop to handle the dialog and normal
13157 * flow of the application will be restored when the object is deleted, so
13158 * the user should handle the popup properly in order to delete the object
13159 * when the action is finished.
13160 * If the function returns @c NULL the popup will be ignored.
13161 *
13162 * @see elm_web_dialog_file selector_hook_set()
13163 */
13164 typedef Evas_Object *(*Elm_Web_Dialog_File_Selector)(void *data, Evas_Object *obj, Eina_Bool allows_multiple, const char *accept_types, Eina_List **selected, Eina_Bool *ret);
13165 /**
13166 * Callback type for the JS console message hook.
13167 *
13168 * When a console message is added from JavaScript, any set function to the
13169 * console message hook will be called for the user to handle. There is no
13170 * default implementation of this hook.
13171 *
13172 * The function parameters are:
13173 * @li @p data User data pointer set when setting the hook function
13174 * @li @p obj The elm_web object that originated the message
13175 * @li @p message The message sent
13176 * @li @p line_number The line number
13177 * @li @p source_id Source id
13178 *
13179 * @see elm_web_console_message_hook_set()
13180 */
13181 typedef void (*Elm_Web_Console_Message)(void *data, Evas_Object *obj, const char *message, unsigned int line_number, const char *source_id);
13182 /**
13183 * Add a new web object to the parent.
13184 *
13185 * @param parent The parent object.
13186 * @return The new object or NULL if it cannot be created.
13187 *
13188 * @see elm_web_uri_set()
13189 * @see elm_web_webkit_view_get()
13190 */
13191 EAPI Evas_Object *elm_web_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
13192
13193 /**
13194 * Get internal ewk_view object from web object.
13195 *
13196 * Elementary may not provide some low level features of EWebKit,
13197 * instead of cluttering the API with proxy methods we opted to
13198 * return the internal reference. Be careful using it as it may
13199 * interfere with elm_web behavior.
13200 *
13201 * @param obj The web object.
13202 * @return The internal ewk_view object or NULL if it does not
13203 * exist. (Failure to create or Elementary compiled without
13204 * ewebkit)
13205 *
13206 * @see elm_web_add()
13207 */
13208 EAPI Evas_Object *elm_web_webkit_view_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
13209
13210 /**
13211 * Sets the function to call when a new window is requested
13212 *
13213 * This hook will be called when a request to create a new window is
13214 * issued from the web page loaded.
13215 * There is no default implementation for this feature, so leaving this
13216 * unset or passing @c NULL in @p func will prevent new windows from
13217 * opening.
13218 *
13219 * @param obj The web object where to set the hook function
13220 * @param func The hook function to be called when a window is requested
13221 * @param data User data
13222 */
13223 EAPI void elm_web_window_create_hook_set(Evas_Object *obj, Elm_Web_Window_Open func, void *data);
13224 /**
13225 * Sets the function to call when an alert dialog
13226 *
13227 * This hook will be called when a JavaScript alert dialog is requested.
13228 * If no function is set or @c NULL is passed in @p func, the default
13229 * implementation will take place.
13230 *
13231 * @param obj The web object where to set the hook function
13232 * @param func The callback function to be used
13233 * @param data User data
13234 *
13235 * @see elm_web_inwin_mode_set()
13236 */
13237 EAPI void elm_web_dialog_alert_hook_set(Evas_Object *obj, Elm_Web_Dialog_Alert func, void *data);
13238 /**
13239 * Sets the function to call when an confirm dialog
13240 *
13241 * This hook will be called when a JavaScript confirm dialog is requested.
13242 * If no function is set or @c NULL is passed in @p func, the default
13243 * implementation will take place.
13244 *
13245 * @param obj The web object where to set the hook function
13246 * @param func The callback function to be used
13247 * @param data User data
13248 *
13249 * @see elm_web_inwin_mode_set()
13250 */
13251 EAPI void elm_web_dialog_confirm_hook_set(Evas_Object *obj, Elm_Web_Dialog_Confirm func, void *data);
13252 /**
13253 * Sets the function to call when an prompt dialog
13254 *
13255 * This hook will be called when a JavaScript prompt dialog is requested.
13256 * If no function is set or @c NULL is passed in @p func, the default
13257 * implementation will take place.
13258 *
13259 * @param obj The web object where to set the hook function
13260 * @param func The callback function to be used
13261 * @param data User data
13262 *
13263 * @see elm_web_inwin_mode_set()
13264 */
13265 EAPI void elm_web_dialog_prompt_hook_set(Evas_Object *obj, Elm_Web_Dialog_Prompt func, void *data);
13266 /**
13267 * Sets the function to call when an file selector dialog
13268 *
13269 * This hook will be called when a JavaScript file selector dialog is
13270 * requested.
13271 * If no function is set or @c NULL is passed in @p func, the default
13272 * implementation will take place.
13273 *
13274 * @param obj The web object where to set the hook function
13275 * @param func The callback function to be used
13276 * @param data User data
13277 *
13278 * @see elm_web_inwin_mode_set()
13279 */
13280 EAPI void elm_web_dialog_file_selector_hook_set(Evas_Object *obj, Elm_Web_Dialog_File_Selector func, void *data);
13281 /**
13282 * Sets the function to call when a console message is emitted from JS
13283 *
13284 * This hook will be called when a console message is emitted from
13285 * JavaScript. There is no default implementation for this feature.
13286 *
13287 * @param obj The web object where to set the hook function
13288 * @param func The callback function to be used
13289 * @param data User data
13290 */
13291 EAPI void elm_web_console_message_hook_set(Evas_Object *obj, Elm_Web_Console_Message func, void *data);
13292 /**
13293 * Gets the status of the tab propagation
13294 *
13295 * @param obj The web object to query
13296 * @return EINA_TRUE if tab propagation is enabled, EINA_FALSE otherwise
13297 *
13298 * @see elm_web_tab_propagate_set()
13299 */
13300 EAPI Eina_Bool elm_web_tab_propagate_get(const Evas_Object *obj);
13301 /**
13302 * Sets whether to use tab propagation
13303 *
13304 * If tab propagation is enabled, whenever the user presses the Tab key,
13305 * Elementary will handle it and switch focus to the next widget.
13306 * The default value is disabled, where WebKit will handle the Tab key to
13307 * cycle focus though its internal objects, jumping to the next widget
13308 * only when that cycle ends.
13309 *
13310 * @param obj The web object
13311 * @param propagate Whether to propagate Tab keys to Elementary or not
13312 */
13313 EAPI void elm_web_tab_propagate_set(Evas_Object *obj, Eina_Bool propagate);
13314 /**
13315 * Sets the URI for the web object
13316 *
13317 * It must be a full URI, with resource included, in the form
13318 * http://www.enlightenment.org or file:///tmp/something.html
13319 *
13320 * @param obj The web object
13321 * @param uri The URI to set
13322 * @return EINA_TRUE if the URI could be, EINA_FALSE if an error occurred
13323 */
13324 EAPI Eina_Bool elm_web_uri_set(Evas_Object *obj, const char *uri);
13325 /**
13326 * Gets the current URI for the object
13327 *
13328 * The returned string must not be freed and is guaranteed to be
13329 * stringshared.
13330 *
13331 * @param obj The web object
13332 * @return A stringshared internal string with the current URI, or NULL on
13333 * failure
13334 */
13335 EAPI const char *elm_web_uri_get(const Evas_Object *obj);
13336 /**
13337 * Gets the current title
13338 *
13339 * The returned string must not be freed and is guaranteed to be
13340 * stringshared.
13341 *
13342 * @param obj The web object
13343 * @return A stringshared internal string with the current title, or NULL on
13344 * failure
13345 */
13346 EAPI const char *elm_web_title_get(const Evas_Object *obj);
13347 /**
13348 * Sets the background color to be used by the web object
13349 *
13350 * This is the color that will be used by default when the loaded page
13351 * does not set it's own. Color values are pre-multiplied.
13352 *
13353 * @param obj The web object
13354 * @param r Red component
13355 * @param g Green component
13356 * @param b Blue component
13357 * @param a Alpha component
13358 */
13359 EAPI void elm_web_bg_color_set(Evas_Object *obj, int r, int g, int b, int a);
13360 /**
13361 * Gets the background color to be used by the web object
13362 *
13363 * This is the color that will be used by default when the loaded page
13364 * does not set it's own. Color values are pre-multiplied.
13365 *
13366 * @param obj The web object
13367 * @param r Red component
13368 * @param g Green component
13369 * @param b Blue component
13370 * @param a Alpha component
13371 */
13372 EAPI void elm_web_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a);
13373 /**
13374 * Gets a copy of the currently selected text
13375 *
13376 * The string returned must be freed by the user when it's done with it.
13377 *
13378 * @param obj The web object
13379 * @return A newly allocated string, or NULL if nothing is selected or an
13380 * error occurred
13381 */
13382 EAPI char *elm_view_selection_get(const Evas_Object *obj);
13383 /**
13384 * Tells the web object which index in the currently open popup was selected
13385 *
13386 * When the user handles the popup creation from the "popup,created" signal,
13387 * it needs to tell the web object which item was selected by calling this
13388 * function with the index corresponding to the item.
13389 *
13390 * @param obj The web object
13391 * @param index The index selected
13392 *
13393 * @see elm_web_popup_destroy()
13394 */
13395 EAPI void elm_web_popup_selected_set(Evas_Object *obj, int index);
13396 /**
13397 * Dismisses an open dropdown popup
13398 *
13399 * When the popup from a dropdown widget is to be dismissed, either after
13400 * selecting an option or to cancel it, this function must be called, which
13401 * will later emit an "popup,willdelete" signal to notify the user that
13402 * any memory and objects related to this popup can be freed.
13403 *
13404 * @param obj The web object
13405 * @return EINA_TRUE if the menu was successfully destroyed, or EINA_FALSE
13406 * if there was no menu to destroy
13407 */
13408 EAPI Eina_Bool elm_web_popup_destroy(Evas_Object *obj);
13409 /**
13410 * Searches the given string in a document.
13411 *
13412 * @param obj The web object where to search the text
13413 * @param string String to search
13414 * @param case_sensitive If search should be case sensitive or not
13415 * @param forward If search is from cursor and on or backwards
13416 * @param wrap If search should wrap at the end
13417 *
13418 * @return @c EINA_TRUE if the given string was found, @c EINA_FALSE if not
13419 * or failure
13420 */
13421 EAPI Eina_Bool elm_web_text_search(const Evas_Object *obj, const char *string, Eina_Bool case_sensitive, Eina_Bool forward, Eina_Bool wrap);
13422 /**
13423 * Marks matches of the given string in a document.
13424 *
13425 * @param obj The web object where to search text
13426 * @param string String to match
13427 * @param case_sensitive If match should be case sensitive or not
13428 * @param highlight If matches should be highlighted
13429 * @param limit Maximum amount of matches, or zero to unlimited
13430 *
13431 * @return number of matched @a string
13432 */
13433 EAPI unsigned int elm_web_text_matches_mark(Evas_Object *obj, const char *string, Eina_Bool case_sensitive, Eina_Bool highlight, unsigned int limit);
13434 /**
13435 * Clears all marked matches in the document
13436 *
13437 * @param obj The web object
13438 *
13439 * @return EINA_TRUE on success, EINA_FALSE otherwise
13440 */
13441 EAPI Eina_Bool elm_web_text_matches_unmark_all(Evas_Object *obj);
13442 /**
13443 * Sets whether to highlight the matched marks
13444 *
13445 * If enabled, marks set with elm_web_text_matches_mark() will be
13446 * highlighted.
13447 *
13448 * @param obj The web object
13449 * @param highlight Whether to highlight the marks or not
13450 *
13451 * @return EINA_TRUE on success, EINA_FALSE otherwise
13452 */
13453 EAPI Eina_Bool elm_web_text_matches_highlight_set(Evas_Object *obj, Eina_Bool highlight);
13454 /**
13455 * Gets whether highlighting marks is enabled
13456 *
13457 * @param The web object
13458 *
13459 * @return EINA_TRUE is marks are set to be highlighted, EINA_FALSE
13460 * otherwise
13461 */
13462 EAPI Eina_Bool elm_web_text_matches_highlight_get(const Evas_Object *obj);
13463 /**
13464 * Gets the overall loading progress of the page
13465 *
13466 * Returns the estimated loading progress of the page, with a value between
13467 * 0.0 and 1.0. This is an estimated progress accounting for all the frames
13468 * included in the page.
13469 *
13470 * @param The web object
13471 *
13472 * @return A value between 0.0 and 1.0 indicating the progress, or -1.0 on
13473 * failure
13474 */
13475 EAPI double elm_web_load_progress_get(const Evas_Object *obj);
13476 /**
13477 * Stops loading the current page
13478 *
13479 * Cancels the loading of the current page in the web object. This will
13480 * cause a "load,error" signal to be emitted, with the is_cancellation
13481 * flag set to EINA_TRUE.
13482 *
13483 * @param obj The web object
13484 *
13485 * @return EINA_TRUE if the cancel was successful, EINA_FALSE otherwise
13486 */
13487 EAPI Eina_Bool elm_web_stop(Evas_Object *obj);
13488 /**
13489 * Requests a reload of the current document in the object
13490 *
13491 * @param obj The web object
13492 *
13493 * @return EINA_TRUE on success, EINA_FALSE otherwise
13494 */
13495 EAPI Eina_Bool elm_web_reload(Evas_Object *obj);
13496 /**
13497 * Requests a reload of the current document, avoiding any existing caches
13498 *
13499 * @param obj The web object
13500 *
13501 * @return EINA_TRUE on success, EINA_FALSE otherwise
13502 */
13503 EAPI Eina_Bool elm_web_reload_full(Evas_Object *obj);
13504 /**
13505 * Goes back one step in the browsing history
13506 *
13507 * This is equivalent to calling elm_web_object_navigate(obj, -1);
13508 *
13509 * @param obj The web object
13510 *
13511 * @return EINA_TRUE on success, EINA_FALSE otherwise
13512 *
13513 * @see elm_web_history_enable_set()
13514 * @see elm_web_back_possible()
13515 * @see elm_web_forward()
13516 * @see elm_web_navigate()
13517 */
13518 EAPI Eina_Bool elm_web_back(Evas_Object *obj);
13519 /**
13520 * Goes forward one step in the browsing history
13521 *
13522 * This is equivalent to calling elm_web_object_navigate(obj, 1);
13523 *
13524 * @param obj The web object
13525 *
13526 * @return EINA_TRUE on success, EINA_FALSE otherwise
13527 *
13528 * @see elm_web_history_enable_set()
13529 * @see elm_web_forward_possible()
13530 * @see elm_web_back()
13531 * @see elm_web_navigate()
13532 */
13533 EAPI Eina_Bool elm_web_forward(Evas_Object *obj);
13534 /**
13535 * Jumps the given number of steps in the browsing history
13536 *
13537 * The @p steps value can be a negative integer to back in history, or a
13538 * positive to move forward.
13539 *
13540 * @param obj The web object
13541 * @param steps The number of steps to jump
13542 *
13543 * @return EINA_TRUE on success, EINA_FALSE on error or if not enough
13544 * history exists to jump the given number of steps
13545 *
13546 * @see elm_web_history_enable_set()
13547 * @see elm_web_navigate_possible()
13548 * @see elm_web_back()
13549 * @see elm_web_forward()
13550 */
13551 EAPI Eina_Bool elm_web_navigate(Evas_Object *obj, int steps);
13552 /**
13553 * Queries whether it's possible to go back in history
13554 *
13555 * @param obj The web object
13556 *
13557 * @return EINA_TRUE if it's possible to back in history, EINA_FALSE
13558 * otherwise
13559 */
13560 EAPI Eina_Bool elm_web_back_possible(Evas_Object *obj);
13561 /**
13562 * Queries whether it's possible to go forward in history
13563 *
13564 * @param obj The web object
13565 *
13566 * @return EINA_TRUE if it's possible to forward in history, EINA_FALSE
13567 * otherwise
13568 */
13569 EAPI Eina_Bool elm_web_forward_possible(Evas_Object *obj);
13570 /**
13571 * Queries whether it's possible to jump the given number of steps
13572 *
13573 * The @p steps value can be a negative integer to back in history, or a
13574 * positive to move forward.
13575 *
13576 * @param obj The web object
13577 * @param steps The number of steps to check for
13578 *
13579 * @return EINA_TRUE if enough history exists to perform the given jump,
13580 * EINA_FALSE otherwise
13581 */
13582 EAPI Eina_Bool elm_web_navigate_possible(Evas_Object *obj, int steps);
13583 /**
13584 * Gets whether browsing history is enabled for the given object
13585 *
13586 * @param obj The web object
13587 *
13588 * @return EINA_TRUE if history is enabled, EINA_FALSE otherwise
13589 */
13590 EAPI Eina_Bool elm_web_history_enable_get(const Evas_Object *obj);
13591 /**
13592 * Enables or disables the browsing history
13593 *
13594 * @param obj The web object
13595 * @param enable Whether to enable or disable the browsing history
13596 */
13597 EAPI void elm_web_history_enable_set(Evas_Object *obj, Eina_Bool enable);
13598 /**
13599 * Gets whether text-only zoom is set
13600 *
13601 * @param obj The web object
13602 *
13603 * @return EINA_TRUE if zoom is set to affect only text, EINA_FALSE
13604 * otherwise
13605 *
13606 * @see elm_web_zoom_text_only_set()
13607 */
13608 EAPI Eina_Bool elm_web_zoom_text_only_get(const Evas_Object *obj);
13609 /**
13610 * Enables or disables zoom to affect only text
13611 *
13612 * If set, then the zoom level set to the page will only be applied on text,
13613 * leaving other objects, such as images, at their original size.
13614 *
13615 * @param obj The web object
13616 * @param setting EINA_TRUE to use text-only zoom, EINA_FALSE to have zoom
13617 * affect the entire page
13618 */
13619 EAPI void elm_web_zoom_text_only_set(Evas_Object *obj, Eina_Bool setting);
13620 /**
13621 * Sets the default dialogs to use an Inwin instead of a normal window
13622 *
13623 * If set, then the default implementation for the JavaScript dialogs and
13624 * file selector will be opened in an Inwin. Otherwise they will use a
13625 * normal separated window.
13626 *
13627 * @param obj The web object
13628 * @param value EINA_TRUE to use Inwin, EINA_FALSE to use a normal window
13629 */
13630 EAPI void elm_web_inwin_mode_set(Evas_Object *obj, Eina_Bool value);
13631 /**
13632 * Gets whether Inwin mode is set for the current object
13633 *
13634 * @param obj The web object
13635 *
13636 * @return EINA_TRUE if Inwin mode is set, EINA_FALSE otherwise
13637 */
13638 EAPI Eina_Bool elm_web_inwin_mode_get(const Evas_Object *obj);
13639
13640 EAPI void elm_web_window_features_ref(Elm_Web_Window_Features *wf);
13641 EAPI void elm_web_window_features_unref(Elm_Web_Window_Features *wf);
13642 EAPI void elm_web_window_features_bool_property_get(const Elm_Web_Window_Features *wf, Eina_Bool *toolbar_visible, Eina_Bool *statusbar_visible, Eina_Bool *scrollbars_visible, Eina_Bool *menubar_visible, Eina_Bool *locationbar_visble, Eina_Bool *fullscreen);
13643 EAPI void elm_web_window_features_int_property_get(const Elm_Web_Window_Features *wf, int *x, int *y, int *w, int *h);
13644
13645 /**
13646 * @}
13647 */
13648
13649 /**
12850 * @defgroup Hoversel Hoversel 13650 * @defgroup Hoversel Hoversel
12851 * 13651 *
12852 * @image html img/widget/hoversel/preview-00.png 13652 * @image html img/widget/hoversel/preview-00.png
diff --git a/legacy/elementary/src/lib/Makefile.am b/legacy/elementary/src/lib/Makefile.am
index 5a52be5e71..941ce64240 100644
--- a/legacy/elementary/src/lib/Makefile.am
+++ b/legacy/elementary/src/lib/Makefile.am
@@ -21,6 +21,7 @@ AM_CPPFLAGS = \
21@ELEMENTARY_EDBUS_CFLAGS@ \ 21@ELEMENTARY_EDBUS_CFLAGS@ \
22@ELEMENTARY_EFREET_CFLAGS@ \ 22@ELEMENTARY_EFREET_CFLAGS@ \
23@ELEMENTARY_ETHUMB_CFLAGS@ \ 23@ELEMENTARY_ETHUMB_CFLAGS@ \
24@ELEMENTARY_WEB_CFLAGS@ \
24@ELEMENTARY_EMAP_CFLAGS@ \ 25@ELEMENTARY_EMAP_CFLAGS@ \
25@EVIL_CFLAGS@ \ 26@EVIL_CFLAGS@ \
26@EIO_CFLAGS@ \ 27@EIO_CFLAGS@ \
@@ -112,6 +113,7 @@ elm_toolbar.c \
112elm_transit.c \ 113elm_transit.c \
113elm_util.c \ 114elm_util.c \
114elm_video.c \ 115elm_video.c \
116elm_web.c \
115elm_widget.c \ 117elm_widget.c \
116elm_win.c \ 118elm_win.c \
117els_box.c \ 119els_box.c \
@@ -138,6 +140,7 @@ libelementary_la_LIBADD = \
138@ELEMENTARY_EDBUS_LIBS@ \ 140@ELEMENTARY_EDBUS_LIBS@ \
139@ELEMENTARY_EFREET_LIBS@ \ 141@ELEMENTARY_EFREET_LIBS@ \
140@ELEMENTARY_ETHUMB_LIBS@ \ 142@ELEMENTARY_ETHUMB_LIBS@ \
143@ELEMENTARY_WEB_LIBS@ \
141@ELEMENTARY_EMAP_LIBS@ \ 144@ELEMENTARY_EMAP_LIBS@ \
142@EVIL_LIBS@ \ 145@EVIL_LIBS@ \
143@EIO_LIBS@ \ 146@EIO_LIBS@ \
diff --git a/legacy/elementary/src/lib/elm_main.c b/legacy/elementary/src/lib/elm_main.c
index db0ba7d2d0..5f19d5ddb6 100644
--- a/legacy/elementary/src/lib/elm_main.c
+++ b/legacy/elementary/src/lib/elm_main.c
@@ -491,6 +491,7 @@ elm_quicklaunch_shutdown(void)
491 _elm_unneed_efreet(); 491 _elm_unneed_efreet();
492 _elm_unneed_e_dbus(); 492 _elm_unneed_e_dbus();
493 _elm_unneed_ethumb(); 493 _elm_unneed_ethumb();
494 _elm_unneed_web();
494 ecore_file_shutdown(); 495 ecore_file_shutdown();
495 496
496#ifdef HAVE_ELEMENTARY_EMAP 497#ifdef HAVE_ELEMENTARY_EMAP
diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h
index 81ad807197..6575ff0cd5 100644
--- a/legacy/elementary/src/lib/elm_priv.h
+++ b/legacy/elementary/src/lib/elm_priv.h
@@ -193,6 +193,7 @@ void _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool
193Eina_Bool _elm_widget_top_win_focused_get(const Evas_Object *obj); 193Eina_Bool _elm_widget_top_win_focused_get(const Evas_Object *obj);
194 194
195void _elm_unneed_ethumb(void); 195void _elm_unneed_ethumb(void);
196void _elm_unneed_web(void);
196 197
197void _elm_rescale(void); 198void _elm_rescale(void);
198void _elm_widget_mirrored_reload(Evas_Object *obj); 199void _elm_widget_mirrored_reload(Evas_Object *obj);
diff --git a/legacy/elementary/src/lib/elm_web.c b/legacy/elementary/src/lib/elm_web.c
new file mode 100644
index 0000000000..312d7ed5ab
--- /dev/null
+++ b/legacy/elementary/src/lib/elm_web.c
@@ -0,0 +1,1566 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4// TODO:
5// 1 - easy to use zoom like elm_photocam API
6// 2 - review scrolling to match elm_scroller. Maybe in future use elm_scroller
7
8#ifdef HAVE_ELEMENTARY_WEB
9#include <EWebKit.h>
10
11/* Similar to iPhone */
12// TODO: switch between iPhone, iPad or Chrome/Safari based on some elm setting?
13#define ELM_WEB_USER_AGENT "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 " PACKAGE_NAME "/" PACKAGE_VERSION
14
15static Ewk_View_Smart_Class _parent_sc = EWK_VIEW_SMART_CLASS_INIT_NULL;
16
17typedef struct _View_Smart_Data View_Smart_Data;
18struct _View_Smart_Data
19{
20 Ewk_View_Smart_Data base;
21 struct {
22 Evas_Event_Mouse_Down event;
23 Evas_Coord x, y;
24 unsigned int move_count;
25 Ecore_Timer *longpress_timer;
26 Ecore_Animator *pan_anim;
27 } mouse;
28};
29#endif
30
31typedef struct _Widget_Data Widget_Data;
32struct _Widget_Data
33{
34 Evas_Object *self;
35#ifdef HAVE_ELEMENTARY_WEB
36 Evas_Object *ewk_view;
37 struct {
38 Elm_Web_Window_Open window_create;
39 void *window_create_data;
40 Elm_Web_Dialog_Alert alert;
41 void *alert_data;
42 Elm_Web_Dialog_Confirm confirm;
43 void *confirm_data;
44 Elm_Web_Dialog_Prompt prompt;
45 void *prompt_data;
46 Elm_Web_Dialog_File_Selector file_selector;
47 void *file_selector_data;
48 Elm_Web_Console_Message console_message;
49 void *console_message_data;
50 } hook;
51 Elm_Win_Keyboard_Mode input_method;
52 Eina_Bool tab_propagate : 1;
53 Eina_Bool inwin_mode : 1;
54#else
55 Evas_Object *label;
56#endif
57};
58
59enum Dialog_Type
60{
61 DIALOG_ALERT,
62 DIALOG_CONFIRM,
63 DIALOG_PROMPT,
64 DIALOG_FILE_SELECTOR
65};
66
67typedef struct _Dialog_Data Dialog_Data;
68struct _Dialog_Data
69{
70 enum Dialog_Type type;
71 Evas_Object *dialog;
72 Evas_Object *box;
73 Evas_Object *bt_ok, *bt_cancel;
74 Evas_Object *entry;
75 Evas_Object *file_sel;
76
77 Eina_Bool *response;
78 char **entry_value;
79 Eina_List **selected_files;
80};
81
82struct _Elm_Web_Callback_Proxy_Context
83{
84 const char *name;
85 Evas_Object *obj;
86};
87typedef struct _Elm_Web_Callback_Proxy_Context Elm_Web_Callback_Proxy_Context;
88
89static const char *widtype = NULL;
90static const Evas_Smart_Cb_Description _elm_web_callback_names[] = {
91 { "download,request", "p" },
92 { "editorclient,contents,changed", "" },
93 { "editorclient,selection,changed", "" },
94 { "frame,created", "p" },
95 { "icon,received", "" },
96 { "inputmethod,changed", "b" },
97 { "js,windowobject,clear", "" },
98 { "link,hover,in", "p" },
99 { "link,hover,out", "" },
100 { "load,document,finished", "p" },
101 { "load,error", "p" },
102 { "load,finished", "p" },
103 { "load,newwindow,show", "" },
104 { "load,progress", "d" },
105 { "load,provisional", "" },
106 { "load,started", "" },
107 { "menubar,visible,get", "b" },
108 { "menubar,visible,set", "b" },
109 { "popup,created", "p" },
110 { "popup,willdelete", "p" },
111 { "ready", "" },
112 { "scrollbars,visible,get", "b" },
113 { "scrollbars,visible,set", "b" },
114 { "statusbar,text,set", "s" },
115 { "statusbar,visible,get", "b" },
116 { "statusbar,visible,set", "b" },
117 { "title,changed", "s" },
118 { "toolbars,visible,get", "b" },
119 { "toolbars,visible,set", "b" },
120 { "tooltip,text,set", "s" },
121 { "uri,changed", "s" },
122 { "view,resized", "" },
123 { "windows,close,request", ""},
124 { "zoom,animated,end", "" },
125 { NULL, NULL }
126};
127
128static void
129_theme_hook(Evas_Object *obj)
130{
131#ifdef HAVE_ELEMENTARY_WEB
132 Elm_Theme *theme = elm_object_theme_get(obj);
133 Widget_Data *wd = elm_widget_data_get(obj);
134 const Eina_List *themes, *l;
135 const char *th;
136 char *view_theme = NULL;
137
138 themes = elm_theme_list_get(theme);
139 EINA_LIST_FOREACH(themes, l, th)
140 {
141 char *path = elm_theme_list_item_path_get(th, NULL);
142 if (!path) continue;
143 if (edje_file_group_exists(path, "webkit/base"))
144 {
145 view_theme = path;
146 break;
147 }
148 free(path);
149 }
150
151 if (view_theme)
152 {
153 ewk_view_theme_set(wd->ewk_view, view_theme);
154 free(view_theme);
155 }
156 else
157 ewk_view_theme_set(wd->ewk_view, WEBKIT_DATADIR"/themes/default.edj");
158#else
159 (void)obj;
160#endif
161}
162
163static void
164_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
165{
166#ifdef HAVE_ELEMENTARY_WEB
167 Widget_Data *wd = elm_widget_data_get(obj);
168 Evas_Object *top = elm_widget_top_get(obj);
169
170 if (!wd) return;
171
172 if (elm_object_focus_get(obj))
173 {
174 evas_object_focus_set(wd->ewk_view, EINA_TRUE);
175 if (top) elm_win_keyboard_mode_set(top, wd->input_method);
176 }
177 else
178 {
179 evas_object_focus_set(wd->ewk_view, EINA_FALSE);
180 if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
181 }
182#else
183 (void)obj;
184#endif
185}
186
187static Eina_Bool
188_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
189{
190#ifdef HAVE_ELEMENTARY_WEB
191 Evas_Event_Key_Down *ev = event_info;
192 Widget_Data *wd = elm_widget_data_get(obj);
193
194 if (!wd) return EINA_FALSE;
195 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
196 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
197 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
198
199 if ((!strcmp(ev->keyname, "Tab")) && (!wd->tab_propagate))
200 {
201 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
202 return EINA_TRUE;
203 }
204 else
205 return EINA_FALSE;
206#else
207 return EINA_FALSE;
208 (void)obj;
209 (void)type;
210 (void)event_info;
211#endif
212}
213
214#ifdef HAVE_ELEMENTARY_WEB
215static Eina_Bool
216_view_pan_animator(void *data)
217{
218 View_Smart_Data *sd = data;
219 Evas_Coord x, y, dx, dy;
220
221 evas_pointer_canvas_xy_get(sd->base.base.evas, &x, &y);
222
223 dx = sd->mouse.x - x;
224 dy = sd->mouse.y - y;
225
226 if ((dx == 0) && (dy == 0))
227 goto end;
228
229 ewk_frame_scroll_add(sd->base.main_frame, dx, dy);
230
231 sd->mouse.x = x;
232 sd->mouse.y = y;
233
234 end:
235 return EINA_TRUE;
236}
237
238static void
239_view_smart_add(Evas_Object *obj)
240{
241 View_Smart_Data *sd;
242
243 sd = calloc(1, sizeof(View_Smart_Data));
244 evas_object_smart_data_set(obj, sd);
245
246 _parent_sc.sc.add(obj);
247
248 ewk_view_history_enable_set(obj, EINA_TRUE);
249 ewk_history_limit_set(ewk_view_history_get(obj), 100);
250 // TODO: auto toggle between smooth/nearest during bring-in animations
251 //ewk_view_zoom_weak_smooth_scale_set(obj, EINA_TRUE);
252}
253
254static void
255_view_smart_del(Evas_Object *obj)
256{
257 View_Smart_Data *sd;
258
259 sd = evas_object_smart_data_get(obj);
260
261 if (sd->mouse.pan_anim)
262 ecore_animator_del(sd->mouse.pan_anim);
263
264 _parent_sc.sc.del(obj);
265}
266
267static Eina_Bool
268_view_longpress_timer(void *data)
269{
270 View_Smart_Data *sd = data;
271
272 sd->mouse.move_count = 0;
273 sd->mouse.longpress_timer = NULL;
274 return ECORE_CALLBACK_CANCEL;
275}
276
277static Eina_Bool
278_view_smart_mouse_down(Ewk_View_Smart_Data *esd, const Evas_Event_Mouse_Down *event)
279{
280 // TODO: mimic elm_scroller and like
281 // TODO-minor: offer hook?
282 View_Smart_Data *sd = (View_Smart_Data *)esd;
283
284 if (event->button != 1)
285 return _parent_sc.mouse_down(esd, event);
286
287 sd->mouse.pan_anim = ecore_animator_add(_view_pan_animator, sd);
288 sd->mouse.longpress_timer = ecore_timer_add(1.0, _view_longpress_timer, sd);
289 sd->mouse.move_count = 1;
290 sd->mouse.x = event->canvas.x;
291 sd->mouse.y = event->canvas.y;
292 sd->mouse.event = *event;
293
294 return EINA_TRUE;
295}
296
297static Eina_Bool
298_view_smart_mouse_up(Ewk_View_Smart_Data *esd, const Evas_Event_Mouse_Up *event)
299{
300 // TODO: mimic elm_scroller and like
301 // TODO-minor: offer hook?
302 View_Smart_Data *sd = (View_Smart_Data *)esd;
303
304 if (sd->mouse.pan_anim)
305 {
306 ecore_animator_del(sd->mouse.pan_anim);
307 sd->mouse.pan_anim = NULL;
308
309 if (sd->mouse.longpress_timer)
310 _parent_sc.mouse_down(esd, &sd->mouse.event);
311 else
312 return EINA_TRUE;
313 }
314
315 if (sd->mouse.longpress_timer)
316 {
317 ecore_timer_del(sd->mouse.longpress_timer);
318 sd->mouse.longpress_timer = NULL;
319 }
320
321 sd->mouse.move_count = 0;
322 return _parent_sc.mouse_up(esd, event);
323}
324
325static Eina_Bool
326_view_smart_mouse_move(Ewk_View_Smart_Data *esd, const Evas_Event_Mouse_Move *event)
327{
328 // TODO: mimic elm_scroller and like
329 // TODO-minor: offer hook?
330 View_Smart_Data *sd = (View_Smart_Data *)esd;
331 sd->mouse.move_count++;
332
333 if (sd->mouse.longpress_timer &&
334 (((sd->mouse.x ^ sd->mouse.event.canvas.x) |
335 (sd->mouse.y ^ sd->mouse.event.canvas.y)) & (~0x07)))
336 {
337 ecore_timer_del(sd->mouse.longpress_timer);
338 sd->mouse.longpress_timer = NULL;
339 }
340
341 if (sd->mouse.pan_anim)
342 {
343 return EINA_FALSE;
344 }
345
346 return _parent_sc.mouse_move(esd, event);
347}
348
349static Evas_Object *
350_view_smart_window_create(Ewk_View_Smart_Data *sd, Eina_Bool javascript, const Ewk_Window_Features *window_features)
351{
352 Evas_Object *new;
353 Evas_Object *obj = evas_object_smart_parent_get(sd->self);
354 Widget_Data *wd = elm_widget_data_get(obj);
355
356 if (!wd->hook.window_create) return NULL;
357 new = wd->hook.window_create(wd->hook.window_create_data, obj, javascript,
358 (const Elm_Web_Window_Features *)window_features);
359 if (new) return elm_web_webkit_view_get(new);
360
361 return NULL;
362}
363
364static void
365_view_smart_window_close(Ewk_View_Smart_Data *sd)
366{
367 Evas_Object *obj = evas_object_smart_parent_get(sd->self);
368 evas_object_smart_callback_call(obj, "windows,close,request", NULL);
369}
370
371static void
372_bt_close(void *data, Evas_Object *obj, void *event_info __UNUSED__)
373{
374 Dialog_Data *d = data;
375
376 *d->response = (obj == d->bt_ok);
377 if ((d->type == DIALOG_PROMPT) && (*d->response == EINA_TRUE))
378 *d->entry_value = strdup(elm_entry_entry_get(d->entry));
379 evas_object_del(d->dialog);
380}
381
382static void
383_file_sel_done(void *data, Evas_Object *obj __UNUSED__, void *event_info)
384{
385 Dialog_Data *d = data;
386 if (event_info)
387 {
388 *d->selected_files = eina_list_append(NULL, strdup(event_info));
389 *d->response = EINA_TRUE;
390 }
391 else
392 *d->response = EINA_FALSE;
393 evas_object_del(d->dialog);
394 free(d);
395}
396
397static Dialog_Data *
398_dialog_new(Evas_Object *parent)
399{
400 Dialog_Data *d;
401 Widget_Data *wd = elm_widget_data_get(parent);
402
403 d = calloc(1, sizeof(Dialog_Data));
404 if (!d) return NULL;
405
406 if (!parent || wd->inwin_mode)
407 {
408 Evas_Object *bg;
409
410 d->dialog = elm_win_add(NULL, "elm-web-popup", ELM_WIN_DIALOG_BASIC);
411 evas_object_smart_callback_add(d->dialog, "delete,request",
412 _bt_close, d);
413
414 bg = elm_bg_add(d->dialog);
415 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
416 EVAS_HINT_EXPAND);
417 elm_win_resize_object_add(d->dialog, bg);
418 evas_object_show(bg);
419
420 d->box = elm_box_add(d->dialog);
421 evas_object_size_hint_weight_set(d->box, EVAS_HINT_EXPAND,
422 EVAS_HINT_EXPAND);
423 elm_win_resize_object_add(d->dialog, d->box);
424 evas_object_show(d->box);
425 }
426 else
427 {
428 Evas_Object *win = elm_widget_top_get(parent);
429 d->dialog = elm_win_inwin_add(win);
430 elm_object_style_set(d->dialog, "minimal");
431 evas_object_size_hint_weight_set(d->dialog, EVAS_HINT_EXPAND,
432 EVAS_HINT_EXPAND);
433
434 d->box = elm_box_add(win);
435 evas_object_size_hint_weight_set(d->box, EVAS_HINT_EXPAND,
436 EVAS_HINT_EXPAND);
437 elm_win_inwin_content_set(d->dialog, d->box);
438 evas_object_show(d->box);
439 }
440
441 return d;
442}
443
444static Evas_Object *
445_run_dialog(Evas_Object *parent, enum Dialog_Type type, const char *message, const char *default_entry_value, char **entry_value, Eina_Bool allows_multiple_files __UNUSED__, const char *accept_types __UNUSED__, Eina_List **selected_filenames, Eina_Bool *response)
446{
447 EINA_SAFETY_ON_TRUE_RETURN_VAL((type != DIALOG_PROMPT) && (!!default_entry_value), EINA_FALSE);
448 EINA_SAFETY_ON_TRUE_RETURN_VAL((type != DIALOG_PROMPT) && (!!entry_value), EINA_FALSE);
449
450 Dialog_Data *dialog_data = _dialog_new(evas_object_smart_parent_get(parent));
451 Evas_Object *lb;
452
453 if (type != DIALOG_FILE_SELECTOR)
454 {
455 lb = elm_label_add(dialog_data->box);
456 elm_object_text_set(lb, message);
457 elm_box_pack_end(dialog_data->box, lb);
458 evas_object_show(lb);
459 }
460
461 dialog_data->type = type;
462 dialog_data->response = response;
463 dialog_data->entry_value = entry_value;
464 dialog_data->selected_files = selected_filenames;
465
466 if (type == DIALOG_ALERT)
467 {
468 dialog_data->bt_ok = elm_button_add(dialog_data->box);
469 elm_object_text_set(dialog_data->bt_ok, "Close");
470 elm_box_pack_end(dialog_data->box, dialog_data->bt_ok);
471 evas_object_size_hint_align_set(dialog_data->bt_ok, EVAS_HINT_FILL, EVAS_HINT_FILL);
472 evas_object_smart_callback_add(dialog_data->bt_ok, "clicked", _bt_close, dialog_data);
473 evas_object_show(dialog_data->bt_ok);
474 }
475 else if (type == DIALOG_FILE_SELECTOR)
476 {
477 dialog_data->file_sel = elm_fileselector_add(dialog_data->dialog);
478 evas_object_size_hint_weight_set(dialog_data->file_sel,
479 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
480 evas_object_size_hint_align_set(dialog_data->file_sel, EVAS_HINT_FILL,
481 EVAS_HINT_FILL);
482 elm_box_pack_end(dialog_data->box, dialog_data->file_sel);
483 evas_object_show(dialog_data->file_sel);
484
485 elm_fileselector_path_set(dialog_data->file_sel, ".");
486 elm_fileselector_is_save_set(dialog_data->file_sel, EINA_FALSE);
487 elm_fileselector_folder_only_set(dialog_data->file_sel, EINA_FALSE);
488 elm_fileselector_buttons_ok_cancel_set(dialog_data->file_sel,
489 EINA_TRUE);
490 elm_fileselector_expandable_set(dialog_data->file_sel, EINA_FALSE);
491 evas_object_smart_callback_add(dialog_data->file_sel, "done",
492 _file_sel_done, dialog_data);
493 // fileselector can't set it's minimum size correctly
494 evas_object_size_hint_min_set(dialog_data->file_sel, 300, 400);
495 }
496 else
497 {
498 if (type == DIALOG_PROMPT)
499 {
500 dialog_data->entry = elm_entry_add(dialog_data->box);
501 elm_entry_single_line_set(dialog_data->entry, EINA_TRUE);
502 elm_entry_scrollable_set(dialog_data->entry, EINA_TRUE);
503 elm_entry_entry_set(dialog_data->entry, default_entry_value);
504 evas_object_size_hint_align_set(dialog_data->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
505 evas_object_size_hint_weight_set(dialog_data->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
506 elm_box_pack_end(dialog_data->box, dialog_data->entry);
507 evas_object_show(dialog_data->entry);
508 }
509
510 if (type == DIALOG_PROMPT || type == DIALOG_CONFIRM)
511 {
512 Evas_Object *bx_h = elm_box_add(dialog_data->box);
513 elm_box_horizontal_set(bx_h, 1);
514 elm_box_pack_end(dialog_data->box, bx_h);
515 evas_object_size_hint_weight_set(bx_h, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
516 evas_object_size_hint_align_set(bx_h, EVAS_HINT_FILL, EVAS_HINT_FILL);
517 evas_object_show(bx_h);
518
519 dialog_data->bt_cancel = elm_button_add(bx_h);
520 elm_object_text_set(dialog_data->bt_cancel, "Cancel");
521 elm_box_pack_end(bx_h, dialog_data->bt_cancel);
522 evas_object_size_hint_weight_set(dialog_data->bt_cancel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
523 evas_object_size_hint_align_set(dialog_data->bt_cancel, EVAS_HINT_FILL, EVAS_HINT_FILL);
524 evas_object_smart_callback_add(dialog_data->bt_cancel, "clicked", _bt_close, dialog_data);
525 evas_object_show(dialog_data->bt_cancel);
526
527 dialog_data->bt_ok = elm_button_add(bx_h);
528 elm_object_text_set(dialog_data->bt_ok, "Ok");
529 elm_box_pack_end(bx_h, dialog_data->bt_ok);
530 evas_object_size_hint_weight_set(dialog_data->bt_ok, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
531 evas_object_size_hint_align_set(dialog_data->bt_ok, EVAS_HINT_FILL, EVAS_HINT_FILL);
532 evas_object_smart_callback_add(dialog_data->bt_ok, "clicked", _bt_close, dialog_data);
533 evas_object_show(dialog_data->bt_ok);
534 }
535 else
536 return EINA_FALSE;
537 }
538
539 evas_object_show(dialog_data->dialog);
540
541 return dialog_data->dialog;
542}
543
544static void
545_dialog_del_cb(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
546{
547 ecore_main_loop_quit();
548}
549
550static void
551_exec_dialog(Evas_Object *dialog)
552{
553 evas_object_event_callback_add(dialog, EVAS_CALLBACK_DEL, _dialog_del_cb,
554 NULL);
555 ecore_main_loop_begin();
556}
557
558/* called by ewk_view when javascript called alert()
559 *
560 */
561static void
562_view_smart_run_javascript_alert(Ewk_View_Smart_Data *esd, Evas_Object *frame __UNUSED__, const char *message)
563{
564 View_Smart_Data *sd = (View_Smart_Data *)esd;
565 Evas_Object *view = sd->base.self;
566 Evas_Object *obj = evas_object_smart_parent_get(view);
567 Evas_Object *diag = NULL;
568 Widget_Data *wd = elm_widget_data_get(obj);
569 Eina_Bool response = EINA_FALSE;
570
571 if (wd->hook.alert)
572 diag = wd->hook.alert(wd->hook.alert_data, obj, message);
573 else
574 diag = _run_dialog(view, DIALOG_ALERT, message, NULL, NULL, EINA_FALSE,
575 NULL, NULL, &response);
576 if (diag) _exec_dialog(diag);
577}
578
579/* called by ewk_view when javascript called confirm()
580 *
581 */
582static Eina_Bool
583_view_smart_run_javascript_confirm(Ewk_View_Smart_Data *esd, Evas_Object *frame __UNUSED__, const char *message)
584{
585 View_Smart_Data *sd = (View_Smart_Data *)esd;
586 Evas_Object *view = sd->base.self;
587 Evas_Object *obj = evas_object_smart_parent_get(view);
588 Evas_Object *diag = NULL;
589 Widget_Data *wd = elm_widget_data_get(obj);
590 Eina_Bool response = EINA_FALSE;
591
592 if (wd->hook.confirm)
593 diag = wd->hook.confirm(wd->hook.confirm_data, obj, message, &response);
594 else
595 diag = _run_dialog(view, DIALOG_CONFIRM, message, NULL, NULL, EINA_FALSE,
596 NULL, NULL, &response);
597 if (diag) _exec_dialog(diag);
598 return response;
599}
600
601/* called by ewk_view when javascript called confirm()
602 *
603 */
604static Eina_Bool
605_view_smart_run_javascript_prompt(Ewk_View_Smart_Data *esd, Evas_Object *frame __UNUSED__, const char *message, const char *default_value, char **value)
606{
607 View_Smart_Data *sd = (View_Smart_Data *)esd;
608 Evas_Object *view = sd->base.self;
609 Evas_Object *obj = evas_object_smart_parent_get(view);
610 Evas_Object *diag = NULL;
611 Widget_Data *wd = elm_widget_data_get(obj);
612 Eina_Bool response = EINA_FALSE;
613
614 if (wd->hook.prompt)
615 diag = wd->hook.prompt(wd->hook.prompt_data, obj, message, default_value,
616 value, &response);
617 else
618 diag = _run_dialog(view, DIALOG_PROMPT, message, default_value, value,
619 EINA_FALSE, NULL, NULL, &response);
620 if (diag) _exec_dialog(diag);
621 if (!response)
622 *value = NULL;
623
624 return EINA_TRUE;
625}
626
627static Eina_Bool
628_view_smart_run_open_panel(Ewk_View_Smart_Data *esd, Evas_Object *frame __UNUSED__, Eina_Bool allows_multiple_files, const char *accept_types, Eina_List **selected_filenames)
629{
630 View_Smart_Data *sd = (View_Smart_Data *)esd;
631 Evas_Object *view = sd->base.self;
632 Evas_Object *obj = evas_object_smart_parent_get(view);
633 Evas_Object *diag = NULL;
634 Widget_Data *wd = elm_widget_data_get(obj);
635 Eina_Bool response = EINA_FALSE;
636
637 if (wd->hook.file_selector)
638 diag = wd->hook.file_selector(wd->hook.file_selector_data, obj,
639 allows_multiple_files, accept_types,
640 selected_filenames, &response);
641 else
642 diag = _run_dialog(view, DIALOG_FILE_SELECTOR, NULL, NULL, NULL,
643 allows_multiple_files, accept_types, selected_filenames,
644 &response);
645 if (diag) _exec_dialog(diag);
646
647 return response;
648}
649
650static Eina_Bool
651_view_smart_focus_can_cycle(Ewk_View_Smart_Data *sd, Ewk_Focus_Direction direction)
652{
653 Evas_Object *obj = evas_object_smart_parent_get(sd->self);
654 Elm_Focus_Direction dir;
655
656 switch (direction)
657 {
658 case EWK_FOCUS_DIRECTION_FORWARD:
659 dir = ELM_FOCUS_NEXT;
660 break;
661 case EWK_FOCUS_DIRECTION_BACKWARD:
662 dir = ELM_FOCUS_PREVIOUS;
663 break;
664 default:
665 return EINA_FALSE;
666 }
667
668 elm_widget_focus_cycle(elm_widget_parent_get(obj), dir);
669
670 return EINA_TRUE;
671}
672
673/**
674 * Creates a new view object given the parent.
675 *
676 * @param parent object to use as parent.
677 *
678 * @return newly added Evas_Object or @c NULL on errors.
679 */
680Evas_Object *
681_view_add(Evas_Object *parent)
682{
683 static Evas_Smart *smart = NULL;
684 Evas *canvas = evas_object_evas_get(parent);
685 Evas_Object *view;
686
687 if (!smart)
688 {
689 static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("EWK_View_Elementary");
690
691#ifndef TILED_BACKING_STORE
692 ewk_view_single_smart_set(&api);
693#else
694 ewk_view_tiled_smart_set(&api);
695#endif
696
697 _parent_sc = api;
698
699 // TODO: check every api method and provide overrides with hooks!
700 // TODO: hooks should provide extension points
701 // TODO: extension should have some kind of "default implementation",
702 // TODO: that can be replaced or controlled by hooks.
703 // TODO: ie: run_javascript_alert() should present an elm_win
704 // TODO: by default, but user could override it to show as inwin.
705 api.sc.add = _view_smart_add;
706 api.sc.del = _view_smart_del;
707 //api.sc.calculate = _view_smart_calculate;
708 api.mouse_down = _view_smart_mouse_down;
709 api.mouse_up = _view_smart_mouse_up;
710 api.mouse_move = _view_smart_mouse_move;
711 //api.add_console_message = _view_smart_add_console_message;
712 api.window_create = _view_smart_window_create;
713 api.window_close = _view_smart_window_close;
714 api.run_javascript_alert = _view_smart_run_javascript_alert;
715 api.run_javascript_confirm = _view_smart_run_javascript_confirm;
716 api.run_javascript_prompt = _view_smart_run_javascript_prompt;
717 api.run_open_panel = _view_smart_run_open_panel;
718 api.focus_can_cycle = _view_smart_focus_can_cycle;
719
720 smart = evas_smart_class_new(&api.sc);
721 if (!smart)
722 {
723 CRITICAL("Could not create smart class");
724 return NULL;
725 }
726 }
727
728 view = evas_object_smart_add(canvas, smart);
729 if (!view)
730 {
731 ERR("Could not create smart object object for view");
732 return NULL;
733 }
734
735 return view;
736}
737
738static void
739_ewk_view_inputmethod_change_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
740{
741 Widget_Data *wd = data;
742 Evas_Object *top = elm_widget_top_get(wd->self);
743 if (!top) return;
744
745 if (event_info)
746 wd->input_method = ELM_WIN_KEYBOARD_ON;
747 else
748 wd->input_method = ELM_WIN_KEYBOARD_OFF;
749 elm_win_keyboard_mode_set(top, wd->input_method);
750}
751
752static void
753_ewk_view_load_started_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
754{
755 _ewk_view_inputmethod_change_cb(data, obj, (void *)(long)EINA_FALSE);
756}
757
758static void
759_popup_del_job(void *data)
760{
761 evas_object_del(data);
762}
763
764static void
765_popup_will_delete(void *data, Evas_Object *obj, void *event_info __UNUSED__)
766{
767 ecore_job_add(_popup_del_job, data);
768 evas_object_smart_callback_del(obj, "popup,willdelete", _popup_will_delete);
769}
770
771static void
772_popup_item_selected(void *data, Evas_Object *obj, void *event_info __UNUSED__)
773{
774 Evas_Object *view = data;
775 Elm_List_Item *it = elm_list_selected_item_get(obj);
776 const Eina_List *itr, *list = elm_list_items_get(obj);
777 void *d;
778 int i = 0;
779
780 EINA_LIST_FOREACH(list, itr, d)
781 {
782 if (d == it)
783 break;
784
785 i++;
786 }
787
788 ewk_view_popup_selected_set(view, i);
789 ewk_view_popup_destroy(view);
790}
791
792static void
793_popup_dismiss_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
794{
795 ewk_view_popup_destroy(data);
796}
797
798static void
799_ewk_view_popup_create_cb(void *data, Evas_Object *obj, void *event_info)
800{
801 Widget_Data *wd = data;
802 Ewk_Menu *m = event_info;
803 Elm_Web_Menu m2;
804 Ewk_Menu_Item *it;
805 Eina_List *itr;
806 Evas_Object *notify, *list;
807
808 m2.items = m->items;
809 m2.x = m->x;
810 m2.y = m->y;
811 m2.width = m->width;
812 m2.height = m->height;
813 m2.handled = EINA_FALSE;
814 evas_object_smart_callback_call(wd->self, "popup,create", &m2);
815 if (m2.handled)
816 return;
817
818 notify = elm_notify_add(obj);
819 elm_notify_repeat_events_set(notify, EINA_FALSE);
820 elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
821
822 list = elm_list_add(obj);
823 elm_list_always_select_mode_set(list, EINA_TRUE);
824 elm_list_bounce_set(list, EINA_FALSE, EINA_FALSE);
825 elm_list_mode_set(list, ELM_LIST_EXPAND);
826 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
827 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
828 elm_notify_content_set(notify, list);
829 evas_object_show(list);
830
831 EINA_LIST_FOREACH(m->items, itr, it)
832 elm_list_item_append(list, it->text, NULL, NULL, _popup_item_selected,
833 obj);
834 elm_list_go(list);
835
836 evas_object_show(notify);
837
838 evas_object_smart_callback_add(obj, "popup,willdelete", _popup_will_delete,
839 notify);
840 evas_object_smart_callback_add(notify, "block,clicked", _popup_dismiss_cb,
841 obj);
842}
843
844static void
845_view_smart_callback_proxy_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
846{
847 free(data);
848}
849
850static void
851_view_smart_callback_proxy_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
852{
853 Elm_Web_Callback_Proxy_Context *ctxt = data;
854
855 evas_object_smart_callback_call(ctxt->obj, ctxt->name, event_info);
856}
857
858static void
859_view_smart_callback_proxy(Evas_Object *view, Evas_Object *parent)
860{
861 const Evas_Smart_Cb_Description **cls_descs, **inst_descs;
862 unsigned int cls_count, inst_count, total;
863 Elm_Web_Callback_Proxy_Context *ctxt;
864
865 evas_object_smart_callbacks_descriptions_get(view, &cls_descs, &cls_count,
866 &inst_descs, &inst_count);
867 total = cls_count + inst_count;
868 if (!total) return;
869 ctxt = malloc(sizeof(Elm_Web_Callback_Proxy_Context) * total);
870 if (!ctxt) return;
871 evas_object_event_callback_add(view, EVAS_CALLBACK_FREE,
872 _view_smart_callback_proxy_free_cb, ctxt);
873
874 for (; cls_count > 0; cls_count--, cls_descs++, ctxt++)
875 {
876 const Evas_Smart_Cb_Description *d = *cls_descs;
877 if (!strcmp(d->name, "popup,create"))
878 continue;
879 ctxt->name = d->name;
880 ctxt->obj = parent;
881 evas_object_smart_callback_add(view, d->name,
882 _view_smart_callback_proxy_cb, ctxt);
883 }
884
885 for (; inst_count > 0; inst_count--, inst_descs++, ctxt++)
886 {
887 const Evas_Smart_Cb_Description *d = *inst_descs;
888 ctxt->name = d->name;
889 ctxt->obj = parent;
890 evas_object_smart_callback_add(view, d->name,
891 _view_smart_callback_proxy_cb, ctxt);
892 }
893}
894#endif
895
896#ifdef HAVE_ELEMENTARY_WEB
897static int _elm_need_web = 0;
898#endif
899
900void
901_elm_unneed_web(void)
902{
903#ifdef HAVE_ELEMENTARY_WEB
904 if (--_elm_need_web) return;
905
906 _elm_need_web = 0;
907 ewk_shutdown();
908#endif
909}
910
911EAPI Eina_Bool
912elm_need_web(void)
913{
914#ifdef HAVE_ELEMENTARY_WEB
915 if (_elm_need_web++) return EINA_TRUE;
916 ewk_init();
917 return EINA_TRUE;
918#else
919 return EINA_FALSE;
920#endif
921}
922
923EAPI Evas_Object *
924elm_web_add(Evas_Object *parent)
925{
926 Evas_Object *obj;
927 Widget_Data *wd;
928 Evas *e;
929
930 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
931
932 wd = calloc(1, sizeof(Widget_Data));
933 e = evas_object_evas_get(parent);
934 if (!e)
935 return NULL;
936 obj = elm_widget_add(e);
937 wd->self = obj;
938
939 if (!widtype)
940 {
941 widtype = eina_stringshare_add("web");
942 elm_widget_type_register(&widtype);
943 }
944
945 elm_widget_type_set(obj, widtype);
946 elm_widget_sub_object_add(parent, obj);
947 elm_widget_theme_hook_set(obj, _theme_hook);
948 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
949 elm_widget_event_hook_set(obj, _event_hook);
950 elm_widget_data_set(obj, wd);
951 elm_widget_can_focus_set(obj, EINA_TRUE);
952
953#ifdef HAVE_ELEMENTARY_WEB
954 wd->ewk_view = _view_add(obj);
955 ewk_view_setting_user_agent_set(wd->ewk_view, ELM_WEB_USER_AGENT);
956
957 wd->input_method = ELM_WIN_KEYBOARD_OFF;
958 evas_object_smart_callback_add(wd->ewk_view, "inputmethod,changed",
959 _ewk_view_inputmethod_change_cb, wd);
960 evas_object_smart_callback_add(wd->ewk_view, "load,started",
961 _ewk_view_load_started_cb, wd);
962 evas_object_smart_callback_add(wd->ewk_view, "popup,create",
963 _ewk_view_popup_create_cb, wd);
964
965 elm_widget_resize_object_set(obj, wd->ewk_view);
966
967 wd->tab_propagate = EINA_FALSE;
968 wd->inwin_mode = _elm_config->inwin_dialogs_enable;
969
970 _view_smart_callback_proxy(wd->ewk_view, wd->self);
971 evas_object_smart_callbacks_descriptions_set(obj, _elm_web_callback_names);
972
973 _theme_hook(obj);
974
975#else
976 wd->label = elm_label_add(obj);
977 elm_object_text_set(wd->label, "WebKit not supported!");
978 evas_object_show(wd->label);
979 elm_widget_resize_object_set(obj, wd->label);
980#endif
981
982 return obj;
983}
984
985EAPI Evas_Object *
986elm_web_webkit_view_get(const Evas_Object *obj)
987{
988 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
989#ifdef HAVE_ELEMENTARY_WEB
990 Widget_Data *wd = elm_widget_data_get(obj);
991 if (!wd) return NULL;
992 return wd->ewk_view;
993#else
994 ERR("Elementary not compiled with EWebKit support.");
995 return NULL;
996#endif
997}
998
999EAPI void
1000elm_web_window_create_hook_set(Evas_Object *obj, Elm_Web_Window_Open func, void *data)
1001{
1002 ELM_CHECK_WIDTYPE(obj, widtype);
1003#ifdef HAVE_ELEMENTARY_WEB
1004 Widget_Data *wd = elm_widget_data_get(obj);
1005 if (!wd) return;
1006 wd->hook.window_create = func;
1007 wd->hook.window_create_data = data;
1008#else
1009 (void)func;
1010 (void)data;
1011#endif
1012}
1013
1014EAPI void
1015elm_web_dialog_alert_hook_set(Evas_Object *obj, Elm_Web_Dialog_Alert func, void *data)
1016{
1017 ELM_CHECK_WIDTYPE(obj, widtype);
1018#ifdef HAVE_ELEMENTARY_WEB
1019 Widget_Data *wd = elm_widget_data_get(obj);
1020 if (!wd) return;
1021 wd->hook.alert = func;
1022 wd->hook.alert_data = data;
1023#else
1024 (void)func;
1025 (void)data;
1026#endif
1027}
1028
1029EAPI void
1030elm_web_dialog_confirm_hook_set(Evas_Object *obj, Elm_Web_Dialog_Confirm func, void *data)
1031{
1032 ELM_CHECK_WIDTYPE(obj, widtype);
1033#ifdef HAVE_ELEMENTARY_WEB
1034 Widget_Data *wd = elm_widget_data_get(obj);
1035 if (!wd) return;
1036 wd->hook.confirm = func;
1037 wd->hook.confirm_data = data;
1038#else
1039 (void)func;
1040 (void)data;
1041#endif
1042}
1043
1044EAPI void
1045elm_web_dialog_prompt_hook_set(Evas_Object *obj, Elm_Web_Dialog_Prompt func, void *data)
1046{
1047 ELM_CHECK_WIDTYPE(obj, widtype);
1048#ifdef HAVE_ELEMENTARY_WEB
1049 Widget_Data *wd = elm_widget_data_get(obj);
1050 if (!wd) return;
1051 wd->hook.prompt = func;
1052 wd->hook.prompt_data = data;
1053#else
1054 (void)func;
1055 (void)data;
1056#endif
1057}
1058
1059EAPI void
1060elm_web_dialog_file_selector_hook_set(Evas_Object *obj, Elm_Web_Dialog_File_Selector func, void *data)
1061{
1062 ELM_CHECK_WIDTYPE(obj, widtype);
1063#ifdef HAVE_ELEMENTARY_WEB
1064 Widget_Data *wd = elm_widget_data_get(obj);
1065 if (!wd) return;
1066 wd->hook.file_selector = func;
1067 wd->hook.file_selector_data = data;
1068#else
1069 (void)func;
1070 (void)data;
1071#endif
1072}
1073
1074EAPI void
1075elm_web_console_message_hook_set(Evas_Object *obj, Elm_Web_Console_Message func, void *data)
1076{
1077 ELM_CHECK_WIDTYPE(obj, widtype);
1078#ifdef HAVE_ELEMENTARY_WEB
1079 Widget_Data *wd = elm_widget_data_get(obj);
1080 if (!wd) return;
1081 wd->hook.console_message = func;
1082 wd->hook.console_message_data = data;
1083#else
1084 (void)func;
1085 (void)data;
1086#endif
1087}
1088
1089EAPI Eina_Bool
1090elm_web_tab_propagate_get(const Evas_Object *obj)
1091{
1092 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1093#ifdef HAVE_ELEMENTARY_WEB
1094 Widget_Data *wd = elm_widget_data_get(obj);
1095 if (!wd) return EINA_FALSE;
1096 return wd->tab_propagate;
1097#else
1098 return EINA_FALSE;
1099#endif
1100}
1101
1102EAPI void
1103elm_web_tab_propagate_set(Evas_Object *obj, Eina_Bool propagate)
1104{
1105 ELM_CHECK_WIDTYPE(obj, widtype);
1106#ifdef HAVE_ELEMENTARY_WEB
1107 Widget_Data *wd = elm_widget_data_get(obj);
1108 if (!wd) return;
1109 wd->tab_propagate = propagate;
1110#else
1111 (void)propagate;
1112#endif
1113}
1114
1115EAPI Eina_Bool
1116elm_web_uri_set(Evas_Object *obj, const char *uri)
1117{
1118 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1119#ifdef HAVE_ELEMENTARY_WEB
1120 Widget_Data *wd = elm_widget_data_get(obj);
1121 if (!wd) return EINA_FALSE;
1122 return ewk_view_uri_set(wd->ewk_view, uri);
1123#else
1124 (void)uri;
1125 return EINA_FALSE;
1126#endif
1127}
1128
1129EAPI const char *
1130elm_web_uri_get(const Evas_Object *obj)
1131{
1132 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1133#ifdef HAVE_ELEMENTARY_WEB
1134 Widget_Data *wd = elm_widget_data_get(obj);
1135 if (!wd) return NULL;
1136 return ewk_view_uri_get(wd->ewk_view);
1137#else
1138 return NULL;
1139#endif
1140}
1141
1142EAPI const char *
1143elm_web_title_get(const Evas_Object *obj)
1144{
1145 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1146#ifdef HAVE_ELEMENTARY_WEB
1147 Widget_Data *wd = elm_widget_data_get(obj);
1148 if (!wd) return NULL;
1149 return ewk_view_title_get(wd->ewk_view);
1150#else
1151 return NULL;
1152#endif
1153}
1154
1155EAPI void
1156elm_web_bg_color_set(Evas_Object *obj, int r, int g, int b, int a)
1157{
1158 ELM_CHECK_WIDTYPE(obj, widtype);
1159#ifdef HAVE_ELEMENTARY_WEB
1160 Widget_Data *wd = elm_widget_data_get(obj);
1161 if (!wd) return;
1162 ewk_view_bg_color_set(wd->ewk_view, r, g, b, a);
1163#else
1164 (void)r;
1165 (void)g;
1166 (void)b;
1167 (void)a;
1168#endif
1169}
1170
1171EAPI void
1172elm_web_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a)
1173{
1174 if (r) *r = 0;
1175 if (g) *g = 0;
1176 if (b) *b = 0;
1177 if (a) *a = 0;
1178 ELM_CHECK_WIDTYPE(obj, widtype);
1179#ifdef HAVE_ELEMENTARY_WEB
1180 Widget_Data *wd = elm_widget_data_get(obj);
1181 if (!wd) return;
1182 return ewk_view_bg_color_get(wd->ewk_view, r, g, b, a);
1183#endif
1184}
1185
1186EAPI char *
1187elm_web_selection_get(const Evas_Object *obj)
1188{
1189 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1190#ifdef HAVE_ELEMENTARY_WEB
1191 Widget_Data *wd = elm_widget_data_get(obj);
1192 if (!wd) return NULL;
1193 return ewk_view_selection_get(wd->ewk_view);
1194#else
1195 return NULL;
1196#endif
1197}
1198
1199EAPI void
1200elm_web_popup_selected_set(Evas_Object *obj, int index)
1201{
1202 ELM_CHECK_WIDTYPE(obj, widtype);
1203#ifdef HAVE_ELEMENTARY_WEB
1204 Widget_Data *wd = elm_widget_data_get(obj);
1205 ewk_view_popup_selected_set(wd->ewk_view, index);
1206#else
1207 (void)index;
1208#endif
1209}
1210
1211EAPI Eina_Bool
1212elm_web_popup_destroy(Evas_Object *obj)
1213{
1214 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1215#ifdef HAVE_ELEMENTARY_WEB
1216 Widget_Data *wd = elm_widget_data_get(obj);
1217 return ewk_view_popup_destroy(wd->ewk_view);
1218#else
1219 return EINA_FALSE;
1220#endif
1221}
1222
1223EAPI Eina_Bool
1224elm_web_text_search(const Evas_Object *obj, const char *string, Eina_Bool case_sensitive, Eina_Bool forward, Eina_Bool wrap)
1225{
1226 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1227#ifdef HAVE_ELEMENTARY_WEB
1228 Widget_Data *wd = elm_widget_data_get(obj);
1229 if (!wd) return EINA_FALSE;
1230 return ewk_view_text_search
1231 (wd->ewk_view, string, case_sensitive, forward, wrap);
1232#else
1233 (void)string;
1234 (void)case_sensitive;
1235 (void)forward;
1236 (void)wrap;
1237 return EINA_FALSE;
1238#endif
1239}
1240
1241EAPI unsigned int
1242elm_web_text_matches_mark(Evas_Object *obj, const char *string, Eina_Bool case_sensitive, Eina_Bool highlight, unsigned int limit)
1243{
1244 ELM_CHECK_WIDTYPE(obj, widtype) 0;
1245#ifdef HAVE_ELEMENTARY_WEB
1246 Widget_Data *wd = elm_widget_data_get(obj);
1247 if (!wd) return 0;
1248 return ewk_view_text_matches_mark
1249 (wd->ewk_view, string, case_sensitive, highlight, limit);
1250#else
1251 (void)string;
1252 (void)case_sensitive;
1253 (void)highlight;
1254 (void)limit;
1255 return 0;
1256#endif
1257}
1258
1259EAPI Eina_Bool
1260elm_web_text_matches_unmark_all(Evas_Object *obj)
1261{
1262 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1263#ifdef HAVE_ELEMENTARY_WEB
1264 Widget_Data *wd = elm_widget_data_get(obj);
1265 if (!wd) return EINA_FALSE;
1266 return ewk_view_text_matches_unmark_all(wd->ewk_view);
1267#else
1268 return EINA_FALSE;
1269#endif
1270}
1271
1272EAPI Eina_Bool
1273elm_web_text_matches_highlight_set(Evas_Object *obj, Eina_Bool highlight)
1274{
1275 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1276#ifdef HAVE_ELEMENTARY_WEB
1277 Widget_Data *wd = elm_widget_data_get(obj);
1278 if (!wd) return EINA_FALSE;
1279 return ewk_view_text_matches_highlight_set(wd->ewk_view, highlight);
1280#else
1281 (void)highlight;
1282 return EINA_FALSE;
1283#endif
1284}
1285
1286EAPI Eina_Bool
1287elm_web_text_matches_highlight_get(const Evas_Object *obj)
1288{
1289 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1290#ifdef HAVE_ELEMENTARY_WEB
1291 Widget_Data *wd = elm_widget_data_get(obj);
1292 if (!wd) return EINA_FALSE;
1293 return ewk_view_text_matches_highlight_get(wd->ewk_view);
1294#else
1295 return EINA_FALSE;
1296#endif
1297}
1298
1299EAPI double
1300elm_web_load_progress_get(const Evas_Object *obj)
1301{
1302 ELM_CHECK_WIDTYPE(obj, widtype) -1.0;
1303#ifdef HAVE_ELEMENTARY_WEB
1304 Widget_Data *wd = elm_widget_data_get(obj);
1305 if (!wd) return -1.0;
1306 return ewk_view_load_progress_get(wd->ewk_view);
1307#else
1308 return EINA_FALSE;
1309#endif
1310}
1311
1312EAPI Eina_Bool
1313elm_web_stop(Evas_Object *obj)
1314{
1315 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1316#ifdef HAVE_ELEMENTARY_WEB
1317 Widget_Data *wd = elm_widget_data_get(obj);
1318 if (!wd) return EINA_FALSE;
1319 return ewk_view_stop(wd->ewk_view);
1320#else
1321 return EINA_FALSE;
1322#endif
1323}
1324
1325EAPI Eina_Bool
1326elm_web_reload(Evas_Object *obj)
1327{
1328 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1329#ifdef HAVE_ELEMENTARY_WEB
1330 Widget_Data *wd = elm_widget_data_get(obj);
1331 if (!wd) return EINA_FALSE;
1332 return ewk_view_reload(wd->ewk_view);
1333#else
1334 return EINA_FALSE;
1335#endif
1336}
1337
1338EAPI Eina_Bool
1339elm_web_reload_full(Evas_Object *obj)
1340{
1341 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1342#ifdef HAVE_ELEMENTARY_WEB
1343 Widget_Data *wd = elm_widget_data_get(obj);
1344 if (!wd) return EINA_FALSE;
1345 return ewk_view_reload_full(wd->ewk_view);
1346#else
1347 return EINA_FALSE;
1348#endif
1349}
1350
1351
1352EAPI Eina_Bool
1353elm_web_back(Evas_Object *obj)
1354{
1355 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1356#ifdef HAVE_ELEMENTARY_WEB
1357 Widget_Data *wd = elm_widget_data_get(obj);
1358 if (!wd) return EINA_FALSE;
1359 return ewk_view_back(wd->ewk_view);
1360#else
1361 return EINA_FALSE;
1362#endif
1363}
1364
1365EAPI Eina_Bool
1366elm_web_forward(Evas_Object *obj)
1367{
1368 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1369#ifdef HAVE_ELEMENTARY_WEB
1370 Widget_Data *wd = elm_widget_data_get(obj);
1371 if (!wd) return EINA_FALSE;
1372 return ewk_view_forward(wd->ewk_view);
1373#else
1374 return EINA_FALSE;
1375#endif
1376}
1377
1378EAPI Eina_Bool
1379elm_web_navigate(Evas_Object *obj, int steps)
1380{
1381 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1382#ifdef HAVE_ELEMENTARY_WEB
1383 Widget_Data *wd = elm_widget_data_get(obj);
1384 if (!wd) return EINA_FALSE;
1385 return ewk_view_navigate(wd->ewk_view, steps);
1386#else
1387 return EINA_FALSE;
1388 (void)steps;
1389#endif
1390}
1391
1392EAPI Eina_Bool
1393elm_web_back_possible(Evas_Object *obj)
1394{
1395 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1396#ifdef HAVE_ELEMENTARY_WEB
1397 Widget_Data *wd = elm_widget_data_get(obj);
1398 if (!wd) return EINA_FALSE;
1399 return ewk_view_back_possible(wd->ewk_view);
1400#else
1401 return EINA_FALSE;
1402#endif
1403}
1404
1405EAPI Eina_Bool
1406elm_web_forward_possible(Evas_Object *obj)
1407{
1408 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1409#ifdef HAVE_ELEMENTARY_WEB
1410 Widget_Data *wd = elm_widget_data_get(obj);
1411 if (!wd) return EINA_FALSE;
1412 return ewk_view_forward_possible(wd->ewk_view);
1413#else
1414 return EINA_FALSE;
1415#endif
1416}
1417
1418EAPI Eina_Bool
1419elm_web_navigate_possible(Evas_Object *obj, int steps)
1420{
1421 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1422#ifdef HAVE_ELEMENTARY_WEB
1423 Widget_Data *wd = elm_widget_data_get(obj);
1424 if (!wd) return EINA_FALSE;
1425 return ewk_view_navigate_possible(wd->ewk_view, steps);
1426#else
1427 return EINA_FALSE;
1428 (void)steps;
1429#endif
1430}
1431
1432EAPI Eina_Bool
1433elm_web_history_enable_get(const Evas_Object *obj)
1434{
1435 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1436#ifdef HAVE_ELEMENTARY_WEB
1437 Widget_Data *wd = elm_widget_data_get(obj);
1438 if (!wd) return EINA_FALSE;
1439 return ewk_view_history_enable_get(wd->ewk_view);
1440#else
1441 return EINA_FALSE;
1442#endif
1443}
1444
1445EAPI void
1446elm_web_history_enable_set(Evas_Object *obj, Eina_Bool enable)
1447{
1448 ELM_CHECK_WIDTYPE(obj, widtype);
1449#ifdef HAVE_ELEMENTARY_WEB
1450 Widget_Data *wd = elm_widget_data_get(obj);
1451 if (!wd) return;
1452 ewk_view_history_enable_set(wd->ewk_view, enable);
1453#else
1454 (void)enable;
1455#endif
1456}
1457
1458//EAPI Ewk_History *ewk_view_history_get(const Evas_Object *obj); // TODO:
1459
1460EAPI Eina_Bool
1461elm_web_zoom_text_only_get(const Evas_Object *obj)
1462{
1463 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1464#ifdef HAVE_ELEMENTARY_WEB
1465 Widget_Data *wd = elm_widget_data_get(obj);
1466 if (!wd) return EINA_FALSE;
1467 return ewk_view_zoom_text_only_get(wd->ewk_view);
1468#else
1469 return EINA_FALSE;
1470#endif
1471}
1472
1473EAPI void
1474elm_web_zoom_text_only_set(Evas_Object *obj, Eina_Bool setting)
1475{
1476 ELM_CHECK_WIDTYPE(obj, widtype);
1477#ifdef HAVE_ELEMENTARY_WEB
1478 Widget_Data *wd = elm_widget_data_get(obj);
1479 if (!wd) return;
1480 ewk_view_zoom_text_only_set(wd->ewk_view, setting);
1481#else
1482 (void)setting;
1483#endif
1484}
1485
1486EAPI void
1487elm_web_inwin_mode_set(Evas_Object *obj, Eina_Bool value)
1488{
1489 ELM_CHECK_WIDTYPE(obj, widtype);
1490#ifdef HAVE_ELEMENTARY_WEB
1491 Widget_Data *wd = elm_widget_data_get(obj);
1492
1493 wd->inwin_mode = value;
1494#else
1495 (void)value;
1496#endif
1497}
1498
1499EAPI Eina_Bool
1500elm_web_inwin_mode_get(const Evas_Object *obj)
1501{
1502 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1503#ifdef HAVE_ELEMENTARY_WEB
1504 Widget_Data *wd = elm_widget_data_get(obj);
1505
1506 return wd->inwin_mode;
1507#else
1508 return EINA_FALSE;
1509#endif
1510}
1511
1512EAPI void
1513elm_web_window_features_ref(Elm_Web_Window_Features *wf)
1514{
1515#ifdef HAVE_ELEMENTARY_WEB
1516 ewk_window_features_ref((Ewk_Window_Features *)wf);
1517#else
1518 (void)wf;
1519#endif
1520}
1521
1522EAPI void
1523elm_web_window_features_unref(Elm_Web_Window_Features *wf)
1524{
1525#ifdef HAVE_ELEMENTARY_WEB
1526 ewk_window_features_unref((Ewk_Window_Features *)wf);
1527#else
1528 (void)wf;
1529#endif
1530}
1531
1532EAPI void
1533elm_web_window_features_bool_property_get(const Elm_Web_Window_Features *wf, Eina_Bool *toolbar_visible, Eina_Bool *statusbar_visible, Eina_Bool *scrollbars_visible, Eina_Bool *menubar_visible, Eina_Bool *locationbar_visible, Eina_Bool *fullscreen)
1534{
1535#ifdef HAVE_ELEMENTARY_WEB
1536 ewk_window_features_bool_property_get((const Ewk_Window_Features *)wf,
1537 toolbar_visible, statusbar_visible,
1538 scrollbars_visible, menubar_visible,
1539 locationbar_visible, fullscreen);
1540#else
1541 (void)wf;
1542 (void)toolbar_visible;
1543 (void)statusbar_visible;
1544 (void)scrollbars_visible;
1545 (void)menubar_visible;
1546 (void)locationbar_visible;
1547 (void)fullscreen;
1548#endif
1549}
1550
1551EAPI void
1552elm_web_window_features_int_property_get(const Elm_Web_Window_Features *wf, int *x, int *y, int *w, int *h)
1553{
1554#ifdef HAVE_ELEMENTARY_WEB
1555 ewk_window_features_int_property_get((const Ewk_Window_Features *)wf,
1556 x, y, w, h);
1557#else
1558 (void)wf;
1559 (void)x;
1560 (void)y;
1561 (void)w;
1562 (void)h;
1563#endif
1564}
1565
1566// TODO: use all ewk_view_zoom stuff to implement bring-in and animated zoom like elm_photocam. Should be simple to use, must not expose every single bit to users!