nautilus r14122 - in branches/multiview: . src src/file-manager



Author: cneumair
Date: Thu May  1 16:33:58 2008
New Revision: 14122
URL: http://svn.gnome.org/viewvc/nautilus?rev=14122&view=rev

Log:
2008-05-01  Christian Neumair  <cneumair gnome org>

	* src/file-manager/fm-actions.h:
	* src/file-manager/fm-directory-view.c
	(action_open_new_tab_callback), (open_one_in_new_tab),
	(real_update_menus):
	* src/file-manager/nautilus-directory-view-ui.xml:
	* src/nautilus-desktop-window.c
	(nautilus_desktop_window_class_init):
	* src/nautilus-navigation-window.c (real_open_slot):
	* src/nautilus-window-manage-views.c (handle_go_back),
	(handle_go_forward), (handle_go_elsewhere), (update_history),
	(update_for_new_location):
	* src/nautilus-window-private.h:
	* src/nautilus-window-slot.c
	(nautilus_window_slot_add_current_location_to_history_list):
	* src/nautilus-window-slot.h:
	* src/nautilus-window.c (nautilus_add_bookmark_to_history_list),
	(nautilus_add_to_history_list_no_notify),
	(nautilus_forget_history), (nautilus_window_class_init):
	* src/nautilus-window.h:
	Add "Open in New Tab" item. Move bookmark history handling code from
	windows to slots.


Modified:
   branches/multiview/ChangeLog
   branches/multiview/src/file-manager/fm-actions.h
   branches/multiview/src/file-manager/fm-directory-view.c
   branches/multiview/src/file-manager/nautilus-directory-view-ui.xml
   branches/multiview/src/nautilus-desktop-window.c
   branches/multiview/src/nautilus-navigation-window.c
   branches/multiview/src/nautilus-window-manage-views.c
   branches/multiview/src/nautilus-window-private.h
   branches/multiview/src/nautilus-window-slot.c
   branches/multiview/src/nautilus-window-slot.h
   branches/multiview/src/nautilus-window.c
   branches/multiview/src/nautilus-window.h

Modified: branches/multiview/src/file-manager/fm-actions.h
==============================================================================
--- branches/multiview/src/file-manager/fm-actions.h	(original)
+++ branches/multiview/src/file-manager/fm-actions.h	Thu May  1 16:33:58 2008
@@ -27,6 +27,7 @@
 
 #define FM_ACTION_OPEN "Open"
 #define FM_ACTION_OPEN_ALTERNATE "OpenAlternate"
+#define FM_ACTION_OPEN_IN_NEW_TAB "OpenInNewTab"
 #define FM_ACTION_OPEN_FOLDER_WINDOW "OpenFolderWindow"
 #define FM_ACTION_LOCATION_OPEN_ALTERNATE "LocationOpenAlternate"
 #define FM_ACTION_LOCATION_OPEN_FOLDER_WINDOW "LocationOpenFolderWindow"

Modified: branches/multiview/src/file-manager/fm-directory-view.c
==============================================================================
--- branches/multiview/src/file-manager/fm-directory-view.c	(original)
+++ branches/multiview/src/file-manager/fm-directory-view.c	Thu May  1 16:33:58 2008
@@ -315,6 +315,8 @@
 								FMDirectoryView      *view);
 static void     open_one_in_new_window                         (gpointer              data,
 								gpointer              callback_data);
+static void     open_one_in_new_tab                            (gpointer              data,
+								gpointer              callback_data);
 static void     open_one_in_folder_window                      (gpointer              data,
 								gpointer              callback_data);
 static void     schedule_update_menus                          (FMDirectoryView      *view);
@@ -783,6 +785,26 @@
 }
 
 static void
+action_open_new_tab_callback (GtkAction *action,
+			      gpointer callback_data)
+{
+	FMDirectoryView *view;
+	GList *selection;
+	GtkWindow *window;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+	selection = fm_directory_view_get_selection (view);
+
+	window = fm_directory_view_get_containing_window (view);
+
+	if (fm_directory_view_confirm_multiple_windows (window, g_list_length (selection))) {
+		g_list_foreach (selection, open_one_in_new_tab, view);
+	}
+
+	nautilus_file_list_free (selection);
+}
+
+static void
 action_open_folder_window_callback (GtkAction *action,
 				gpointer callback_data)
 {
@@ -3962,6 +3984,18 @@
 }
 
 static void
