nautilus r14158 - in branches/multiview: . libnautilus-private src src/file-manager



Author: cneumair
Date: Tue May 13 11:05:17 2008
New Revision: 14158
URL: http://svn.gnome.org/viewvc/nautilus?rev=14158&view=rev

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

	* libnautilus-private/nautilus-icon-container.c (keyboard_space):
	* src/file-manager/fm-icon-view.c
	(icon_container_activate_alternate_callback):
	* src/nautilus-navigation-window-menus.c
	(update_tab_action_sensitivity), (update_tab_menu),
	(nautilus_navigation_window_initialize_tabs_menu),
	(action_tabs_previous_callback), (action_tabs_next_callback),
	(action_tabs_move_left_callback),
	(action_tabs_move_right_callback),
	(nautilus_navigation_window_initialize_menus):
	* src/nautilus-navigation-window-ui.xml:
	* src/nautilus-notebook.c
	(nautilus_notebook_reorder_current_child_relative),
	(nautilus_notebook_set_current_page_relative),
	(nautilus_notebook_is_valid_relative_position),
	(nautilus_notebook_can_reorder_current_child_relative),
	(nautilus_notebook_can_set_current_page_relative):
	* src/nautilus-notebook.h:
	* src/nautilus-window-manage-views.c
	(nautilus_window_slot_open_location_full):
	Add "Tabs" menu, for now it just contains actions for moving/switching
	tabs. Refine view keybindings for opening in new window/tab.


Modified:
   branches/multiview/ChangeLog
   branches/multiview/libnautilus-private/nautilus-icon-container.c
   branches/multiview/src/file-manager/fm-icon-view.c
   branches/multiview/src/nautilus-navigation-window-menus.c
   branches/multiview/src/nautilus-navigation-window-ui.xml
   branches/multiview/src/nautilus-notebook.c
   branches/multiview/src/nautilus-notebook.h
   branches/multiview/src/nautilus-window-manage-views.c

Modified: branches/multiview/libnautilus-private/nautilus-icon-container.c
==============================================================================
--- branches/multiview/libnautilus-private/nautilus-icon-container.c	(original)
+++ branches/multiview/libnautilus-private/nautilus-icon-container.c	Tue May 13 11:05:17 2008
@@ -2973,7 +2973,8 @@
 	NautilusIcon *icon;
 	
 	/* Control-space toggles the selection state of the current icon. */
-	if ((event->state & GDK_CONTROL_MASK) != 0) {
+	if ((event->state & GDK_CONTROL_MASK) != 0 &&
+	    (event->state & GDK_SHIFT_MASK) == 0) {
 		if (container->details->keyboard_focus != NULL) {
 			icon_toggle_selected (container, container->details->keyboard_focus);
 			g_signal_emit (container, signals[SELECTION_CHANGED], 0);

Modified: branches/multiview/src/file-manager/fm-icon-view.c
==============================================================================
--- branches/multiview/src/file-manager/fm-icon-view.c	(original)
+++ branches/multiview/src/file-manager/fm-icon-view.c	Tue May 13 11:05:17 2008
@@ -1722,14 +1722,49 @@
 					    GList *file_list,
 					    FMIconView *icon_view)
 {
+	GdkEvent *event;
+	GdkEventButton *button_event;
+	GdkEventKey *key_event;
+	gboolean open_in_tab;
+	NautilusWindowInfo *window_info;
+	NautilusWindowOpenFlags flags;
+
 	g_assert (FM_IS_ICON_VIEW (icon_view));
 	g_assert (container == get_icon_container (icon_view));
 
+	open_in_tab = FALSE;
+
+	window_info = fm_directory_view_get_nautilus_window (FM_DIRECTORY_VIEW (icon_view));
+
+	if (nautilus_window_info_get_window_type (window_info) == NAUTILUS_WINDOW_NAVIGATION) {
+		event = gtk_get_current_event ();
+		if (event->type == GDK_BUTTON_PRESS ||
+		    event->type == GDK_BUTTON_RELEASE ||
+		    event->type == GDK_2BUTTON_PRESS ||
+		    event->type == GDK_3BUTTON_PRESS) {
+			button_event = (GdkEventButton *) event;
+			open_in_tab = (button_event->state & GDK_SHIFT_MASK) == 0;
+		} else if (event->type == GDK_KEY_PRESS ||
+			   event->type == GDK_KEY_RELEASE) {
+			key_event = (GdkEventKey *) event;
+			open_in_tab = !((key_event->state & GDK_SHIFT_MASK) != 0 &&
+				       (key_event->state & GDK_CONTROL_MASK) != 0);
+		} else {
+			open_in_tab = TRUE;
+		}
+	}
+
+	flags = NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND;
+	if (open_in_tab) {
+		flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
+	} else {
+		flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW;
+	}
+
 	fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view), 
 					  file_list, 
 					  NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
-					  NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND |
-					  NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW);
+					  flags);
 }
 
 static void

