win: Fixup doc & code of icon_object
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 31 Aug 2017 09:32:02 +0000 (18:32 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Fri, 1 Sep 2017 01:09:37 +0000 (10:09 +0900)
Ref T5322

src/lib/elementary/efl_ui_win.c
src/lib/elementary/efl_ui_win.eo

index 9df4c72..b06bdaa 100644 (file)
@@ -3282,6 +3282,8 @@ _elm_win_xwin_update(Efl_Ui_Win_Data *sd)
 
         if (efl_isa(sd->icon, EFL_CANVAS_IMAGE_INTERNAL_CLASS))
           image = sd->icon;
+        else if (efl_isa(sd->icon, EFL_UI_IMAGE_CLASS))
+          image = elm_image_object_get(sd->icon);
 
         if (image)
           {
@@ -4535,14 +4537,11 @@ _win_inlined_image_set(Efl_Ui_Win_Data *sd)
 }
 
 static void
-_elm_win_on_icon_del(void *data,
-                     Evas *e EINA_UNUSED,
-                     Evas_Object *obj,
-                     void *event_info EINA_UNUSED)
+_elm_win_on_icon_del(void *data, const Efl_Event *ev)
 {
    ELM_WIN_DATA_GET(data, sd);
 
-   if (sd->icon == obj) sd->icon = NULL;
+   if (sd->icon == ev->object) sd->icon = NULL;
 }
 
 EOLIAN static void
@@ -5489,15 +5488,23 @@ _efl_ui_win_role_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
 EOLIAN static void
 _efl_ui_win_icon_object_set(Eo *obj, Efl_Ui_Win_Data *sd, Evas_Object *icon)
 {
+   if (icon && (!efl_isa(sd->icon, EFL_CANVAS_IMAGE_INTERNAL_CLASS) &&
+                !efl_isa(sd->icon, EFL_UI_IMAGE_CLASS)))
+     {
+        ERR("Icon object type is not supported!");
+        efl_del(icon);
+        return;
+     }
+
    if (sd->icon)
-     evas_object_event_callback_del_full(sd->icon, EVAS_CALLBACK_DEL,
-       _elm_win_on_icon_del, obj);
-   evas_object_del(sd->icon);
+     {
+        efl_event_callback_del(sd->icon, EFL_EVENT_DEL, _elm_win_on_icon_del, obj);
+        efl_del(sd->icon);
+     }
    sd->icon = icon;
    if (sd->icon)
      {
-        evas_object_event_callback_add(sd->icon, EVAS_CALLBACK_DEL,
-          _elm_win_on_icon_del, obj);
+        efl_event_callback_add(sd->icon, EFL_EVENT_DEL, _elm_win_on_icon_del, obj);
         if (sd->frame_obj)
           {
              edje_object_part_swallow(sd->frame_obj, "elm.swallow.icon", sd->icon);
index f53b611..c2950d3 100644 (file)
@@ -364,20 +364,12 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
               used, and the image pixels will be used as-is when this
               function is called. If the image object has been updated,
               then call this function again to source the image pixels
-              and put them on the window's icon. Note that only Evas
-              image objects are allowed.
+              and put them on the window's icon. Note that only objects of
+              type @Efl.Canvas.Image or @Efl.Ui.Image are allowed.
             ]]
-            /* FIXME-doc
-            Example of usage:
-            @code
-            icon = evas_object_image_add(evas_object_evas_get(elm_window));
-            evas_object_image_file_set(icon, "/path/to/the/icon", NULL);
-            elm_win_icon_object_set(elm_window, icon);
-            evas_object_show(icon);
-            @endcode
-            */
             values {
-               icon: Efl.Canvas.Object @nullable; [[The Evas image object to use for an icon.]]
+               icon: own(Efl.Canvas.Object) @nullable;
+                  [[The image object to use for an icon.]]
             }
          }
          get {
@@ -387,7 +379,8 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
               the object to use for the window icon.
             ]]
             values {
-               icon: const(Efl.Canvas.Object) @nullable; [[The Evas image object to use for an icon.]]
+               icon: const(Efl.Canvas.Object) @nullable;
+                  [[The Evas image object to use for an icon.]]
             }
          }
       }