elementary / menu, list, index, pager - modified to use signal callback table.
authorChunEon Park <hermet@hermet.pe.kr>
Thu, 21 Apr 2011 15:57:03 +0000 (15:57 +0000)
committerChunEon Park <hermet@hermet.pe.kr>
Thu, 21 Apr 2011 15:57:03 +0000 (15:57 +0000)
SVN revision: 58807

src/lib/elm_index.c
src/lib/elm_list.c
src/lib/elm_menu.c
src/lib/elm_pager.c

index 3260694..c700efe 100644 (file)
@@ -51,6 +51,21 @@ static void _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int level);
 static void _index_box_clear(Evas_Object *obj, Evas_Object *box, int level);
 static void _item_free(Elm_Index_Item *it);
 
+static const char SIG_CHANGED[] = "changed";
+static const char SIG_DELAY_CHANGED[] = "delay,changed";
+static const char SIG_SELECTED[] = "selected";
+static const char SIG_LEVEL_UP[] = "level,up";
+static const char SIG_LEVEL_DOWN[] = "level,down";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+   {SIG_CHANGED, ""},
+   {SIG_DELAY_CHANGED, ""},
+   {SIG_SELECTED, ""},
+   {SIG_LEVEL_UP, ""},
+   {SIG_LEVEL_DOWN, ""},
+   {NULL, NULL}
+};
+
 static void
 _del_pre_hook(Evas_Object *obj)
 {
@@ -303,7 +318,7 @@ _delay_change(void *data)
    if (!wd) return ECORE_CALLBACK_CANCEL;
    wd->delay = NULL;
    d = (void *)elm_index_item_selected_get(data, wd->level);
-   if (d) evas_object_smart_callback_call(data, "delay,changed", d);
+   if (d) evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, d);
    return ECORE_CALLBACK_CANCEL;
 }
 
@@ -387,7 +402,7 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
                   selectraise = edje_object_data_get(it->base.view, "selectraise");
                   if ((selectraise) && (!strcmp(selectraise, "on")))
                     evas_object_raise(it->base.view);
-                  evas_object_smart_callback_call((void *)obj, "changed", (void *)it->base.data);
+                  evas_object_smart_callback_call((void *)obj, SIG_CHANGED, (void *)it->base.data);
                   if (wd->delay) ecore_timer_del(wd->delay);
                   wd->delay = ecore_timer_add(0.2, _delay_change, obj);
                }
@@ -456,7 +471,7 @@ _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event
    if (ev->button != 1) return;
    wd->down = 0;
    d = (void *)elm_index_item_selected_get(data, wd->level);
-   if (d) evas_object_smart_callback_call(data, "selected", d);
+   if (d) evas_object_smart_callback_call(data, SIG_SELECTED, d);
    elm_index_active_set(data, 0);
    edje_object_signal_emit(wd->base, "elm,state,level,0", "elm");
 }
@@ -488,7 +503,7 @@ _mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *eve
                   wd->level = 1;
                   snprintf(buf, sizeof(buf), "elm,state,level,%i", wd->level);
                   edje_object_signal_emit(wd->base, buf, "elm");
-                  evas_object_smart_callback_call(data, "level,up", NULL);
+                  evas_object_smart_callback_call(data, SIG_LEVEL_UP, NULL);
                }
           }
         else
@@ -498,7 +513,7 @@ _mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *eve
                   wd->level = 0;
                   snprintf(buf, sizeof(buf), "elm,state,level,%i", wd->level);
                   edje_object_signal_emit(wd->base, buf, "elm");
-                  evas_object_smart_callback_call(data, "level,down", NULL);
+                  evas_object_smart_callback_call(data, SIG_LEVEL_DOWN, NULL);
                }
           }
      }
@@ -580,6 +595,8 @@ elm_index_add(Evas_Object *parent)
         evas_object_show(wd->bx[1]);
      }
 
+   evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
    _mirrored_set(obj, elm_widget_mirrored_get(obj));
    _sizing_eval(obj);
    return obj;
index 9e958f7..04ea206 100644 (file)
@@ -95,6 +95,27 @@ static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
                              Evas_Callback_Type type, void *event_info);
 static Eina_Bool _deselect_all_items(Widget_Data *wd);
 
+static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
+static const char SIG_SELECTED[] = "selected";
+static const char SIG_UNSELECTED[] = "unselected";
+static const char SIG_LONGPRESSED[] = "longpressed";
+static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
+static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
+static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
+static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+   {SIG_CLICKED_DOUBLE, ""},
+   {SIG_SELECTED, ""},
+   {SIG_UNSELECTED, ""},
+   {SIG_LONGPRESSED, ""},
+   {SIG_SCROLL_EDGE_TOP, ""},
+   {SIG_SCROLL_EDGE_BOTTOM, ""},
+   {SIG_SCROLL_EDGE_LEFT, ""},
+   {SIG_SCROLL_EDGE_RIGHT, ""},
+   {NULL, NULL}
+};
+
 #define ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, ...)                      \
    ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, __VA_ARGS__);             \
 if (it->deleted)                                                         \