Modified: branches/multiview/src/nautilus-navigation-window-menus.c
==============================================================================
--- branches/multiview/src/nautilus-navigation-window-menus.c	(original)
+++ branches/multiview/src/nautilus-navigation-window-menus.c	Tue May 13 11:05:17 2008
@@ -30,6 +30,7 @@
 #include <locale.h> 
 
 #include "nautilus-actions.h"
+#include "nautilus-notebook.h"
 #include "nautilus-navigation-action.h"
 #include "nautilus-application.h"
 #include "nautilus-bookmark-list.h"
@@ -413,6 +414,60 @@
 }
 
 static void
+update_tab_action_sensitivity (NautilusNavigationWindow *window)
+{
+	GtkActionGroup *action_group;
+	GtkAction *action;
+	NautilusNotebook *notebook;
+	gboolean sensitive;
+
+	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+
+	notebook = NAUTILUS_NOTEBOOK (window->notebook);
+	action_group = window->details->navigation_action_group;
+
+	action = gtk_action_group_get_action (action_group, "TabsPrevious");
+	sensitive = nautilus_notebook_can_set_current_page_relative (notebook, -1);
+	g_object_set (action, "sensitive", sensitive, NULL);
+
+	action = gtk_action_group_get_action (action_group, "TabsNext");
+	sensitive = nautilus_notebook_can_set_current_page_relative (notebook, 1);
+	g_object_set (action, "sensitive", sensitive, NULL);
+
+	action = gtk_action_group_get_action (action_group, "TabsMoveLeft");
+	sensitive = nautilus_notebook_can_reorder_current_child_relative (notebook, -1);
+	g_object_set (action, "sensitive", sensitive, NULL);
+
+	action = gtk_action_group_get_action (action_group, "TabsMoveRight");
+	sensitive = nautilus_notebook_can_reorder_current_child_relative (notebook, 1);
+	g_object_set (action, "sensitive", sensitive, NULL);
+}
+
+static void
+update_tab_menu (NautilusNavigationWindow *window)
+{
+	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
+
+	update_tab_action_sensitivity (window);
+}
+
+static void 
+nautilus_navigation_window_initialize_tabs_menu (NautilusNavigationWindow *window)
+{
+	g_signal_connect_object (window->notebook, "page-added",
+				 G_CALLBACK (refresh_tab_actions), window, G_CONNECT_SWAPPED);
+	g_signal_connect_object (window->notebook, "page-removed",
+				 G_CALLBACK (refresh_tab_actions), window, G_CONNECT_SWAPPED);
+	g_signal_connect_object (window->notebook, "page-reordered",
+				 G_CALLBACK (refresh_tab_actions), window, G_CONNECT_SWAPPED);
+	g_signal_connect_object (window->notebook, "switch-page",
+				 G_CALLBACK (refresh_tab_action_sensitivity), window,
+				 G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+
+	refresh_tab_actions (window);
+}
+
+static void
 action_new_window_callback (GtkAction *action,
 			    gpointer user_data)
 {
@@ -494,9 +549,50 @@
 	nautilus_navigation_window_show_search (window);
 }
 
+static void
+action_tabs_previous_callback (GtkAction *action,
+			       gpointer user_data)
+{
+	NautilusNavigationWindow *window;
+
+	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
+	nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (window->notebook), -1);
+}
+
+static void
+action_tabs_next_callback (GtkAction *action,
+			   gpointer user_data)
+{
+	NautilusNavigationWindow *window;
+
+	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
+	nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (window->notebook), 1);
+}
+
+static void
+action_tabs_move_left_callback (GtkAction *action,
+				gpointer user_data)
+{
+	NautilusNavigationWindow *window;
+
+	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
+	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), -1);
+}
+
+static void
+action_tabs_move_right_callback (GtkAction *action,
+				 gpointer user_data)
+{
+	NautilusNavigationWindow *window;
+
+	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
+	nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), 1);
+}
+
 static const GtkActionEntry navigation_entries[] = {
   /* name, stock id, label */  { "Go", NULL, N_("_Go") },
   /* name, stock id, label */  { "Bookmarks", NULL, N_("_Bookmarks") },
+  /* name, stock id, label */  { "Tabs", NULL, N_("_Tabs") },
   /* name, stock id, label */  { "New Window", "window-new", N_("New _Window"),
                                  "<control>N", N_("Open another Nautilus window for the displayed location"),
                                  G_CALLBACK (action_new_window_callback) },
@@ -524,7 +620,20 @@
   /* name, stock id, label */  { "Search", "gtk-find", N_("_Search for Files..."),
                                  "<control>F", N_("Locate documents and folders on this computer by name or content"),
                                  G_CALLBACK (action_search_callback) },
-		     
+
+	{ "TabsPrevious", NULL, N_("_Previous Tab"), "<control>Page_Up",
+	  N_("Activate previous tab"),
+	  G_CALLBACK (action_tabs_previous_callback) },
+	{ "TabsNext", NULL, N_("_Next Tab"), "<control>Page_Down",
+	  N_("Activate next tab"),
+	  G_CALLBACK (action_tabs_next_callback) },
+	{ "TabsMoveLeft", NULL, N_("Move Tab _Left"), "<shift><control>Page_Up",
+	  N_("Move current tab to left"),
+	  G_CALLBACK (action_tabs_move_left_callback) },
+	{ "TabsMoveRight", NULL, N_("Move Tab _Right"), "<shift><control>Page_Down",
+	  N_("Move current tab to right"),
+	  G_CALLBACK (action_tabs_move_right_callback) },
+
 };
 
 static const GtkToggleActionEntry navigation_toggle_entries[] = {
@@ -633,5 +742,6 @@
 	nautilus_navigation_window_update_spatial_menu_item (window);
 
         nautilus_navigation_window_initialize_go_menu (window);
+        nautilus_navigation_window_initialize_tabs_menu (window);
 }
 

