[Elementary] Add menu buttons as submenus in Elm_Toolbar "More" button.
authorLeandro Pereira <leandro@profusion.mobi>
Wed, 20 Oct 2010 21:30:03 +0000 (21:30 +0000)
committerLeandro Pereira <leandro@profusion.mobi>
Wed, 20 Oct 2010 21:30:03 +0000 (21:30 +0000)
Previously, if there were buttons with menus in the toolbar, they would be
added but not its menu items.  Even though this is working fine, this is a
hack, since Elm_Menu should really offer reparenting or something like that
-- and this will destroy and recreate the whole menu structure on every
toolbar resize.

SVN revision: 53695

src/lib/elm_menu.c
src/lib/elm_priv.h
src/lib/elm_toolbar.c

index 6c3c58387cf0ca08d2b314ecd844de3f37675568..a59272e3aa6724de88888c6c8542bb1f9b6c0d7e 100644 (file)
@@ -522,6 +522,36 @@ elm_menu_object_get(const Elm_Menu_Item *it)
    return it->base.view;
 }
 
+static void
+_item_clone(Evas_Object *obj, Elm_Menu_Item *parent, Elm_Menu_Item *item)
+{
+   Elm_Menu_Item *new_item, *subitem;
+   Eina_List *iter;
+
+   if (item->separator)
+      new_item = elm_menu_item_separator_add(obj, parent);
+   else
+      new_item = elm_menu_item_add(obj, parent, item->icon_str, item->label, item->func, item->base.data);
+   elm_menu_item_disabled_set(new_item, item->disabled);
+
+   EINA_LIST_FOREACH(item->submenu.items, iter, subitem)
+      _item_clone(obj, new_item, subitem);
+}
+
+void
+elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Menu_Item *parent)
+{
+   ELM_CHECK_WIDTYPE(from_menu, widtype);
+   ELM_CHECK_WIDTYPE(to_menu, widtype);
+   Widget_Data *from_wd = elm_widget_data_get(from_menu);
+   Eina_List *iter;
+   Elm_Menu_Item *item;
+
+   if (!from_wd) return;
+   EINA_LIST_FOREACH(from_wd->items, iter, item)
+      _item_clone(to_menu, parent, item);
+}
+
 /**
  * Add an item at the end
  *
index 7bf2f3f23077da8442908a11613dc177ab175856..8efb7cfed1d76341300d6aabd9c6e4b5fc66b132 100644 (file)
@@ -146,6 +146,8 @@ void                 elm_object_sub_tooltip_content_cb_set(Evas_Object *eventare
 void                 elm_cursor_theme(Elm_Cursor *cur);
 void                 elm_object_sub_cursor_set(Evas_Object *eventarea, Evas_Object *owner, const char *cursor);
 
+void                 elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Menu_Item *parent);
+
 Eina_Bool           _elm_dangerous_call_check(const char *call);
 
 Evas_Object        *_elm_scroller_edje_object_get(Evas_Object *obj);
index be68445625421d0cd6ca68498d628f52b5ec19ff..22169c7940f6926585bb398cd9d0757cace590e1 100644 (file)
@@ -361,6 +361,7 @@ _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event
                             item = elm_menu_item_add(menu, NULL, it->icon_str, it->label,
                                                      it->func, it->base.data);
                             elm_menu_item_disabled_set(item, it->disabled);
+                            if (it->o_menu) elm_menu_clone(it->o_menu, menu, item);
                          }
                        evas_object_hide(it->base.view);
                     }