diff options
author | Benjamin Otte <otte@redhat.com> | 2011-11-05 02:31:04 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-12-16 20:09:12 +0100 |
commit | 35198e142da35e016e2f2782b328a87689ba7292 (patch) | |
tree | 744933788c6c3c9c6ffa1dc9ba4470c49d3d6d2b /gtk/gtkfilechooserentry.c | |
parent | e0859004f66f4db59538007038f2051acfa7beae (diff) | |
download | gtk+-35198e142da35e016e2f2782b328a87689ba7292.tar.gz |
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?
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r-- | gtk/gtkfilechooserentry.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 4e0ff8c898..d603569a9b 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -199,6 +199,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); @@ -1647,14 +1648,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); } |