summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-06-30 19:37:10 +0300
committerYossi Kantor <yossi.kantor@samsung.com>2014-08-03 14:50:41 +0300
commitf399fee1cd37ad0faf91d7f64aa2f769da42c350 (patch)
treeedbb1f0307b96eb7818a04dc6c30634a9ea55d53
parent8ad175beb60397299c90aadce8d2dfd4450f1524 (diff)
downloadelementary-f399fee1cd37ad0faf91d7f64aa2f769da42c350.tar.gz
Integration of Menu Item
-rw-r--r--src/lib/Makefile.am7
-rw-r--r--src/lib/elm_dbus_menu.c63
-rw-r--r--src/lib/elm_menu.c558
-rw-r--r--src/lib/elm_menu_item.eo139
-rw-r--r--src/lib/elm_widget_menu.h27
5 files changed, 524 insertions, 270 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 15bd7cd83..c95782055 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -788,7 +788,9 @@ BUILT_SOURCES = \
elm_slideshow_item.eo.c \
elm_slideshow_item.eo.h \
elm_flipselector_item.eo.c \
- elm_flipselector_item.eo.h
+ elm_flipselector_item.eo.h \
+ elm_menu_item.eo.c \
+ elm_menu_item.eo.h
elementaryeolianfilesdir = $(datadir)/eolian/include/elementary-@VMAJ@
elementaryeolianfiles_DATA = \
@@ -887,7 +889,8 @@ elementaryeolianfiles_DATA = \
elm_hoversel_item.eo \
elm_segment_control_item.eo \
elm_slideshow_item.eo \
- elm_flipselector_item.eo
+ elm_flipselector_item.eo \
+ elm_menu_item.eo
EXTRA_DIST += \
${elementaryeolianfiles_DATA}
diff --git a/src/lib/elm_dbus_menu.c b/src/lib/elm_dbus_menu.c
index 021ee3b9d..b52ec6cb7 100644
--- a/src/lib/elm_dbus_menu.c
+++ b/src/lib/elm_dbus_menu.c
@@ -59,19 +59,20 @@ struct _Callback_Data
};
static Eina_Bool
-_menu_add_recursive(Elm_DBus_Menu *dbus_menu, Elm_Menu_Item *item)
+_menu_add_recursive(Elm_DBus_Menu *dbus_menu, Elm_Widobj_Item *item)
{
int32_t id;
Eina_List *l;
- Elm_Menu_Item *subitem;
+ Elm_Widobj_Item *subitem;
id = ++dbus_menu->timestamp;
if (!eina_hash_add(dbus_menu->elements, &id, item))
return EINA_FALSE;
- item->dbus_idx = id;
+ ELM_MENU_ITEM_DATA_GET(item, item_data);
+ item_data->dbus_idx = id;
- EINA_LIST_FOREACH (item->submenu.items, l, subitem)
+ EINA_LIST_FOREACH (item_data->submenu.items, l, subitem)
{
if (!_menu_add_recursive(dbus_menu, subitem))
return EINA_FALSE;
@@ -168,25 +169,27 @@ _str_to_property(const char *str)
}
static Eina_Bool
-_freedesktop_icon_exists(Elm_Menu_Item *item)
+_freedesktop_icon_exists(Elm_Widobj_Item *item)
{
- if (!item->icon_str) return EINA_FALSE;
+ ELM_MENU_ITEM_DATA_GET(item, item_data);
+ if (!item_data->icon_str) return EINA_FALSE;
- ELM_ICON_CHECK(item->content) EINA_FALSE;
+ ELM_ICON_CHECK(item_data->content) EINA_FALSE;
- ELM_ICON_DATA_GET(item->content, sd);
+ ELM_ICON_DATA_GET(item_data->content, sd);
if (sd->freedesktop.use) return EINA_TRUE;
return EINA_FALSE;
}
static Eina_Bool
-_property_exists(Elm_Menu_Item *item,
+_property_exists(Elm_Widobj_Item *item,
Elm_DBus_Property property)
{
Elm_Object_Item *item_obj;
- if (item->separator)
+ ELM_MENU_ITEM_DATA_GET(item, item_data);
+ if (item_data->separator)
{
if (property == ELM_DBUS_PROPERTY_TYPE) return EINA_TRUE;
return EINA_FALSE;
@@ -199,7 +202,7 @@ _property_exists(Elm_Menu_Item *item,
return EINA_TRUE;
case ELM_DBUS_PROPERTY_CHILDREN_DISPLAY:
- if (eina_list_count(item->submenu.items)) return EINA_TRUE;
+ if (eina_list_count(item_data->submenu.items)) return EINA_TRUE;
return EINA_FALSE;
case ELM_DBUS_PROPERTY_ENABLED:
@@ -221,7 +224,7 @@ _property_exists(Elm_Menu_Item *item,
// Ad-hoc dbusmenu property dictionary subset implementation
// Depends on _property_exists results
static void
-_property_append(Elm_Menu_Item *item,
+_property_append(Elm_Widobj_Item *item,
Elm_DBus_Property property,
Eldbus_Message_Iter *iter)
{
@@ -229,6 +232,7 @@ _property_append(Elm_Menu_Item *item,
Elm_Object_Item *item_obj = (Elm_Object_Item *)item;
const char *t;
+ ELM_MENU_ITEM_DATA_GET(item, item_data);
switch (property)
{
case ELM_DBUS_PROPERTY_LABEL:
@@ -236,7 +240,7 @@ _property_append(Elm_Menu_Item *item,
t = elm_object_item_part_text_get(item_obj, NULL);
if (!t)
{
- t = elm_object_part_text_get(item->content, NULL);
+ t = elm_object_part_text_get(item_data->content, NULL);
if (!t) t = "";
}
@@ -260,7 +264,7 @@ _property_append(Elm_Menu_Item *item,
case ELM_DBUS_PROPERTY_ICON_NAME:
variant = eldbus_message_iter_container_new(iter, 'v', "s");
- eldbus_message_iter_basic_append(variant, 's', item->icon_str);
+ eldbus_message_iter_basic_append(variant, 's', item_data->icon_str);
break;
case ELM_DBUS_PROPERTY_UNKNOWN:
@@ -272,7 +276,7 @@ _property_append(Elm_Menu_Item *item,
}
static void
-_property_dict_build(Elm_Menu_Item *item,
+_property_dict_build(Elm_Widobj_Item *item,
Eina_List *property_list, Eldbus_Message_Iter *iter)
{
char *propstr;
@@ -299,22 +303,23 @@ _property_dict_build(Elm_Menu_Item *item,
}
static void
-_layout_build_recursive(Elm_Menu_Item *item,
+_layout_build_recursive(Elm_Widobj_Item *item,
Eina_List *property_list, unsigned recursion_depth,
Eldbus_Message_Iter *iter)
{
Eina_List *l;
- Elm_Menu_Item *subitem;
+ Elm_Widobj_Item *subitem;
Eldbus_Message_Iter *layout, *array, *variant;
+ ELM_MENU_ITEM_DATA_GET(item, item_data);
layout = eldbus_message_iter_container_new(iter, 'r', NULL);
- eldbus_message_iter_basic_append(layout, 'i', item->dbus_idx);
+ eldbus_message_iter_basic_append(layout, 'i', item_data->dbus_idx);
_property_dict_build(item, property_list, layout);
array = eldbus_message_iter_container_new(layout, 'a', "v");
if (recursion_depth > 0)
{
- EINA_LIST_FOREACH (item->submenu.items, l, subitem)
+ EINA_LIST_FOREACH (item_data->submenu.items, l, subitem)
{
variant = eldbus_message_iter_container_new(array, 'v',
"(ia{sv}av)");
@@ -337,7 +342,7 @@ _root_layout_build(Elm_DBus_Menu *dbus_menu, Eina_List *property_list,
const Eina_List *ret = NULL;
Eina_List *items;
Eina_List *l;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *item;
layout = eldbus_message_iter_container_new(iter, 'r', NULL);
eldbus_message_iter_basic_append(layout, 'i', 0);
@@ -395,7 +400,7 @@ _empty_properties_handle(Eina_List *property_list)
static Eina_Bool
_event_handle(Elm_DBus_Menu *dbus_menu, Eldbus_Message_Iter *iter, int *error_id)
{
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *item;
const char *event;
int id;
int32_t i;
@@ -424,7 +429,7 @@ _elm_dbus_menu_add(Eo *menu)
Elm_DBus_Menu *dbus_menu;
const Eina_List *ret = NULL;
Eina_List *items, *l;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *item;
ELM_MENU_CHECK(menu) NULL;
@@ -483,7 +488,7 @@ _method_layout_get(const Eldbus_Service_Interface *iface,
Eldbus_Message *reply;
Eldbus_Message_Iter *iter, *array;
Elm_DBus_Menu *dbus_menu;
- Elm_Menu_Item *item = NULL;
+ Elm_Widobj_Item *item = NULL;
dbus_menu = eldbus_service_object_data_get(iface, DBUS_DATA_KEY);
@@ -532,7 +537,7 @@ _method_group_properties_get(const Eldbus_Service_Interface *iface,
Eldbus_Message_Iter *iter, *array, *tuple;
Eina_List *property_list = NULL;
Elm_DBus_Menu *dbus_menu;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *item;
char *property;
int id;
int32_t i;
@@ -560,7 +565,8 @@ _method_group_properties_get(const Eldbus_Service_Interface *iface,
{
item = data;
tuple = eldbus_message_iter_container_new(array, 'r', NULL);
- eldbus_message_iter_basic_append(tuple, 'i', item->dbus_idx);
+ ELM_MENU_ITEM_DATA_GET(item, item_data);
+ eldbus_message_iter_basic_append(tuple, 'i', item_data->dbus_idx);
_property_dict_build(item, property_list, tuple);
eldbus_message_iter_container_close(array, tuple);
}
@@ -575,7 +581,8 @@ _method_group_properties_get(const Eldbus_Service_Interface *iface,
if (!item) continue;
tuple = eldbus_message_iter_container_new(array, 'r', NULL);
- eldbus_message_iter_basic_append(tuple, 'i', item->dbus_idx);
+ ELM_MENU_ITEM_DATA_GET(item, item_data);
+ eldbus_message_iter_basic_append(tuple, 'i', item_data->dbus_idx);
_property_dict_build(item, property_list, tuple);
eldbus_message_iter_container_close(array, tuple);
}
@@ -595,7 +602,7 @@ _method_property_get(const Eldbus_Service_Interface *iface,
Eldbus_Message_Iter *iter, *variant;
Elm_DBus_Property property;
Elm_DBus_Menu *dbus_menu;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *item;
int id;
int32_t i;
char *name;
@@ -996,7 +1003,7 @@ _elm_dbus_menu_app_menu_unregister(Eo *obj)
int
_elm_dbus_menu_item_add(Elm_DBus_Menu *dbus_menu, Elm_Object_Item *item_obj)
{
- Elm_Menu_Item *item = (Elm_Menu_Item *)item_obj;
+ Elm_Widobj_Item *item = (Elm_Widobj_Item *)item_obj;
int32_t id = dbus_menu->timestamp + 1;
if (!eina_hash_add(dbus_menu->elements, &id, item))
diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c
index aa4c02582..42c462e09 100644
--- a/src/lib/elm_menu.c
+++ b/src/lib/elm_menu.c
@@ -29,20 +29,21 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
EOLIAN static Eina_Bool
_elm_menu_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd)
{
- Elm_Menu_Item *it;
+ Elm_Widobj_Item *it;
Eina_List *l;
EINA_LIST_FOREACH(sd->items, l, it)
- elm_widget_item_translate(it);
+ eo_do (it, elm_wdg_item_translate());
return EINA_TRUE;
}
static void
-_item_del(Elm_Menu_Item *item)
+_item_del(Elm_Widobj_Item *eo_item)
{
- Elm_Menu_Item *child;
+ Elm_Widobj_Item *child;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
EINA_LIST_FREE(item->submenu.items, child)
_item_del(child);
@@ -51,33 +52,33 @@ _item_del(Elm_Menu_Item *item)
evas_object_del(item->submenu.location);
eina_stringshare_del(item->icon_str);
- elm_widget_item_free(item);
+ eo_del(eo_item);
}
static void
-_submenu_hide(Elm_Menu_Item *item)
+_submenu_hide(Elm_Widobj_Item *eo_item)
{
Eina_List *l;
- Elm_Menu_Item *item2;
+ Elm_Widobj_Item *eo_item2;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
evas_object_hide(item->submenu.hv);
item->submenu.open = EINA_FALSE;
- EINA_LIST_FOREACH(item->submenu.items, l, item2)
+ EINA_LIST_FOREACH(item->submenu.items, l, eo_item2)
{
- if (item2->submenu.open) _submenu_hide(item2);
+ ELM_MENU_ITEM_DATA_GET(eo_item2, item2);
+ if (item2->submenu.open) _submenu_hide(eo_item2);
}
}
static void
-_item_disable_hook(Elm_Object_Item *it)
+_elm_menu_item_elm_widget_item_disable(Eo *eo_item, Elm_Menu_Item_Data *item)
{
- Elm_Menu_Item *item = (Elm_Menu_Item *)it;
-
- if (elm_widget_item_disabled_get(item))
+ if (elm_object_item_disabled_get((Elm_Object_Item*)eo_item))
{
elm_layout_signal_emit(VIEW(item), "elm,state,disabled", "elm");
- if (item->submenu.open) _submenu_hide(item);
+ if (item->submenu.open) _submenu_hide(eo_item);
}
else
elm_layout_signal_emit(VIEW(item), "elm,state,enabled", "elm");
@@ -87,16 +88,22 @@ _item_disable_hook(Elm_Object_Item *it)
}
static void
-_submenu_sizing_eval(Elm_Menu_Item *parent_it)
+_submenu_sizing_eval(Elm_Widobj_Item *eo_parent_it)
{
Eina_List *l;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2,
h2, bx, by, bw, bh, px, py, pw, ph;
+
+ ELM_MENU_ITEM_DATA_GET(eo_parent_it, parent_it);
ELM_MENU_DATA_GET_OR_RETURN(WIDGET(parent_it), sd);
- EINA_LIST_FOREACH(parent_it->submenu.items, l, item)
- elm_layout_sizing_eval(VIEW(item));
+ EINA_LIST_FOREACH(parent_it->submenu.items, l, eo_item)
+ {
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+ elm_layout_sizing_eval(VIEW(item));
+ }
+
evas_object_geometry_get
(parent_it->submenu.location, &x_p, &y_p, &w_p, &h_p);
@@ -108,7 +115,7 @@ _submenu_sizing_eval(Elm_Menu_Item *parent_it)
px = 0;
py = 0;
}
-
+
if (sd->menu_bar && !parent_it->parent)
{
x_p = x2;
@@ -142,9 +149,10 @@ _submenu_sizing_eval(Elm_Menu_Item *parent_it)
evas_object_size_hint_max_set(parent_it->submenu.location, bw, h_p);
elm_hover_target_set(parent_it->submenu.hv, parent_it->submenu.location);
- EINA_LIST_FOREACH(parent_it->submenu.items, l, item)
+ EINA_LIST_FOREACH(parent_it->submenu.items, l, eo_item)
{
- if (item->submenu.open) _submenu_sizing_eval(item);
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+ if (item->submenu.open) _submenu_sizing_eval(eo_item);
}
}
@@ -152,7 +160,7 @@ static void
_sizing_eval(Evas_Object *obj)
{
Eina_List *l;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
Evas_Coord x_p, y_p, w_p, h_p, x2, y2, w2, h2, bw, bh;
Elm_Widget_Smart_Data *hover;
@@ -160,8 +168,11 @@ _sizing_eval(Evas_Object *obj)
if (!sd->parent) return;
- EINA_LIST_FOREACH(sd->items, l, item)
- elm_layout_sizing_eval(VIEW(item));
+ EINA_LIST_FOREACH(sd->items, l, eo_item)
+ {
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+ elm_layout_sizing_eval(VIEW(item));
+ }
evas_object_geometry_get(sd->location, NULL, NULL, &w_p, &h_p);
evas_object_geometry_get(sd->parent, &x2, &y2, &w2, &h2);
@@ -194,8 +205,11 @@ _sizing_eval(Evas_Object *obj)
NULL, &bw, &bh);
evas_object_size_hint_min_set(obj, bw, bh);
- EINA_LIST_FOREACH(sd->items, l, item)
- if (item->submenu.open) _submenu_sizing_eval(item);
+ EINA_LIST_FOREACH(sd->items, l, eo_item)
+ {
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+ if (item->submenu.open) _submenu_sizing_eval(eo_item);
+ }
}
EOLIAN static Eina_Bool
@@ -204,7 +218,7 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
Eina_Bool int_ret = EINA_FALSE;
Eina_List *l, *_l, *_ll, *ll = NULL;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
const char *s;
char style[1024];
@@ -220,8 +234,9 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
ll = eina_list_append(ll, sd->items);
EINA_LIST_FOREACH(ll, _ll, l)
{
- EINA_LIST_FOREACH(l, _l, item)
+ EINA_LIST_FOREACH(l, _l, eo_item)
{
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
ll = eina_list_append(ll, item->submenu.items);
if (item->separator)
{
@@ -252,13 +267,13 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
elm_widget_style_get(obj)))
CRI("Failed to set layout!");
- elm_object_item_text_set((Elm_Object_Item *)item,
+ elm_object_item_text_set((Elm_Object_Item *)eo_item,
item->label);
if (item->icon_str)
- elm_menu_item_icon_name_set((Elm_Object_Item *)item,
+ elm_menu_item_icon_name_set((Elm_Object_Item *)eo_item,
item->icon_str);
}
- _item_disable_hook((Elm_Object_Item *)item);
+ _elm_menu_item_elm_widget_item_disable(eo_item, item);
/* SEOZ
edje_object_scale_set
(VIEW(item), elm_widget_scale_get(obj) *
@@ -274,17 +289,14 @@ _elm_menu_elm_widget_theme_apply(Eo *obj, Elm_Menu_Data *sd)
return EINA_TRUE;
}
-static void
-_item_text_set_hook(Elm_Object_Item *it,
- const char *part,
- const char *label)
+EOLIAN static void
+_elm_menu_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
+ Elm_Menu_Item_Data *item,
+ const char *part,
+ const char *label)
{
- Elm_Menu_Item *item;
-
if (part && strcmp(part, "default")) return;
- item = (Elm_Menu_Item *)it;
-
eina_stringshare_replace(&item->label, label);
if (label)
@@ -298,25 +310,24 @@ _item_text_set_hook(Elm_Object_Item *it,
_sizing_eval(WIDGET(item));
}
-static const char *
-_item_text_get_hook(const Elm_Object_Item *it,
- const char *part)
+EOLIAN static const char *
+_elm_menu_item_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
+ Elm_Menu_Item_Data *it,
+ const char *part)
{
if (part && strcmp(part, "default")) return NULL;
- return ((Elm_Menu_Item *)it)->label;
+ return it->label;
}
-static void
-_item_content_set_hook(Elm_Object_Item *it,
- const char *part,
- Evas_Object *content)
+EOLIAN static void
+_elm_menu_item_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
+ Elm_Menu_Item_Data *item,
+ const char *part,
+ Evas_Object *content)
{
- Elm_Menu_Item *item;
-
if (part && strcmp(part, "default")) return;
- item = (Elm_Menu_Item *)it;
if (content == item->content) return;
evas_object_del(item->content);
@@ -327,13 +338,14 @@ _item_content_set_hook(Elm_Object_Item *it,
_sizing_eval(WIDGET(item));
}
-static Evas_Object *
-_item_content_get_hook(const Elm_Object_Item *it,
- const char *part)
+EOLIAN static Evas_Object *
+_elm_menu_item_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
+ Elm_Menu_Item_Data *it,
+ const char *part)
{
if (part && strcmp(part, "default")) return NULL;
- return ((Elm_Menu_Item *)it)->content;
+ return it->content;
}
static void
@@ -374,9 +386,9 @@ _item_move_resize_cb(void *data,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
- Elm_Menu_Item *item = data;
-
- if (item->submenu.open) _submenu_sizing_eval(item);
+ Elm_Widobj_Item *eo_item = data;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+ if (item->submenu.open) _submenu_sizing_eval(eo_item);
}
static void
@@ -385,7 +397,7 @@ _menu_hide(void *data,
void *event_info EINA_UNUSED)
{
Eina_List *l;
- Elm_Menu_Item *item2;
+ Elm_Widobj_Item *eo_item2;
ELM_MENU_DATA_GET(data, sd);
@@ -395,9 +407,10 @@ _menu_hide(void *data,
evas_object_hide(data);
}
- EINA_LIST_FOREACH(sd->items, l, item2)
+ EINA_LIST_FOREACH(sd->items, l, eo_item2)
{
- if (item2->submenu.open) _submenu_hide(item2);
+ ELM_MENU_ITEM_DATA_GET(eo_item2, item);
+ if (item->submenu.open) _submenu_hide(eo_item2);
}
}
@@ -417,19 +430,21 @@ _submenu_open_cb(void *data,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
- Elm_Menu_Item *item = data;
+ Elm_Widobj_Item *eo_item = data;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
item->submenu.open = EINA_TRUE;
evas_object_show(item->submenu.hv);
- _submenu_sizing_eval(item);
+ _submenu_sizing_eval(eo_item);
}
void
_elm_dbus_menu_item_select_cb(Elm_Object_Item *obj_item)
{
- Elm_Menu_Item *item = (Elm_Menu_Item *)obj_item;
+ Elm_Widobj_Item *eo_item = (Elm_Widobj_Item *)obj_item;
- if (item->func) item->func((void *)(item->base.data), WIDGET(item), item);
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+ if (item->func) item->func((void *)(item->base->data), WIDGET(item), eo_item);
}
static void
@@ -438,16 +453,17 @@ _menu_item_select_cb(void *data,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
- Elm_Menu_Item *item = data;
+ Elm_Widobj_Item *eo_item = data;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
if (item->submenu.items)
{
- if (!item->submenu.open) _submenu_open_cb(item, NULL, NULL, NULL);
- else _submenu_hide(item);
+ if (!item->submenu.open) _submenu_open_cb(eo_item, NULL, NULL, NULL);
+ else _submenu_hide(eo_item);
}
else _menu_hide(WIDGET(item), NULL, NULL);
- if (item->func) item->func((void *)(item->base.data), WIDGET(item), item);
+ if (item->func) item->func((void *)(item->base->data), WIDGET(item), eo_item);
}
static void
@@ -457,15 +473,18 @@ _menu_item_activate_cb(void *data,
const char *source EINA_UNUSED)
{
Eina_List *l;
- Elm_Menu_Item *item2;
- Elm_Menu_Item *item = data;
+ Elm_Widobj_Item *item2;
+ Elm_Widobj_Item *eo_item = data;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
item->selected = 1;
+
if (item->parent)
{
- EINA_LIST_FOREACH(item->parent->submenu.items, l, item2)
+ ELM_MENU_ITEM_DATA_GET(item->parent, parent_data);
+ EINA_LIST_FOREACH(parent_data->submenu.items, l, item2)
{
- if (item2 != item)
+ if (item2 != eo_item)
elm_menu_item_selected_set((Elm_Object_Item *)item2, 0);
}
}
@@ -474,7 +493,7 @@ _menu_item_activate_cb(void *data,
ELM_MENU_DATA_GET(WIDGET(item), sd);
EINA_LIST_FOREACH(sd->items, l, item2)
{
- if (item2 != item)
+ if (item2 != eo_item)
elm_menu_item_selected_set((Elm_Object_Item *)item2, 0);
}
}
@@ -486,23 +505,25 @@ _menu_item_inactivate_cb(void *data,
const char *emission EINA_UNUSED,
const char *source EINA_UNUSED)
{
- Elm_Menu_Item *item = data;
+ Elm_Widobj_Item *eo_item = data;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
item->selected = 0;
- if (item->submenu.open) _submenu_hide(item);
+ if (item->submenu.open) _submenu_hide(eo_item);
}
static void
_block_menu(void *_sd, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
const Eina_List *l;
- Elm_Menu_Item *current;
+ Elm_Widobj_Item *current;
Elm_Menu_Data *sd = _sd;
Eina_List *items = sd->items;
EINA_LIST_FOREACH(items, l, current)
{
- if (!current->blocked) current->was_enabled = !elm_widget_item_disabled_get(current);
- current->blocked = EINA_TRUE;
+ ELM_MENU_ITEM_DATA_GET(current, item);
+ if (!item->blocked) item->was_enabled = !elm_widget_item_disabled_get(current);
+ item->blocked = EINA_TRUE;
elm_object_item_disabled_set((Elm_Object_Item *)current, EINA_TRUE);
}
}
@@ -511,13 +532,14 @@ static void
_unblock_menu(void *_sd, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
const Eina_List *l;
- Elm_Menu_Item *current;
+ Elm_Widobj_Item *eo_current;
Elm_Menu_Data *sd = _sd;
Eina_List *items = sd->items;
- EINA_LIST_FOREACH(items, l, current)
+ EINA_LIST_FOREACH(items, l, eo_current)
{
- elm_object_item_disabled_set((Elm_Object_Item *)current, !current->was_enabled);
- current->blocked = EINA_FALSE;
+ ELM_MENU_ITEM_DATA_GET(eo_current, curreny);
+ elm_object_item_disabled_set((Elm_Object_Item *)eo_current, !curreny->was_enabled);
+ curreny->blocked = EINA_FALSE;
}
}
@@ -528,8 +550,10 @@ _elm_menu_evas_object_smart_show(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd)
}
static void
-_item_obj_create(Elm_Menu_Item *item)
+_item_obj_create(Elm_Widobj_Item *eo_item)
{
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+
VIEW(item) = elm_layout_add(WIDGET(item));
evas_object_size_hint_weight_set
(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -540,19 +564,21 @@ _item_obj_create(Elm_Menu_Item *item)
else
{
elm_layout_signal_callback_add(VIEW(item), "elm,action,click", "*",
- _menu_item_select_cb, item);
+ _menu_item_select_cb, eo_item);
elm_layout_signal_callback_add(VIEW(item), "elm,action,activate", "*",
- _menu_item_activate_cb, item);
+ _menu_item_activate_cb, eo_item);
elm_layout_signal_callback_add(VIEW(item), "elm,action,inactivate", "*",
_menu_item_inactivate_cb,
- item);
+ eo_item);
evas_object_show(VIEW(item));
}
}
static void
-_item_separator_obj_create(Elm_Menu_Item *item)
+_item_separator_obj_create(Elm_Widobj_Item *eo_item)
{
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+
VIEW(item) = elm_layout_add(WIDGET(item));
evas_object_size_hint_weight_set
(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -563,14 +589,16 @@ _item_separator_obj_create(Elm_Menu_Item *item)
else
{
elm_layout_signal_callback_add
- (VIEW(item), "elm,action,activate", "*", _menu_item_activate_cb, item);
+ (VIEW(item), "elm,action,activate", "*", _menu_item_activate_cb, eo_item);
evas_object_show(VIEW(item));
}
}
static void
-_item_submenu_obj_create(Elm_Menu_Item *item)
+_item_submenu_obj_create(Elm_Widobj_Item *eo_item)
{
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+
ELM_MENU_DATA_GET(WIDGET(item), sd);
Evas_Object *hv, *bx;
char style[1024];
@@ -617,17 +645,17 @@ _item_submenu_obj_create(Elm_Menu_Item *item)
CRI("Failed to set layout!");
}
- elm_object_item_text_set((Elm_Object_Item *)item, item->label);
+ elm_object_item_text_set((Elm_Object_Item *)eo_item, item->label);
if (item->icon_str)
- elm_menu_item_icon_name_set((Elm_Object_Item *)item, item->icon_str);
+ elm_menu_item_icon_name_set((Elm_Object_Item *)eo_item, item->icon_str);
elm_layout_signal_callback_add(VIEW(item), "elm,action,open", "*",
- _submenu_open_cb, item);
+ _submenu_open_cb, eo_item);
evas_object_event_callback_add
- (VIEW(item), EVAS_CALLBACK_MOVE, _item_move_resize_cb, item);
+ (VIEW(item), EVAS_CALLBACK_MOVE, _item_move_resize_cb, eo_item);
evas_object_event_callback_add
- (VIEW(item), EVAS_CALLBACK_RESIZE, _item_move_resize_cb, item);
+ (VIEW(item), EVAS_CALLBACK_RESIZE, _item_move_resize_cb, eo_item);
evas_object_event_callback_add(bx, EVAS_CALLBACK_RESIZE,
_menu_resize_cb, WIDGET(item));
@@ -662,7 +690,7 @@ _elm_menu_evas_object_smart_add(Eo *obj, Elm_Menu_Data *priv)
EOLIAN static void
_elm_menu_evas_object_smart_del(Eo *obj, Elm_Menu_Data *sd)
{
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
_elm_dbus_menu_unregister(obj);
@@ -671,8 +699,8 @@ _elm_menu_evas_object_smart_del(Eo *obj, Elm_Menu_Data *sd)
evas_object_event_callback_del_full
(sd->parent, EVAS_CALLBACK_DEL, _parent_del_cb, obj);
- EINA_LIST_FREE(sd->items, item)
- _item_del(item);
+ EINA_LIST_FREE(sd->items, eo_item)
+ _item_del(eo_item);
evas_object_event_callback_del_full
(sd->bx, EVAS_CALLBACK_RESIZE, _menu_resize_cb, obj);
@@ -697,7 +725,7 @@ void
_elm_menu_menu_bar_set(Eo *obj, Eina_Bool menu_bar)
{
Eina_List *l;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
char style[1024];
ELM_MENU_DATA_GET_OR_RETURN(obj, sd);
@@ -714,8 +742,9 @@ _elm_menu_menu_bar_set(Eo *obj, Eina_Bool menu_bar)
snprintf(style, sizeof(style), "menu/%s", elm_widget_style_get(obj));
elm_object_style_set(sd->hv, style);
- EINA_LIST_FOREACH(sd->items, l, item)
+ EINA_LIST_FOREACH(sd->items, l, eo_item)
{
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
if (!item->submenu.bx) continue;
if (menu_bar)
@@ -783,7 +812,7 @@ EOLIAN static void
_elm_menu_elm_widget_parent_set(Eo *obj, Elm_Menu_Data *sd, Evas_Object *parent)
{
Eina_List *l, *_l, *_ll, *ll = NULL;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
if (sd->parent == parent) return;
if (sd->parent)
@@ -806,8 +835,9 @@ _elm_menu_elm_widget_parent_set(Eo *obj, Elm_Menu_Data *sd, Evas_Object *parent)
ll = eina_list_append(ll, sd->items);
EINA_LIST_FOREACH(ll, _ll, l)
{
- EINA_LIST_FOREACH(l, _l, item)
+ EINA_LIST_FOREACH(l, _l, eo_item)
{
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
if (item->submenu.hv)
{
elm_hover_parent_set(item->submenu.hv, parent);
@@ -850,21 +880,22 @@ _elm_menu_close(Eo *obj, Elm_Menu_Data *sd)
_menu_hide(obj, sd->hv, NULL);
}
-EAPI Evas_Object *
-elm_menu_item_object_get(const Elm_Object_Item *it)
+EOLIAN static Evas_Object *
+_elm_menu_item_object_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- return VIEW(((Elm_Menu_Item *)it));
+ return VIEW(item);
}
static void
_item_clone(Evas_Object *obj,
- Elm_Menu_Item *parent,
- Elm_Menu_Item *item)
+ Elm_Widobj_Item *parent,
+ Elm_Widobj_Item *eo_item)
{
Elm_Object_Item *new_item;
- Elm_Menu_Item *subitem;
+ Elm_Widobj_Item *subitem;
Eina_List *iter;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
if (item->separator)
new_item = elm_menu_item_separator_add(obj, (Elm_Object_Item *)parent);
else
@@ -873,13 +904,13 @@ _item_clone(Evas_Object *obj,
item->icon_str,
item->label,
item->func,
- item->base.data);
+ item->base->data);
elm_object_item_disabled_set
- (new_item, elm_widget_item_disabled_get(item));
+ (new_item, elm_widget_item_disabled_get(eo_item));
EINA_LIST_FOREACH(item->submenu.items, iter, subitem)
- _item_clone(obj, (Elm_Menu_Item *)new_item, subitem);
+ _item_clone(obj, (Elm_Widobj_Item *)new_item, subitem);
}
void
@@ -888,59 +919,62 @@ elm_menu_clone(Evas_Object *from_menu,
Elm_Object_Item *parent)
{
Eina_List *iter;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
ELM_MENU_CHECK(from_menu);
ELM_MENU_CHECK(to_menu);
ELM_MENU_DATA_GET_OR_RETURN(from_menu, from_sd);
- EINA_LIST_FOREACH(from_sd->items, iter, item)
- _item_clone(to_menu, (Elm_Menu_Item *)parent, item);
+ EINA_LIST_FOREACH(from_sd->items, iter, eo_item)
+ _item_clone(to_menu, (Elm_Widobj_Item *)parent, eo_item);
}
static void
_elm_menu_item_add_helper(Evas_Object *obj,
- Elm_Menu_Item *parent,
- Elm_Menu_Item *subitem,
+ Elm_Widobj_Item *eo_parent,
+ Elm_Widobj_Item *eo_subitem,
Elm_Menu_Data *sd)
{
- if (parent)
+ ELM_MENU_ITEM_DATA_GET(eo_parent, parent);
+ ELM_MENU_ITEM_DATA_GET(eo_subitem, subitem);
+ if (eo_parent)
{
- if (!parent->submenu.bx) _item_submenu_obj_create(parent);
+ if (!parent->submenu.bx) _item_submenu_obj_create(eo_parent);
elm_box_pack_end(parent->submenu.bx, VIEW(subitem));
parent->submenu.items =
- eina_list_append(parent->submenu.items, subitem);
+ eina_list_append(parent->submenu.items, eo_subitem);
subitem->idx = eina_list_count(parent->submenu.items) - 1;
}
else
{
elm_box_pack_end(sd->bx, VIEW(subitem));
- sd->items = eina_list_append(sd->items, subitem);
+ sd->items = eina_list_append(sd->items, eo_subitem);
subitem->idx = eina_list_count(sd->items) - 1;
}
_sizing_eval(obj);
}
-static Eina_Bool
-_item_del_pre_hook(Elm_Object_Item *it)
+EOLIAN static Eina_Bool
+_elm_menu_item_elm_widget_item_del_pre(Eo *eo_item, Elm_Menu_Item_Data *item)
{
- Elm_Menu_Item *item = (Elm_Menu_Item *)it;
-
ELM_MENU_DATA_GET(WIDGET(item), sd);
- elm_menu_item_subitems_clear(it);
+ elm_menu_item_subitems_clear((Elm_Object_Item*)eo_item);
eina_stringshare_del(item->label);
evas_object_del(item->content);
evas_object_del(item->submenu.hv);
evas_object_del(item->submenu.location);
if (item->parent)
- item->parent->submenu.items =
- eina_list_remove(item->parent->submenu.items, item);
+ {
+ ELM_MENU_ITEM_DATA_GET(item->parent, parent_data);
+ parent_data->submenu.items =
+ eina_list_remove(parent_data->submenu.items, eo_item);
+ }
else
- sd->items = eina_list_remove(sd->items, item);
+ sd->items = eina_list_remove(sd->items, eo_item);
if (sd->dbus_menu)
_elm_dbus_menu_item_delete(sd->dbus_menu, item->dbus_idx);
@@ -948,68 +982,67 @@ _item_del_pre_hook(Elm_Object_Item *it)
return EINA_TRUE;
}
+EOLIAN static void
+_elm_menu_item_eo_base_constructor(Eo *obj, Elm_Menu_Item_Data *it)
+{
+ eo_do_super(obj, ELM_MENU_ITEM_CLASS, eo_constructor());
+ it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
+}
+
EOLIAN static Elm_Object_Item*
_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)
{
- Elm_Menu_Item *it;
+ Elm_Widobj_Item *eo_item;
Evas_Object *icon_obj;
icon_obj = elm_icon_add(obj);
if (!icon_obj) return NULL;
- it = elm_widget_item_new(obj, Elm_Menu_Item);
- if (!it)
+ eo_item = eo_add(ELM_MENU_ITEM_CLASS, obj);
+ if (!eo_item)
{
evas_object_del(icon_obj);
return NULL;
}
- elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
- elm_widget_item_disable_hook_set(it, _item_disable_hook);
- elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
- elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
- elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
- elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
+ ELM_MENU_ITEM_DATA_GET(eo_item, it);
- it->base.data = data;
+ it->base->data = data;
it->func = func;
- it->parent = (Elm_Menu_Item *)parent;
+ it->parent = (Elm_Widobj_Item *)parent;
it->content = icon_obj;
- _item_obj_create(it);
- elm_object_item_text_set((Elm_Object_Item *)it, label);
+ _item_obj_create(eo_item);
+ elm_object_item_text_set((Elm_Object_Item *)eo_item, label);
elm_layout_content_set(VIEW(it), "elm.swallow.content",
it->content);
- if (icon) elm_menu_item_icon_name_set((Elm_Object_Item *)it, icon);
+ if (icon) elm_menu_item_icon_name_set((Elm_Object_Item *)eo_item, icon);
- _elm_menu_item_add_helper(obj, (Elm_Menu_Item *)parent, it, sd);
+ _elm_menu_item_add_helper(obj, (Elm_Widobj_Item *)parent, eo_item, sd);
if (sd->dbus_menu)
{
- it->dbus_idx = _elm_dbus_menu_item_add(sd->dbus_menu, (Elm_Object_Item *)it);
+ it->dbus_idx = _elm_dbus_menu_item_add(sd->dbus_menu, (Elm_Object_Item *)eo_item);
it->dbus_menu = sd->dbus_menu;
}
- return (Elm_Object_Item *)it;
+ return (Elm_Object_Item *)eo_item;
}
-EAPI unsigned int
-elm_menu_item_index_get(const Elm_Object_Item *it)
+EOLIAN static unsigned int
+_elm_menu_item_index_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- ELM_MENU_ITEM_CHECK_OR_RETURN(it, 0);
-
- return ((Elm_Menu_Item *)it)->idx;
+ return item->idx;
}
-EAPI void
-elm_menu_item_icon_name_set(Elm_Object_Item *it,
- const char *icon)
+EOLIAN static void
+_elm_menu_item_icon_name_set(Eo *eo_item EINA_UNUSED,
+ Elm_Menu_Item_Data *item,
+ const char *icon)
{
char icon_tmp[512];
- Elm_Menu_Item *item = (Elm_Menu_Item *)it;
- ELM_MENU_ITEM_CHECK_OR_RETURN(it);
EINA_SAFETY_ON_NULL_RETURN(icon);
if ((icon[0] != '\0') &&
@@ -1030,89 +1063,79 @@ elm_menu_item_icon_name_set(Elm_Object_Item *it,
EOLIAN static Elm_Object_Item*
_elm_menu_item_separator_add(Eo *obj, Elm_Menu_Data *sd, Elm_Object_Item *parent)
{
- Elm_Menu_Item *subitem;
- Elm_Menu_Item *p_item = (Elm_Menu_Item *)parent;
+ Elm_Widobj_Item *eo_subitem;
+ Elm_Widobj_Item *eo_p_item = (Elm_Widobj_Item *)parent;
+ ELM_MENU_ITEM_DATA_GET(eo_p_item, p_item);
/* don't add a separator as the first item */
if (!sd->items) return NULL;
/* don't allow adding more than one separator in a row */
- if (p_item)
+ if (eo_p_item)
{
if (!p_item->submenu.items) return NULL;
- subitem = eina_list_last(p_item->submenu.items)->data;
+ eo_subitem = eina_list_last(p_item->submenu.items)->data;
}
- else subitem = eina_list_last(sd->items)->data;
+ else eo_subitem = eina_list_last(sd->items)->data;
- if (subitem->separator) return NULL;
+ ELM_MENU_ITEM_DATA_GET(eo_subitem, sitem_data);
+ if (sitem_data->separator) return NULL;
- subitem = elm_widget_item_new(obj, Elm_Menu_Item);
- if (!subitem) return NULL;
+ eo_subitem = eo_add(ELM_MENU_ITEM_CLASS, obj);
+ if (!eo_subitem) return NULL;
- elm_widget_item_del_pre_hook_set(subitem, _item_del_pre_hook);
- elm_widget_item_disable_hook_set(subitem, _item_disable_hook);
- elm_widget_item_text_set_hook_set(subitem, _item_text_set_hook);
- elm_widget_item_text_get_hook_set(subitem, _item_text_get_hook);
- elm_widget_item_content_set_hook_set(subitem, _item_content_set_hook);
- elm_widget_item_content_get_hook_set(subitem, _item_content_get_hook);
+ ELM_MENU_ITEM_DATA_GET(eo_subitem, subitem);
subitem->separator = EINA_TRUE;
- _item_separator_obj_create(subitem);
- if (!p_item)
+ _item_separator_obj_create(eo_subitem);
+ if (!eo_p_item)
{
elm_box_pack_end(sd->bx, VIEW(subitem));
- sd->items = eina_list_append(sd->items, subitem);
+ sd->items = eina_list_append(sd->items, eo_subitem);
}
else
{
- if (!p_item->submenu.bx) _item_submenu_obj_create(p_item);
+ if (!p_item->submenu.bx) _item_submenu_obj_create(eo_p_item);
elm_box_pack_end(p_item->submenu.bx, VIEW(subitem));
p_item->submenu.items = eina_list_append
- (p_item->submenu.items, subitem);
+ (p_item->submenu.items, eo_subitem);
}
_sizing_eval(obj);
if (sd->dbus_menu)
subitem->dbus_idx = _elm_dbus_menu_item_add(sd->dbus_menu,
- (Elm_Object_Item *)subitem);
- return (Elm_Object_Item *)subitem;
+ (Elm_Object_Item *)eo_subitem);
+ return (Elm_Object_Item *)eo_subitem;
}
-EAPI const char *
-elm_menu_item_icon_name_get(const Elm_Object_Item *it)
+EOLIAN static const char *
+_elm_menu_item_icon_name_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- ELM_MENU_ITEM_CHECK_OR_RETURN(it, NULL);
-
- return ((Elm_Menu_Item *)it)->icon_str;
+ return item->icon_str;
}
-EAPI Eina_Bool
-elm_menu_item_is_separator(Elm_Object_Item *it)
+EOLIAN static Eina_Bool
+_elm_menu_item_is_separator(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- ELM_MENU_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
-
- return ((Elm_Menu_Item *)it)->separator;
+ return item->separator;
}
-EAPI const Eina_List *
-elm_menu_item_subitems_get(const Elm_Object_Item *it)
+EOLIAN static const Eina_List *
+_elm_menu_item_subitems_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- ELM_MENU_ITEM_CHECK_OR_RETURN(it, NULL);
-
- return ((Elm_Menu_Item *)it)->submenu.items;
+ return item->submenu.items;
}
-EAPI void
-elm_menu_item_subitems_clear(Elm_Object_Item *it)
+EOLIAN static void
+_elm_menu_item_subitems_clear(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *it)
{
- Elm_Object_Item *sub_it;
+ Elm_Widobj_Item *sub_it;
Eina_List *l, *l_next;
- ELM_MENU_ITEM_CHECK_OR_RETURN(it);
- EINA_LIST_FOREACH_SAFE(((Elm_Menu_Item *)it)->submenu.items,
+ EINA_LIST_FOREACH_SAFE(it->submenu.items,
l, l_next, sub_it)
- elm_widget_item_del(sub_it);
+ eo_do(sub_it, elm_wdg_item_del());
}
EOLIAN static const Eina_List*
@@ -1121,48 +1144,40 @@ _elm_menu_items_get(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd)
return sd->items;
}
-EAPI void
-elm_menu_item_selected_set(Elm_Object_Item *it,
- Eina_Bool selected)
+EOLIAN static void
+_elm_menu_item_selected_set(Eo *eo_item,
+ Elm_Menu_Item_Data *item,
+ Eina_Bool selected)
{
- Elm_Menu_Item *item = (Elm_Menu_Item *)it;
-
- ELM_MENU_ITEM_CHECK_OR_RETURN(item);
-
if (selected == item->selected) return;
item->selected = selected;
if (selected)
{
elm_layout_signal_emit(VIEW(item), "elm,state,selected", "elm");
- _menu_item_activate_cb(item, NULL, NULL, NULL);
+ _menu_item_activate_cb(eo_item, NULL, NULL, NULL);
}
else
{
elm_layout_signal_emit(VIEW(item), "elm,state,unselected", "elm");
- _menu_item_inactivate_cb(item, NULL, NULL, NULL);
+ _menu_item_inactivate_cb(eo_item, NULL, NULL, NULL);
}
edje_object_message_signal_process(elm_layout_edje_get(VIEW(item)));
}
-EAPI Eina_Bool
-elm_menu_item_selected_get(const Elm_Object_Item *it)
+EOLIAN static Eina_Bool
+_elm_menu_item_selected_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- ELM_MENU_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
-
- return ((Elm_Menu_Item *)it)->selected;
+ return item->selected;
}
-EAPI Elm_Object_Item *
-elm_menu_item_prev_get(const Elm_Object_Item *it)
+EOLIAN static Elm_Widobj_Item *
+_elm_menu_item_prev_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- Elm_Menu_Item *item = (Elm_Menu_Item *)it;
-
- ELM_MENU_ITEM_CHECK_OR_RETURN(item, NULL);
-
if (item->parent)
{
+ ELM_MENU_ITEM_DATA_GET(item->parent, parent_data);
Eina_List *l = eina_list_data_find_list
- (item->parent->submenu.items, item);
+ (parent_data->submenu.items, eo_item);
l = eina_list_prev(l);
if (!l) return NULL;
return l->data;
@@ -1171,7 +1186,7 @@ elm_menu_item_prev_get(const Elm_Object_Item *it)
{
ELM_MENU_DATA_GET(WIDGET(item), sd);
if (!sd || !sd->items) return NULL;
- Eina_List *l = eina_list_data_find_list(sd->items, item);
+ Eina_List *l = eina_list_data_find_list(sd->items, eo_item);
l = eina_list_prev(l);
if (!l) return NULL;
return l->data;
@@ -1180,17 +1195,14 @@ elm_menu_item_prev_get(const Elm_Object_Item *it)
return NULL;
}
-EAPI Elm_Object_Item *
-elm_menu_item_next_get(const Elm_Object_Item *it)
+EOLIAN static Elm_Widobj_Item *
+_elm_menu_item_next_get(Eo *eo_item EINA_UNUSED, Elm_Menu_Item_Data *item)
{
- Elm_Menu_Item *item = (Elm_Menu_Item *)it;
-
- ELM_MENU_ITEM_CHECK_OR_RETURN(item, NULL);
-
if (item->parent)
{
+ ELM_MENU_ITEM_DATA_GET(item->parent, parent_data);
Eina_List *l =
- eina_list_data_find_list(item->parent->submenu.items, item);
+ eina_list_data_find_list(parent_data->submenu.items, eo_item);
l = eina_list_next(l);
if (!l) return NULL;
return l->data;
@@ -1199,7 +1211,7 @@ elm_menu_item_next_get(const Elm_Object_Item *it)
{
ELM_MENU_DATA_GET(WIDGET(item), sd);
if (!sd || !sd->items) return NULL;
- Eina_List *l = eina_list_data_find_list(sd->items, item);
+ Eina_List *l = eina_list_data_find_list(sd->items, eo_item);
l = eina_list_next(l);
if (!l) return NULL;
return l->data;
@@ -1225,11 +1237,12 @@ EOLIAN static Elm_Object_Item*
_elm_menu_selected_item_get(Eo *obj EINA_UNUSED, Elm_Menu_Data *sd)
{
Eina_List *l;
- Elm_Menu_Item *item;
+ Elm_Widobj_Item *eo_item;
- EINA_LIST_FOREACH(sd->items, l, item)
+ EINA_LIST_FOREACH(sd->items, l, eo_item)
{
- if (item->selected) return (Elm_Object_Item *)item;
+ ELM_MENU_ITEM_DATA_GET(eo_item, item);
+ if (item->selected) return (Elm_Object_Item *)eo_item;
}
return NULL;
@@ -1241,4 +1254,89 @@ _elm_menu_class_constructor(Eo_Class *klass)
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
}
-#include "elm_menu.eo.c"
+EAPI Evas_Object *
+elm_menu_item_object_get(const Elm_Object_Item *it)
+{
+ Evas_Object *ret = NULL;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_object_get());
+ return ret;
+}
+
+EAPI void
+elm_menu_item_selected_set(Elm_Object_Item *it,
+ Eina_Bool selected)
+{
+ eo_do((Eo*)it, elm_obj_menu_item_selected_set(selected));
+}
+
+EAPI Eina_Bool
+elm_menu_item_selected_get(const Elm_Object_Item *it)
+{
+ Eina_Bool ret;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_selected_get());
+ return ret;
+}
+
+EAPI Elm_Object_Item *
+elm_menu_item_prev_get(const Elm_Object_Item *it)
+{
+ Elm_Widobj_Item *ret = NULL;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_prev_get());
+ return (Elm_Object_Item*)ret;
+}
+
+EAPI Elm_Object_Item *
+elm_menu_item_next_get(const Elm_Object_Item *it)
+{
+ Elm_Widobj_Item *ret = NULL;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_next_get());
+ return (Elm_Object_Item*)ret;
+}
+
+EAPI const char *
+elm_menu_item_icon_name_get(const Elm_Object_Item *it)
+{
+ const char *ret = NULL;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_icon_name_get());
+ return ret;
+}
+
+EAPI Eina_Bool
+elm_menu_item_is_separator(Elm_Object_Item *it)
+{
+ Eina_Bool ret;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_is_separator());
+ return ret;
+}
+
+EAPI const Eina_List *
+elm_menu_item_subitems_get(const Elm_Object_Item *it)
+{
+ const Eina_List *ret = NULL;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_subitems_get());
+ return ret;
+}
+
+EAPI void
+elm_menu_item_subitems_clear(Elm_Object_Item *it)
+{
+ eo_do((Eo*)it, elm_obj_menu_item_subitems_clear());
+}
+
+EAPI unsigned int
+elm_menu_item_index_get(const Elm_Object_Item *it)
+{
+ unsigned int ret;
+ eo_do((Eo*)it, ret = elm_obj_menu_item_index_get());
+ return ret;
+}
+
+EAPI void
+elm_menu_item_icon_name_set(Elm_Object_Item *it,
+ const char *icon)
+{
+ eo_do((Eo*)it, elm_obj_menu_item_icon_name_set(icon));
+}
+
+#include "elm_menu_item.eo.c"
+#include "elm_menu.eo.c" \ No newline at end of file
diff --git a/src/lib/elm_menu_item.eo b/src/lib/elm_menu_item.eo
new file mode 100644
index 000000000..54fe9d167
--- /dev/null
+++ b/src/lib/elm_menu_item.eo
@@ -0,0 +1,139 @@
+class Elm_Menu_Item(Elm_Widget_Item)
+{
+ legacy_prefix: null;
+ eo_prefix: elm_obj_menu_item;
+ properties {
+ icon_name {
+ get {
+ /*@
+ Get the string representation from the icon of a menu item
+
+ Once this icon is set, any previously set icon will be deleted.
+ To hide icon set it to "".
+
+ @see elm_menu_item_icon_name_set()
+ @ingroup Menu
+ */
+ }
+ set {
+ /*@
+ Set the icon of a menu item to the standard icon with name @p icon
+
+ Once this icon is set, any previously set icon will be deleted.
+ To hide icon set it to "".
+
+ @ingroup Menu
+ */
+ }
+ values {
+ const char* icon; /*@ The name of icon object */
+ }
+ }
+ selected {
+ get {
+ /*@
+ Get the selected state of @p item.
+
+ @see elm_menu_item_selected_set()
+
+ @ingroup Menu
+ */
+ }
+ set {
+ /*@
+ Set the selected state of @p item.
+
+ @ingroup Menu
+ */
+ }
+ values {
+ Eina_Bool selected; /*@ EINA_TRUE if selected EINA_FALSE otherwise */
+ }
+ }
+ }
+ methods {
+ prev_get {
+ /*@
+ Get the previous item in the menu.
+
+ @ingroup Menu
+ */
+ const;
+ return Elm_Widobj_Item*;
+ }
+ next_get {
+ /*@
+ Get the next item in the menu.
+
+ @ingroup Menu
+ */
+ const;
+ return Elm_Widobj_Item*;
+ }
+ index_get {
+ /*@
+ Get the next item in the menu.
+
+ @ingroup Menu
+ */
+ const;
+ return unsigned int;
+ }
+ subitems_clear {
+ /*@
+ Remove all sub-items (children) of the given item
+ @since 1.8
+
+ This removes all items that are children (and their descendants) of the
+ given item @p it.
+
+ @see elm_object_item_del()
+
+ @ingroup Menu
+ */
+ }
+ subitems_get {
+ /*@
+ Returns a list of @p item's subitems.
+
+ @see elm_menu_add()
+
+ @ingroup Menu
+ */
+ const;
+ return const Eina_List *; /*@ An Eina_List* of @p item's subitems */
+ }
+ is_separator {
+ /*@
+ Returns whether @p item is a separator.
+
+ @see elm_menu_item_separator_add()
+
+ @ingroup Menu
+ */
+ const;
+ return Eina_Bool; /*@ If true, @p item is a separator */
+ }
+ object_get {
+ /*@
+ Get the real Evas(Edje) object created to implement the view of a given
+ menu @p item.
+
+ @warning Don't manipulate this object!
+
+ @ingroup Menu
+ */
+ const;
+ return Evas_Object*; /*@ The base Edje object containing the swallowed content associated with@p it. */
+ }
+ }
+ implements {
+ Eo_Base::constructor;
+ Elm_Widget_Item::del_pre;
+ Elm_Widget_Item::disable;
+ Elm_Widget_Item::part_text::get;
+ Elm_Widget_Item::part_text::set;
+ Elm_Widget_Item::part_content::get;
+ Elm_Widget_Item::part_content::set;
+ }
+} \ No newline at end of file
diff --git a/src/lib/elm_widget_menu.h b/src/lib/elm_widget_menu.h
index 21027ed7e..7c912a40d 100644
--- a/src/lib/elm_widget_menu.h
+++ b/src/lib/elm_widget_menu.h
@@ -3,6 +3,9 @@
#include "Elementary.h"
+#include "elm_object_item_migration_temp.h"
+#include "elm_menu_item.eo.h"
+
/**
* @addtogroup Widget
* @{
@@ -29,12 +32,12 @@ struct _Elm_Menu_Data
Eina_Bool menu_bar : 1;
};
-typedef struct _Elm_Menu_Item Elm_Menu_Item;
-struct _Elm_Menu_Item
+typedef struct _Elm_Menu_Item_Data Elm_Menu_Item_Data;
+struct _Elm_Menu_Item_Data
{
- ELM_WIDGET_ITEM;
+ Elm_Widget_Item_Data *base;
- Elm_Menu_Item *parent;
+ Elm_Widobj_Item *parent;
Evas_Object *content;
const char *icon_str;
const char *label;
@@ -82,16 +85,20 @@ struct _Elm_Menu_Item
return val; \
}
+#define ELM_MENU_ITEM_DATA_GET(o, sd) \
+ Elm_Menu_Item_Data * sd = eo_data_scope_get(o, ELM_MENU_ITEM_CLASS)
+
#define ELM_MENU_CHECK(obj) \
if (EINA_UNLIKELY(!eo_isa((obj), ELM_MENU_CLASS))) \
return
-#define ELM_MENU_ITEM_CHECK(it) \
- ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
- ELM_MENU_CHECK(it->base.widget);
+#define ELM_MENU_ITEM_CHECK(obj) \
+ if (EINA_UNLIKELY(!eo_isa((obj), ELM_MENU_ITEM_CLASS))) \
+ return
+
+#define ELM_MENU_ITEM_CHECK_OR_RETURN(obj, ...) \
+ if (EINA_UNLIKELY(!eo_isa((obj), ELM_MENU_ITEM_CLASS))) \
+ return __VA_ARGS__;
-#define ELM_MENU_ITEM_CHECK_OR_RETURN(it, ...) \
- ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
- ELM_MENU_CHECK(it->base.widget) __VA_ARGS__;
#endif