seoz pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=29bd265dc453c135f4ce9ad6fc8b54868347b839

commit 29bd265dc453c135f4ce9ad6fc8b54868347b839
Author: Daniel Juyung Seo <[email protected]>
Date:   Sun Jul 20 01:46:35 2014 +0900

    toolbar: added selected and unselected smartcallbacks to toolbar.
    
    - Item based widget should emit this signal. This is good for the
    consistency and makes application developers easy to guess.
    - Added test case to elementary_test -> toolbar
    
    @feature
---
 src/bin/test_toolbar.c | 13 +++++++++++++
 src/lib/elm_toolbar.c  |  6 ++++++
 src/lib/elm_toolbar.eo |  2 ++
 src/lib/elm_toolbar.h  |  4 ++++
 4 files changed, 25 insertions(+)

diff --git a/src/bin/test_toolbar.c b/src/bin/test_toolbar.c
index f247e6a..eff8857 100644
--- a/src/bin/test_toolbar.c
+++ b/src/bin/test_toolbar.c
@@ -6,6 +6,17 @@
 Evas_Object * _focus_autoscroll_mode_frame_create(Evas_Object *parent);
 
 static void
+_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
+{
+   const char *str = elm_object_item_text_get(event_info);
+   printf("item %p is %s.", event_info, (char *)data);
+   if (str)
+     printf(" string is \"%s\"\n", str);
+   else
+     printf("\n");
+}
+
+static void
 _tb_sel1_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
 {
    char buf[PATH_MAX];
@@ -106,6 +117,8 @@ test_toolbar(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_i
    evas_object_show(bx);
 
    tb = elm_toolbar_add(win);
+   evas_object_smart_callback_add(tb, "selected", _selected_cb, "selected");
+   evas_object_smart_callback_add(tb, "unselected", _selected_cb, 
"unselected");
    elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU);
    evas_object_size_hint_weight_set(tb, 0.0, 0.0);
    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0);
diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c
index 047dce3..fdaa4e0 100644
--- a/src/lib/elm_toolbar.c
+++ b/src/lib/elm_toolbar.c
@@ -26,6 +26,8 @@ static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
 static const char SIG_CLICKED[] = "clicked";
+static const char SIG_SELECTED[] = "selected";
+static const char SIG_UNSELECTED[] = "unselected";
 static const char SIG_LONGPRESSED[] = "longpressed";
 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
 static const char SIG_ITEM_FOCUSED[] = "item,focused";
@@ -37,6 +39,8 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {SIG_SCROLL_DRAG_START, ""},
    {SIG_SCROLL_DRAG_STOP, ""},
    {SIG_CLICKED, ""},
+   {SIG_SELECTED, ""},
+   {SIG_UNSELECTED, ""},
    {SIG_LONGPRESSED, ""},
    {SIG_CLICKED_DOUBLE, ""},
    {SIG_ITEM_FOCUSED, ""},
@@ -153,6 +157,7 @@ _item_unselect(Elm_Toolbar_Item *item)
    edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
    if (item->icon)
      elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
+   evas_object_smart_callback_call(WIDGET(item), SIG_UNSELECTED, item);
 }
 
 static void
@@ -1100,6 +1105,7 @@ _item_select(Elm_Toolbar_Item *it)
         if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
      }
    evas_object_smart_callback_call(obj, SIG_CLICKED, it);
+   evas_object_smart_callback_call(obj, SIG_SELECTED, it);
 }
 
 static void
diff --git a/src/lib/elm_toolbar.eo b/src/lib/elm_toolbar.eo
index 24f38c2..ca49702 100644
--- a/src/lib/elm_toolbar.eo
+++ b/src/lib/elm_toolbar.eo
@@ -523,6 +523,8 @@ class Elm_Toolbar (Elm_Widget, Elm_Interface_Scrollable)
       scroll,drag,start;
       scroll,drag,stop;
       clicked;
+      selected;
+      unselected;
       longpressed;
       clicked,double;
       language,changed;
diff --git a/src/lib/elm_toolbar.h b/src/lib/elm_toolbar.h
index d80deda..042d795 100644
--- a/src/lib/elm_toolbar.h
+++ b/src/lib/elm_toolbar.h
@@ -33,6 +33,10 @@
  * - @c "unfocused" - When the toolbar has lost focus. (since 1.8)
  * - @c "item,focused" - When the toolbar item has received focus. (since 1.10)
  * - @c "item,unfocused" - When the toolbar item has lost focus. (since 1.10)
+ * - @c "selected" - when an item is selected. @p event_info is a selected
+ *   item. (since 1.11)
+ * - @c "unselected" - when an item is unselected. @p event_info is a
+ *   unselected item. (since 1.11)
  *
  * Available styles for it:
  * - @c "default"

-- 


Reply via email to