[gtk+/gtk-2-24] filechooserentry: Ensure the base folder is always valid



commit 39dbcbab9710e3ef8ba357f2fdafae11df35d508
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 5 02:31:04 2011 +0100

    filechooserentry: Ensure the base folder is always valid
    
    If the base folder is set to NULL, then we just assume the home dir.
    FIXME: Should we disallow a NULL folder?

 gtk/gtkfilechooserentry.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 455ba3e..0b045a6 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -202,6 +202,7 @@ _gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
   GtkCellRenderer *cell;
 
   chooser_entry->local_only = TRUE;
+  chooser_entry->base_folder = g_file_new_for_path (g_get_home_dir ());
 
   g_object_set (chooser_entry, "truncate-multiline", TRUE, NULL);
 
@@ -1645,14 +1646,22 @@ void
 _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
                                         GFile               *file)
 {
+  if (file)
+    g_object_ref (file);
+  else
+    file = g_file_new_for_path (g_get_home_dir ());
+
+  if (g_file_equal (chooser_entry->base_folder, file))
+    {
+      g_object_unref (file);
+      return;
+    }
+
   if (chooser_entry->base_folder)
     g_object_unref (chooser_entry->base_folder);
 
   chooser_entry->base_folder = file;
 
-  if (chooser_entry->base_folder)
-    g_object_ref (chooser_entry->base_folder);
-
   clear_completions (chooser_entry);
 }
 


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