[nautilus/gnome-3-6] slot: use the default mount location when switching to a mount root



commit 414208dfc4b6f736ca7fd54e1df5c72cf4c1cc37
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Oct 26 17:01:40 2012 -0400

    slot: use the default mount location when switching to a mount root
    
    Add a new flag to signal that we really want the default mount location
    to be loaded if possible. This way we can still get to the mount root
    e.g. by going up or typing it directly in the location bar, but the
    default location between sidebar mounts and using Connect to Server will
    be the same.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=522917

 src/nautilus-application.c         |   13 +++++------
 src/nautilus-window-manage-views.c |   42 ++++++++++++++++++++++++++++++++---
 src/nautilus-window-slot.h         |    1 +
 src/nautilus-window.h              |    4 ++-
 4 files changed, 48 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 4ae2264..2309a86 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -706,10 +706,10 @@ action_new_window (GSimpleAction *action,
 
 static gboolean
 go_to_server_cb (NautilusWindow *window,
+		 GFile          *location,
 		 GError         *error,
 		 gpointer        user_data)
 {
-	GFile *location = user_data;
 	gboolean retval;
 
 	if (error == NULL) {
@@ -761,8 +761,6 @@ go_to_server_cb (NautilusWindow *window,
 		retval = FALSE;
 	}
 
-	g_object_unref (location);
-
 	return retval;
 }
 
@@ -773,13 +771,14 @@ on_connect_server_response (GtkDialog      *dialog,
 {
 	if (response == GTK_RESPONSE_OK) {
 		GFile *location;
+		NautilusWindow *window = NAUTILUS_WINDOW (get_focus_window (application));
 
 		location = nautilus_connect_server_dialog_get_location (NAUTILUS_CONNECT_SERVER_DIALOG (dialog));
 		if (location != NULL) {
-			nautilus_window_go_to_full (NAUTILUS_WINDOW (get_focus_window (application)),
-						    location,
-						    go_to_server_cb,
-						    location);
+			nautilus_window_slot_open_location_full (nautilus_window_get_active_slot (window),
+								 location,
+								 NAUTILUS_WINDOW_OPEN_FLAG_USE_DEFAULT_LOCATION,
+								 NULL, go_to_server_cb, application);
 		}
 	}
 
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 475ee96..80d3677 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -530,12 +530,13 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
 	    !is_desktop) {
 
 		if (callback != NULL) {
-			callback (window, NULL, user_data);
+			callback (window, location, NULL, user_data);
 		}
 
 		goto done;
         }
 
+	slot->pending_use_default_location = ((flags & NAUTILUS_WINDOW_OPEN_FLAG_USE_DEFAULT_LOCATION) != 0);
         begin_location_change (target_slot, location, old_location, new_selection,
 			       NAUTILUS_LOCATION_CHANGE_STANDARD, 0, NULL, callback, user_data);
 
@@ -571,6 +572,7 @@ report_callback (NautilusWindowSlot *slot,
 	if (slot->open_callback != NULL) {
 		gboolean res;
 		res = slot->open_callback (nautilus_window_slot_get_window (slot),
+					   slot->pending_location,
 					   error, slot->open_callback_user_data);
 		slot->open_callback = NULL;
 		slot->open_callback_user_data = NULL;
@@ -758,7 +760,8 @@ mount_not_mounted_callback (GObject *source_object,
 	} else {
 		nautilus_file_invalidate_all_attributes (slot->determine_view_file);
 		nautilus_file_call_when_ready (slot->determine_view_file,
-					       NAUTILUS_FILE_ATTRIBUTE_INFO,
+					       NAUTILUS_FILE_ATTRIBUTE_INFO |
+					       NAUTILUS_FILE_ATTRIBUTE_MOUNT,
 					       got_file_info_for_view_selection_callback,
 					       slot);
 	}
@@ -776,10 +779,11 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
 	NautilusWindow *window;
 	NautilusWindowSlot *slot;
 	NautilusFile *viewed_file, *parent_file;
-	GFile *location;
+	GFile *location, *default_location;
 	GMountOperation *mount_op;
 	MountNotMountedData *data;
 	GtkApplication *app;
+	GMount *mount;
 
 	slot = callback_data;
 	window = nautilus_window_slot_get_window (slot);
@@ -814,6 +818,35 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
 		goto done;
 	}
 
+	mount = NULL;
+	default_location = NULL;
+
+	if (slot->pending_use_default_location) {
+		mount = nautilus_file_get_mount (file);
+		slot->pending_use_default_location = FALSE;
+	}
+
+	if (mount != NULL) {
+		default_location = g_mount_get_default_location (mount);
+		g_object_unref (mount);
+	}
+
+	if (default_location != NULL &&
+	    !g_file_equal (slot->pending_location, default_location)) {
+		g_clear_object (&slot->pending_location);
+		slot->pending_location = default_location;
+		slot->determine_view_file = nautilus_file_get (default_location);
+
+		nautilus_file_invalidate_all_attributes (slot->determine_view_file);
+		nautilus_file_call_when_ready (slot->determine_view_file,
+					       NAUTILUS_FILE_ATTRIBUTE_INFO |
+					       NAUTILUS_FILE_ATTRIBUTE_MOUNT,
+					       got_file_info_for_view_selection_callback,
+					       slot);
+
+		goto done;
+	}
+
 	parent_file = nautilus_file_get_parent (file);
 	if ((parent_file != NULL) &&
 	    nautilus_file_get_file_type (file) == G_FILE_TYPE_REGULAR) {
@@ -831,7 +864,8 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
 
 		nautilus_file_invalidate_all_attributes (slot->determine_view_file);
 		nautilus_file_call_when_ready (slot->determine_view_file,
-					       NAUTILUS_FILE_ATTRIBUTE_INFO,
+					       NAUTILUS_FILE_ATTRIBUTE_INFO |
+					       NAUTILUS_FILE_ATTRIBUTE_MOUNT,
 					       got_file_info_for_view_selection_callback,
 					       slot);		
 
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index fd53cf6..2c91c70 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -98,6 +98,7 @@ struct NautilusWindowSlot {
 	GFile *pending_location;
 	char *pending_scroll_to;
 	GList *pending_selection;
+	gboolean pending_use_default_location;
 	NautilusFile *determine_view_file;
 	GCancellable *mount_cancellable;
 	GError *mount_error;
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 799fac9..98903a4 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -41,7 +41,8 @@ typedef struct NautilusWindowDetails NautilusWindowDetails;
 typedef enum {
         NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND = 1 << 0,
         NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW = 1 << 1,
-        NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB = 1 << 2
+        NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB = 1 << 2,
+        NAUTILUS_WINDOW_OPEN_FLAG_USE_DEFAULT_LOCATION = 1 << 3
 } NautilusWindowOpenFlags;
 
 typedef enum {
@@ -50,6 +51,7 @@ typedef enum {
 }  NautilusWindowOpenSlotFlags;
 
 typedef gboolean (* NautilusWindowGoToCallback) (NautilusWindow *window,
+                                                 GFile *location,
                                                  GError *error,
                                                  gpointer user_data);
 



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