[gtk+/places-sidebar] Make gtk_places_sidebar_set_current_uri() handle NULL URIs to unselect all



commit e56ee840695df0ee5f9d8ab8804e078e69e8f550
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Sep 30 08:10:57 2011 -0500

    Make gtk_places_sidebar_set_current_uri() handle NULL URIs to unselect all
    
    Signed-off-by: Federico Mena Quintero <federico gnome org>

 gtk/gtkplacessidebar.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index d9db9c6..8916d3a 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -3397,12 +3397,23 @@ gtk_places_sidebar_set_current_uri (GtkPlacesSidebar *sidebar, const char *uri)
 	gboolean 	 valid;
 	char  		 *iter_uri;
 
-        if (strcmp (sidebar->uri, uri) != 0) {
+	g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
+
+	selection = gtk_tree_view_get_selection (sidebar->tree_view);
+
+	if (uri == NULL) {
+		g_free (sidebar->uri);
+		sidebar->uri = NULL;
+
+		gtk_tree_selection_unselect_all (selection);
+		return;
+	}
+
+        if (sidebar->uri == NULL || strcmp (sidebar->uri, uri) != 0) {
 		g_free (sidebar->uri);
                 sidebar->uri = g_strdup (uri);
 
 		/* set selection if any place matches the uri */
-		selection = gtk_tree_view_get_selection (sidebar->tree_view);
 		gtk_tree_selection_unselect_all (selection);
   		valid = gtk_tree_model_get_iter_first (sidebar->filter_model, &iter);
 



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