@@ -103,6 +124,8 @@ if (it->deleted)                                                         \
    return __VA_ARGS__;                                                   \
 }
 
+
+
 static inline void
 _elm_list_item_free(Elm_List_Item *it)
 {
@@ -707,7 +730,7 @@ call:
    _elm_list_walk(wd);
 
    if (it->func) it->func((void *)it->base.data, it->base.widget, it);
-   evas_object_smart_callback_call(obj, "selected", it);
+   evas_object_smart_callback_call(obj, SIG_SELECTED, it);
    it->wd->last_selected_item = it;
 
    _elm_list_unwalk(wd);
@@ -741,7 +764,7 @@ _item_unselect(Elm_List_Item *it)
      {
         it->selected = EINA_FALSE;
         wd->selected = eina_list_remove(wd->selected, it);
-        evas_object_smart_callback_call(it->base.widget, "unselected", it);
+        evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
      }
 
    _elm_list_unwalk(wd);
@@ -808,28 +831,28 @@ static void
 _scroll_edge_left(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
 {
    Evas_Object *obj = data;
-   evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
+   evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
 }
 
 static void
 _scroll_edge_right(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
 {
    Evas_Object *obj = data;
-   evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
+   evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
 }
 
 static void
 _scroll_edge_top(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
 {
    Evas_Object *obj = data;
-   evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
+   evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
 }
 
 static void
 _scroll_edge_bottom(void *data, Evas_Object *scr __UNUSED__, void *event_info __UNUSED__)
 {
    Evas_Object *obj = data;
-   evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
+   evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
 }
 
 static Eina_Bool
@@ -846,7 +869,7 @@ _long_press(void *data)
    if (it->disabled) goto end;
 
    wd->longpressed = EINA_TRUE;
-   evas_object_smart_callback_call(it->base.widget, "longpressed", it);
+   evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
 
 end:
    return ECORE_CALLBACK_CANCEL;
@@ -900,7 +923,7 @@ _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void
    /* Always call the callbacks last - the user may delete our context! */
    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
      {
-        evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
+        evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
         evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
      }
    wd->swipe = EINA_FALSE;
@@ -1341,6 +1364,8 @@ elm_list_add(Evas_Object *parent)
    evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
    evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
 
+   evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
    _mirrored_set(obj, elm_widget_mirrored_get(obj));
    _sizing_eval(obj);
    return obj;
index 9fce2d0..09a2dde 100644 (file)
@@ -55,6 +55,14 @@ static void _parent_resize(void *data, Evas *e, Evas_Object *obj, void *event_in
 static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void _menu_hide(void *data, Evas_Object *obj, void *event_info);
 
+static const char SIG_CLICKED[] = "clicked";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+   {SIG_CLICKED, ""},
+   {NULL, NULL}
+};
+
+
 static void
 _del_item(Elm_Menu_Item *item)
 {
@@ -273,7 +281,7 @@ static void
 _hover_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
    _menu_hide(data, obj, event_info);
-   evas_object_smart_callback_call(data, "clicked", NULL);
+   evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
 }
 
 static void
@@ -483,6 +491,8 @@ elm_menu_add(Evas_Object *parent)
 
    evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _menu_resize, obj);
 
+   evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
    _sizing_eval(obj);
    return obj;
 }
index 222d71a..96bec5c 100644 (file)
@@ -50,6 +50,14 @@ static void _sizing_eval(Evas_Object *obj);
 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
 
+static const char SIG_HIDE_FINISHED[] = "hide,finished";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+   {SIG_HIDE_FINISHED, ""},
+   {NULL, NULL}
+};
+
+
 static void
 _del_hook(Evas_Object *obj)
 {
@@ -239,7 +247,7 @@ _signal_hide_finished(void *data, Evas_Object *obj __UNUSED__, const char *emiss
    Evas_Object *obj2 = it->obj;
    evas_object_hide(it->base);
    edje_object_signal_emit(it->base, "elm,action,reset", "elm");
-   evas_object_smart_callback_call(obj2, "hide,finished", it->content);
+   evas_object_smart_callback_call(obj2, SIG_HIDE_FINISHED, it->content);
    edje_object_message_signal_process(it->base);
    evas_object_hide(it->content);
    if (it->popme) evas_object_del(it->content);
@@ -286,6 +294,8 @@ elm_pager_add(Evas_Object *parent)
 
    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
 
+   evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
    _mirrored_set(obj, elm_widget_mirrored_get(obj));
    _sizing_eval(obj);
    return obj;