+open_one_in_new_tab (gpointer data, gpointer callback_data)
+{
+	g_assert (NAUTILUS_IS_FILE (data));
+	g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
+
+	fm_directory_view_activate_file (FM_DIRECTORY_VIEW (callback_data),
+					 NAUTILUS_FILE (data),
+					 NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+					 NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB);
+}
+
+static void
 open_one_in_folder_window (gpointer data, gpointer callback_data)
 {
 	g_assert (NAUTILUS_IS_FILE (data));
@@ -6270,6 +6304,10 @@
   /* label, accelerator */       N_("Open in Navigation Window"), "<control><shift>o",
   /* tooltip */                  N_("Open each selected item in a navigation window"),
                                  G_CALLBACK (action_open_alternate_callback) },
+  /* name, stock id */         { "OpenInNewTab", NULL,
+  /* label, accelerator */       N_("Open in New Tab"), "<control><shift>o",
+  /* tooltip */                  N_("Open each selected item in a new tab"),
+                                 G_CALLBACK (action_open_new_tab_callback) },
   /* name, stock id */         { "OpenFolderWindow", NULL,
   /* label, accelerator */       N_("Open in Folder Window"), NULL,
   /* tooltip */                  N_("Open each selected item in a folder window"),
@@ -7158,6 +7196,30 @@
 
 	gtk_action_set_sensitive (action,  selection_count != 0);
 	gtk_action_set_visible (action, show_open_alternate);
+
+	/* Open in New Tab action */
+	if (nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
+		if (selection_count == 0 || selection_count == 1) {
+			label_with_underscore = g_strdup (_("Open in New Tab"));
+		} else {
+			label_with_underscore = g_strdup_printf (ngettext("Open in %'d New Tab",
+									  "Open in %'d New Tabs",
+									  selection_count), 
+								 selection_count);
+		}
+		action = gtk_action_group_get_action (view->details->dir_action_group,
+						      FM_ACTION_OPEN_IN_NEW_TAB);
+		gtk_action_set_visible (action, show_open_alternate);
+		g_object_set (action, "label", 
+			      label_with_underscore,
+			      NULL);
+		g_free (label_with_underscore);
+	} else {
+		action = gtk_action_group_get_action (view->details->dir_action_group,
+						      FM_ACTION_OPEN_IN_NEW_TAB);
+		gtk_action_set_visible (action, FALSE);
+	}
+
 	
 	action = gtk_action_group_get_action (view->details->dir_action_group,
 					      FM_ACTION_OPEN_FOLDER_WINDOW);

Modified: branches/multiview/src/file-manager/nautilus-directory-view-ui.xml
==============================================================================
--- branches/multiview/src/file-manager/nautilus-directory-view-ui.xml	(original)
+++ branches/multiview/src/file-manager/nautilus-directory-view-ui.xml	Thu May  1 16:33:58 2008
@@ -18,6 +18,7 @@
 		<placeholder name="Open Placeholder">
 			<menuitem name="Open" action="Open"/>
 			<menuitem name="OpenAlternate" action="OpenAlternate"/>
+			<menuitem name="OpenInNewTab" action="OpenInNewTab"/>
 			<placeholder name="Applications Placeholder">
                         </placeholder>
 			<menu action="Open With">
@@ -116,6 +117,7 @@
 	<placeholder name="Open Placeholder">
 		<menuitem name="Open" action="Open"/>
 		<menuitem name="OpenAlternate" action="OpenAlternate"/>
+		<menuitem name="OpenInNewTab" action="OpenInNewTab"/>
 		<menuitem name="OpenFolderWindow" action="OpenFolderWindow"/>
 		<separator name="applications separator"/>
 		<placeholder name="Applications Placeholder"/>

Modified: branches/multiview/src/nautilus-desktop-window.c
==============================================================================
--- branches/multiview/src/nautilus-desktop-window.c	(original)
+++ branches/multiview/src/nautilus-desktop-window.c	Thu May  1 16:33:58 2008
@@ -237,14 +237,6 @@
 			  G_CALLBACK (nautilus_desktop_window_screen_size_changed), window);
 }
 