Modified: branches/multiview/src/nautilus-navigation-window-ui.xml
==============================================================================
--- branches/multiview/src/nautilus-navigation-window-ui.xml	(original)
+++ branches/multiview/src/nautilus-navigation-window-ui.xml	Tue May 13 11:05:17 2008
@@ -47,6 +47,18 @@
 			<separator/>
 			<placeholder name="Bookmarks Placeholder"/>
 		</menu>
+		<menu action="Tabs">
+			<menuitem name="TabsPreviousMenu" action="TabsPrevious"/>
+			<menuitem name="TabsNextMenu" action="TabsNext"/>
+			<separator name="TabsSep1"/>
+			<placeholder name="TabsMoveGroup">
+				<menuitem name="TabsMoveLeftMenu" action="TabsMoveLeft"/>
+				<menuitem name="TabsMoveRightMenu" action="TabsMoveRight"/>
+			</placeholder>
+			<placeholder name="TabsOpen">
+				<separator name="TabsSep2"/>
+			</placeholder>
+		</menu>
         </placeholder>
 </menubar>
 <toolbar name="Toolbar">

Modified: branches/multiview/src/nautilus-notebook.c
==============================================================================
--- branches/multiview/src/nautilus-notebook.c	(original)
+++ branches/multiview/src/nautilus-notebook.c	Tue May 13 11:05:17 2008
@@ -650,3 +650,84 @@
 				    gtk_notebook_get_n_pages (gnotebook) > 1);
 
 }
