summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-09-22 12:36:27 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-09-22 15:02:45 +0900
commit97a2d7ff33d9e8493427bf4eb4fdea4163808bf2 (patch)
tree5076119c33620b8902b70d5099761cad19f59934
parent834222d3a019e548a238a59f040f869487c14adc (diff)
elm_image: Move back download events to legacy only
The events for (async) image download will be redefined by @cedric later. So, remove them from eo now and only keep their legacy implementation. Also, improve elm_test example and add docs.
-rw-r--r--src/bin/elementary/test_image.c133
-rw-r--r--src/lib/efl/interfaces/efl_file.eo1
-rw-r--r--src/lib/elementary/efl_ui_image.c12
-rw-r--r--src/lib/elementary/efl_ui_image.eo6
-rw-r--r--src/lib/elementary/elm_image.h7
5 files changed, 139 insertions, 20 deletions
diff --git a/src/bin/elementary/test_image.c b/src/bin/elementary/test_image.c
index 7ef6914776..38624ea893 100644
--- a/src/bin/elementary/test_image.c
+++ b/src/bin/elementary/test_image.c
@@ -81,10 +81,84 @@ test_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
81 evas_object_show(win); 81 evas_object_show(win);
82} 82}
83 83
84static void
85_download_start_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
86{
87 Evas_Object *win = data, *txt;
88 const char *url = NULL;
89 char buf[4096] = {0};
90
91 txt = evas_object_data_get(win, "txt");
92 elm_image_file_get(txt, &url, NULL);
93 snprintf(buf, sizeof(buf) - 1, "Remote image download started:\n%s", url);
94 elm_object_text_set(txt, buf);
95 printf("%s\n", buf);
96 fflush(stdout);
97}
98
99static void
100_download_progress_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
101{
102 Elm_Image_Progress *p = event_info;
103 Evas_Object *win = data, *txt;
104 char buf[4096] = {0};
105
106 txt = evas_object_data_get(win, "txt");
107 snprintf(buf, sizeof(buf) - 1, "Remote image download progress %.2f/%.2f.", p->now, p->total);
108 elm_object_text_set(txt, buf);
109 printf("%s\n", buf);
110 fflush(stdout);
111}
112
113static void
114_download_done_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
115{
116 Evas_Object *win = data, *txt;
117 char buf[4096] = {0};
118
119 txt = evas_object_data_get(win, "txt");
120 snprintf(buf, sizeof(buf) - 1, "Remote image download done.");
121 elm_object_text_set(txt, buf);
122 printf("%s\n", buf);
123 fflush(stdout);
124
125 evas_object_hide(txt);
126}
127
128static void
129_download_error_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
130{
131 Evas_Object *win = data, *txt;
132 char buf[4096] = {0};
133
134 txt = evas_object_data_get(win, "txt");
135 snprintf(buf, sizeof(buf) - 1, "Remote image download failed.");
136 elm_object_text_set(txt, buf);
137 printf("%s\n", buf);
138 fflush(stdout);
139
140 evas_object_show(txt);
141}
142
143static void
144_url_activate_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
145{
146 Evas_Object *win = data, *txt, *im;
147 const char *url;
148
149 im = evas_object_data_get(win, "im");
150 txt = evas_object_data_get(win, "txt");
151
152 url = elm_object_text_get(obj);
153 elm_image_file_set(im, url, NULL);
154
155 evas_object_show(txt);
156}
157
84void 158void
85test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 159test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
86{ 160{
87 Evas_Object *win, *box, *im, *rd, *rdg = NULL; 161 Evas_Object *win, *box, *im, *rd, *rdg = NULL, *box2, *o, *tbl, *txt;
88 int i; 162 int i;
89 163
90 win = elm_win_util_standard_add("image test", "Image Test"); 164 win = elm_win_util_standard_add("image test", "Image Test");
@@ -95,15 +169,32 @@ test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
95 elm_win_resize_object_add(win, box); 169 elm_win_resize_object_add(win, box);
96 evas_object_show(box); 170 evas_object_show(box);
97 171
98 im = elm_image_add(win); 172 tbl = o = elm_table_add(win);
99 elm_image_file_set(im, "http://41.media.tumblr.com/29f1ecd4f98aaff73fb21f479b450d4c/tumblr_mqsxdciQmB1rrju89o1_1280.jpg", NULL); 173 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
100 evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 174 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
101 evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
102 175
103 elm_box_pack_end(box, im); 176 txt = o = elm_label_add(box);
104 evas_object_show(im); 177 elm_label_line_wrap_set(o, 1);
178 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
179 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
180 elm_table_pack(tbl, o, 0, 0, 1, 1);
181 evas_object_data_set(win, "txt", o);
182 evas_object_hide(o);
105 183
106 evas_object_data_set(win, "im", im); 184 im = o = elm_image_add(win);
185 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
186 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
187 evas_object_data_set(win, "im", o);
188 elm_table_pack(tbl, o, 0, 0, 1, 1);
189 evas_object_show(o);
190
191 elm_box_pack_end(box, tbl);
192 evas_object_show(tbl);
193
194 evas_object_smart_callback_add(im, "download,start", _download_start_cb, win);
195 evas_object_smart_callback_add(im, "download,progress", _download_progress_cb, win);
196 evas_object_smart_callback_add(im, "download,done", _download_done_cb, win);
197 evas_object_smart_callback_add(im, "download,error", _download_error_cb, win);
107 198
108 for (i = 0; images_orient[i].name; ++i) 199 for (i = 0; images_orient[i].name; ++i)
109 { 200 {
@@ -126,6 +217,32 @@ test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
126 } 217 }
127 } 218 }
128 219
220 box2 = o = elm_box_add(box);
221 elm_box_horizontal_set(o, 1);
222 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
223 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
224
225 o = elm_label_add(box2);
226 elm_object_text_set(o, "URL:");
227 elm_box_pack_end(box2, o);
228 evas_object_show(o);
229
230 o = elm_entry_add(box2);
231 elm_entry_scrollable_set(o, 1);
232 elm_entry_single_line_set(o, 1);
233 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
234 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
235 elm_object_text_set(o, "http://41.media.tumblr.com/29f1ecd4f98aaff73fb21f479b450d4c/tumblr_mqsxdciQmB1rrju89o1_1280.jpg");
236 evas_object_smart_callback_add(o, "activated", _url_activate_cb, win);
237 elm_box_pack_end(box2, o);
238 evas_object_show(o);
239
240 elm_box_pack_end(box, box2);
241 evas_object_show(box2);
242
243 // set file now
244 _url_activate_cb(win, o, NULL);
245
129 evas_object_resize(win, 320, 480); 246 evas_object_resize(win, 320, 480);
130 evas_object_show(win); 247 evas_object_show(win);
131} 248}
diff --git a/src/lib/efl/interfaces/efl_file.eo b/src/lib/efl/interfaces/efl_file.eo
index ab89ec1ded..63f9e9b010 100644
--- a/src/lib/efl/interfaces/efl_file.eo
+++ b/src/lib/efl/interfaces/efl_file.eo
@@ -127,6 +127,7 @@ interface Efl.File {
127 } 127 }
128 } 128 }
129 events { 129 events {
130 /* FIXME - remove Efl.File events: async,{opened,error} */
130 async,opened; [[The file was successfully opened asynchronously]] 131 async,opened; [[The file was successfully opened asynchronously]]
131 async,error; [[Error occurred in asynchronous file operation]] 132 async,error; [[Error occurred in asynchronous file operation]]
132 } 133 }
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index 546233b568..bb8ef95dee 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -897,7 +897,7 @@ _efl_ui_image_smart_download_done(void *data, Elm_Url *url, Eina_Binbuf *downloa
897 897
898 free(sd->remote_data); 898 free(sd->remote_data);
899 sd->remote_data = NULL; 899 sd->remote_data = NULL;
900 efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_ERROR, &err); 900 evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &err);
901 } 901 }
902 else 902 else
903 { 903 {
@@ -906,8 +906,7 @@ _efl_ui_image_smart_download_done(void *data, Elm_Url *url, Eina_Binbuf *downloa
906 sd->preload_status = EFL_UI_IMAGE_PRELOADING; 906 sd->preload_status = EFL_UI_IMAGE_PRELOADING;
907 evas_object_image_preload(sd->img, EINA_FALSE); 907 evas_object_image_preload(sd->img, EINA_FALSE);
908 } 908 }
909 909 evas_object_smart_callback_call(obj, SIG_DOWNLOAD_DONE, NULL);
910 efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_DONE, NULL);
911 } 910 }
912 911
913 ELM_SAFE_FREE(sd->key, eina_stringshare_del); 912 ELM_SAFE_FREE(sd->key, eina_stringshare_del);
@@ -920,7 +919,7 @@ _efl_ui_image_smart_download_cancel(void *data, Elm_Url *url EINA_UNUSED, int er
920 Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS); 919 Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
921 Efl_Ui_Image_Error err = { error, EINA_FALSE }; 920 Efl_Ui_Image_Error err = { error, EINA_FALSE };
922 921
923 efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_ERROR, &err); 922 evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &err);
924 923
925 sd->remote = NULL; 924 sd->remote = NULL;
926 ELM_SAFE_FREE(sd->key, eina_stringshare_del); 925 ELM_SAFE_FREE(sd->key, eina_stringshare_del);
@@ -934,7 +933,7 @@ _efl_ui_image_smart_download_progress(void *data, Elm_Url *url EINA_UNUSED, doub
934 933
935 progress.now = now; 934 progress.now = now;
936 progress.total = total; 935 progress.total = total;
937 efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_PROGRESS, &progress); 936 evas_object_smart_callback_call(obj, SIG_DOWNLOAD_PROGRESS, &progress);
938} 937}
939 938
940static const char *remote_uri[] = { 939static const char *remote_uri[] = {
@@ -969,8 +968,7 @@ _efl_ui_image_efl_file_file_set(Eo *obj, Efl_Ui_Image_Data *sd, const char *file
969 obj); 968 obj);
970 if (sd->remote) 969 if (sd->remote)
971 { 970 {
972 efl_event_callback_legacy_call 971 evas_object_smart_callback_call(obj, SIG_DOWNLOAD_START, NULL);
973 (obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_START, NULL);
974 eina_stringshare_replace(&sd->key, key); 972 eina_stringshare_replace(&sd->key, key);
975 return EINA_TRUE; 973 return EINA_TRUE;
976 } 974 }
diff --git a/src/lib/elementary/efl_ui_image.eo b/src/lib/elementary/efl_ui_image.eo
index 90c05b9e1b..d84139e89e 100644
--- a/src/lib/elementary/efl_ui_image.eo
+++ b/src/lib/elementary/efl_ui_image.eo
@@ -160,11 +160,7 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Draggable,
160 Elm.Interface.Atspi_Widget_Action.elm_actions.get; 160 Elm.Interface.Atspi_Widget_Action.elm_actions.get;
161 } 161 }
162 events { 162 events {
163 drop; 163 drop; /* FIXME - Belongs to DnD interface */
164 download,start;
165 download,progress;
166 download,done;
167 download,error;
168 } 164 }
169 165
170} 166}
diff --git a/src/lib/elementary/elm_image.h b/src/lib/elementary/elm_image.h
index 693086d201..51ba0cf44e 100644
--- a/src/lib/elementary/elm_image.h
+++ b/src/lib/elementary/elm_image.h
@@ -30,6 +30,13 @@
30 * typed object onto the object in question -- the 30 * typed object onto the object in question -- the
31 * event info argument is the path to that image file 31 * event info argument is the path to that image file
32 * @li @c "clicked" - This is called when a user has clicked the image 32 * @li @c "clicked" - This is called when a user has clicked the image
33 * @li @c "download,start" - This is called when the remote image file download
34 * has started.
35 * @li @c "download,progress" - This is continuously called before the remote
36 * image file download has done. The event info
37 * data is of type Elm_Image_Progress.
38 * @li @c "download,done" - This is called when the download has completed.
39 * @li @c "download,error"- This is called when the download has failed.
33 * 40 *
34 * An example of usage for this API follows: 41 * An example of usage for this API follows:
35 * @li @ref tutorial_image 42 * @li @ref tutorial_image