evas_object_show(win);
}
+static void
+_download_start_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Evas_Object *win = data, *txt;
+ const char *url = NULL;
+ char buf[4096] = {0};
+
+ txt = evas_object_data_get(win, "txt");
+ elm_image_file_get(txt, &url, NULL);
+ snprintf(buf, sizeof(buf) - 1, "Remote image download started:\n%s", url);
+ elm_object_text_set(txt, buf);
+ printf("%s\n", buf);
+ fflush(stdout);
+}
+
+static void
+_download_progress_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+ Elm_Image_Progress *p = event_info;
+ Evas_Object *win = data, *txt;
+ char buf[4096] = {0};
+
+ txt = evas_object_data_get(win, "txt");
+ snprintf(buf, sizeof(buf) - 1, "Remote image download progress %.2f/%.2f.", p->now, p->total);
+ elm_object_text_set(txt, buf);
+ printf("%s\n", buf);
+ fflush(stdout);
+}
+
+static void
+_download_done_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Evas_Object *win = data, *txt;
+ char buf[4096] = {0};
+
+ txt = evas_object_data_get(win, "txt");
+ snprintf(buf, sizeof(buf) - 1, "Remote image download done.");
+ elm_object_text_set(txt, buf);
+ printf("%s\n", buf);
+ fflush(stdout);
+
+ evas_object_hide(txt);
+}
+
+static void
+_download_error_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Evas_Object *win = data, *txt;
+ char buf[4096] = {0};
+
+ txt = evas_object_data_get(win, "txt");
+ snprintf(buf, sizeof(buf) - 1, "Remote image download failed.");
+ elm_object_text_set(txt, buf);
+ printf("%s\n", buf);
+ fflush(stdout);
+
+ evas_object_show(txt);
+}
+
+static void
+_url_activate_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+ Evas_Object *win = data, *txt, *im;
+ const char *url;
+
+ im = evas_object_data_get(win, "im");
+ txt = evas_object_data_get(win, "txt");
+
+ url = elm_object_text_get(obj);
+ elm_image_file_set(im, url, NULL);
+
+ evas_object_show(txt);
+}
+
void
test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
- Evas_Object *win, *box, *im, *rd, *rdg = NULL;
+ Evas_Object *win, *box, *im, *rd, *rdg = NULL, *box2, *o, *tbl, *txt;
int i;
win = elm_win_util_standard_add("image test", "Image Test");
elm_win_resize_object_add(win, box);
evas_object_show(box);
- im = elm_image_add(win);
- elm_image_file_set(im, "http://41.media.tumblr.com/29f1ecd4f98aaff73fb21f479b450d4c/tumblr_mqsxdciQmB1rrju89o1_1280.jpg", NULL);
- evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ tbl = o = elm_table_add(win);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(box, im);
- evas_object_show(im);
+ txt = o = elm_label_add(box);
+ elm_label_line_wrap_set(o, 1);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_table_pack(tbl, o, 0, 0, 1, 1);
+ evas_object_data_set(win, "txt", o);
+ evas_object_hide(o);
- evas_object_data_set(win, "im", im);
+ im = o = elm_image_add(win);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_data_set(win, "im", o);
+ elm_table_pack(tbl, o, 0, 0, 1, 1);
+ evas_object_show(o);
+
+ elm_box_pack_end(box, tbl);
+ evas_object_show(tbl);
+
+ evas_object_smart_callback_add(im, "download,start", _download_start_cb, win);
+ evas_object_smart_callback_add(im, "download,progress", _download_progress_cb, win);
+ evas_object_smart_callback_add(im, "download,done", _download_done_cb, win);
+ evas_object_smart_callback_add(im, "download,error", _download_error_cb, win);
for (i = 0; images_orient[i].name; ++i)
{
}
}
+ box2 = o = elm_box_add(box);
+ elm_box_horizontal_set(o, 1);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
+ evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ o = elm_label_add(box2);
+ elm_object_text_set(o, "URL:");
+ elm_box_pack_end(box2, o);
+ evas_object_show(o);
+
+ o = elm_entry_add(box2);
+ elm_entry_scrollable_set(o, 1);
+ elm_entry_single_line_set(o, 1);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0);
+ evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_object_text_set(o, "http://41.media.tumblr.com/29f1ecd4f98aaff73fb21f479b450d4c/tumblr_mqsxdciQmB1rrju89o1_1280.jpg");
+ evas_object_smart_callback_add(o, "activated", _url_activate_cb, win);
+ elm_box_pack_end(box2, o);
+ evas_object_show(o);
+
+ elm_box_pack_end(box, box2);
+ evas_object_show(box2);
+
+ // set file now
+ _url_activate_cb(win, o, NULL);
+
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
free(sd->remote_data);
sd->remote_data = NULL;
- efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_ERROR, &err);
+ evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &err);
}
else
{
sd->preload_status = EFL_UI_IMAGE_PRELOADING;
evas_object_image_preload(sd->img, EINA_FALSE);
}
-
- efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_DONE, NULL);
+ evas_object_smart_callback_call(obj, SIG_DOWNLOAD_DONE, NULL);
}
ELM_SAFE_FREE(sd->key, eina_stringshare_del);
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
Efl_Ui_Image_Error err = { error, EINA_FALSE };
- efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_ERROR, &err);
+ evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &err);
sd->remote = NULL;
ELM_SAFE_FREE(sd->key, eina_stringshare_del);
progress.now = now;
progress.total = total;
- efl_event_callback_legacy_call(obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_PROGRESS, &progress);
+ evas_object_smart_callback_call(obj, SIG_DOWNLOAD_PROGRESS, &progress);
}
static const char *remote_uri[] = {
obj);
if (sd->remote)
{
- efl_event_callback_legacy_call
- (obj, EFL_UI_IMAGE_EVENT_DOWNLOAD_START, NULL);
+ evas_object_smart_callback_call(obj, SIG_DOWNLOAD_START, NULL);
eina_stringshare_replace(&sd->key, key);
return EINA_TRUE;
}