Commit c81da1a4 authored by Germán Poo-Caamaño's avatar Germán Poo-Caamaño Committed by Germán Poó Caamaño

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
parent 5af57e53
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.
2008-06-05 Cosimo Cecchi <cosimoc@gnome.org>
* src/file-manager/fm-icon-view.c:
......
......@@ -4471,7 +4471,7 @@ search_in_menu_items (GList* items, const char *item_name)
GList* submenus;
submenus = nautilus_menu_get_items (menu);
ret = search_in_menu_items (submenus, name);
ret = search_in_menu_items (submenus, item_name);
nautilus_menu_item_list_free (submenus);
g_object_unref (menu);
if (ret) {
......@@ -4672,7 +4672,6 @@ static void
reset_extension_actions_menu (FMDirectoryView *view, GList *selection)
{
GList *items;
GList *l;
GtkUIManager *ui_manager;
/* Clear any previous inserted items in the extension actions placeholder */
......@@ -4692,10 +4691,7 @@ reset_extension_actions_menu (FMDirectoryView *view, GList *selection)
if (items != NULL) {
add_extension_menu_items (view, selection, items, "");
for (l = items; l != NULL; l = l->next) {
g_object_unref (l->data);
}
g_list_foreach (items, (GFunc) g_object_unref, NULL);
g_list_free (items);
}
}
......
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment