summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel@osg.samsung.com>2017-12-04 20:23:52 +0000
committerMarcel Hollerbach <marcel@osg.samsung.com>2017-12-04 20:23:52 +0000
commited96310fa5b46c94c9edd6925f3465f1a0d0c117 (patch)
tree762c02fdca8633b18dcf26b2e51d82aa5bb1a1df
parent9090962f01137ffdea56cbfd76be0d26a964aa84 (diff)
wiked: use smart callbacks to show uris in the browser
-rw-r--r--src/main.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/main.c b/src/main.c
index 9890201..8fc8d8f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,31 +2,26 @@
2#include <Ecore_Con.h> 2#include <Ecore_Con.h>
3#include <Elementary.h> 3#include <Elementary.h>
4 4
5static Evas_Object *win;
5static Ecore_Timer *timer = NULL; 6static Ecore_Timer *timer = NULL;
6static Wiki *w; 7static Wiki *w;
7 8
8static void 9static void
9_wiki_item_clicked_twice(void *data EINA_UNUSED, Evas_Object *obj, void *event_info) 10_wiki_item_clicked_twice(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
10{ 11{
11 Eina_Strbuf *buf; 12 evas_object_smart_callback_call(win, "gadget_open_uri", elm_object_item_data_get(event_info));
12
13 buf = eina_strbuf_new();
14 eina_strbuf_append(buf, "xdg-open ");
15 eina_strbuf_append(buf, elm_object_item_data_get(event_info));
16
17 system(eina_strbuf_release(buf));
18} 13}
19 14
20static Eina_Value 15static Eina_Value
21_wiki_arrived(void *data, const Eina_Value value, const Eina_Future *f) 16_wiki_arrived(void *data, const Eina_Value value, const Eina_Future *f)
22{ 17{
23 Evas_Object *win, *entry = data, *list; 18 Evas_Object *popup, *entry = data, *list;
24 19
25 //this creates a new popup due to runner 20 //this creates a new popup due to runner
26 win = elm_win_add(elm_win_get(entry), "win", ELM_WIN_POPUP_MENU); 21 popup = elm_win_add(elm_win_get(entry), "win", ELM_WIN_POPUP_MENU);
27 elm_win_alpha_set(win, 1); 22 elm_win_alpha_set(popup, 1);
28 23
29 list = elm_list_add(win); 24 list = elm_list_add(popup);
30 evas_object_smart_callback_add(list, "clicked,double", _wiki_item_clicked_twice, NULL); 25 evas_object_smart_callback_add(list, "clicked,double", _wiki_item_clicked_twice, NULL);
31 26
32 for (int i = 0; i < eina_value_array_count(&value); ++i) 27 for (int i = 0; i < eina_value_array_count(&value); ++i)
@@ -55,9 +50,9 @@ _wiki_arrived(void *data, const Eina_Value value, const Eina_Future *f)
55 evas_object_size_hint_min_set(list, 200, 150); 50 evas_object_size_hint_min_set(list, 200, 150);
56 evas_object_show(list); 51 evas_object_show(list);
57 52
58 elm_win_resize_object_add(win, list); 53 elm_win_resize_object_add(popup, list);
59 54
60 evas_object_show(win); 55 evas_object_show(popup);
61 56
62 return value; 57 return value;
63} 58}
@@ -113,7 +108,7 @@ _changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
113 108
114int elm_main(int argc, char *argv[]) 109int elm_main(int argc, char *argv[])
115{ 110{
116 Evas_Object *win, *o; 111 Evas_Object *o;
117 112
118 //create the wiki instance 113 //create the wiki instance
119 w = wiki_new(ecore_main_loop_get(), "en.wikipedia.org"); 114 w = wiki_new(ecore_main_loop_get(), "en.wikipedia.org");