summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2014-07-20 01:46:35 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2014-07-20 01:46:35 +0900
commit29bd265dc453c135f4ce9ad6fc8b54868347b839 (patch)
tree99a36c4135141607f47735fec19a1b8794d59bc3
parent41748e9df246af09e19c5cd017621340de1f2be2 (diff)
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
-rw-r--r--src/bin/test_toolbar.c13
-rw-r--r--src/lib/elm_toolbar.c6
-rw-r--r--src/lib/elm_toolbar.eo2
-rw-r--r--src/lib/elm_toolbar.h4
4 files changed, 25 insertions, 0 deletions
diff --git a/src/bin/test_toolbar.c b/src/bin/test_toolbar.c
index f247e6a5f..eff88578f 100644
--- a/src/bin/test_toolbar.c
+++ b/src/bin/test_toolbar.c
@@ -6,6 +6,17 @@
6Evas_Object * _focus_autoscroll_mode_frame_create(Evas_Object *parent); 6Evas_Object * _focus_autoscroll_mode_frame_create(Evas_Object *parent);
7 7
8static void 8static void
9_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
10{
11 const char *str = elm_object_item_text_get(event_info);
12 printf("item %p is %s.", event_info, (char *)data);
13 if (str)
14 printf(" string is \"%s\"\n", str);
15 else
16 printf("\n");
17}
18
19static void
9_tb_sel1_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 20_tb_sel1_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
10{ 21{
11 char buf[PATH_MAX]; 22 char buf[PATH_MAX];
@@ -106,6 +117,8 @@ test_toolbar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
106 evas_object_show(bx); 117 evas_object_show(bx);
107 118
108 tb = elm_toolbar_add(win); 119 tb = elm_toolbar_add(win);
120 evas_object_smart_callback_add(tb, "selected", _selected_cb, "selected");
121 evas_object_smart_callback_add(tb, "unselected", _selected_cb, "unselected");
109 elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU); 122 elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_MENU);
110 evas_object_size_hint_weight_set(tb, 0.0, 0.0); 123 evas_object_size_hint_weight_set(tb, 0.0, 0.0);
111 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0); 124 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 047dce33a..fdaa4e07f 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";
26static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start"; 26static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
27static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop"; 27static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
28static const char SIG_CLICKED[] = "clicked"; 28static const char SIG_CLICKED[] = "clicked";
29static const char SIG_SELECTED[] = "selected";
30static const char SIG_UNSELECTED[] = "unselected";
29static const char SIG_LONGPRESSED[] = "longpressed"; 31static const char SIG_LONGPRESSED[] = "longpressed";
30static const char SIG_CLICKED_DOUBLE[] = "clicked,double"; 32static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
31static const char SIG_ITEM_FOCUSED[] = "item,focused"; 33static const char SIG_ITEM_FOCUSED[] = "item,focused";
@@ -37,6 +39,8 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
37 {SIG_SCROLL_DRAG_START, ""}, 39 {SIG_SCROLL_DRAG_START, ""},
38 {SIG_SCROLL_DRAG_STOP, ""}, 40 {SIG_SCROLL_DRAG_STOP, ""},
39 {SIG_CLICKED, ""}, 41 {SIG_CLICKED, ""},
42 {SIG_SELECTED, ""},
43 {SIG_UNSELECTED, ""},
40 {SIG_LONGPRESSED, ""}, 44 {SIG_LONGPRESSED, ""},
41 {SIG_CLICKED_DOUBLE, ""}, 45 {SIG_CLICKED_DOUBLE, ""},
42 {SIG_ITEM_FOCUSED, ""}, 46 {SIG_ITEM_FOCUSED, ""},
@@ -153,6 +157,7 @@ _item_unselect(Elm_Toolbar_Item *item)
153 edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm"); 157 edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
154 if (item->icon) 158 if (item->icon)
155 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm"); 159 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
160 evas_object_smart_callback_call(WIDGET(item), SIG_UNSELECTED, item);
156} 161}
157 162
158static void 163static void
@@ -1100,6 +1105,7 @@ _item_select(Elm_Toolbar_Item *it)
1100 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it); 1105 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
1101 } 1106 }
1102 evas_object_smart_callback_call(obj, SIG_CLICKED, it); 1107 evas_object_smart_callback_call(obj, SIG_CLICKED, it);
1108 evas_object_smart_callback_call(obj, SIG_SELECTED, it);
1103} 1109}
1104 1110
1105static void 1111static void
diff --git a/src/lib/elm_toolbar.eo b/src/lib/elm_toolbar.eo
index 24f38c282..ca49702db 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)
523 scroll,drag,start; 523 scroll,drag,start;
524 scroll,drag,stop; 524 scroll,drag,stop;
525 clicked; 525 clicked;
526 selected;
527 unselected;
526 longpressed; 528 longpressed;
527 clicked,double; 529 clicked,double;
528 language,changed; 530 language,changed;
diff --git a/src/lib/elm_toolbar.h b/src/lib/elm_toolbar.h
index d80deda62..042d7950c 100644
--- a/src/lib/elm_toolbar.h
+++ b/src/lib/elm_toolbar.h
@@ -33,6 +33,10 @@
33 * - @c "unfocused" - When the toolbar has lost focus. (since 1.8) 33 * - @c "unfocused" - When the toolbar has lost focus. (since 1.8)
34 * - @c "item,focused" - When the toolbar item has received focus. (since 1.10) 34 * - @c "item,focused" - When the toolbar item has received focus. (since 1.10)
35 * - @c "item,unfocused" - When the toolbar item has lost focus. (since 1.10) 35 * - @c "item,unfocused" - When the toolbar item has lost focus. (since 1.10)
36 * - @c "selected" - when an item is selected. @p event_info is a selected
37 * item. (since 1.11)
38 * - @c "unselected" - when an item is unselected. @p event_info is a
39 * unselected item. (since 1.11)
36 * 40 *
37 * Available styles for it: 41 * Available styles for it:
38 * - @c "default" 42 * - @c "default"