-static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
-	/* Do nothing. The desktop window's location should not
-	 * show up in the history list.
-	 */
-}
-
 static char *
 real_get_title (NautilusWindow *window)
 {
@@ -270,8 +262,6 @@
 
 	NAUTILUS_WINDOW_CLASS (class)->window_type = NAUTILUS_WINDOW_DESKTOP;
 
-	NAUTILUS_WINDOW_CLASS (class)->add_current_location_to_history_list 
-		= real_add_current_location_to_history_list;
 	NAUTILUS_WINDOW_CLASS (class)->get_title 
 		= real_get_title;
 	NAUTILUS_WINDOW_CLASS (class)->get_icon

Modified: branches/multiview/src/nautilus-navigation-window.c
==============================================================================
--- branches/multiview/src/nautilus-navigation-window.c	(original)
+++ branches/multiview/src/nautilus-navigation-window.c	Thu May  1 16:33:58 2008
@@ -1654,7 +1654,7 @@
 				   (flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0 ?
 				   -1 :
 				   gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) + 1,
-				   TRUE); // FIXME jump_to
+				   FALSE);
 	g_signal_handlers_unblock_by_func (notebook,
 					   G_CALLBACK (notebook_switch_page_cb),
 					   window);

Modified: branches/multiview/src/nautilus-window-manage-views.c
==============================================================================
--- branches/multiview/src/nautilus-window-manage-views.c	(original)
+++ branches/multiview/src/nautilus-window-manage-views.c	Thu May  1 16:33:58 2008
@@ -184,18 +184,15 @@
 }
 
 static void
-handle_go_back (NautilusNavigationWindow *window, GFile *location)
+handle_go_back (NautilusNavigationWindowSlot *navigation_slot,
+		GFile *location)
 {
 	NautilusWindowSlot *slot;
-	NautilusNavigationWindowSlot *navigation_slot;
         guint i;
         GList *link;
         NautilusBookmark *bookmark;
 
-        g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
-
-	slot = NAUTILUS_WINDOW (window)->details->active_slot;
-	navigation_slot = (NautilusNavigationWindowSlot *) slot;
+	slot = NAUTILUS_WINDOW_SLOT (navigation_slot);
 
         /* Going back. Move items from the back list to the forward list. */
 	g_assert (g_list_length (navigation_slot->back_list) > slot->location_change_distance);
@@ -230,18 +227,15 @@
 }
 
 static void
