Elm Hoversel Item: Migrate to Eo
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Sun, 28 Sep 2014 05:14:00 +0000 (08:14 +0300)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Wed, 12 Nov 2014 10:03:54 +0000 (12:03 +0200)
src/lib/Makefile.am
src/lib/elc_hoversel.c
src/lib/elc_hoversel_legacy.h
src/lib/elm_hoversel.eo
src/lib/elm_hoversel_item.eo [new file with mode: 0644]
src/lib/elm_widget_hoversel.h

index fa8a3c0..0669d99 100644 (file)
@@ -606,7 +606,8 @@ elm_widget.eo \
 elm_win.eo \
 elm_widget_item.eo \
 elm_color_item.eo \
-elm_dayselector_item.eo
+elm_dayselector_item.eo \
+elm_hoversel_item.eo
 
 elm_eolian_c = $(elm_eolian_files:%.eo=%.eo.c)
 elm_eolian_h = $(elm_eolian_files:%.eo=%.eo.h)
@@ -720,7 +721,8 @@ elementaryeolianfiles_DATA = \
             elm_win.eo \
             elm_widget_item.eo \
             elm_color_item.eo \
-            elm_dayselector_item.eo
+            elm_dayselector_item.eo \
+            elm_hoversel_item.eo
 
 EXTRA_DIST += ${elementaryeolianfiles_DATA}
 
index 27db5a5..bb94f9b 100644 (file)
@@ -5,6 +5,7 @@
 #define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
 #define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
 
+#define ELM_WIDGET_ITEM_PROTECTED
 #include <Elementary.h>
 #include "elm_priv.h"
 #include "elm_widget_hoversel.h"
