diff options
author | German Poo-Caamano <gpoo@gnome.org> | 2008-06-09 21:07:03 +0000 |
---|---|---|
committer | Germán Poó Caamaño <gpoo@src.gnome.org> | 2008-06-09 21:07:03 +0000 |
commit | c81da1a482ed6b9007ad764d1c73822158c58411 (patch) | |
tree | 1258a2fc765d56edd6c880389194e14f06aa0651 /src/nautilus-window-menus.c | |
parent | 5af57e531dd5a035d574cd6b70e423d591aca48b (diff) | |
download | nautilus-c81da1a482ed6b9007ad764d1c73822158c58411.tar.gz |
New function to fill submenus from extensions using
2008-06-08 German Poo-Caamano <gpoo@gnome.org>
* src/nautilus-window-menus.c:
(add_extension_menu_items): New function to fill submenus from
extensions using NautilusMenuProvider::get_background_items.
(nautilus_window_load_extension_menus): Fixed submenu support
for extensions using NautilusMenuProvider::get_background_items.
* src/file-manager/fm-directory-view.c:
(search_in_menu_items): Fix typo. Submenus provided by
extensions were not activated (#508878).
(reset_extension_actions_menu): Code cleanup, using g_list_foreach
instead for.
svn path=/trunk/; revision=14249
Diffstat (limited to 'src/nautilus-window-menus.c')
-rw-r--r-- | src/nautilus-window-menus.c | 100 |
1 files changed, 69 insertions, 31 deletions
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c index 3fa51ab93..6089ff740 100644 --- a/src/nautilus-window-menus.c +++ b/src/nautilus-window-menus.c @@ -767,15 +767,76 @@ get_extension_menus (NautilusWindow *window) return items; } +static void +add_extension_menu_items (NautilusWindow *window, + guint merge_id, + GtkActionGroup *action_group, + GList *menu_items, + const char *subdirectory) +{ + GtkUIManager *ui_manager; + GList *l; + + ui_manager = window->details->ui_manager; + + for (l = menu_items; l; l = l->next) { + NautilusMenuItem *item; + NautilusMenu *menu; + GtkAction *action; + char *path; + + item = NAUTILUS_MENU_ITEM (l->data); + + g_object_get (item, "menu", &menu, NULL); + + action = nautilus_action_from_menu_item (item); + gtk_action_group_add_action (action_group, action); + + path = g_build_path ("/", POPUP_PATH_EXTENSION_ACTIONS, subdirectory, NULL); + gtk_ui_manager_add_ui (ui_manager, + merge_id, + path, + gtk_action_get_name (action), + gtk_action_get_name (action), + (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, + FALSE); + g_free (path); + + path = g_build_path ("/", MENU_PATH_EXTENSION_ACTIONS, subdirectory, NULL); + gtk_ui_manager_add_ui (ui_manager, + merge_id, + path, + gtk_action_get_name (action), + gtk_action_get_name (action), + (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, + FALSE); + g_free (path); + + /* recursively fill the menu */ + if (menu != NULL) { + char *subdir; + GList *children; + + children = nautilus_menu_get_items (menu); + + subdir = g_build_path ("/", subdirectory, "/", gtk_action_get_name (action), NULL); + add_extension_menu_items (window, + merge_id, + action_group, + children, + subdir); + + nautilus_menu_item_list_free (children); + g_free (subdir); + } + } +} + void nautilus_window_load_extension_menus (NautilusWindow *window) { - NautilusMenuItem *item; GtkActionGroup *action_group; - GtkAction *action; GList *items; - GList *l; - int i; guint merge_id; if (window->details->extensions_menu_merge_id != 0) { @@ -800,35 +861,12 @@ nautilus_window_load_extension_menus (NautilusWindow *window) items = get_extension_menus (window); - for (l = items, i = 0; l != NULL; l = l->next, i++) { - item = NAUTILUS_MENU_ITEM (l->data); + if (items != NULL) { + add_extension_menu_items (window, merge_id, action_group, items, ""); - action = nautilus_action_from_menu_item (item); - gtk_action_group_add_action (action_group, - GTK_ACTION (action)); - g_object_unref (action); - - gtk_ui_manager_add_ui (window->details->ui_manager, - merge_id, - MENU_PATH_EXTENSION_ACTIONS, - gtk_action_get_name (action), - gtk_action_get_name (action), - GTK_UI_MANAGER_MENUITEM, - FALSE); - - gtk_ui_manager_add_ui (window->details->ui_manager, - merge_id, - POPUP_PATH_EXTENSION_ACTIONS, - gtk_action_get_name (action), - gtk_action_get_name (action), - GTK_UI_MANAGER_MENUITEM, - FALSE); - - - g_object_unref (item); + g_list_foreach (items, (GFunc) g_object_unref, NULL); + g_list_free (items); } - - g_list_free (items); } |