summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-07-29 15:08:56 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-07-29 15:08:56 +0000
commit67ec384e14f654d76889dced828e7c9ee56ba08a (patch)
tree21bd78263a22dcf50fd64250b9f9606f89443661
parent2f874f39b81869cd1e0cc2d460e8be689c97a68a (diff)
unbreak elm_menu_item api
the following functions are now DEPRECATED and will be removed on 5 AUG 2011: elm_menu_item_object_icon_get -> elm_menu_item_object_content_get elm_menu_item_icon_get -> elm_menu_item_object_icon_name_get elm_menu_item_icon_set -> elm_menu_item_object_icon_name_set added the following NEW functions: elm_menu_item_object_content_set elm_menu_item_menu_get (this will probably be replaced by an eventual elm_object_item_owner_get() or whatever it gets named) SVN revision: 61899
-rw-r--r--src/lib/Elementary.h.in11
-rw-r--r--src/lib/elm_menu.c108
2 files changed, 93 insertions, 26 deletions
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index bf78fb483..3ede57f75 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -9809,9 +9809,13 @@ extern "C" {
9809 EAPI Elm_Menu_Item *elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *subobj, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); 9809 EAPI Elm_Menu_Item *elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *subobj, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1);
9810 EAPI void elm_menu_item_label_set(Elm_Menu_Item *item, const char *label) EINA_ARG_NONNULL(1); 9810 EAPI void elm_menu_item_label_set(Elm_Menu_Item *item, const char *label) EINA_ARG_NONNULL(1);
9811 EAPI const char *elm_menu_item_label_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); 9811 EAPI const char *elm_menu_item_label_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
9812 EAPI void elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon) EINA_ARG_NONNULL(1, 2); 9812 EAPI void elm_menu_item_object_icon_name_set(Elm_Menu_Item *item, const char *icon) EINA_ARG_NONNULL(1, 2);
9813 EAPI const char *elm_menu_item_icon_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); 9813 EAPI const char *elm_menu_item_object_icon_name_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
9814 EAPI const Evas_Object *elm_menu_item_object_icon_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); 9814 EAPI void elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon) EINA_ARG_NONNULL(1, 2) EINA_DEPRECATED;
9815 EAPI const char *elm_menu_item_icon_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_DEPRECATED;
9816 EAPI Eina_Bool elm_menu_item_object_content_set(Elm_Menu_Item *item, Evas_Object *obj) EINA_ARG_NONNULL(1);
9817 EAPI Evas_Object *elm_menu_item_object_content_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
9818 EAPI Evas_Object *elm_menu_item_object_icon_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_DEPRECATED;
9815 EAPI void elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected) EINA_ARG_NONNULL(1); 9819 EAPI void elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected) EINA_ARG_NONNULL(1);
9816 EAPI Eina_Bool elm_menu_item_selected_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); 9820 EAPI Eina_Bool elm_menu_item_selected_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
9817 EAPI void elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled) EINA_ARG_NONNULL(1); 9821 EAPI void elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled) EINA_ARG_NONNULL(1);
@@ -9824,6 +9828,7 @@ extern "C" {
9824 EAPI void elm_menu_item_data_set(Elm_Menu_Item *item, const void *data) EINA_ARG_NONNULL(1); 9828 EAPI void elm_menu_item_data_set(Elm_Menu_Item *item, const void *data) EINA_ARG_NONNULL(1);
9825 EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); 9829 EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1);
9826 EAPI unsigned int elm_menu_item_index_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_PURE; 9830 EAPI unsigned int elm_menu_item_index_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_PURE;
9831 EAPI Evas_Object *elm_menu_item_menu_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_PURE;
9827 EAPI Elm_Menu_Item *elm_menu_selected_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); 9832 EAPI Elm_Menu_Item *elm_menu_selected_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1);
9828 EAPI Elm_Menu_Item *elm_menu_last_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); 9833 EAPI Elm_Menu_Item *elm_menu_last_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1);
9829 EAPI Elm_Menu_Item *elm_menu_first_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); 9834 EAPI Elm_Menu_Item *elm_menu_first_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1);
diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c
index d7197a79d..dcced6445 100644
--- a/src/lib/elm_menu.c
+++ b/src/lib/elm_menu.c
@@ -20,7 +20,7 @@ struct _Elm_Menu_Item
20{ 20{
21 Elm_Widget_Item base; 21 Elm_Widget_Item base;
22 Elm_Menu_Item *parent; 22 Elm_Menu_Item *parent;
23 Evas_Object *icon; 23 Evas_Object *content;
24 const char *icon_str; 24 const char *icon_str;
25 const char *label; 25 const char *label;
26 Evas_Smart_Cb func; 26 Evas_Smart_Cb func;
@@ -130,14 +130,14 @@ _theme_hook(Evas_Object *obj)
130 (obj, item->base.view, "menu", "item_with_submenu", 130 (obj, item->base.view, "menu", "item_with_submenu",
131 elm_widget_style_get(obj)); 131 elm_widget_style_get(obj));
132 elm_menu_item_label_set(item, item->label); 132 elm_menu_item_label_set(item, item->label);
133 elm_menu_item_icon_set(item, item->icon_str); 133 elm_menu_item_object_icon_name_set(item, item->icon_str);
134 } 134 }
135 else 135 else
136 { 136 {
137 _elm_theme_object_set(obj, item->base.view, "menu", "item", 137 _elm_theme_object_set(obj, item->base.view, "menu", "item",
138 elm_widget_style_get(obj)); 138 elm_widget_style_get(obj));
139 elm_menu_item_label_set(item, item->label); 139 elm_menu_item_label_set(item, item->label);
140 elm_menu_item_icon_set(item, item->icon_str); 140 elm_menu_item_object_icon_name_set(item, item->icon_str);
141 } 141 }
142 if (item->disabled) 142 if (item->disabled)
143 edje_object_signal_emit 143 edje_object_signal_emit
@@ -433,7 +433,7 @@ _item_submenu_obj_create(Elm_Menu_Item *item)
433 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget)); 433 edje_object_mirrored_set(item->base.view, elm_widget_mirrored_get(item->base.widget));
434 _elm_theme_object_set(item->base.widget, item->base.view, "menu", "item_with_submenu", elm_widget_style_get(item->base.widget)); 434 _elm_theme_object_set(item->base.widget, item->base.view, "menu", "item_with_submenu", elm_widget_style_get(item->base.widget));
435 elm_menu_item_label_set(item, item->label); 435 elm_menu_item_label_set(item, item->label);
436 if (item->icon_str) elm_menu_item_icon_set(item, item->icon_str); 436 if (item->icon_str) elm_menu_item_object_icon_name_set(item, item->icon_str);
437 437
438 edje_object_signal_callback_add(item->base.view, "elm,action,open", "", 438 edje_object_signal_callback_add(item->base.view, "elm,action,open", "",
439 _submenu_open, item); 439 _submenu_open, item);
@@ -696,14 +696,14 @@ elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, con
696 subitem->base.data = data; 696 subitem->base.data = data;
697 subitem->func = func; 697 subitem->func = func;
698 subitem->parent = parent; 698 subitem->parent = parent;
699 subitem->icon = icon_obj; 699 subitem->content = icon_obj;
700 700
701 _item_obj_create(subitem); 701 _item_obj_create(subitem);
702 elm_menu_item_label_set(subitem, label); 702 elm_menu_item_label_set(subitem, label);
703 703
704 elm_widget_sub_object_add(subitem->base.widget, subitem->icon); 704 elm_widget_sub_object_add(subitem->base.widget, subitem->content);
705 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subitem->icon); 705 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subitem->content);
706 if (icon) elm_menu_item_icon_set(subitem, icon); 706 if (icon) elm_menu_item_object_icon_name_set(subitem, icon);
707 707
708 _elm_menu_item_add_helper(obj, parent, subitem, wd); 708 _elm_menu_item_add_helper(obj, parent, subitem, wd);
709 709
@@ -737,11 +737,11 @@ elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *s
737 subitem->func = func; 737 subitem->func = func;
738 subitem->parent = parent; 738 subitem->parent = parent;
739 subitem->object_item = EINA_TRUE; 739 subitem->object_item = EINA_TRUE;
740 subitem->icon = subobj; 740 subitem->content = subobj;
741 741
742 _item_obj_create(subitem); 742 _item_obj_create(subitem);
743 743
744 elm_widget_sub_object_add(subitem->base.widget, subitem->icon); 744 elm_widget_sub_object_add(subitem->base.widget, subitem->content);
745 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subobj); 745 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subobj);
746 _sizing_eval(subitem->base.widget); 746 _sizing_eval(subitem->base.widget);
747 747
@@ -807,17 +807,17 @@ elm_menu_item_label_get(const Elm_Menu_Item *item)
807} 807}
808 808
809/** 809/**
810 * Set the icon of a menu item 810 * Set the content of a menu item to an icon
811 * 811 *
812 * Once the icon object is set, a previously set one will be deleted. 812 * Once this content object is set, any previously set object will be deleted.
813 * 813 *
814 * @param item The menu item object. 814 * @param item The menu item object.
815 * @param icon The icon object to set for @p item 815 * @param icon The icon object to set for the content of @p item
816 * 816 *
817 * @ingroup Menu 817 * @ingroup Menu
818 */ 818 */
819EAPI void 819EAPI void
820elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon) 820elm_menu_item_object_icon_name_set(Elm_Menu_Item *item, const char *icon)
821{ 821{
822 char icon_tmp[512]; 822 char icon_tmp[512];
823 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); 823 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
@@ -825,7 +825,7 @@ elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon)
825 if (!*icon) return; 825 if (!*icon) return;
826 if ((item->icon_str) && (!strcmp(item->icon_str, icon))) return; 826 if ((item->icon_str) && (!strcmp(item->icon_str, icon))) return;
827 if ((snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) && 827 if ((snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) &&
828 (elm_icon_standard_set(item->icon, icon_tmp))) 828 (elm_icon_standard_set(item->content, icon_tmp)))
829 { 829 {
830 eina_stringshare_replace(&item->icon_str, icon); 830 eina_stringshare_replace(&item->icon_str, icon);
831 edje_object_signal_emit(item->base.view, "elm,state,icon,visible", "elm"); 831 edje_object_signal_emit(item->base.view, "elm,state,icon,visible", "elm");
@@ -836,6 +836,12 @@ elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon)
836 _sizing_eval(item->base.widget); 836 _sizing_eval(item->base.widget);
837} 837}
838 838
839EAPI void
840elm_menu_item_icon_set(Elm_Menu_Item *item, const char *icon)
841{
842 elm_menu_item_object_icon_name_set(item, icon);
843}
844
839/** 845/**
840 * Set the disabled state of @p item. 846 * Set the disabled state of @p item.
841 * 847 *
@@ -920,20 +926,56 @@ elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent)
920} 926}
921 927
922/** 928/**
923 * Get the icon object from a menu item 929 * Set the content object of a menu item
930 *
931 * Use this function to change the object swallowed by a menu item,
932 * deleting any previously swallowed object.
933 * @param item The menu item object
934 * @param The content object or NULL
935 * @return EINA_TRUE on success, else EINA_FALSE
936 *
937 * @ingroup Menu
938 */
939EAPI Eina_Bool
940elm_menu_item_object_content_set(Elm_Menu_Item *item, Evas_Object *obj)
941{
942 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
943 if (item->content)
944 {
945 elm_widget_sub_object_del(item->base.widget, item->content);
946 evas_object_del(item->content);
947 }
948
949 item->content = obj;
950
951 elm_widget_sub_object_add(item->base.widget, item->content);
952 edje_object_part_swallow(item->base.view, "elm.swallow.content", item->content);
953 _sizing_eval(item->base.widget);
954 return EINA_TRUE;
955}
956
957/**
958 * Get the content object of a menu item
924 * 959 *
925 * @param item The menu item object 960 * @param item The menu item object
926 * @return The icon object or NULL if there's no icon 961 * @return The content object or NULL
927 * @note If @p item was added with elm_menu_item_add_object, this 962 * @note If @p item was added with elm_menu_item_add_object, this
928 * function will return the object passed. 963 * function will return the object passed, else it will return the
964 * icon object.
929 * 965 *
930 * @ingroup Menu 966 * @ingroup Menu
931 */ 967 */
932EAPI const Evas_Object * 968EAPI Evas_Object *
933elm_menu_item_object_icon_get(const Elm_Menu_Item *item) 969elm_menu_item_object_content_get(const Elm_Menu_Item *item)
934{ 970{
935 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); 971 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
936 return (const Evas_Object *)item->icon; 972 return item->content;
973}
974
975EAPI Evas_Object *
976elm_menu_item_object_icon_get(const Elm_Menu_Item *item)
977{
978 return elm_menu_item_object_content_get(item);
937} 979}
938 980
939/** 981/**
@@ -945,12 +987,18 @@ elm_menu_item_object_icon_get(const Elm_Menu_Item *item)
945 * @ingroup Menu 987 * @ingroup Menu
946 */ 988 */
947EAPI const char * 989EAPI const char *
948elm_menu_item_icon_get(const Elm_Menu_Item *item) 990elm_menu_item_object_icon_name_get(const Elm_Menu_Item *item)
949{ 991{
950 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); 992 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
951 return item->icon_str; 993 return item->icon_str;
952} 994}
953 995
996EAPI const char *
997elm_menu_item_icon_get(const Elm_Menu_Item *item)
998{
999 return elm_menu_item_object_icon_name_get(item);
1000}
1001
954/** 1002/**
955 * Returns whether @p item is a separator. 1003 * Returns whether @p item is a separator.
956 * 1004 *
@@ -983,7 +1031,7 @@ elm_menu_item_del(Elm_Menu_Item *item)
983 1031
984 EINA_LIST_FREE(item->submenu.items, _item) elm_menu_item_del(_item); 1032 EINA_LIST_FREE(item->submenu.items, _item) elm_menu_item_del(_item);
985 if (item->label) eina_stringshare_del(item->label); 1033 if (item->label) eina_stringshare_del(item->label);
986 if (item->icon) evas_object_del(item->icon); 1034 if (item->content) evas_object_del(item->content);
987 if (item->submenu.hv) evas_object_del(item->submenu.hv); 1035 if (item->submenu.hv) evas_object_del(item->submenu.hv);
988 if (item->submenu.location) evas_object_del(item->submenu.location); 1036 if (item->submenu.location) evas_object_del(item->submenu.location);
989 1037
@@ -1179,6 +1227,20 @@ elm_menu_item_next_get(const Elm_Menu_Item *it)
1179} 1227}
1180 1228
1181/** 1229/**
1230 * @brief Return a menu item's owner menu
1231 *
1232 * Use this function to get the menu object owning an item.
1233 * @param item The menu item
1234 * @return The menu object owning @p item, or NULL on failure
1235 */
1236EAPI Evas_Object *
1237elm_menu_item_menu_get(const Elm_Menu_Item *item)
1238{
1239 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1240 return item->base.widget;
1241}
1242
1243/**
1182 * Get the first item in the menu 1244 * Get the first item in the menu
1183 * 1245 *
1184 * @param obj The menu object 1246 * @param obj The menu object