-handle_go_forward (NautilusNavigationWindow *window, GFile *location)
+handle_go_forward (NautilusNavigationWindowSlot *navigation_slot,
+		   GFile *location)
 {
 	NautilusWindowSlot *slot;
-	NautilusNavigationWindowSlot *navigation_slot;
         guint i;
         GList *link;
         NautilusBookmark *bookmark;
 
-	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
-
-	slot = NAUTILUS_WINDOW (window)->details->active_slot;
-	navigation_slot = (NautilusNavigationWindowSlot *) slot;
+	slot = NAUTILUS_WINDOW_SLOT (navigation_slot);
 
         /* Going forward. Move items from the forward list to the back list. */
 	g_assert (g_list_length (navigation_slot->forward_list) > slot->location_change_distance);
@@ -278,15 +272,13 @@
  * multiview-TODO: handle this on a per-slot basis
  */
 static void
-handle_go_elsewhere (NautilusWindow *window, GFile *location)
+handle_go_elsewhere (NautilusWindowSlot *slot, GFile *location)
 {
 #if !NEW_UI_COMPLETE
-	NautilusWindowSlot *slot;
 	NautilusNavigationWindowSlot *navigation_slot;
 
-        if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
-		slot = window->details->active_slot;
-		navigation_slot = (NautilusNavigationWindowSlot *) slot;
+        if (NAUTILUS_IS_NAVIGATION_WINDOW_SLOT (slot)) {
+		navigation_slot = NAUTILUS_NAVIGATION_WINDOW_SLOT (slot);
 
                 /* Clobber the entire forward list, and move displayed location to back list */
                 nautilus_navigation_window_slot_clear_forward_list (navigation_slot);
@@ -432,28 +424,26 @@
 }
 
 static void
-update_history (NautilusWindow *window,
+update_history (NautilusWindowSlot *slot,
                 NautilusLocationChangeType type,
                 GFile *new_location)
 {
         switch (type) {
         case NAUTILUS_LOCATION_CHANGE_STANDARD:
         case NAUTILUS_LOCATION_CHANGE_FALLBACK:
-                nautilus_window_add_current_location_to_history_list (window);
-                handle_go_elsewhere (window, new_location);
+                nautilus_window_slot_add_current_location_to_history_list (slot);
+                handle_go_elsewhere (slot, new_location);
                 return;
         case NAUTILUS_LOCATION_CHANGE_RELOAD:
                 /* for reload there is no work to do */
                 return;
         case NAUTILUS_LOCATION_CHANGE_BACK:
-                nautilus_window_add_current_location_to_history_list (window);
-                handle_go_back (NAUTILUS_NAVIGATION_WINDOW (window), 
-                                new_location);
+                nautilus_window_slot_add_current_location_to_history_list (slot);
+                handle_go_back (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), new_location);
                 return;
         case NAUTILUS_LOCATION_CHANGE_FORWARD:
-                nautilus_window_add_current_location_to_history_list (window);
-                handle_go_forward (NAUTILUS_NAVIGATION_WINDOW (window), 
-                                   new_location);
+                nautilus_window_slot_add_current_location_to_history_list (slot);
+                handle_go_forward (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), new_location);
                 return;
         case NAUTILUS_LOCATION_CHANGE_REDIRECT:
                 /* for the redirect case, the caller can do the updating */
@@ -1594,7 +1584,7 @@
 
 	set_displayed_location (slot, new_location);
 
-	update_history (window, slot->location_change_type, new_location);
+	update_history (slot, slot->location_change_type, new_location);
 
 	location_really_changed =
 		slot->location == NULL ||

Modified: branches/multiview/src/nautilus-window-private.h
==============================================================================
--- branches/multiview/src/nautilus-window-private.h	(original)
+++ branches/multiview/src/nautilus-window-private.h	Thu May  1 16:33:58 2008
@@ -191,8 +191,8 @@
 									  NautilusWindowSlot *slot);
 
 void               nautilus_send_history_list_changed                    (void);
-void               nautilus_window_add_current_location_to_history_list  (NautilusWindow    *window);
 void               nautilus_remove_from_history_list_no_notify           (GFile             *location);
+gboolean           nautilus_add_bookmark_to_history_list                 (NautilusBookmark  *bookmark);
 gboolean           nautilus_add_to_history_list_no_notify                (GFile             *location,
 									  const char        *name,
 									  gboolean           has_custom_name,

Modified: branches/multiview/src/nautilus-window-slot.c
==============================================================================
--- branches/multiview/src/nautilus-window-slot.c	(original)
+++ branches/multiview/src/nautilus-window-slot.c	Thu May  1 16:33:58 2008
@@ -24,6 +24,7 @@
 #include "nautilus-window-slot.h"
 #include "nautilus-navigation-window-slot.h"
 
+#include "nautilus-desktop-window.h"
 #include "nautilus-window-private.h"
 #include "nautilus-window-manage-views.h"
 #include <libnautilus-private/nautilus-file.h>
@@ -329,6 +330,16 @@
 	gtk_widget_show (slot->extra_location_widgets);
 }
 
+void
+nautilus_window_slot_add_current_location_to_history_list (NautilusWindowSlot *slot)
+{
+
+	if ((slot->window == NULL || !NAUTILUS_IS_DESKTOP_WINDOW (slot->window)) &&
+	    nautilus_add_bookmark_to_history_list (slot->current_location_bookmark)) {
+		nautilus_send_history_list_changed ();
+	}
+}
+
 static void
 nautilus_window_slot_dispose (GObject *object)
 {

Modified: branches/multiview/src/nautilus-window-slot.h
==============================================================================
--- branches/multiview/src/nautilus-window-slot.h	(original)
+++ branches/multiview/src/nautilus-window-slot.h	Thu May  1 16:33:58 2008
@@ -140,4 +140,6 @@
 							    GtkWidget       *widget);
 void    nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *slot);
 
+void    nautilus_window_slot_add_current_location_to_history_list (NautilusWindowSlot *slot);
+
 #endif /* NAUTILUS_WINDOW_SLOT_H */

Modified: branches/multiview/src/nautilus-window.c
==============================================================================
--- branches/multiview/src/nautilus-window.c	(original)
+++ branches/multiview/src/nautilus-window.c	Thu May  1 16:33:58 2008
@@ -1538,8 +1538,8 @@
 	}
 }
 
