summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-06-30 19:37:10 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-09-17 15:08:42 +0300
commit7f8b8b5bb88c7af262d4a891aebd9b5feb9a0dab (patch)
treece9d08dbff9b65ff865e47d7e6e260da15db50aa
parente6e014e20c71629c44c44c3fb5d99aab8844e856 (diff)
Porting to Eo: Elm Menu Item
-rw-r--r--src/lib/Makefile.am11
-rw-r--r--src/lib/elm_dbus_menu.c40
-rw-r--r--src/lib/elm_menu.c412
-rw-r--r--src/lib/elm_menu_common.h113
-rw-r--r--src/lib/elm_menu_item.eo133
-rw-r--r--src/lib/elm_widget_menu.h24
6 files changed, 409 insertions, 324 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 49a76ac06..368a3ec60 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -857,7 +857,9 @@ BUILT_SOURCES = \
857 elm_slideshow_item.eo.c \ 857 elm_slideshow_item.eo.c \
858 elm_slideshow_item.eo.h \ 858 elm_slideshow_item.eo.h \
859 elm_flipselector_item.eo.c \ 859 elm_flipselector_item.eo.c \
860 elm_flipselector_item.eo.h 860 elm_flipselector_item.eo.h \
861 elm_menu_item.eo.c \
862 elm_menu_item.eo.h
861 863
862elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@ 864elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
863elementaryeolianfiles_DATA = \ 865elementaryeolianfiles_DATA = \
@@ -958,7 +960,8 @@ elementaryeolianfiles_DATA = \
958 elm_hoversel_item.eo \ 960 elm_hoversel_item.eo \
959 elm_segment_control_item.eo \ 961 elm_segment_control_item.eo \
960 elm_slideshow_item.eo \ 962 elm_slideshow_item.eo \
961 elm_flipselector_item.eo 963 elm_flipselector_item.eo \
964 elm_menu_item.eo
962 965
963EXTRA_DIST += ${elementaryeolianfiles_DATA} 966EXTRA_DIST += ${elementaryeolianfiles_DATA}
964 967
@@ -1060,6 +1063,7 @@ nodist_includesunstable_HEADERS = \
1060 elm_hoversel_item.eo.h \ 1063 elm_hoversel_item.eo.h \
1061 elm_segment_control_item.eo.h \ 1064 elm_segment_control_item.eo.h \
1062 elm_flipselector_item.eo.h \ 1065 elm_flipselector_item.eo.h \
1066 elm_menu_item.eo.h \
1063 elm_slideshow_item.eo.h \ 1067 elm_slideshow_item.eo.h \
1064 elm_layout.eo.legacy.h \ 1068 elm_layout.eo.legacy.h \
1065 elm_frame.eo.legacy.h \ 1069 elm_frame.eo.legacy.h \
@@ -1130,7 +1134,8 @@ nodist_includesunstable_HEADERS = \
1130 elm_hoversel_item.eo.legacy.h \ 1134 elm_hoversel_item.eo.legacy.h \
1131 elm_segment_control_item.eo.legacy.h \ 1135 elm_segment_control_item.eo.legacy.h \
1132 elm_slideshow_item.eo.legacy.h \ 1136 elm_slideshow_item.eo.legacy.h \
1133 elm_flipselector_item.eo.legacy.h 1137 elm_flipselector_item.eo.legacy.h \
1138 elm_menu_item.eo.legacy.h
1134 1139
1135if HAVE_CXX11 1140if HAVE_CXX11
1136 1141
diff --git a/src/lib/elm_dbus_menu.c b/src/lib/elm_dbus_menu.c
index 021ee3b9d..59fa09338 100644
--- a/src/lib/elm_dbus_menu.c
+++ b/src/lib/elm_dbus_menu.c
@@ -59,11 +59,11 @@ struct _Callback_Data
59}; 59};
60 60
61static Eina_Bool 61static Eina_Bool
62_menu_add_recursive(Elm_DBus_Menu *dbus_menu, Elm_Menu_Item *item) 62_menu_add_recursive(Elm_DBus_Menu *dbus_menu, Elm_Menu_Item_Data *item)
63{ 63{
64 int32_t id; 64 int32_t id;
65 Eina_List *l; 65 Eina_List *l;
66 Elm_Menu_Item *subitem; 66 Elm_Menu_Item_Data *subitem;
67 67
68 id = ++dbus_menu->timestamp; 68 id = ++dbus_menu->timestamp;
69 if (!eina_hash_add(dbus_menu->elements, &id, item)) 69 if (!eina_hash_add(dbus_menu->elements, &id, item))
@@ -168,7 +168,7 @@ _str_to_property(const char *str)
168} 168}
169 169
170static Eina_Bool 170static Eina_Bool
171_freedesktop_icon_exists(Elm_Menu_Item *item) 171_freedesktop_icon_exists(Elm_Menu_Item_Data *item)
172{ 172{
173 if (!item->icon_str) return EINA_FALSE; 173 if (!item->icon_str) return EINA_FALSE;
174 174
@@ -181,11 +181,9 @@ _freedesktop_icon_exists(Elm_Menu_Item *item)
181} 181}
182 182
183static Eina_Bool 183static Eina_Bool
184_property_exists(Elm_Menu_Item *item, 184_property_exists(Elm_Menu_Item_Data *item,
185 Elm_DBus_Property property) 185 Elm_DBus_Property property)
186{ 186{
187 Elm_Object_Item *item_obj;
188
189 if (item->separator) 187 if (item->separator)
190 { 188 {
191 if (property == ELM_DBUS_PROPERTY_TYPE) return EINA_TRUE; 189 if (property == ELM_DBUS_PROPERTY_TYPE) return EINA_TRUE;
@@ -203,8 +201,7 @@ _property_exists(Elm_Menu_Item *item,
203 return EINA_FALSE; 201 return EINA_FALSE;
204 202
205 case ELM_DBUS_PROPERTY_ENABLED: 203 case ELM_DBUS_PROPERTY_ENABLED:
206 item_obj = (Elm_Object_Item *)item; 204 return elm_object_item_disabled_get((Elm_Object_Item *)EO_OBJ(item));
207 return elm_object_item_disabled_get(item_obj);
208 205
209 case ELM_DBUS_PROPERTY_ICON_NAME: 206 case ELM_DBUS_PROPERTY_ICON_NAME:
210 return _freedesktop_icon_exists(item); 207 return _freedesktop_icon_exists(item);
@@ -221,19 +218,18 @@ _property_exists(Elm_Menu_Item *item,
221// Ad-hoc dbusmenu property dictionary subset implementation 218// Ad-hoc dbusmenu property dictionary subset implementation
222// Depends on _property_exists results 219// Depends on _property_exists results
223static void 220static void
224_property_append(Elm_Menu_Item *item, 221_property_append(Elm_Menu_Item_Data *item,
225 Elm_DBus_Property property, 222 Elm_DBus_Property property,
226 Eldbus_Message_Iter *iter) 223 Eldbus_Message_Iter *iter)
227{ 224{
228 Eldbus_Message_Iter *variant = NULL; 225 Eldbus_Message_Iter *variant = NULL;
229 Elm_Object_Item *item_obj = (Elm_Object_Item *)item;
230 const char *t; 226 const char *t;
231 227
232 switch (property) 228 switch (property)
233 { 229 {
234 case ELM_DBUS_PROPERTY_LABEL: 230 case ELM_DBUS_PROPERTY_LABEL:
235 variant = eldbus_message_iter_container_new(iter, 'v', "s"); 231 variant = eldbus_message_iter_container_new(iter, 'v', "s");
236 t = elm_object_item_part_text_get(item_obj, NULL); 232 t = elm_object_item_part_text_get((Elm_Object_Item *)EO_OBJ(item), NULL);
237 if (!t) 233 if (!t)
238 { 234 {
239 t = elm_object_part_text_get(item->content, NULL); 235 t = elm_object_part_text_get(item->content, NULL);
@@ -272,7 +268,7 @@ _property_append(Elm_Menu_Item *item,
272} 268}
273 269
274static void 270static void
275_property_dict_build(Elm_Menu_Item *item, 271_property_dict_build(Elm_Menu_Item_Data *item,
276 Eina_List *property_list, Eldbus_Message_Iter *iter) 272 Eina_List *property_list, Eldbus_Message_Iter *iter)
277{ 273{
278 char *propstr; 274 char *propstr;
@@ -299,12 +295,12 @@ _property_dict_build(Elm_Menu_Item *item,
299} 295}
300 296
301static void 297static void
302_layout_build_recursive(Elm_Menu_Item *item, 298_layout_build_recursive(Elm_Menu_Item_Data *item,
303 Eina_List *property_list, unsigned recursion_depth, 299 Eina_List *property_list, unsigned recursion_depth,
304 Eldbus_Message_Iter *iter) 300 Eldbus_Message_Iter *iter)
305{ 301{
306 Eina_List *l; 302 Eina_List *l;
307 Elm_Menu_Item *subitem; 303 Elm_Menu_Item_Data *subitem;
308 Eldbus_Message_Iter *layout, *array, *variant; 304 Eldbus_Message_Iter *layout, *array, *variant;
309 305
310 layout = eldbus_message_iter_container_new(iter, 'r', NULL); 306 layout = eldbus_message_iter_container_new(iter, 'r', NULL);
@@ -337,7 +333,7 @@ _root_layout_build(Elm_DBus_Menu *dbus_menu, Eina_List *property_list,
337 const Eina_List *ret = NULL; 333 const Eina_List *ret = NULL;
338 Eina_List *items; 334 Eina_List *items;
339 Eina_List *l; 335 Eina_List *l;
340 Elm_Menu_Item *item; 336 Elm_Menu_Item_Data *item;
341 337
342 layout = eldbus_message_iter_container_new(iter, 'r', NULL); 338 layout = eldbus_message_iter_container_new(iter, 'r', NULL);
343 eldbus_message_iter_basic_append(layout, 'i', 0); 339 eldbus_message_iter_basic_append(layout, 'i', 0);
@@ -395,7 +391,7 @@ _empty_properties_handle(Eina_List *property_list)
395static Eina_Bool 391static Eina_Bool
396_event_handle(Elm_DBus_Menu *dbus_menu, Eldbus_Message_Iter *iter, int *error_id) 392_event_handle(Elm_DBus_Menu *dbus_menu, Eldbus_Message_Iter *iter, int *error_id)
397{ 393{
398 Elm_Menu_Item *item; 394 Elm_Menu_Item_Data *item;
399 const char *event; 395 const char *event;
400 int id; 396 int id;
401 int32_t i; 397 int32_t i;
@@ -413,7 +409,7 @@ _event_handle(Elm_DBus_Menu *dbus_menu, Eldbus_Message_Iter *iter, int *error_id
413 } 409 }
414 410
415 if (!strcmp(event, "clicked")) 411 if (!strcmp(event, "clicked"))
416 _elm_dbus_menu_item_select_cb((Elm_Object_Item *)item); 412 _elm_dbus_menu_item_select_cb((Elm_Object_Item *)EO_OBJ(item));
417 413
418 return EINA_TRUE; 414 return EINA_TRUE;
419} 415}
@@ -424,7 +420,7 @@ _elm_dbus_menu_add(Eo *menu)
424 Elm_DBus_Menu *dbus_menu; 420 Elm_DBus_Menu *dbus_menu;
425 const Eina_List *ret = NULL; 421 const Eina_List *ret = NULL;
426 Eina_List *items, *l; 422 Eina_List *items, *l;
427 Elm_Menu_Item *item; 423 Elm_Menu_Item_Data *item;
428 424
429 ELM_MENU_CHECK(menu) NULL; 425 ELM_MENU_CHECK(menu) NULL;
430 426
@@ -483,7 +479,7 @@ _method_layout_get(const Eldbus_Service_Interface *iface,
483 Eldbus_Message *reply; 479 Eldbus_Message *reply;
484 Eldbus_Message_Iter *iter, *array; 480 Eldbus_Message_Iter *iter, *array;
485 Elm_DBus_Menu *dbus_menu; 481 Elm_DBus_Menu *dbus_menu;
486 Elm_Menu_Item *item = NULL; 482 Elm_Menu_Item_Data *item = NULL;
487 483
488 dbus_menu = eldbus_service_object_data_get(iface, DBUS_DATA_KEY); 484 dbus_menu = eldbus_service_object_data_get(iface, DBUS_DATA_KEY);
489 485
@@ -532,7 +528,7 @@ _method_group_properties_get(const Eldbus_Service_Interface *iface,
532 Eldbus_Message_Iter *iter, *array, *tuple; 528 Eldbus_Message_Iter *iter, *array, *tuple;
533 Eina_List *property_list = NULL; 529 Eina_List *property_list = NULL;
534 Elm_DBus_Menu *dbus_menu; 530 Elm_DBus_Menu *dbus_menu;
535 Elm_Menu_Item *item; 531 Elm_Menu_Item_Data *item;
536 char *property; 532 char *property;
537 int id; 533 int id;
538 int32_t i; 534 int32_t i;
@@ -595,7 +591,7 @@ _method_property_get(const Eldbus_Service_Interface *iface,
595 Eldbus_Message_Iter *iter, *variant; 591 Eldbus_Message_Iter *iter, *variant;
596 Elm_DBus_Property property; 592 Elm_DBus_Property property;
597 Elm_DBus_Menu *dbus_menu; 593 Elm_DBus_Menu *dbus_menu;
598 Elm_Menu_Item *item; 594 Elm_Menu_Item_Data *item;
599 int id; 595 int id;
600 int32_t i; 596 int32_t i;
601 char *name; 597 char *name;
@@ -996,7 +992,7 @@ _elm_dbus_menu_app_menu_unregister(Eo *obj)
996int 992int
997_elm_dbus_menu_item_add(Elm_DBus_Menu *dbus_menu, Elm_Object_Item *item_obj) 993_elm_dbus_menu_item_add(Elm_DBus_Menu *dbus_menu, Elm_Object_Item *item_obj)
998{ 994{
999 Elm_Menu_Item *item = (Elm_Menu_Item *)item_obj; 995 ELM_MENU_ITEM_DATA_GET(item_obj, item);
1000 int32_t id = dbus_menu->timestamp + 1; 996 int32_t id = dbus_menu->timestamp + 1;
1001 997
1002 if (!eina_hash_add(dbus_menu->elements, &id, item)) 998 if (!eina_hash_add(dbus_menu->elements, &id, item))
diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c
index e3b9da8c3..6785c515b 100644
--- a/src/lib/elm_menu.c
+++ b/src/lib/elm_menu.c
@@ -2,6 +2,7 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4 4
5#define ELM_WIDGET_ITEM_PROTECTED
5#include <Elementary.h> 6#include <Elementary.h>
6 7
7#include "elm_priv.h" 8#include "elm_priv.h"
@@ -33,19 +34,20 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
33EOLIAN static Eina_Bool 34EOLIAN static Eina_Bool
34_elm_menu_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd) 35_elm_menu_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd)
35{ 36{
36 Elm_Menu_Item *it; 37 Elm_Menu_Item_Data *it;
37 Eina_List *l; 38 Eina_List *l;
38 39
39 EINA_LIST_FOREACH(sd->items, l, it) 40 EINA_LIST_FOREACH(sd->items, l, it)
40 elm_widget_item_translate(it); 41 eo_do ((Eo *)EO_OBJ(it), elm_wdg_item_translate());
41 42
42 return EINA_TRUE; 43 return EINA_TRUE;
43} 44}
44 45
45static void 46static void
46_item_del(Elm_Menu_Item *item) 47_item_del(Elm_Object_Item *eo_item)
47{ 48{
48 Elm_Menu_Item *child; 49 Elm_Object_Item *child;
50 ELM_MENU_ITEM_DATA_GET(eo_item, item);
49 51
50 EINA_LIST_FREE(item->submenu.items, child) 52 EINA_LIST_FREE(item->submenu.items, child)
51 _item_del(child); 53 _item_del(child);
@@ -55,30 +57,29 @@ _item_del(Elm_Menu_Item *item)
55 evas_object_del(item->submenu.location); 57 evas_object_del(item->submenu.location);
56 eina_stringshare_del(item->icon_str); 58 eina_stringshare_del(item->icon_str);
57 59
58 elm_widget_item_free(item); 60 eo_del((Eo *)eo_item);
59} 61}
60 62
61static void 63static void
62_submenu_hide(Elm_Menu_Item *item) 64_submenu_hide(Elm_Menu_Item_Data *item)
63{ 65{
64 Eina_List *l; 66 Eina_List *l;
65 Elm_Menu_Item *item2; 67 Elm_Object_Item *eo_item2;
66 68
67 evas_object_hide(item->submenu.hv); 69 evas_object_hide(item->submenu.hv);
68 item->submenu.open = EINA_FALSE; 70 item->submenu.open = EINA_FALSE;
69 71
70 EINA_LIST_FOREACH(item->submenu.items, l, item2) 72 EINA_LIST_FOREACH(item->submenu.items, l, eo_item2)
71 { 73 {
74 ELM_MENU_ITEM_DATA_GET(eo_item2, item2);
72 if (item2->submenu.open) _submenu_hide(item2); 75 if (item2->submenu.open) _submenu_hide(item2);
73 } 76 }
74} 77}
75 78
76static void 79static void
77_item_disable_hook(Elm_Object_Item *it) 80_elm_menu_item_elm_widget_item_disable(Eo *eo_item, Elm_Menu_Item_Data *item)
78{ 81{
79 Elm_Menu_Item *item = (Elm_Menu_Item *)it; 82 if (elm_object_item_disabled_get((Elm_Object_Item*)eo_item))
80
81 if (elm_widget_item_disabled_get(item))
82 { 83 {
83 elm_layout_signal_emit(VIEW(item), "elm,state,disabled", "elm"); 84 elm_layout_signal_emit(VIEW(item), "elm,state,disabled", "elm");
84 if (item->submenu.open) _submenu_hide(item); 85 if (item->submenu.open) _submenu_hide(item);
@@ -91,16 +92,20 @@ _item_disable_hook(Elm_Object_Item *it)
91} 92}
92 93
93static void 94static void
94_submenu_sizing_eval(Elm_Menu_Item *parent_it) 95_submenu_sizing_eval(Elm_Menu_Item_Data *parent_it)
95{ 96{
96 Eina_List *l; 97 Eina_List *l;
97 Elm_Menu_Item *item; 98 Elm_Object_Item *eo_item;
98 Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2, 99 Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2,
99 h2, bx, by, bw, bh, px, py, pw, ph; 100 h2, bx, by, bw, bh, px, py, pw, ph;
100 ELM_MENU_DATA_GET_OR_RETURN(WIDGET(parent_it), sd); 101 ELM_MENU_DATA_GET_OR_RETURN(WIDGET(parent_it), sd);
101 102
102 EINA_LIST_FOREACH(parent_it->submenu.items, l, item) 103 EINA_LIST_FOREACH(parent_it->submenu.items, l, eo_item)
103 elm_layout_sizing_eval(VIEW(item)); 104 {
105 ELM_MENU_ITEM_DATA_GET(eo_item, item);
106 elm_layout_sizing_eval(VIEW(item));
107 }
108
104 109
105 evas_object_geometry_get 110 evas_object_geometry_get
106 (parent_it->submenu.location, &x_p, &y_p, &w_p, &h_p); 111 (parent_it->submenu.location, &x_p, &y_p, &w_p, &h_p);
@@ -146,8 +151,9 @@ _submenu_sizing_eval(Elm_Menu_Item *parent_it)
146 evas_object_size_hint_max_set(parent_it->submenu.location, bw, h_p); 151 evas_object_size_hint_max_set(parent_it->submenu.location, bw, h_p);
147 elm_hover_target_set(parent_it->submenu.hv, parent_it->submenu.location); 152 elm_hover_target_set(parent_it->submenu.hv, parent_it->submenu.location);
148 153
149 EINA_LIST_FOREACH(parent_it->submenu.items, l, item) 154 EINA_LIST_FOREACH(parent_it->submenu.items, l, eo_item)
150 { 155 {
156 ELM_MENU_ITEM_DATA_GET(eo_item, item);
151 if (item->submenu.open) _submenu_sizing_eval(item); 157 if (item->submenu.open) _submenu_sizing_eval(item);
152 } 158 }
153} 159}
@@ -156,7 +162,7 @@ static void
156_sizing_eval(Evas_Object *obj) 162_sizing_eval(Evas_Object *obj)
157{ 163{
158 Eina_List *l; 164 Eina_List *l;
159 Elm_Menu_Item *item; 165 Elm_Object_Item *eo_item;
160 Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2, h2, bw, bh; 166 Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2, h2, bw, bh;
161 Elm_Widget_Smart_Data *hover; 167 Elm_Widget_Smart_Data *hover;
162 168
@@ -164,8 +170,11 @@ _sizing_eval(Evas_Object *obj)
164 170
165 if (!sd->parent) return; 171 if (!sd->parent) return;
166 172
167 EINA_LIST_FOREACH(sd->items, l, item) 173 EINA_LIST_FOREACH(sd->items, l, eo_item)
168 elm_layout_sizing_eval(VIEW(item)); 174 {
175 ELM_MENU_ITEM_DATA_GET(eo_item, item);
176 elm_layout_sizing_eval(VIEW(item));
177 }
169 178
170 evas_object_geometry_get(sd->location, NULL, NULL, &w_p, &h_p); 179 evas_object_geometry_get(sd->location, NULL, NULL, &w_p, &h_p);
171 evas_object_geometry_get(sd->parent, &x2, &y2, &w2, &h2); 180 evas_object_geometry_get(sd->parent, &x2, &y2, &w2, &h2);
@@ -198,8 +207,11 @@ _sizing_eval(Evas_Object *obj)
198 NULL, &bw, &bh); 207 NULL, &bw, &bh);
199 evas_object_size_hint_min_set(obj, bw, bh); 208 evas_object_size_hint_min_set(obj, bw, bh);
200 209
201 EINA_LIST_FOREACH(sd->items, l, item) 210 EINA_LIST_FOREACH(sd->items, l, eo_item)
202 if (item->submenu.open) _submenu_sizing_eval(item); 211 {
212 ELM_MENU_ITEM_DATA_GET(eo_item, item);
213 if (item->submenu.open) _submenu_sizing_eval(item);
214 }
203} 215}
204 216
205EOLIAN static Eina_Bool 217EOLIAN static Eina_Bool
@@ -208,7 +220,7 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
208 Eina_Bool int_ret = EINA_FALSE; 220 Eina_Bool int_ret = EINA_FALSE;
209 221
210 Eina_List *l, *_l, *_ll, *ll = NULL; 222 Eina_List *l, *_l, *_ll, *ll = NULL;
211 Elm_Menu_Item *item; 223 Elm_Object_Item *eo_item;
212 const char *s; 224 const char *s;
213 char style[1024]; 225 char style[1024];
214 226
@@ -224,8 +236,9 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
224 ll = eina_list_append(ll, sd->items); 236 ll = eina_list_append(ll, sd->items);
225 EINA_LIST_FOREACH(ll, _ll, l) 237 EINA_LIST_FOREACH(ll, _ll, l)
226 { 238 {
227 EINA_LIST_FOREACH(l, _l, item) 239 EINA_LIST_FOREACH(l, _l, eo_item)
228 { 240 {
241 ELM_MENU_ITEM_DATA_GET(eo_item, item);
229 ll = eina_list_append(ll, item->submenu.items); 242 ll = eina_list_append(ll, item->submenu.items);
230 if (item->separator) 243 if (item->separator)
231 { 244 {
@@ -244,10 +257,10 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
244 snprintf(style, sizeof(style), "menu/%s", elm_widget_style_get(WIDGET(item))); 257 snprintf(style, sizeof(style), "menu/%s", elm_widget_style_get(WIDGET(item)));
245 elm_object_style_set(item->submenu.hv, style); 258 elm_object_style_set(item->submenu.hv, style);
246 259
247 elm_object_item_text_set((Elm_Object_Item *)item, 260 elm_object_item_text_set(eo_item,
248 item->label); 261 item->label);
249 if (item->icon_str) 262 if (item->icon_str)
250 elm_menu_item_icon_name_set((Elm_Object_Item *)item, 263 elm_menu_item_icon_name_set(eo_item,
251 item->icon_str); 264 item->icon_str);
252 } 265 }
253 else 266 else
@@ -256,13 +269,13 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
256 elm_widget_style_get(obj))) 269 elm_widget_style_get(obj)))
257 CRI("Failed to set layout!"); 270 CRI("Failed to set layout!");
258 271
259 elm_object_item_text_set((Elm_Object_Item *)item, 272 elm_object_item_text_set((Elm_Object_Item *)eo_item,
260 item->label); 273 item->label);
261 if (item->icon_str) 274 if (item->icon_str)
262 elm_menu_item_icon_name_set((Elm_Object_Item *)item, 275 elm_menu_item_icon_name_set((Elm_Object_Item *)eo_item,
263 item->icon_str); 276 item->icon_str);
264 } 277 }
265 _item_disable_hook((Elm_Object_Item *)item); 278 eo_do((Eo *)eo_item, elm_wdg_item_disable());
266 /* SEOZ 279 /* SEOZ
267 edje_object_scale_set 280 edje_object_scale_set
268 (VIEW(item), elm_widget_scale_get(obj) * 281 (VIEW(item), elm_widget_scale_get(obj) *
@@ -278,17 +291,14 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
278 return EINA_TRUE; 291 return EINA_TRUE;
279} 292}
280 293
281static void 294EOLIAN static void
282_item_text_set_hook(Elm_Object_Item *it, 295_elm_menu_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
283 const char *part, 296 Elm_Menu_Item_Data *item,
284 const char *label) 297 const char *part,
298 const char *label)
285{ 299{
286 Elm_Menu_Item *item;
287
288 if (part && strcmp(part, "default")) return; 300 if (part && strcmp(part, "default")) return;
289 301
290 item = (Elm_Menu_Item *)it;
291
292 eina_stringshare_replace(&item->label, label); 302 eina_stringshare_replace(&item->label, label);
293 303
294 if (label) 304 if (label)
@@ -302,25 +312,24 @@ _item_text_set_hook(Elm_Object_Item *it,
302 _sizing_eval(WIDGET(item)); 312 _sizing_eval(WIDGET(item));
303} 313}
304 314
305static const char * 315EOLIAN static const char *
306_item_text_get_hook(const Elm_Object_Item *it, 316_elm_menu_item_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
307 const char *part) 317 Elm_Menu_Item_Data *it,
318 const char *part)
308{ 319{
309 if (part && strcmp(part, "default")) return NULL; 320 if (part && strcmp(part, "default")) return NULL;
310 321
311 return ((Elm_Menu_Item *)it)->label; 322 return it->label;
312} 323}
313 324
314static void 325EOLIAN static void
315_item_content_set_hook(Elm_Object_Item *it, 326_elm_menu_item_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
316 const char *part, 327 Elm_Menu_Item_Data *item,
317 Evas_Object *content) 328 const char *part,
329 Evas_Object *content)
318{ 330{
319 Elm_Menu_Item *item;
320
321 if (part && strcmp(part, "default")) return; 331 if (part && strcmp(part, "default")) return;
322 332
323 item = (Elm_Menu_Item *)it;
324 if (content == item->content) return; 333 if (content == item->content) return;
325 334
326 evas_object_del(item->content); 335 evas_object_del(item->content);
@@ -331,13 +340,14 @@ _item_content_set_hook(Elm_Object_Item *it,
331 _sizing_eval(WIDGET(item)); 340 _sizing_eval(WIDGET(item));
332} 341}
333 342
334static Evas_Object * 343EOLIAN static Evas_Object *
335_item_content_get_hook(const Elm_Object_Item *it, 344_elm_menu_item_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
336 const char *part) 345 Elm_Menu_Item_Data *it,
346 const char *part)
337{ 347{
338 if (part && strcmp(part, "default")) return NULL; 348 if (part && strcmp(part, "default")) return NULL;
339 349
340 return ((Elm_Menu_Item *)it)->content; 350 return it->content;
341} 351}
342 352
343static void 353static void
@@ -378,7 +388,7 @@ _item_move_resize_cb(void *data,
378 Evas_Object *obj EINA_UNUSED, 388 Evas_Object *obj EINA_UNUSED,
379 void *event_info EINA_UNUSED) 389 void *event_info EINA_UNUSED)
380{ 390{
381 Elm_Menu_Item *item = data; 391 Elm_Menu_Item_Data *item = data;
382 392
383 if (item->submenu.open) _submenu_sizing_eval(item); 393 if (item->submenu.open) _submenu_sizing_eval(item);
384} 394}
@@ -389,7 +399,7 @@ _menu_hide(void *data,
389 void *event_info EINA_UNUSED) 399 void *event_info EINA_UNUSED)
390{ 400{
391 Eina_List *l; 401 Eina_List *l;
392 Elm_Menu_Item *item2; 402 Elm_Object_Item *eo_item2;
393 403
394 ELM_MENU_DATA_GET(data, sd); 404 ELM_MENU_DATA_GET(data, sd);
395 405
@@ -399,8 +409,9 @@ _menu_hide(void *data,
399 evas_object_hide(data); 409 evas_object_hide(data);
400 } 410 }
401 411
402 EINA_LIST_FOREACH(sd->items, l, item2) 412 EINA_LIST_FOREACH(sd->items, l, eo_item2)
403 { 413 {
414 ELM_MENU_ITEM_DATA_GET(eo_item2, item2);
404 if (item2->submenu.open) _submenu_hide(item2); 415 if (item2->submenu.open) _submenu_hide(item2);
405 } 416 }
406} 417}
@@ -421,7 +432,7 @@ _submenu_open_cb(void *data,
421 const char *emission EINA_UNUSED, 432 const char *emission EINA_UNUSED,
422 const char *source EINA_UNUSED) 433 const char *source EINA_UNUSED)
423{ 434{
424 Elm_Menu_Item *item = data; 435 Elm_Menu_Item_Data *item = data;
425 436
426 item->submenu.open = EINA_TRUE; 437 item->submenu.open = EINA_TRUE;
427 evas_object_show(item->submenu.hv); 438 evas_object_show(item->submenu.hv);
@@ -431,9 +442,8 @@ _submenu_open_cb(void *data,
431void 442void
432_elm_dbus_menu_item_select_cb(Elm_Object_Item *obj_item) 443_elm_dbus_menu_item_select_cb(Elm_Object_Item *obj_item)
433{ 444{
434 Elm_Menu_Item *item = (Elm_Menu_Item *)obj_item; 445 ELM_MENU_ITEM_DATA_GET(obj_item, item);
435 446 if (item->func) item->func((void *)(item->base->data), WIDGET(item), obj_item);
436 if (item->func) item->func((void *)(item->base.data), WIDGET(item), item);
437} 447}
438 448
439static void 449static void
@@ -442,7 +452,7 @@ _menu_item_select_cb(void *data,
442 const char *emission EINA_UNUSED, 452 const char *emission EINA_UNUSED,
443 const char *source EINA_UNUSED) 453 const char *source EINA_UNUSED)
444{ 454{
445 Elm_Menu_Item *item = data; 455 Elm_Menu_Item_Data *item = data;
446 456
447 if (item->submenu.items) 457 if (item->submenu.items)
448 { 458 {
@@ -451,7 +461,7 @@ _menu_item_select_cb(void *data,
451 } 461 }
452 else _menu_hide(WIDGET(item), NULL, NULL); 462 else _menu_hide(WIDGET(item), NULL, NULL);
453 463
454 if (item->func) item->func((void *)(item->base.data), WIDGET(item), item); 464 if (item->func) item->func((void *)(item->base->data), WIDGET(item), EO_OBJ(item));
455} 465}
456 466
457static void 467static void
@@ -461,25 +471,25 @@ _menu_item_activate_cb(void *data,
461 const char *source EINA_UNUSED) 471 const char *source EINA_UNUSED)
462{ 472{
463 Eina_List *l; 473 Eina_List *l;
464 Elm_Menu_Item *item2; 474 Elm_Object_Item *eo_item2;
465 Elm_Menu_Item *item = data; 475 Elm_Menu_Item_Data *item = data;
466 476
467 item->selected = 1; 477 item->selected = 1;
468 if (item->parent) 478 if (item->parent)
469 { 479 {
470 EINA_LIST_FOREACH(item->parent->submenu.items, l, item2) 480 EINA_LIST_FOREACH(item->parent->submenu.items, l, eo_item2)
471 { 481 {
472 if (item2 != item) 482 if (eo_item2 != EO_OBJ(item))
473 elm_menu_item_selected_set((Elm_Object_Item *)item2, 0); 483 elm_menu_item_selected_set(eo_item2, 0);
474 } 484 }
475 } 485 }
476 else 486 else
477 { 487 {
478 ELM_MENU_DATA_GET(WIDGET(item), sd); 488 ELM_MENU_DATA_GET(WIDGET(item), sd);
479 EINA_LIST_FOREACH(sd->items, l, item2) 489 EINA_LIST_FOREACH(sd->items, l, eo_item2)
480 { 490 {
481 if (item2 != item) 491 if (eo_item2 != EO_OBJ(item))
482 elm_menu_item_selected_set((Elm_Object_Item *)item2, 0); 492 elm_menu_item_selected_set(eo_item2, 0);
483 } 493 }
484 } 494 }
485} 495}
@@ -490,7 +500,7 @@ _menu_item_inactivate_cb(void *data,
490 const char *emission EINA_UNUSED, 500 const char *emission EINA_UNUSED,
491 const char *source EINA_UNUSED) 501 const char *source EINA_UNUSED)
492{ 502{
493 Elm_Menu_Item *item = data; 503 Elm_Menu_Item_Data *item = data;
494 504
495 item->selected = 0; 505 item->selected = 0;
496 if (item->submenu.open) _submenu_hide(item); 506 if (item->submenu.open) _submenu_hide(item);
@@ -500,14 +510,15 @@ static void
500_block_menu(void *_sd, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 510_block_menu(void *_sd, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
501{ 511{
502 const Eina_List *l; 512 const Eina_List *l;
503 Elm_Menu_Item *current; 513 Elm_Object_Item *eo_current;
504 Elm_Menu_Data *sd = _sd; 514 Elm_Menu_Data *sd = _sd;
505 Eina_List *items = sd->items; 515 Eina_List *items = sd->items;
506 EINA_LIST_FOREACH(items, l, current) 516 EINA_LIST_FOREACH(items, l, eo_current)
507 { 517 {
508 if (!current->blocked) current->was_enabled = !elm_widget_item_disabled_get(current); 518 ELM_MENU_ITEM_DATA_GET(eo_current, current);
519 if (!current->blocked) current->was_enabled = !eo_do((Eo *)eo_current, elm_wdg_item_disabled_get());
509 current->blocked = EINA_TRUE; 520 current->blocked = EINA_TRUE;
510 elm_object_item_disabled_set((Elm_Object_Item *)current, EINA_TRUE); 521 elm_object_item_disabled_set(eo_current, EINA_TRUE);
511 } 522 }
512} 523}
513 524
@@ -515,12 +526,13 @@ static void
515_unblock_menu(void *_sd, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 526_unblock_menu(void *_sd, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
516{ 527{
517 const Eina_List *l; 528 const Eina_List *l;
518 Elm_Menu_Item *current; 529 Elm_Object_Item *eo_current;
519 Elm_Menu_Data *sd = _sd; 530 Elm_Menu_Data *sd = _sd;
520 Eina_List *items = sd->items; 531 Eina_List *items = sd->items;
521 EINA_LIST_FOREACH(items, l, current) 532 EINA_LIST_FOREACH(items, l, eo_current)
522 { 533 {
523 elm_object_item_disabled_set((Elm_Object_Item *)current, !current->was_enabled); 534 ELM_MENU_ITEM_DATA_GET(eo_current, current);
535 elm_object_item_disabled_set(eo_current, !current->was_enabled);
524 current->blocked = EINA_FALSE; 536 current->blocked = EINA_FALSE;
525 } 537 }
526} 538}
@@ -532,7 +544,7 @@ _elm_menu_evas_object_smart_show(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd)
532} 544}
533 545
534static void 546static void
535_item_obj_create(Elm_Menu_Item *item) 547_item_obj_create(Elm_Menu_Item_Data *item)
536{ 548{
537 VIEW(item) = elm_layout_add(WIDGET(item)); 549 VIEW(item) = elm_layout_add(WIDGET(item));
538 evas_object_size_hint_weight_set 550 evas_object_size_hint_weight_set
@@ -555,7 +567,7 @@ _item_obj_create(Elm_Menu_Item *item)
555} 567}
556 568
557static void 569static void
558_item_separator_obj_create(Elm_Menu_Item *item) 570_item_separator_obj_create(Elm_Menu_Item_Data *item)
559{ 571{
560 VIEW(item) = elm_layout_add(WIDGET(item)); 572 VIEW(item) = elm_layout_add(WIDGET(item));
561 evas_object_size_hint_weight_set 573 evas_object_size_hint_weight_set
@@ -573,7 +585,7 @@ _item_separator_obj_create(Elm_Menu_Item *item)
573} 585}
574 586
575static void 587static void
576_item_submenu_obj_create(Elm_Menu_Item *item) 588_item_submenu_obj_create(Elm_Menu_Item_Data *item)
577{ 589{
578 ELM_MENU_DATA_GET(WIDGET(item), sd); 590 ELM_MENU_DATA_GET(WIDGET(item), sd);
579 Evas_Object *hv, *bx; 591 Evas_Object *hv, *bx;
@@ -621,10 +633,10 @@ _item_submenu_obj_create(Elm_Menu_Item *item)
621 CRI("Failed to set layout!"); 633 CRI("Failed to set layout!");
622 } 634 }
623 635
624 elm_object_item_text_set((Elm_Object_Item *)item, item->label); 636 elm_object_item_text_set(EO_OBJ(item), item->label);
625 637
626 if (item->icon_str) 638 if (item->icon_str)
627 elm_menu_item_icon_name_set((Elm_Object_Item *)item, item->icon_str); 639 elm_menu_item_icon_name_set(EO_OBJ(item), item->icon_str);
628 640
629 elm_layout_signal_callback_add(VIEW(item), "elm,action,open", "*", 641 elm_layout_signal_callback_add(VIEW(item), "elm,action,open", "*",
630 _submenu_open_cb, item); 642 _submenu_open_cb, item);
@@ -666,7 +678,7 @@ _elm_menu_evas_object_smart_add(Eo *obj, Elm_Menu_Data *priv)
666EOLIAN static void 678EOLIAN static void
667_elm_menu_evas_object_smart_del(Eo *obj, Elm_Menu_Data *sd) 679_elm_menu_evas_object_smart_del(Eo *obj, Elm_Menu_Data *sd)
668{ 680{
669 Elm_Menu_Item *item; 681 Elm_Object_Item *eo_item;
670 682
671 _elm_dbus_menu_unregister(obj); 683 _elm_dbus_menu_unregister(obj);
672 684
@@ -675,8 +687,8 @@ _elm_menu_evas_object_smart_del(Eo *obj, Elm_Menu_Data *sd)
675 evas_object_event_callback_del_full 687 evas_object_event_callback_del_full
676 (sd->parent, EVAS_CALLBACK_DEL, _parent_del_cb, obj); 688 (sd->parent, EVAS_CALLBACK_DEL, _parent_del_cb, obj);
677 689
678 EINA_LIST_FREE(sd->items, item) 690 EINA_LIST_FREE(sd->items, eo_item)
679 _item_del(item); 691 _item_del(eo_item);
680 692
681 evas_object_event_callback_del_full 693 evas_object_event_callback_del_full
682 (sd->bx, EVAS_CALLBACK_RESIZE, _menu_resize_cb, obj); 694 (sd->bx, EVAS_CALLBACK_RESIZE, _menu_resize_cb, obj);
@@ -701,7 +713,7 @@ void
701_elm_menu_menu_bar_set(Eo *obj, Eina_Bool menu_bar) 713_elm_menu_menu_bar_set(Eo *obj, Eina_Bool menu_bar)
702{ 714{
703 Eina_List *l; 715 Eina_List *l;
704 Elm_Menu_Item *item; 716 Elm_Object_Item *eo_item;
705 char style[1024]; 717 char style[1024];
706 718
707 ELM_MENU_DATA_GET_OR_RETURN(obj, sd); 719 ELM_MENU_DATA_GET_OR_RETURN(obj, sd);
@@ -718,8 +730,9 @@ _elm_menu_menu_bar_set(Eo *obj, Eina_Bool menu_bar)
718 snprintf(style, sizeof(style), "menu/%s", elm_widget_style_get(obj)); 730 snprintf(style, sizeof(style), "menu/%s", elm_widget_style_get(obj));
719 elm_object_style_set(sd->hv, style); 731 elm_object_style_set(sd->hv, style);
720 732
721 EINA_LIST_FOREACH(sd->items, l, item) 733 EINA_LIST_FOREACH(sd->items, l, eo_item)
722 { 734 {
735 ELM_MENU_ITEM_DATA_GET(eo_item, item);
723 if (!item->submenu.bx) continue; 736 if (!item->submenu.bx) continue;
724 737
725 if (menu_bar) 738 if (menu_bar)
@@ -788,7 +801,7 @@ EOLIAN static void
788_elm_menu_elm_widget_parent_set(Eo *obj, Elm_Menu_Data *sd, Evas_Object *parent) 801_elm_menu_elm_widget_parent_set(Eo *obj, Elm_Menu_Data *sd, Evas_Object *parent)
789{ 802{
790 Eina_List *l, *_l, *_ll, *ll = NULL; 803 Eina_List *l, *_l, *_ll, *ll = NULL;
791 Elm_Menu_Item *item; 804 Elm_Object_Item *eo_item;
792 805
793 if (sd->parent == parent) return; 806 if (sd->parent == parent) return;
794 if (sd->parent) 807 if (sd->parent)
@@ -811,8 +824,9 @@ _elm_menu_elm_widget_parent_set(Eo *obj, Elm_Menu_Data *sd, Evas_Object *parent)
811 ll = eina_list_append(ll, sd->items); 824 ll = eina_list_append(ll, sd->items);
812 EINA_LIST_FOREACH(ll, _ll, l) 825 EINA_LIST_FOREACH(ll, _ll, l)
813 { 826 {
814 EINA_LIST_FOREACH(l, _l, item) 827 EINA_LIST_FOREACH(l, _l, eo_item)
815 { 828 {
829 ELM_MENU_ITEM_DATA_GET(eo_item, item);
816 if (item->submenu.hv) 830 if (item->submenu.hv)
817 { 831 {
818 elm_hover_parent_set(item->submenu.hv, parent); 832 elm_hover_parent_set(item->submenu.hv, parent);
@@ -858,18 +872,25 @@ _elm_menu_close(Eo *obj, Elm_Menu_Data *sd)
858EAPI Evas_Object * 872EAPI Evas_Object *
859elm_menu_item_object_get(const Elm_Object_Item *it) 873elm_menu_item_object_get(const Elm_Object_Item *it)
860{ 874{
861 return VIEW(((Elm_Menu_Item *)it)); 875 return eo_do((Eo*)it, elm_obj_menu_item_object_get());
876}
877
878EOLIAN static Evas_Object *
879_elm_menu_item_object_get(Eo *eo_it EINA_UNUSED, Elm_Menu_Item_Data *it)
880{
881 return VIEW(it);
862} 882}
863 883
864static void 884static void
865_item_clone(Evas_Object *obj, 885_item_clone(Evas_Object *obj,
866 Elm_Menu_Item *parent, 886 Elm_Object_Item *parent,
867 Elm_Menu_Item *item) 887 Elm_Object_Item *eo_item)
868{ 888{
869 Elm_Object_Item *new_item; 889 Elm_Object_Item *new_item;
870 Elm_Menu_Item *subitem; 890 Elm_Object_Item *subitem;
871 Eina_List *iter; 891 Eina_List *iter;
872 892
893 ELM_MENU_ITEM_DATA_GET(eo_item, item);
873 if (item->separator) 894 if (item->separator)
874 new_item = elm_menu_item_separator_add(obj, (Elm_Object_Item *)parent); 895 new_item = elm_menu_item_separator_add(obj, (Elm_Object_Item *)parent);
875 else 896 else
@@ -878,13 +899,13 @@ _item_clone(Evas_Object *obj,
878 item->icon_str, 899 item->icon_str,
879 item->label, 900 item->label,
880 item->func, 901 item->func,
881 item->base.data); 902 item->base->data);
882 903
883 elm_object_item_disabled_set 904 Eina_Bool disabled = eo_do((Eo *)eo_item, elm_wdg_item_disabled_get());
884 (new_item, elm_widget_item_disabled_get(item)); 905 eo_do((Eo *)new_item, elm_wdg_item_disabled_set(disabled));
885 906
886 EINA_LIST_FOREACH(item->submenu.items, iter, subitem) 907 EINA_LIST_FOREACH(item->submenu.items, iter, subitem)
887 _item_clone(obj, (Elm_Menu_Item *)new_item, subitem); 908 _item_clone(obj, new_item, subitem);
888} 909}
889 910
890void 911void
@@ -893,21 +914,21 @@ elm_menu_clone(Evas_Object *from_menu,
893 Elm_Object_Item *parent) 914 Elm_Object_Item *parent)
894{ 915{
895 Eina_List *iter; 916 Eina_List *iter;
896 Elm_Menu_Item *item; 917 Elm_Object_Item *eo_item;
897 918
898 ELM_MENU_CHECK(from_menu); 919 ELM_MENU_CHECK(from_menu);
899 ELM_MENU_CHECK(to_menu); 920 ELM_MENU_CHECK(to_menu);
900 921
901 ELM_MENU_DATA_GET_OR_RETURN(from_menu, from_sd); 922 ELM_MENU_DATA_GET_OR_RETURN(from_menu, from_sd);
902 923
903 EINA_LIST_FOREACH(from_sd->items, iter, item) 924 EINA_LIST_FOREACH(from_sd->items, iter, eo_item)
904 _item_clone(to_menu, (Elm_Menu_Item *)parent, item); 925 _item_clone(to_menu, parent, eo_item);
905} 926}
906 927
907static void 928static void
908_elm_menu_item_add_helper(Evas_Object *obj, 929_elm_menu_item_add_helper(Evas_Object *obj,
909 Elm_Menu_Item *parent, 930 Elm_Menu_Item_Data *parent,
910 Elm_Menu_Item *subitem, 931 Elm_Menu_Item_Data *subitem,
911 Elm_Menu_Data *sd) 932 Elm_Menu_Data *sd)
912{ 933{
913 if (parent) 934 if (parent)
@@ -915,27 +936,25 @@ _elm_menu_item_add_helper(Evas_Object *obj,
915 if (!parent->submenu.bx) _item_submenu_obj_create(parent); 936 if (!parent->submenu.bx) _item_submenu_obj_create(parent);
916 elm_box_pack_end(parent->submenu.bx, VIEW(subitem)); 937 elm_box_pack_end(parent->submenu.bx, VIEW(subitem));
917 parent->submenu.items = 938 parent->submenu.items =
918 eina_list_append(parent->submenu.items, subitem); 939 eina_list_append(parent->submenu.items, EO_OBJ(subitem));
919 subitem->idx = eina_list_count(parent->submenu.items) - 1; 940 subitem->idx = eina_list_count(parent->submenu.items) - 1;
920 } 941 }
921 else 942 else
922 { 943 {
923 elm_box_pack_end(sd->bx, VIEW(subitem)); 944 elm_box_pack_end(sd->bx, VIEW(subitem));
924 sd->items = eina_list_append(sd->items, subitem); 945 sd->items = eina_list_append(sd->items, EO_OBJ(subitem));
925 subitem->idx = eina_list_count(sd->items) - 1; 946 subitem->idx = eina_list_count(sd->items) - 1;
926 } 947 }
927 948
928 _sizing_eval(obj); 949 _sizing_eval(obj);
929} 950}
930 951
931static Eina_Bool 952EOLIAN static Eina_Bool
932_item_del_pre_hook(Elm_Object_Item *it) 953_elm_menu_item_elm_widget_item_del_pre(Eo *eo_item, Elm_Menu_Item_Data *item)
933{ 954{
934 Elm_Menu_Item *item = (Elm_Menu_Item *)it;
935
936 ELM_MENU_DATA_GET(WIDGET(item), sd); 955 ELM_MENU_DATA_GET(WIDGET(item), sd);
937 956
938 elm_menu_item_subitems_clear(it); 957 elm_menu_item_subitems_clear((Elm_Object_Item *)eo_item);
939 eina_stringshare_del(item->label); 958 eina_stringshare_del(item->label);
940 evas_object_del(item->content); 959 evas_object_del(item->content);
941 evas_object_del(item->submenu.hv); 960 evas_object_del(item->submenu.hv);
@@ -943,9 +962,9 @@ _item_del_pre_hook(Elm_Object_Item *it)
943 962
944 if (item->parent) 963 if (item->parent)
945 item->parent->submenu.items = 964 item->parent->submenu.items =
946 eina_list_remove(item->parent->submenu.items, item); 965 eina_list_remove(item->parent->submenu.items, eo_item);
947 else 966 else
948 sd->items = eina_list_remove(sd->items, item); 967 sd->items = eina_list_remove(sd->items, eo_item);
949 968
950 if (sd->dbus_menu) 969 if (sd->dbus_menu)
951 _elm_dbus_menu_item_delete(sd->dbus_menu, item->dbus_idx); 970 _elm_dbus_menu_item_delete(sd->dbus_menu, item->dbus_idx);
@@ -953,68 +972,80 @@ _item_del_pre_hook(Elm_Object_Item *it)
953 return EINA_TRUE; 972 return EINA_TRUE;
954} 973}
955 974
975EOLIAN static void
976_elm_menu_item_eo_base_constructor(Eo *eo_item, Elm_Menu_Item_Data *item)
977{
978 eo_do_super(eo_item, ELM_MENU_ITEM_CLASS, eo_constructor());
979 item->base = eo_data_scope_get(eo_item, ELM_WIDGET_ITEM_CLASS);
980}
981
956EOLIAN static Elm_Object_Item* 982EOLIAN static Elm_Object_Item*
957_elm_menu_item_add(Eo *obj, Elm_Menu_Data *sd, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) 983_elm_menu_item_add(Eo *obj, Elm_Menu_Data *sd, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
958{ 984{
959 Elm_Menu_Item *it; 985 Elm_Object_Item *eo_item;
960 Evas_Object *icon_obj; 986 Evas_Object *icon_obj;
961 987
962 icon_obj = elm_icon_add(obj); 988 icon_obj = elm_icon_add(obj);
963 if (!icon_obj) return NULL; 989 if (!icon_obj) return NULL;
964 990
965 it = elm_widget_item_new(obj, Elm_Menu_Item); 991 eo_item = (Elm_Object_Item *)eo_add(ELM_MENU_ITEM_CLASS, obj);
966 if (!it) 992 if (!eo_item)
967 { 993 {
968 evas_object_del(icon_obj); 994 evas_object_del(icon_obj);
969 return NULL; 995 return NULL;
970 } 996 }
971 997
972 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook); 998 ELM_MENU_ITEM_DATA_GET(eo_item, it);
973 elm_widget_item_disable_hook_set(it, _item_disable_hook);
974 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
975 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
976 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
977 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
978 999
979 it->base.data = data; 1000 it->base->data = data;
980 it->func = func; 1001 it->func = func;
981 it->parent = (Elm_Menu_Item *)parent; 1002 it->parent = eo_data_scope_get((Eo *)parent, ELM_MENU_ITEM_CLASS);
982 it->content = icon_obj; 1003 it->content = icon_obj;
983 1004
984 _item_obj_create(it); 1005 _item_obj_create(it);
985 elm_object_item_text_set((Elm_Object_Item *)it, label); 1006 elm_object_item_text_set(eo_item, label);
986 1007
987 elm_layout_content_set(VIEW(it), "elm.swallow.content", 1008 elm_layout_content_set(VIEW(it), "elm.swallow.content",
988 it->content); 1009 it->content);
989 1010
990 if (icon) elm_menu_item_icon_name_set((Elm_Object_Item *)it, icon); 1011 if (icon) elm_menu_item_icon_name_set(eo_item, icon);
991 1012
992 _elm_menu_item_add_helper(obj, (Elm_Menu_Item *)parent, it, sd); 1013 _elm_menu_item_add_helper(obj, it->parent, it, sd);
993 1014
994 if (sd->dbus_menu) 1015 if (sd->dbus_menu)
995 { 1016 {
996 it->dbus_idx = _elm_dbus_menu_item_add(sd->dbus_menu, (Elm_Object_Item *)it); 1017 it->dbus_idx = _elm_dbus_menu_item_add(sd->dbus_menu, eo_item);
997 it->dbus_menu = sd->dbus_menu; 1018 it->dbus_menu = sd->dbus_menu;
998 } 1019 }
999 return (Elm_Object_Item *)it; 1020 return eo_item;
1000} 1021}
1001 1022
1002EAPI unsigned int 1023EAPI unsigned int
1003elm_menu_item_index_get(const Elm_Object_Item *it) 1024elm_menu_item_index_get(const Elm_Object_Item *it)
1004{ 1025{
1005 ELM_MENU_ITEM_CHECK_OR_RETURN(it, 0); 1026 return eo_do((Eo*)it, elm_obj_menu_item_index_get());
1027}
1006 1028
1007 return ((Elm_Menu_Item *)it)->idx; 1029EOLIAN static unsigned int
1030_elm_menu_item_index_get(Eo *eo_it EINA_UNUSED, Elm_Menu_Item_Data *it)
1031{
1032 return it->idx;
1008} 1033}
1009 1034
1010EAPI void 1035EAPI void
1011elm_menu_item_icon_name_set(Elm_Object_Item *it, 1036elm_menu_item_icon_name_set(Elm_Object_Item *it,
1012 const char *icon) 1037 const char *icon)
1013{ 1038{
1039 eo_do((Eo*)it, elm_obj_menu_item_icon_name_set(icon));
1040}
1041
1042EOLIAN static void
1043_elm_menu_item_icon_name_set(Eo *eo_item EINA_UNUSED,
1044 Elm_Menu_Item_Data *item,
1045 const char *icon)
1046{
1014 char icon_tmp[512]; 1047 char icon_tmp[512];
1015 Elm_Menu_Item *item = (Elm_Menu_Item *)it;
1016 1048
1017 ELM_MENU_ITEM_CHECK_OR_RETURN(it);
1018 EINA_SAFETY_ON_NULL_RETURN(icon); 1049 EINA_SAFETY_ON_NULL_RETURN(icon);
1019 1050
1020 if ((icon[0] != '\0') && 1051 if ((icon[0] != '\0') &&
@@ -1033,91 +1064,104 @@ elm_menu_item_icon_name_set(Elm_Object_Item *it,
1033} 1064}
1034 1065
1035EOLIAN static Elm_Object_Item* 1066EOLIAN static Elm_Object_Item*
1036_elm_menu_item_separator_add(Eo *obj, Elm_Menu_Data *sd, Elm_Object_Item *parent) 1067_elm_menu_item_separator_add(Eo *obj, Elm_Menu_Data *sd, Elm_Object_Item *eo_p_item)
1037{ 1068{
1038 Elm_Menu_Item *subitem; 1069 Elm_Object_Item *eo_subitem;
1039 Elm_Menu_Item *p_item = (Elm_Menu_Item *)parent;
1040 1070
1071 ELM_MENU_ITEM_DATA_GET(eo_p_item, p_item);
1041 /* don't add a separator as the first item */ 1072 /* don't add a separator as the first item */
1042 if (!sd->items) return NULL; 1073 if (!sd->items) return NULL;
1043 1074
1044 /* don't allow adding more than one separator in a row */ 1075 /* don't allow adding more than one separator in a row */
1045 if (p_item) 1076 if (eo_p_item)
1046 { 1077 {
1047 if (!p_item->submenu.items) return NULL; 1078 if (!p_item->submenu.items) return NULL;
1048 subitem = eina_list_last(p_item->submenu.items)->data; 1079 eo_subitem = eina_list_last(p_item->submenu.items)->data;
1049 } 1080 }
1050 else subitem = eina_list_last(sd->items)->data; 1081 else eo_subitem = eina_list_last(sd->items)->data;
1051 1082
1083 ELM_MENU_ITEM_DATA_GET(eo_subitem, subitem);
1052 if (subitem->separator) return NULL; 1084 if (subitem->separator) return NULL;
1053 1085
1054 subitem = elm_widget_item_new(obj, Elm_Menu_Item); 1086 eo_subitem = (Elm_Object_Item *)eo_add(ELM_MENU_ITEM_CLASS, obj);
1055 if (!subitem) return NULL; 1087 if (!eo_subitem) return NULL;
1056 1088
1057 elm_widget_item_del_pre_hook_set(subitem, _item_del_pre_hook); 1089 subitem = eo_data_scope_get((Eo *)eo_subitem, ELM_MENU_ITEM_CLASS);
1058 elm_widget_item_disable_hook_set(subitem, _item_disable_hook);
1059 elm_widget_item_text_set_hook_set(subitem, _item_text_set_hook);
1060 elm_widget_item_text_get_hook_set(subitem, _item_text_get_hook);
1061 elm_widget_item_content_set_hook_set(subitem, _item_content_set_hook);
1062 elm_widget_item_content_get_hook_set(subitem, _item_content_get_hook);
1063 1090
1064 subitem->separator = EINA_TRUE; 1091 subitem->separator = EINA_TRUE;
1065 _item_separator_obj_create(subitem); 1092 _item_separator_obj_create(subitem);
1066 if (!p_item) 1093 if (!eo_p_item)
1067 { 1094 {
1068 elm_box_pack_end(sd->bx, VIEW(subitem)); 1095 elm_box_pack_end(sd->bx, VIEW(subitem));
1069 sd->items = eina_list_append(sd->items, subitem); 1096 sd->items = eina_list_append(sd->items, eo_subitem);
1070 } 1097 }
1071 else 1098 else
1072 { 1099 {
1073 if (!p_item->submenu.bx) _item_submenu_obj_create(p_item); 1100 if (!p_item->submenu.bx) _item_submenu_obj_create(p_item);
1074 elm_box_pack_end(p_item->submenu.bx, VIEW(subitem)); 1101 elm_box_pack_end(p_item->submenu.bx, VIEW(subitem));
1075 p_item->submenu.items = eina_list_append 1102 p_item->submenu.items = eina_list_append
1076 (p_item->submenu.items, subitem); 1103 (p_item->submenu.items, eo_subitem);
1077 } 1104 }
1078 1105
1079 _sizing_eval(obj); 1106 _sizing_eval(obj);
1080 1107
1081 if (sd->dbus_menu) 1108 if (sd->dbus_menu)
1082 subitem->dbus_idx = _elm_dbus_menu_item_add(sd->dbus_menu, 1109 subitem->dbus_idx = _elm_dbus_menu_item_add(sd->dbus_menu,
1083 (Elm_Object_Item *)subitem); 1110 eo_subitem);
1084 return (Elm_Object_Item *)subitem; 1111 return (Elm_Object_Item *)eo_subitem;
1085} 1112}
1086 1113
1087EAPI const char * 1114EAPI const char *
1088elm_menu_item_icon_name_get(const Elm_Object_Item *it) 1115elm_menu_item_icon_name_get(const Elm_Object_Item *it)
1089{ 1116{
1090 ELM_MENU_ITEM_CHECK_OR_RETURN(it, NULL); 1117 return eo_do((Eo*)it, elm_obj_menu_item_icon_name_get());
1118}
1091 1119
1092 return ((Elm_Menu_Item *)it)->icon_str; 1120EOLIAN static const char *
1121_elm_menu_item_icon_name_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
1122{
1123 return item->icon_str;
1093} 1124}
1094 1125
1095EAPI Eina_Bool 1126EAPI Eina_Bool
1096elm_menu_item_is_separator(Elm_Object_Item *it) 1127elm_menu_item_is_separator(Elm_Object_Item *it)
1097{ 1128{
1098 ELM_MENU_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); 1129 return eo_do((Eo*)it, elm_obj_menu_item_is_separator());
1130}
1099 1131
1100 return ((Elm_Menu_Item *)it)->separator; 1132EOLIAN static Eina_Bool
1133_elm_menu_item_is_separator(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
1134{
1135 return item->separator;
1101} 1136}
1102 1137
1103EAPI const Eina_List * 1138EAPI const Eina_List *
1104elm_menu_item_subitems_get(const Elm_Object_Item *it) 1139elm_menu_item_subitems_get(const Elm_Object_Item *it)
1105{ 1140{
1106 ELM_MENU_ITEM_CHECK_OR_RETURN(it, NULL); 1141 return eo_do((Eo*)it, elm_obj_menu_item_subitems_get());
1142}
1107 1143
1108 return ((Elm_Menu_Item *)it)->submenu.items; 1144EOLIAN static const Eina_List *
1145_elm_menu_item_subitems_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
1146{
1147 return item->submenu.items;
1109} 1148}
1110 1149
1111EAPI void 1150EAPI void
1112elm_menu_item_subitems_clear(Elm_Object_Item *it) 1151elm_menu_item_subitems_clear(Elm_Object_Item *it)
1113{ 1152{
1153 eo_do((Eo*)it, elm_obj_menu_item_subitems_clear());
1154}
1155
1156EOLIAN static void
1157_elm_menu_item_subitems_clear(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *it)
1158{
1114 Elm_Object_Item *sub_it; 1159 Elm_Object_Item *sub_it;
1115 Eina_List *l, *l_next; 1160 Eina_List *l, *l_next;
1116 1161
1117 ELM_MENU_ITEM_CHECK_OR_RETURN(it); 1162 EINA_LIST_FOREACH_SAFE(it->submenu.items,
1118 EINA_LIST_FOREACH_SAFE(((Elm_Menu_Item *)it)->submenu.items,
1119 l, l_next, sub_it) 1163 l, l_next, sub_it)
1120 elm_widget_item_del(sub_it); 1164 eo_do((Eo *)sub_it, elm_wdg_item_del());
1121} 1165}
1122 1166
1123EOLIAN static const Eina_List* 1167EOLIAN static const Eina_List*
@@ -1130,10 +1174,14 @@ EAPI void
1130elm_menu_item_selected_set(Elm_Object_Item *it, 1174elm_menu_item_selected_set(Elm_Object_Item *it,
1131 Eina_Bool selected) 1175 Eina_Bool selected)
1132{ 1176{
1133 Elm_Menu_Item *item = (Elm_Menu_Item *)it; 1177 eo_do((Eo*)it, elm_obj_menu_item_selected_set(selected));
1134 1178}
1135 ELM_MENU_ITEM_CHECK_OR_RETURN(item);
1136 1179
1180EOLIAN static void
1181_elm_menu_item_selected_set(Eo *eo_item EINA_UNUSED,
1182 Elm_Menu_Item_Data *item,
1183 Eina_Bool selected)
1184{
1137 if (selected == item->selected) return; 1185 if (selected == item->selected) return;
1138 item->selected = selected; 1186 item->selected = selected;
1139 if (selected) 1187 if (selected)
@@ -1152,22 +1200,28 @@ elm_menu_item_selected_set(Elm_Object_Item *it,
1152EAPI Eina_Bool 1200EAPI Eina_Bool
1153elm_menu_item_selected_get(const Elm_Object_Item *it) 1201elm_menu_item_selected_get(const Elm_Object_Item *it)
1154{ 1202{
1155 ELM_MENU_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); 1203 return eo_do((Eo*)it, elm_obj_menu_item_selected_get());
1204}
1156 1205
1157 return ((Elm_Menu_Item *)it)->selected; 1206EOLIAN static Eina_Bool
1207_elm_menu_item_selected_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
1208{
1209 return item->selected;
1158} 1210}
1159 1211
1160EAPI Elm_Object_Item * 1212EAPI Elm_Object_Item *
1161elm_menu_item_prev_get(const Elm_Object_Item *it) 1213elm_menu_item_prev_get(const Elm_Object_Item *it)
1162{ 1214{
1163 Elm_Menu_Item *item = (Elm_Menu_Item *)it; 1215 return (Elm_Object_Item *)eo_do((Eo*)it, elm_obj_menu_item_prev_get());
1164 1216}
1165 ELM_MENU_ITEM_CHECK_OR_RETURN(item, NULL);
1166 1217
1218EOLIAN static Elm_Object_Item *
1219_elm_menu_item_prev_get(Eo *eo_item, Elm_Menu_Item_Data *item)
1220{
1167 if (item->parent) 1221 if (item->parent)
1168 { 1222 {
1169 Eina_List *l = eina_list_data_find_list 1223 Eina_List *l = eina_list_data_find_list
1170 (item->parent->submenu.items, item); 1224 (item->parent->submenu.items, eo_item);
1171 l = eina_list_prev(l); 1225 l = eina_list_prev(l);
1172 if (!l) return NULL; 1226 if (!l) return NULL;
1173 return l->data; 1227 return l->data;
@@ -1176,7 +1230,7 @@ elm_menu_item_prev_get(const Elm_Object_Item *it)
1176 { 1230 {
1177 ELM_MENU_DATA_GET(WIDGET(item), sd); 1231 ELM_MENU_DATA_GET(WIDGET(item), sd);
1178 if (!sd || !sd->items) return NULL; 1232 if (!sd || !sd->items) return NULL;
1179 Eina_List *l = eina_list_data_find_list(sd->items, item); 1233 Eina_List *l = eina_list_data_find_list(sd->items, eo_item);
1180 l = eina_list_prev(l); 1234 l = eina_list_prev(l);
1181 if (!l) return NULL; 1235 if (!l) return NULL;
1182 return l->data; 1236 return l->data;
@@ -1188,14 +1242,16 @@ elm_menu_item_prev_get(const Elm_Object_Item *it)
1188EAPI Elm_Object_Item * 1242EAPI Elm_Object_Item *
1189elm_menu_item_next_get(const Elm_Object_Item *it) 1243elm_menu_item_next_get(const Elm_Object_Item *it)
1190{ 1244{
1191 Elm_Menu_Item *item = (Elm_Menu_Item *)it; 1245 return (Elm_Object_Item *)eo_do((Eo*)it, elm_obj_menu_item_next_get());
1192 1246}
1193 ELM_MENU_ITEM_CHECK_OR_RETURN(item, NULL);
1194 1247
1248EOLIAN static Elm_Object_Item *
1249_elm_menu_item_next_get(Eo *eo_item, Elm_Menu_Item_Data *item)
1250{
1195 if (item->parent) 1251 if (item->parent)
1196 { 1252 {
1197 Eina_List *l = 1253 Eina_List *l =
1198 eina_list_data_find_list(item->parent->submenu.items, item); 1254 eina_list_data_find_list(item->parent->submenu.items, eo_item);
1199 l = eina_list_next(l); 1255 l = eina_list_next(l);
1200 if (!l) return NULL; 1256 if (!l) return NULL;
1201 return l->data; 1257 return l->data;
@@ -1204,7 +1260,7 @@ elm_menu_item_next_get(const Elm_Object_Item *it)
1204 { 1260 {
1205 ELM_MENU_DATA_GET(WIDGET(item), sd); 1261 ELM_MENU_DATA_GET(WIDGET(item), sd);
1206 if (!sd || !sd->items) return NULL; 1262 if (!sd || !sd->items) return NULL;
1207 Eina_List *l = eina_list_data_find_list(sd->items, item); 1263 Eina_List *l = eina_list_data_find_list(sd->items, eo_item);
1208 l = eina_list_next(l); 1264 l = eina_list_next(l);
1209 if (!l) return NULL; 1265 if (!l) return NULL;
1210 return l->data; 1266 return l->data;
@@ -1230,11 +1286,12 @@ EOLIAN static Elm_Object_Item*
1230_elm_menu_selected_item_get(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd) 1286_elm_menu_selected_item_get(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd)
1231{ 1287{
1232 Eina_List *l; 1288 Eina_List *l;
1233 Elm_Menu_Item *item; 1289 Elm_Object_Item *eo_item;
1234 1290
1235 EINA_LIST_FOREACH(sd->items, l, item) 1291 EINA_LIST_FOREACH(sd->items, l, eo_item)
1236 { 1292 {
1237 if (item->selected) return (Elm_Object_Item *)item; 1293 ELM_MENU_ITEM_DATA_GET(eo_item, item);
1294 if (item->selected) return eo_item;
1238 } 1295 }
1239 1296
1240 return NULL; 1297 return NULL;
@@ -1246,4 +1303,5 @@ _elm_menu_class_constructor(Eo_Class *klass)
1246 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 1303 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
1247} 1304}
1248 1305
1306#include "elm_menu_item.eo.c"
1249#include "elm_menu.eo.c" 1307#include "elm_menu.eo.c"
diff --git a/src/lib/elm_menu_common.h b/src/lib/elm_menu_common.h
index 8eadda4c6..053fdd550 100644
--- a/src/lib/elm_menu_common.h
+++ b/src/lib/elm_menu_common.h
@@ -1,135 +1,22 @@
1/**
2 * Get the real Evas(Edje) object created to implement the view of a given
3 * menu @p item.
4 *
5 * @param it The menu item.
6 * @return The base Edje object containing the swallowed content associated with
7 * @p it.
8 *
9 * @warning Don't manipulate this object!
10 *
11 * @ingroup Menu
12 */
13EAPI Evas_Object *elm_menu_item_object_get(const Elm_Object_Item *it); 1EAPI Evas_Object *elm_menu_item_object_get(const Elm_Object_Item *it);
14 2
15/**
16 * @brief Set the icon of a menu item to the standard icon with name @p icon
17 *
18 * @param it The menu item object.
19 * @param icon The name of icon object to set for the content of @p item
20 *
21 * Once this icon is set, any previously set icon will be deleted.
22 * To hide icon set it to "".
23 *
24 * @ingroup Menu
25 */
26EAPI void elm_menu_item_icon_name_set(Elm_Object_Item *it, const char *icon); 3EAPI void elm_menu_item_icon_name_set(Elm_Object_Item *it, const char *icon);
27 4
28/**
29 * @brief Get the string representation from the icon of a menu item
30 *
31 * @param it The menu item object.
32 * @return The string representation of @p item's icon or NULL
33 *
34 * @see elm_menu_item_icon_name_set()
35 *
36 * @ingroup Menu
37 */
38EAPI const char *elm_menu_item_icon_name_get(const Elm_Object_Item *it); 5EAPI const char *elm_menu_item_icon_name_get(const Elm_Object_Item *it);
39 6
40/**
41 * @brief Set the selected state of @p item.
42 *
43 * @param it The menu item object.
44 * @param selected The selected/unselected state of the item
45 *
46 * @ingroup Menu
47 */
48EAPI void elm_menu_item_selected_set(Elm_Object_Item *it, Eina_Bool selected); 7EAPI void elm_menu_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
49 8
50/**
51 * @brief Get the selected state of @p item.
52 *
53 * @param it The menu item object.
54 * @return The selected/unselected state of the item
55 *
56 * @see elm_menu_item_selected_set()
57 *
58 * @ingroup Menu
59 */
60EAPI Eina_Bool elm_menu_item_selected_get(const Elm_Object_Item *it); 9EAPI Eina_Bool elm_menu_item_selected_get(const Elm_Object_Item *it);
61 10
62/**
63 * @brief Returns whether @p item is a separator.
64 *
65 * @param it The item to check
66 * @return If true, @p item is a separator
67 *
68 * @see elm_menu_item_separator_add()
69 *
70 * @ingroup Menu
71 */
72EAPI Eina_Bool elm_menu_item_is_separator(Elm_Object_Item *it); 11EAPI Eina_Bool elm_menu_item_is_separator(Elm_Object_Item *it);
73 12
74/**
75 * @brief Returns a list of @p item's subitems.
76 *
77 * @param it The item
78 * @return An Eina_List* of @p item's subitems
79 *
80 * @see elm_menu_add()
81 *
82 * @ingroup Menu
83 */
84EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Object_Item *it); 13EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Object_Item *it);
85 14
86/**
87 * Remove all sub-items (children) of the given item
88 * @since 1.8
89 *
90 * @param it The item
91 *
92 * This removes all items that are children (and their descendants) of the
93 * given item @p it.
94 *
95 * @see elm_object_item_del()
96 *
97 * @ingroup Menu
98 */
99EAPI void elm_menu_item_subitems_clear(Elm_Object_Item *it); 15EAPI void elm_menu_item_subitems_clear(Elm_Object_Item *it);
100 16
101/**
102 * @brief Get the position of a menu item
103 *
104 * @param it The menu item
105 * @return The item's index
106 *
107 * This function returns the index position of a menu item in a menu.
108 * For a sub-menu, this number is relative to the first item in the sub-menu.
109 *
110 * @note Index values begin with 0
111 *
112 * @ingroup Menu
113 */
114EAPI unsigned int elm_menu_item_index_get(const Elm_Object_Item *it); 17EAPI unsigned int elm_menu_item_index_get(const Elm_Object_Item *it);
115 18
116/**
117 * @brief Get the next item in the menu.
118 *
119 * @param it The menu item object.
120 * @return The item after it, or NULL if none
121 *
122 * @ingroup Menu
123 */
124EAPI Elm_Object_Item *elm_menu_item_next_get(const Elm_Object_Item *it); 19EAPI Elm_Object_Item *elm_menu_item_next_get(const Elm_Object_Item *it);
125 20
126/**
127 * @brief Get the previous item in the menu.
128 *
129 * @param it The menu item object.
130 * @return The item before it, or NULL if none
131 *
132 * @ingroup Menu
133 */
134EAPI Elm_Object_Item *elm_menu_item_prev_get(const Elm_Object_Item *it); 21EAPI Elm_Object_Item *elm_menu_item_prev_get(const Elm_Object_Item *it);
135 22
diff --git a/src/lib/elm_menu_item.eo b/src/lib/elm_menu_item.eo
new file mode 100644
index 000000000..36c3f89cf
--- /dev/null
+++ b/src/lib/elm_menu_item.eo
@@ -0,0 +1,133 @@
1class Elm_Menu_Item(Elm_Widget_Item)
2{
3 legacy_prefix: null;
4 eo_prefix: elm_obj_menu_item;
5 properties {
6 icon_name {
7 get {
8 /*@
9 Get the string representation from the icon of a menu item
10
11 Once this icon is set, any previously set icon will be deleted.
12 To hide icon set it to "".
13
14 @see elm_menu_item_icon_name_set()
15 @ingroup Menu
16 */
17 }
18 set {
19 /*@
20 Set the icon of a menu item to the standard icon with name @p icon
21
22 Once this icon is set, any previously set icon will be deleted.
23 To hide icon set it to "".
24
25 @ingroup Menu
26 */
27 }
28 values {
29 const (char)* icon; /*@ The name of icon object */
30 }
31 }
32 selected {
33 get {
34 /*@
35 Get the selected state of @p item.
36
37 @see elm_menu_item_selected_set()
38
39 @ingroup Menu
40 */
41 }
42 set {
43 /*@
44 Set the selected state of @p item.
45
46 @ingroup Menu
47 */
48 }
49 values {
50 Eina_Bool selected; /*@ EINA_TRUE if selected EINA_FALSE otherwise */
51 }
52 }
53 }
54 methods {
55 prev_get @const {
56 /*@
57 Get the previous item in the menu.
58
59 @ingroup Menu
60 */
61 return: Elm_Object_Item*;
62 }
63 next_get @const {
64 /*@
65 Get the next item in the menu.
66
67 @ingroup Menu
68 */
69 return: Elm_Object_Item*;
70 }
71 index_get @const {
72 /*@
73 Get the next item in the menu.
74
75 @ingroup Menu
76 */
77 return: uint;
78 }
79 subitems_clear {
80 /*@
81 Remove all sub-items (children) of the given item
82 @since 1.8
83
84 This removes all items that are children (and their descendants) of the
85 given item @p it.
86
87 @see elm_object_item_del()
88
89 @ingroup Menu
90 */
91 }
92 subitems_get @const {
93 /*@
94 Returns a list of @p item's subitems.
95
96 @see elm_menu_add()
97
98 @ingroup Menu
99 */
100 return: const (Eina_List) *; /*@ An Eina_List* of @p item's subitems */
101 }
102 is_separator @const {
103 /*@
104 Returns whether @p item is a separator.
105
106 @see elm_menu_item_separator_add()
107
108 @ingroup Menu
109 */
110 return: bool; /*@ If true, @p item is a separator */
111 }
112 object_get @const {
113 /*@
114 Get the real Evas(Edje) object created to implement the view of a given
115 menu @p item.
116
117 @warning Don't manipulate this object!
118
119 @ingroup Menu
120 */
121 return: Evas_Object*; /*@ The base Edje object containing the swallowed content associated with@p it. */
122 }
123 }
124 implements {
125 Eo.Base.constructor;
126 Elm_Widget_Item.del_pre;
127 Elm_Widget_Item.disable;
128 Elm_Widget_Item.part_text.get;
129 Elm_Widget_Item.part_text.set;
130 Elm_Widget_Item.part_content.get;
131 Elm_Widget_Item.part_content.set;
132 }
133}
diff --git a/src/lib/elm_widget_menu.h b/src/lib/elm_widget_menu.h
index a29665c9c..64c1b84ee 100644
--- a/src/lib/elm_widget_menu.h
+++ b/src/lib/elm_widget_menu.h
@@ -8,6 +8,8 @@
8 * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK 8 * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
9 * IT AT RUNTIME. 9 * IT AT RUNTIME.
10 */ 10 */
11#include "elm_object_item_migration_temp.h"
12#include "elm_menu_item.eo.h"
11 13
12/** 14/**
13 * @addtogroup Widget 15 * @addtogroup Widget
@@ -35,12 +37,12 @@ struct _Elm_Menu_Data
35 Eina_Bool menu_bar : 1; 37 Eina_Bool menu_bar : 1;
36}; 38};
37 39
38typedef struct _Elm_Menu_Item Elm_Menu_Item; 40typedef struct _Elm_Menu_Item_Data Elm_Menu_Item_Data;
39struct _Elm_Menu_Item 41struct _Elm_Menu_Item_Data
40{ 42{
41 ELM_WIDGET_ITEM; 43 Elm_Widget_Item_Data *base;
42 44
43 Elm_Menu_Item *parent; 45 Elm_Menu_Item_Data *parent;
44 Evas_Object *content; 46 Evas_Object *content;
45 const char *icon_str; 47 const char *icon_str;
46 const char *label; 48 const char *label;
@@ -88,16 +90,20 @@ struct _Elm_Menu_Item
88 return val; \ 90 return val; \
89 } 91 }
90 92
93#define ELM_MENU_ITEM_DATA_GET(o, sd) \
94 Elm_Menu_Item_Data *sd = eo_data_scope_get((Eo *)o, ELM_MENU_ITEM_CLASS)
95
91#define ELM_MENU_CHECK(obj) \ 96#define ELM_MENU_CHECK(obj) \
92 if (EINA_UNLIKELY(!eo_isa((obj), ELM_MENU_CLASS))) \ 97 if (EINA_UNLIKELY(!eo_isa((obj), ELM_MENU_CLASS))) \
93 return 98 return
94 99
95#define ELM_MENU_ITEM_CHECK(it) \ 100#define ELM_MENU_ITEM_CHECK(it) \
96 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, ); \ 101 if (EINA_UNLIKELY(!eo_isa((it->base->eo_obj), ELM_MENU_ITEM_CLASS))) \
97 ELM_MENU_CHECK(it->base.widget); 102 return
103
104#define ELM_MENU_ITEM_CHECK_OR_RETURN(it, ...) \
105 if (EINA_UNLIKELY(!eo_isa((it->base->eo_obj), ELM_MENU_ITEM_CLASS))) \
106 return __VA_ARGS__;
98 107
99#define ELM_MENU_ITEM_CHECK_OR_RETURN(it, ...) \
100 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \
101 ELM_MENU_CHECK(it->base.widget) __VA_ARGS__;
102 108
103#endif 109#endif