@@ -42,11 +43,11 @@ static const Elm_Action key_actions[] = {
 EOLIAN static Eina_Bool
 _elm_hoversel_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
 {
-   Elm_Hoversel_Item *it;
+   Eo *it;
    Eina_List *l;
 
    EINA_LIST_FOREACH(sd->items, l, it)
-     elm_widget_item_translate(it);
+     eo_do(it, elm_wdg_item_translate());
 
    eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
 
@@ -101,11 +102,11 @@ _on_item_clicked(void *data,
                  Evas_Object *obj EINA_UNUSED,
                  void *event_info EINA_UNUSED)
 {
-   Elm_Hoversel_Item *item = data;
+   Elm_Hoversel_Item_Data *item = data;
    Evas_Object *obj2 = WIDGET(item);
 
-   if (item->func) item->func((void *)item->base.data, obj2, item);
-   evas_object_smart_callback_call(obj2, SIG_SELECTED, item);
+   if (item->func) item->func((void *)item->base->data, obj2, EO_OBJ(item));
+   evas_object_smart_callback_call(obj2, SIG_SELECTED, EO_OBJ(item));
    elm_hoversel_hover_end(obj2);
 }
 
@@ -114,9 +115,9 @@ _item_focused_cb(void *data,
                  Evas_Object *obj EINA_UNUSED,
                  void *event_info EINA_UNUSED)
 {
-   Elm_Object_Item *it = data;
+   Elm_Hoversel_Item_Data *it = data;
 
-   evas_object_smart_callback_call(WIDGET(it), SIG_ITEM_FOCUSED, it);
+   evas_object_smart_callback_call(WIDGET(it), SIG_ITEM_FOCUSED, EO_OBJ(it));
 }
 
 static void
@@ -124,15 +125,15 @@ _item_unfocused_cb(void *data,
                    Evas_Object *obj EINA_UNUSED,
                    void *event_info EINA_UNUSED)
 {
-   Elm_Object_Item *it = data;
+   Elm_Hoversel_Item_Data *it = data;
 
-   evas_object_smart_callback_call(WIDGET(it), SIG_ITEM_UNFOCUSED, it);
+   evas_object_smart_callback_call(WIDGET(it), SIG_ITEM_UNFOCUSED, EO_OBJ(it));
 }
 
 static void
 _activate(Evas_Object *obj)
 {
-   Elm_Hoversel_Item *item;
+   Elm_Object_Item *eo_item;
    Evas_Object *bt, *bx, *ic;
    const Eina_List *l;
    char buf[4096];
@@ -178,8 +179,9 @@ _activate(Evas_Object *obj)
      snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s",
               elm_widget_style_get(obj));
 
-   EINA_LIST_FOREACH(sd->items, l, item)
+   EINA_LIST_FOREACH(sd->items, l, eo_item)
      {
+        ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
         VIEW(item) = bt = elm_button_add(bx);
         elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
         elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj));
@@ -235,43 +237,45 @@ _on_parent_del(void *data,
 }
 
 static const char *
-_item_text_get_hook(const Elm_Object_Item *it,
-                    const char *part)
+_elm_hoversel_item_elm_widget_item_part_text_get(Eo *eo_it EINA_UNUSED,
+                                            Elm_Hoversel_Item_Data *it,
+                                            const char *part)
 {
    if (part && strcmp(part, "default")) return NULL;
-   return ((Elm_Hoversel_Item *)it)->label;
+   return it->label;
 }
 
-static void
-_item_signal_emit_hook(Elm_Object_Item *it,
-                       const char *emission,
-                       const char *source)
+EOLIAN static void
+_elm_hoversel_item_elm_widget_item_signal_emit(Eo *eo_it EINA_UNUSED,
+                                         Elm_Hoversel_Item_Data *it,
+                                         const char *emission,
+                                         const char *source)
 {
    elm_object_signal_emit(VIEW(it), emission, source);
 }
 
-static void
-_item_style_set_hook(Elm_Object_Item *it,
-                     const char *style)
+EOLIAN static void
+_elm_hoversel_item_elm_widget_item_style_set(Eo *eo_it EINA_UNUSED,
+                                             Elm_Hoversel_Item_Data *it,
+                                             const char *style)
 {
    elm_object_style_set(VIEW(it), style);
 }
 
-static const char *
-_item_style_get_hook(Elm_Object_Item *it)
+EOLIAN static const char *
+_elm_hoversel_item_elm_widget_item_style_get(Eo *eo_it EINA_UNUSED,
+                                             Elm_Hoversel_Item_Data *it)
 {
    return elm_object_style_get(VIEW(it));
 }
 
-static Eina_Bool
-_item_del_pre_hook(Elm_Object_Item *it)
+EOLIAN static Eina_Bool
+_elm_hoversel_item_elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Hoversel_Item_Data *item)
 {
-   Elm_Hoversel_Item *item = (Elm_Hoversel_Item *)it;
-
    ELM_HOVERSEL_DATA_GET_OR_RETURN_VAL(WIDGET(item), sd, EINA_FALSE);
 
    elm_hoversel_hover_end(WIDGET(item));
-   sd->items = eina_list_remove(sd->items, item);
+   sd->items = eina_list_remove(sd->items, eo_item);
    eina_stringshare_del(item->label);
    eina_stringshare_del(item->icon_file);
    eina_stringshare_del(item->icon_group);
@@ -296,14 +300,15 @@ _elm_hoversel_evas_object_smart_add(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED)
 EOLIAN static void
 _elm_hoversel_evas_object_smart_del(Eo *obj, Elm_Hoversel_Data *sd)
 {
-   Elm_Hoversel_Item *item;
+   Elm_Object_Item *eo_item;
 
-   EINA_LIST_FREE(sd->items, item)
+   EINA_LIST_FREE(sd->items, eo_item)
      {
+        ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
         eina_stringshare_del(item->label);
         eina_stringshare_del(item->icon_file);
         eina_stringshare_del(item->icon_group);
-        elm_widget_item_free(item);
+        eo_del((Eo *)eo_item);
      }
    elm_hoversel_hover_parent_set(obj, NULL);
 
@@ -355,6 +360,13 @@ _elm_hoversel_eo_base_constructor(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED)
 }
 
 EOLIAN static void
+_elm_hoversel_eo_base_destructor(Eo *obj, Elm_Hoversel_Data *_pd EINA_UNUSED)
+{
+   eo_do(obj, elm_obj_hoversel_clear());
+   eo_do_super(obj, MY_CLASS, eo_destructor());
+}
+
+EOLIAN static void
 _elm_hoversel_hover_parent_set(Eo *obj, Elm_Hoversel_Data *sd, Evas_Object *parent)
 {
    if (sd->hover_parent)
@@ -398,15 +410,16 @@ _elm_hoversel_hover_begin(Eo *obj, Elm_Hoversel_Data *sd)
 EOLIAN static void
 _elm_hoversel_hover_end(Eo *obj, Elm_Hoversel_Data *sd)
 {
-   Elm_Object_Item *it;
+   Elm_Object_Item *eo_item;
    Eina_List *l;
 
    if (!sd->hover) return;
 
    sd->expanded = EINA_FALSE;
 
-   EINA_LIST_FOREACH(sd->items, l, it)
+   EINA_LIST_FOREACH(sd->items, l, eo_item)
      {
+        ELM_HOVERSEL_ITEM_DATA_GET(eo_item, it);
         VIEW(it) = NULL;
      }
    ELM_SAFE_FREE(sd->hover, evas_object_del);
@@ -428,7 +441,7 @@ _elm_hoversel_clear(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
 
    EINA_LIST_FOREACH_SAFE(sd->items, l, ll, it)
      {
-        elm_widget_item_del(it);
+        eo_do((Eo *)it, elm_wdg_item_del());
      }
 }
 
@@ -438,27 +451,30 @@ _elm_hoversel_items_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
    return sd->items;
 }
 
+EOLIAN static void
+_elm_hoversel_item_eo_base_constructor(Eo *obj, Elm_Hoversel_Item_Data *it)
+{
+   eo_do_super(obj, ELM_HOVERSEL_ITEM_CLASS, eo_constructor());
+   it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
+}
+
 EOLIAN static Elm_Object_Item*
 _elm_hoversel_item_add(Eo *obj, Elm_Hoversel_Data *sd, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
 {
-   Elm_Hoversel_Item *item = elm_widget_item_new(obj, Elm_Hoversel_Item);
-   if (!item) return NULL;
+   Eo *eo_item = eo_add(ELM_HOVERSEL_ITEM_CLASS, obj);
+   if (!eo_item) return NULL;
 
-   elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
-   elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
-   elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
-   elm_widget_item_style_set_hook_set(item, _item_style_set_hook);
-   elm_widget_item_style_get_hook_set(item, _item_style_get_hook);
+   ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
 
    item->label = eina_stringshare_add(label);
    item->icon_file = eina_stringshare_add(icon_file);
    item->icon_type = icon_type;
    item->func = func;
-   item->base.data = data;
+   item->base->data = data;
 
-   sd->items = eina_list_append(sd->items, item);
+   sd->items = eina_list_append(sd->items, eo_item);
 
-   return (Elm_Object_Item *)item;
+   return (Elm_Object_Item *)eo_item;
 }
 
 EAPI void
@@ -467,10 +483,16 @@ elm_hoversel_item_icon_set(Elm_Object_Item *it,
                            const char *icon_group,
                            Elm_Icon_Type icon_type)
 {
-   ELM_HOVERSEL_ITEM_CHECK_OR_RETURN(it);
-
-   Elm_Hoversel_Item *item = (Elm_Hoversel_Item *)it;
+   eo_do((Eo *)it, elm_obj_hoversel_item_icon_set(icon_file, icon_group, icon_type));
+}
 
+EOLIAN static void
+_elm_hoversel_item_icon_set(Eo *eo_item EINA_UNUSED,
+                            Elm_Hoversel_Item_Data *item,
+                            const char *icon_file,
+                            const char *icon_group,
+                            Elm_Icon_Type icon_type)
+{
    eina_stringshare_replace(&item->icon_file, icon_file);
    eina_stringshare_replace(&item->icon_group, icon_group);
 
@@ -483,24 +505,33 @@ elm_hoversel_item_icon_get(const Elm_Object_Item *it,
                            const char **icon_group,
                            Elm_Icon_Type *icon_type)
 {
-   ELM_HOVERSEL_ITEM_CHECK_OR_RETURN(it);
-
-   Elm_Hoversel_Item *item = (Elm_Hoversel_Item *)it;
+   eo_do((Eo *)it, elm_obj_hoversel_item_icon_get(icon_file, icon_group, icon_type));
+}
 
+EOLIAN static void
+_elm_hoversel_item_icon_get(Eo *eo_item EINA_UNUSED,
+                            Elm_Hoversel_Item_Data *item,
+                            const char **icon_file,
+                            const char **icon_group,
+                            Elm_Icon_Type *icon_type)
+{
    if (icon_file) *icon_file = item->icon_file;
    if (icon_group) *icon_group = item->icon_group;
    if (icon_type) *icon_type = item->icon_type;
 }
 
-static Elm_Hoversel_Item *
+static Elm_Object_Item *
 item_focused_get(Elm_Hoversel_Data *sd)
 {
-   Elm_Hoversel_Item *item;
+   Elm_Object_Item *eo_item;
    Eina_List *l;
 
-   EINA_LIST_FOREACH(sd->items, l, item)
-     if (elm_object_focus_get(VIEW(item)))
-       return item;
+   EINA_LIST_FOREACH(sd->items, l, eo_item)
+     {
+        ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
+        if (elm_object_focus_get(VIEW(item)))
+          return eo_item;
+     }
    return NULL;
 }
 
@@ -510,15 +541,16 @@ _key_action_move(Evas_Object *obj, const char *params)
    ELM_HOVERSEL_DATA_GET(obj, sd);
    const char *dir = params;
 
-   Elm_Hoversel_Item  *litem, *fitem;
-   litem = eina_list_last_data_get(sd->items);
-   fitem = eina_list_data_get(sd->items);
+   Elm_Object_Item  *eo_litem, *eo_fitem;
+   eo_litem = eina_list_last_data_get(sd->items);
+   eo_fitem = eina_list_data_get(sd->items);
 
    if (!strcmp(dir, "down"))
      {
         if ((!sd->horizontal) &&
-            (item_focused_get(sd) == litem))
+            (item_focused_get(sd) == eo_litem))
           {
+            ELM_HOVERSEL_ITEM_DATA_GET(eo_fitem, fitem);
             elm_object_focus_set(VIEW(fitem), EINA_TRUE);
             return EINA_TRUE;
           }
@@ -528,8 +560,9 @@ _key_action_move(Evas_Object *obj, const char *params)
    else if (!strcmp(dir, "up"))
      {
         if ((!sd->horizontal) &&
-            (item_focused_get(sd) == fitem))
+            (item_focused_get(sd) == eo_fitem))
           {
+            ELM_HOVERSEL_ITEM_DATA_GET(eo_litem, litem);
             elm_object_focus_set(VIEW(litem), EINA_TRUE);
             return EINA_TRUE;
           }
@@ -539,8 +572,9 @@ _key_action_move(Evas_Object *obj, const char *params)
    else if (!strcmp(dir, "left"))
      {
         if (sd->horizontal &&
-            (item_focused_get(sd) == fitem))
+            (item_focused_get(sd) == eo_fitem))
           {
+            ELM_HOVERSEL_ITEM_DATA_GET(eo_litem, litem);
             elm_object_focus_set(VIEW(litem), EINA_TRUE);
             return EINA_TRUE;
           }
@@ -550,8 +584,9 @@ _key_action_move(Evas_Object *obj, const char *params)
    else if (!strcmp(dir, "right"))
      {
         if (sd->horizontal &&
-            (item_focused_get(sd) == litem))
+            (item_focused_get(sd) == eo_litem))
           {
+            ELM_HOVERSEL_ITEM_DATA_GET(eo_fitem, fitem);
             elm_object_focus_set(VIEW(fitem), EINA_TRUE);
             return EINA_TRUE;
           }
@@ -601,4 +636,5 @@ _elm_hoversel_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNU
    return &atspi_actions[0];
 }
 
+#include "elm_hoversel_item.eo.c"
 #include "elm_hoversel.eo.c"
index 00f00f2..afe0326 100644 (file)
@@ -8,40 +8,8 @@
  */
 EAPI Evas_Object                 *elm_hoversel_add(Evas_Object *parent);
 
-/**
- * @brief This sets the icon for the given hoversel item.
- *
- * @param it The item to set the icon
- * @param icon_file An image file path on disk to use for the icon or standard
- * icon name
- * @param icon_group The edje group to use if @p icon_file is an edje file. Set this
- * to NULL if the icon is not an edje file
- * @param icon_type The icon type
- *
- * The icon can be loaded from the standard set, from an image file, or from
- * an edje file.
- *
- * @see elm_hoversel_item_add()
- *
- * @ingroup Hoversel
- */
 EAPI void                         elm_hoversel_item_icon_set(Elm_Object_Item *it, const char *icon_file, const char *icon_group, Elm_Icon_Type icon_type);
 
-/**
- * @brief Get the icon object of the hoversel item
- *
- * @param it The item to get the icon from
- * @param icon_file The image file path on disk used for the icon or standard
- * icon name
- * @param icon_group The edje group used if @p icon_file is an edje file. NULL
- * if the icon is not an edje file
- * @param icon_type The icon type
- *
- * @see elm_hoversel_item_icon_set()
- * @see elm_hoversel_item_add()
- *
- * @ingroup Hoversel
- */
 EAPI void                         elm_hoversel_item_icon_get(const Elm_Object_Item *it, const char **icon_file, const char **icon_group, Elm_Icon_Type *icon_type);
 
-#include "elm_hoversel.eo.legacy.h"
\ No newline at end of file
+#include "elm_hoversel.eo.legacy.h"
index adb3e84..76644d1 100644 (file)
@@ -141,6 +141,7 @@ class Elm_Hoversel (Elm_Button, Evas.Selectable_Interface,
    implements {
       class.constructor;
       Eo.Base.constructor;
+      Eo.Base.destructor;
       Evas.Object_Smart.hide;
       Evas.Object_Smart.show;
       Evas.Object_Smart.add;
diff --git a/src/lib/elm_hoversel_item.eo b/src/lib/elm_hoversel_item.eo
new file mode 100644 (file)
index 0000000..091de18
--- /dev/null
@@ -0,0 +1,45 @@
+class Elm_Hoversel_Item(Elm_Widget_Item)
+{
+   legacy_prefix: null;
+   eo_prefix: elm_obj_hoversel_item;
+   properties {
+        icon {
+             get {
+                 /*@
+                  @brief This sets the icon for the given hoversel item.
+
+                  The icon can be loaded from the standard set, from an image file, or from
+                  an edje file.
+
+                  @see elm_hoversel_item_add()
+
+                  @ingroup Hoversel
+                 */
+             }
+             set {
+                 /*@
+                  @brief Get the icon object of the hoversel item.
+
+                  @see elm_hoversel_item_add()
+
+                  @ingroup Hoversel
+                 */
+             }
+             values {
+                const (char) *icon_file; /*@ An image file path on disk to use for the icon or standard icon name */
+                const (char) *icon_group; /*@ The edje group to use if @p icon_file is an edje file. Set this to NULL if the icon is not an edje file */
+                Elm_Icon_Type icon_type; /*@ The icon type */
+             }
+        }
+   }
+   methods {
+   }
+   implements {
+        Eo.Base.constructor;
+        Elm_Widget_Item.signal_emit;
+        Elm_Widget_Item.del_pre;
+        Elm_Widget_Item.part_text.get;
+        Elm_Widget_Item.style.get;
+        Elm_Widget_Item.style.set;
+   }
+}
index 524fecd..d9b6fee 100644 (file)
@@ -2,6 +2,9 @@
 #define ELM_WIDGET_HOVERSEL_H
 
 #include "Elementary.h"
+#include "elm_hoversel_item.eo.h"
+
+#include "elm_object_item_migration_temp.h"
 
 #include <Eio.h>
 
@@ -38,10 +41,10 @@ struct _Elm_Hoversel_Data
    Eina_Bool             expanded   : 1;
 };
 
-typedef struct _Elm_Hoversel_Item Elm_Hoversel_Item;
-struct _Elm_Hoversel_Item
+typedef struct _Elm_Hoversel_Item_Data Elm_Hoversel_Item_Data;
+struct _Elm_Hoversel_Item_Data
 {
-   ELM_WIDGET_ITEM;
+   Elm_Widget_Item_Data *base;
 
    const char   *label;
    const char   *icon_file;
@@ -76,16 +79,19 @@ struct _Elm_Hoversel_Item
        return val;                                       \
     }
 
-#define ELM_HOVERSEL_CHECK(obj)                              \
+#define ELM_HOVERSEL_CHECK(obj)                          \
   if (EINA_UNLIKELY(!eo_isa((obj), ELM_HOVERSEL_CLASS))) \
     return
 
-#define ELM_HOVERSEL_ITEM_CHECK(it)                         \
-  ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, ); \
-  ELM_HOVERSEL_CHECK(it->base.widget);
+#define ELM_HOVERSEL_ITEM_DATA_GET(o, sd) \
+  Elm_Hoversel_Item_Data *sd = eo_data_scope_get((Eo *)o, ELM_HOVERSEL_ITEM_CLASS)
+
+#define ELM_HOVERSEL_ITEM_CHECK(it)                           \
+  if (EINA_UNLIKELY(!eo_isa((Eo *)it->base->eo_obj, ELM_HOVERSEL_ITEM_CLASS))) \
+    return
 
-#define ELM_HOVERSEL_ITEM_CHECK_OR_RETURN(it, ...)                     \
-  ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \
-  ELM_HOVERSEL_CHECK(it->base.widget) __VA_ARGS__;
+#define ELM_HOVERSEL_ITEM_CHECK_OR_RETURN(it, ...)         \
+  if (EINA_UNLIKELY(!eo_isa((Eo *)it->base->eo_obj, ELM_HOVERSEL_ITEM_CLASS))) \
+    return __VA_ARGS__;
 
 #endif