nautilus r14249 - in trunk: . src src/file-manager



Author: gpoo
Date: Mon Jun  9 21:07:03 2008
New Revision: 14249
URL: http://svn.gnome.org/viewvc/nautilus?rev=14249&view=rev

Log:
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.



Modified:
   trunk/ChangeLog
   trunk/src/file-manager/fm-directory-view.c
   trunk/src/nautilus-window-menus.c

Modified: trunk/src/file-manager/fm-directory-view.c
==============================================================================
--- trunk/src/file-manager/fm-directory-view.c	(original)
+++ trunk/src/file-manager/fm-directory-view.c	Mon Jun  9 21:07:03 2008
@@ -4471,7 +4471,7 @@
 			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 @@
 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 @@
 	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);
 	}
 }

Modified: trunk/src/nautilus-window-menus.c
==============================================================================
--- trunk/src/nautilus-window-menus.c	(original)
+++ trunk/src/nautilus-window-menus.c	Mon Jun  9 21:07:03 2008
@@ -767,15 +767,76 @@
 	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 @@
 
 	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);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]