forked from enlightenment/efl
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.
This commit is contained in:
parent
834222d3a0
commit
97a2d7ff33
|
@ -81,10 +81,84 @@ test_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
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");
|
||||
|
@ -95,15 +169,32 @@ test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
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)
|
||||
{
|
||||
|
@ -126,6 +217,32 @@ test_remote_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ interface Efl.File {
|
|||
}
|
||||
}
|
||||
events {
|
||||
/* FIXME - remove Efl.File events: async,{opened,error} */
|
||||
async,opened; [[The file was successfully opened asynchronously]]
|
||||
async,error; [[Error occurred in asynchronous file operation]]
|
||||
}
|
||||
|
|
|
@ -897,7 +897,7 @@ _efl_ui_image_smart_download_done(void *data, Elm_Url *url, Eina_Binbuf *downloa
|
|||
|
||||
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
|
||||
{
|
||||
|
@ -906,8 +906,7 @@ _efl_ui_image_smart_download_done(void *data, Elm_Url *url, Eina_Binbuf *downloa
|
|||
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);
|
||||
|
@ -920,7 +919,7 @@ _efl_ui_image_smart_download_cancel(void *data, Elm_Url *url EINA_UNUSED, int er
|
|||
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);
|
||||
|
@ -934,7 +933,7 @@ _efl_ui_image_smart_download_progress(void *data, Elm_Url *url EINA_UNUSED, doub
|
|||
|
||||
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[] = {
|
||||
|
@ -969,8 +968,7 @@ _efl_ui_image_efl_file_file_set(Eo *obj, Efl_Ui_Image_Data *sd, const char *file
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -160,11 +160,7 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Draggable,
|
|||
Elm.Interface.Atspi_Widget_Action.elm_actions.get;
|
||||
}
|
||||
events {
|
||||
drop;
|
||||
download,start;
|
||||
download,progress;
|
||||
download,done;
|
||||
download,error;
|
||||
drop; /* FIXME - Belongs to DnD interface */
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,13 @@
|
|||
* typed object onto the object in question -- the
|
||||
* event info argument is the path to that image file
|
||||
* @li @c "clicked" - This is called when a user has clicked the image
|
||||
* @li @c "download,start" - This is called when the remote image file download
|
||||
* has started.
|
||||
* @li @c "download,progress" - This is continuously called before the remote
|
||||
* image file download has done. The event info
|
||||
* data is of type Elm_Image_Progress.
|
||||
* @li @c "download,done" - This is called when the download has completed.
|
||||
* @li @c "download,error"- This is called when the download has failed.
|
||||
*
|
||||
* An example of usage for this API follows:
|
||||
* @li @ref tutorial_image
|
||||
|
|
Loading…
Reference in New Issue