jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=97a2d7ff33d9e8493427bf4eb4fdea4163808bf2

commit 97a2d7ff33d9e8493427bf4eb4fdea4163808bf2
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Thu Sep 22 12:36:27 2016 +0900

    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.
---
 src/bin/elementary/test_image.c    | 133 ++++++++++++++++++++++++++++++++++---
 src/lib/efl/interfaces/efl_file.eo |   1 +
 src/lib/elementary/efl_ui_image.c  |  12 ++--
 src/lib/elementary/efl_ui_image.eo |   6 +-
 src/lib/elementary/elm_image.h     |   7 ++
 5 files changed, 139 insertions(+), 20 deletions(-)

diff --git a/src/bin/elementary/test_image.c b/src/bin/elementary/test_image.c
index 7ef6914..38624ea 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
    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);
 }
diff --git a/src/lib/efl/interfaces/efl_file.eo 
b/src/lib/efl/interfaces/efl_file.eo
index ab89ec1..63f9e9b 100644
--- a/src/lib/efl/interfaces/efl_file.eo
+++ b/src/lib/efl/interfaces/efl_file.eo
@@ -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]]
    }
diff --git a/src/lib/elementary/efl_ui_image.c 
b/src/lib/elementary/efl_ui_image.c
index 546233b..bb8ef95 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
 
         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;
             }
diff --git a/src/lib/elementary/efl_ui_image.eo 
b/src/lib/elementary/efl_ui_image.eo
index 90c05b9..d84139e 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,
       Elm.Interface.Atspi_Widget_Action.elm_actions.get;
    }
    events {
-      drop;
-      download,start;
-      download,progress;
-      download,done;
-      download,error;
+      drop; /* FIXME - Belongs to DnD interface */
    }
 
 }
diff --git a/src/lib/elementary/elm_image.h b/src/lib/elementary/elm_image.h
index 693086d..51ba0cf 100644
--- a/src/lib/elementary/elm_image.h
+++ b/src/lib/elementary/elm_image.h
@@ -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

-- 


Reply via email to