[gtk+/multiroot-filechooser: 14/15] Allow NULL prefixes in _gtk_file_chooser_uri_has_prefix()



commit 754361bbd89113123476ec3fe58d649a9217b7ec
Author: Federico Mena Quintero <federico novell com>
Date:   Tue Jun 15 16:45:47 2010 -0500

    Allow NULL prefixes in _gtk_file_chooser_uri_has_prefix()
    
    This allows us to just call that function with whatever root_uris we
    have, instead of manually comparing the root_uris for NULL every time.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 gtk/gtkfilechooser.c       |    7 ++++---
 gtk/gtkfilechooserbutton.c |    3 +--
 gtk/gtkfilechooserentry.c  |    4 +---
 gtk/gtkpathbar.c           |    3 +--
 4 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index 752c70d..5ba01b4 100644
--- a/gtk/gtkfilechooser.c
+++ b/gtk/gtkfilechooser.c
@@ -2889,7 +2889,9 @@ _gtk_file_chooser_uri_has_prefix (const char *uri, GSList *prefixes)
   GSList *l;
 
   g_return_val_if_fail (uri != NULL, FALSE);
-  g_return_val_if_fail (prefixes != NULL, FALSE);
+
+  if (prefixes == NULL)
+    return TRUE; /* No prefix means all URIs are good */
 
   for (l = prefixes; l != NULL; l = l->next)
     {
@@ -2913,8 +2915,7 @@ _gtk_file_chooser_is_uri_in_root (GtkFileChooser *chooser,
 
   root_uris = gtk_file_chooser_get_root_uris (chooser);
 
-  return root_uris == NULL ||
-         _gtk_file_chooser_uri_has_prefix (uri, root_uris);
+  return _gtk_file_chooser_uri_has_prefix (uri, root_uris);
 }
 
 gboolean
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 1c79a75..74b7a02 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -2217,8 +2217,7 @@ test_if_file_is_visible (GtkFileSystem *fs,
     return FALSE;
 
   uri = g_file_get_uri (file);
-  result = (root_uris == NULL ||
-            _gtk_file_chooser_uri_has_prefix (uri, root_uris));
+  result = _gtk_file_chooser_uri_has_prefix (uri, root_uris);
   g_free (uri);
 
   if (!result)
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index e216cea..5b35bd5 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -454,9 +454,7 @@ is_file_in_root (GtkFileChooserEntry *chooser_entry,
                  GFile               *file)
 {
   char *uri = g_file_get_uri (file);
-  gboolean result =
-    chooser_entry->root_uris == NULL ||
-    _gtk_file_chooser_uri_has_prefix (uri, chooser_entry->root_uris);
+  gboolean result = _gtk_file_chooser_uri_has_prefix (uri, chooser_entry->root_uris);
   g_free (uri);
 
   return result;
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 0e14863..c2f1150 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -1666,8 +1666,7 @@ is_file_in_root (GtkPathBar *path_bar,
                  GFile      *file)
 {
   char *uri = g_file_get_uri (file);
-  gboolean result = path_bar->root_uris == NULL ||
-                    _gtk_file_chooser_uri_has_prefix (uri, path_bar->root_uris);
+  gboolean result = _gtk_file_chooser_uri_has_prefix (uri, path_bar->root_uris);
   g_free(uri);
 
   return result;



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