summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-07-29 14:04:54 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-07-29 14:04:54 +0000
commit1005a075c1e232569b2364a6be8da3a14e5c7323 (patch)
tree293c189a84e7931e7e76c22ce18372ce035f2f9b
parent3beb65b66e034d970b374140ed82c9aeb3718f86 (diff)
helper function for menu item creation to deduplicate code
SVN revision: 61893
-rw-r--r--src/lib/elm_menu.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c
index 6d5380c6d..d7197a79d 100644
--- a/src/lib/elm_menu.c
+++ b/src/lib/elm_menu.c
@@ -643,6 +643,26 @@ elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Menu_Item *pare
643 _item_clone(to_menu, parent, item); 643 _item_clone(to_menu, parent, item);
644} 644}
645 645
646static void
647_elm_menu_item_add_helper(Evas_Object *obj, Elm_Menu_Item *parent, Elm_Menu_Item *subitem, Widget_Data *wd)
648{
649 if (parent)
650 {
651 if (!parent->submenu.bx) _item_submenu_obj_create(parent);
652 elm_box_pack_end(parent->submenu.bx, subitem->base.view);
653 parent->submenu.items = eina_list_append(parent->submenu.items, subitem);
654 subitem->idx = eina_list_count(parent->submenu.items) - 1;
655 }
656 else
657 {
658 elm_box_pack_end(wd->bx, subitem->base.view);
659 wd->items = eina_list_append(wd->items, subitem);
660 subitem->idx = eina_list_count(wd->items) - 1;
661 }
662
663 _sizing_eval(obj);
664}
665
646/** 666/**
647 * Add an item at the end 667 * Add an item at the end
648 * 668 *
@@ -685,21 +705,8 @@ elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, con
685 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subitem->icon); 705 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subitem->icon);
686 if (icon) elm_menu_item_icon_set(subitem, icon); 706 if (icon) elm_menu_item_icon_set(subitem, icon);
687 707
688 if (parent) 708 _elm_menu_item_add_helper(obj, parent, subitem, wd);
689 {
690 if (!parent->submenu.bx) _item_submenu_obj_create(parent);
691 elm_box_pack_end(parent->submenu.bx, subitem->base.view);
692 parent->submenu.items = eina_list_append(parent->submenu.items, subitem);
693 subitem->idx = eina_list_count(parent->submenu.items) - 1;
694 }
695 else
696 {
697 elm_box_pack_end(wd->bx, subitem->base.view);
698 wd->items = eina_list_append(wd->items, subitem);
699 subitem->idx = eina_list_count(wd->items) - 1;
700 }
701 709
702 _sizing_eval(obj);
703 return subitem; 710 return subitem;
704} 711}
705 712
@@ -738,21 +745,8 @@ elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *s
738 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subobj); 745 edje_object_part_swallow(subitem->base.view, "elm.swallow.content", subobj);
739 _sizing_eval(subitem->base.widget); 746 _sizing_eval(subitem->base.widget);
740 747
741 if (parent) 748 _elm_menu_item_add_helper(obj, parent, subitem, wd);
742 {
743 if (!parent->submenu.bx) _item_submenu_obj_create(parent);
744 elm_box_pack_end(parent->submenu.bx, subitem->base.view);
745 parent->submenu.items = eina_list_append(parent->submenu.items, subitem);
746 subitem->idx = eina_list_count(parent->submenu.items) - 1;
747 }
748 else
749 {
750 elm_box_pack_end(wd->bx, subitem->base.view);
751 wd->items = eina_list_append(wd->items, subitem);
752 subitem->idx = eina_list_count(wd->items) - 1;
753 }
754 749
755 _sizing_eval(obj);
756 return subitem; 750 return subitem;
757} 751}
758 752