diff options
author | Federico Mena Quintero <federico@novell.com> | 2009-01-21 03:16:28 +0000 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2009-01-21 03:16:28 +0000 |
commit | 92ec0276fc2795a575729bb61e257a62a6abbb70 (patch) | |
tree | e6eeab30631053d25c90a3d09172188b1b60311a /gtk/gtkfilechooserentry.c | |
parent | 9f62525f2bba5e810b34bf421703eda24e02b7ab (diff) | |
download | gtk+-92ec0276fc2795a575729bb61e257a62a6abbb70.tar.gz |
Factor out code to discard the current_folder
Patch by Carlos Garnacho <carlos@imendio.com>:
* gtk/gtkfilechooserentry.c (discard_current_folder): New
function, factored out for when we need to get rid of the
current_folder.
(gtk_file_chooser_entry_dispose): Use discard_current_folder().
(finished_loading_cb): Fix prototype.
(load_directory_get_folder_callback): Discard the completion
store, as well as clearing the completion feedback, if we find an
error while loading the folder. Also, use
discard_current_folder().
(reload_current_folder): Use discard_current_folder().
Signed-off-by: Federico Mena Quintero <federico@novell.com>
svn path=/trunk/; revision=22155
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r-- | gtk/gtkfilechooserentry.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index ea71fa6683..07bee3b9a9 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -145,8 +145,8 @@ typedef enum { static void refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry, RefreshMode refresh_mode); -static void finished_loading_cb (GFile *file, - gpointer data); +static void finished_loading_cb (GtkFolder *folder, + gpointer data); static void autocomplete (GtkFileChooserEntry *chooser_entry); static void install_start_autocompletion_idle (GtkFileChooserEntry *chooser_entry); static void remove_completion_feedback (GtkFileChooserEntry *chooser_entry); @@ -245,11 +245,24 @@ gtk_file_chooser_entry_finalize (GObject *object) } static void +discard_current_folder (GtkFileChooserEntry *chooser_entry) +{ + if (chooser_entry->current_folder) + { + g_signal_handlers_disconnect_by_func (chooser_entry->current_folder, + G_CALLBACK (finished_loading_cb), chooser_entry); + g_object_unref (chooser_entry->current_folder); + chooser_entry->current_folder = NULL; + } +} + +static void gtk_file_chooser_entry_dispose (GObject *object) { GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object); remove_completion_feedback (chooser_entry); + discard_current_folder (chooser_entry); if (chooser_entry->start_autocompletion_idle_id != 0) { @@ -269,14 +282,6 @@ gtk_file_chooser_entry_dispose (GObject *object) chooser_entry->load_folder_cancellable = NULL; } - if (chooser_entry->current_folder) - { - g_signal_handlers_disconnect_by_func (chooser_entry->current_folder, - G_CALLBACK (finished_loading_cb), chooser_entry); - g_object_unref (chooser_entry->current_folder); - chooser_entry->current_folder = NULL; - } - if (chooser_entry->file_system) { g_object_unref (chooser_entry->file_system); @@ -1292,8 +1297,8 @@ finish_folder_load (GtkFileChooserEntry *chooser_entry) /* Callback when the current folder finishes loading */ static void -finished_loading_cb (GFile *file, - gpointer data) +finished_loading_cb (GtkFolder *folder, + gpointer data) { GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (data); @@ -1321,6 +1326,7 @@ load_directory_get_folder_callback (GCancellable *cancellable, old_load_complete_action = chooser_entry->load_complete_action; + discard_completion_store (chooser_entry); clear_completions (chooser_entry); if (old_load_complete_action == LOAD_COMPLETE_EXPLICIT_COMPLETION) @@ -1331,11 +1337,7 @@ load_directory_get_folder_callback (GCancellable *cancellable, pop_up_completion_feedback (chooser_entry, error->message); } - if (chooser_entry->current_folder) - { - g_object_unref (chooser_entry->current_folder); - chooser_entry->current_folder = NULL; - } + discard_current_folder (chooser_entry); } if (cancelled || error) @@ -1392,18 +1394,13 @@ reload_current_folder (GtkFileChooserEntry *chooser_entry, /* We changed our current directory. We need to clear out the old * directory information. */ - if (chooser_entry->current_folder) - { - if (chooser_entry->load_folder_cancellable) - { - g_cancellable_cancel (chooser_entry->load_folder_cancellable); - chooser_entry->load_folder_cancellable = NULL; - } - - g_object_unref (chooser_entry->current_folder); - chooser_entry->current_folder = NULL; - } + if (chooser_entry->load_folder_cancellable) + { + g_cancellable_cancel (chooser_entry->load_folder_cancellable); + chooser_entry->load_folder_cancellable = NULL; + } + discard_current_folder (chooser_entry); g_object_unref (chooser_entry->current_folder_file); chooser_entry->current_folder_file = g_object_ref (folder_file); } |