-static gboolean
-add_to_history_list (NautilusBookmark *bookmark)
+gboolean
+nautilus_add_bookmark_to_history_list (NautilusBookmark *bookmark)
 {
 	/* Note that the history is shared amongst all windows so
 	 * this is not a NautilusNavigationWindow function. Perhaps it belongs
@@ -1601,35 +1601,12 @@
 	gboolean ret;
 
 	bookmark = nautilus_bookmark_new_with_icon (location, name, has_custom_name, icon);
-	ret = add_to_history_list (bookmark);
+	ret = nautilus_add_bookmark_to_history_list (bookmark);
 	g_object_unref (bookmark);
 
 	return ret;
 }
 
-static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
-	NautilusWindowSlot *slot;
-
-        g_assert (NAUTILUS_IS_WINDOW (window));
-
-	slot = window->details->active_slot;
-                
-	if (add_to_history_list (slot->current_location_bookmark)) {
-		nautilus_send_history_list_changed ();
-	}
-}
-
-#if 0
-static void
-real_add_slot (NautilusWindow *window,
-	       NautilusWindowSlot *slot)
-{
-	window->details->slots = 
-}
-#endif
-
 NautilusWindowSlot *
 nautilus_window_get_slot_for_view (NautilusWindow *window,
 				   NautilusView *view)
@@ -1667,15 +1644,6 @@
 }
 
 void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
-{
-	g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
-	EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
-                         add_current_location_to_history_list, (window));
-}
-
-void
 nautilus_forget_history (void) 
 {
 	NautilusWindowSlot *slot;
@@ -1724,9 +1692,14 @@
 	     window_node != NULL;
 	     window_node = window_node->next) {
 		NautilusWindow *window;
-		
+		NautilusWindowSlot *slot;
+		GList *l;
+
 		window = NAUTILUS_WINDOW (window_node->data);
-		nautilus_window_add_current_location_to_history_list (NAUTILUS_WINDOW (window));
+		for (l = window->details->slots; l != NULL; l = l->next) {
+			slot = NAUTILUS_WINDOW_SLOT (l->data);
+			nautilus_window_slot_add_current_location_to_history_list (slot);
+		}
 	}
 }
 
@@ -1856,7 +1829,6 @@
 	GTK_WIDGET_CLASS (class)->size_request = nautilus_window_size_request;
 	GTK_WIDGET_CLASS (class)->realize = nautilus_window_realize;
 	GTK_WIDGET_CLASS (class)->key_press_event = nautilus_window_key_press_event;
-	class->add_current_location_to_history_list = real_add_current_location_to_history_list;
 	class->get_title = real_get_title;
 	class->sync_title = real_sync_title;
 	class->connect_content_view = real_connect_content_view;

Modified: branches/multiview/src/nautilus-window.h
==============================================================================
--- branches/multiview/src/nautilus-window.h	(original)
+++ branches/multiview/src/nautilus-window.h	Thu May  1 16:33:58 2008
@@ -69,13 +69,6 @@
 
 	/* Function pointers for overriding, without corresponding signals */
 
-	/* add_current_location_to_history_list is a function pointer that
-	 * subclasses may override if they wish to add something other than
-	 * NautilusWindow's idea of the "current location" to the history
-	 * list, or nothing at all.
-	 */
-        void   (* add_current_location_to_history_list) (NautilusWindow *window);
-
         char * (* get_title) (NautilusWindow *window);
         void   (* sync_title) (NautilusWindow *window,
 			       NautilusWindowSlot *slot);



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