+
+void
+nautilus_notebook_reorder_current_child_relative (NautilusNotebook *notebook,
+						  int offset)
+{
+	GtkNotebook *gnotebook;
+	GtkWidget *child;
+	int page;
+
+	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
+
+	if (!nautilus_notebook_can_reorder_current_child_relative (notebook, offset)) {
+		return;
+	}
+
+	gnotebook = GTK_NOTEBOOK (notebook);
+
+	page = gtk_notebook_get_current_page (gnotebook);
+	child = gtk_notebook_get_nth_page (gnotebook, page);
+	gtk_notebook_reorder_child (gnotebook, child, page + offset);
+}
+
+void
+nautilus_notebook_set_current_page_relative (NautilusNotebook *notebook,
+					     int offset)
+{
+	GtkNotebook *gnotebook;
+	int page;
+
+	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
+
+	if (!nautilus_notebook_can_set_current_page_relative (notebook, offset)) {
+		return;
+	}
+
+	gnotebook = GTK_NOTEBOOK (notebook);
+
+	page = gtk_notebook_get_current_page (gnotebook);
+	gtk_notebook_set_current_page (gnotebook, page + offset);
+
+}
+
+static gboolean
+nautilus_notebook_is_valid_relative_position (NautilusNotebook *notebook,
+					      int offset)
+{
+	GtkNotebook *gnotebook;
+	int page;
+	int n_pages;
+
+	gnotebook = GTK_NOTEBOOK (notebook);
+
+	page = gtk_notebook_get_current_page (gnotebook);
+	n_pages = gtk_notebook_get_n_pages (gnotebook) - 1;
+	if (page < 0 ||
+	    (offset < 0 && page < -offset) ||
+	    (offset > 0 && page > n_pages - offset)) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+gboolean
+nautilus_notebook_can_reorder_current_child_relative (NautilusNotebook *notebook,
+						      int offset)
+{
+	g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), FALSE);
+
+	return nautilus_notebook_is_valid_relative_position (notebook, offset);
+}
+
+gboolean
+nautilus_notebook_can_set_current_page_relative (NautilusNotebook *notebook,
+						 int offset)
+{
+	g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), FALSE);
+
+	return nautilus_notebook_is_valid_relative_position (notebook, offset);
+}
+

Modified: branches/multiview/src/nautilus-notebook.h
==============================================================================
--- branches/multiview/src/nautilus-notebook.h	(original)
+++ branches/multiview/src/nautilus-notebook.h	Tue May 13 11:05:17 2008
@@ -78,6 +78,16 @@
 void		nautilus_notebook_sync_loading   (NautilusNotebook *nb,
 						  NautilusWindowSlot *slot);
 
+void		nautilus_notebook_reorder_current_child_relative (NautilusNotebook *notebook,
+								  int offset);
+void		nautilus_notebook_set_current_page_relative (NautilusNotebook *notebook,
+							     int offset);
+
+gboolean        nautilus_notebook_can_reorder_current_child_relative (NautilusNotebook *notebook,
+								      int offset);
+gboolean        nautilus_notebook_can_set_current_page_relative (NautilusNotebook *notebook,
+								 int offset);
+
 G_END_DECLS
 
 #endif /* NAUTILUS_NOTEBOOK_H */

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	Tue May 13 11:05:17 2008
@@ -497,7 +497,7 @@
 	char *old_uri, *new_uri;
 
 	window = slot->window;
-        
+
         target_window = NULL;
 	target_slot = NULL;
 
@@ -514,6 +514,9 @@
 	g_free (old_uri);
 	g_free (new_uri);
 
+	g_assert (!((flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0 &&
+		    (flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0));
+
 
 	old_location = nautilus_window_slot_get_location (slot);
 	switch (mode) {



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