[gtk+/places-sidebar] Oops, actually update the internal location of the places sidebar prior to notifying the caller



commit 637bd8f2b84455f32b1d34deec334ed4492f2721
Author: Federico Mena Quintero <federico gnome org>
Date:   Sat Nov 24 10:59:48 2012 -0600

    Oops, actually update the internal location of the places sidebar prior to notifying the caller
    
    This is so that the sidebar will already know the URI of the location it is showing.  When
    the caller asks the sidebar to change back to the same location, the call will be idempotent.
    
    Signed-off-by: Federico Mena Quintero <federico gnome org>

 gtk/gtkplacessidebar.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 2adcb1f..cfc79cd 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -1924,6 +1924,18 @@ drive_start_from_bookmark_cb (GObject      *source_object,
 	}
 }
 
+static void
+change_location_and_notify (GtkPlacesSidebar *sidebar, GFile *location, GtkPlacesOpenMode open_mode)
+{
+	g_free (sidebar->uri);
+	sidebar->uri = NULL;
+
+	if (location)
+		sidebar->uri = g_file_get_uri (location);
+
+	emit_location_selected (sidebar, location, open_mode);
+}
+
 /* Callback from g_volume_mount() */
 static void
 volume_mount_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
@@ -1957,7 +1969,7 @@ volume_mount_cb (GObject *source_object, GAsyncResult *result, gpointer user_dat
 		GFile *location;
 
 		location = g_mount_get_default_location (mount);
-		emit_location_selected (sidebar, location, sidebar->go_to_after_mount_open_mode);
+		change_location_and_notify (sidebar, location, sidebar->go_to_after_mount_open_mode);
 
 		g_object_unref (G_OBJECT (location));
 		g_object_unref (G_OBJECT (mount));
@@ -1996,7 +2008,7 @@ open_selected_bookmark (GtkPlacesSidebar *sidebar,
 
 	if (uri != NULL) {
 		location = g_file_new_for_uri (uri);
-		emit_location_selected (sidebar, location, open_mode);
+		change_location_and_notify (sidebar, location, open_mode);
 
 		g_object_unref (location);
 		g_free (uri);



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