diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 813a10750d..90baae4bba 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -1749,8 +1749,6 @@ shortcuts_append_recent (GtkFileChooserDefault *impl) if (pixbuf) g_object_unref (pixbuf); - - impl->has_recent = TRUE; } /* Appends an item for the user's home directory to the shortcuts model */ @@ -1866,12 +1864,12 @@ shortcuts_get_index (GtkFileChooserDefault *impl, if (where == SHORTCUTS_RECENT) goto out; - n += impl->has_recent ? 1 : 0; + n += 1; /* we always have the recently-used item */ if (where == SHORTCUTS_RECENT_SEPARATOR) goto out; - n += impl->has_recent ? 1 : 0; + n += 1; /* we always have the separator after the recently-used item */ if (where == SHORTCUTS_HOME) goto out; @@ -5212,33 +5210,11 @@ gtk_file_chooser_default_get_property (GObject *object, } } -/* Removes the settings signal handler. It's safe to call multiple times */ +/* This cancels everything that may be going on in the background. */ static void -remove_settings_signal (GtkFileChooserDefault *impl, - GdkScreen *screen) -{ - if (impl->settings_signal_id) - { - GtkSettings *settings; - - settings = gtk_settings_get_for_screen (screen); - g_signal_handler_disconnect (settings, - impl->settings_signal_id); - impl->settings_signal_id = 0; - } -} - -static void -gtk_file_chooser_default_dispose (GObject *object) +cancel_all_operations (GtkFileChooserDefault *impl) { GSList *l; - GtkFileChooserDefault *impl = (GtkFileChooserDefault *) object; - - if (impl->extra_widget) - { - g_object_unref (impl->extra_widget); - impl->extra_widget = NULL; - } pending_select_files_free (impl); @@ -5308,6 +5284,36 @@ gtk_file_chooser_default_dispose (GObject *object) search_stop_searching (impl, TRUE); recent_stop_loading (impl); +} + +/* Removes the settings signal handler. It's safe to call multiple times */ +static void +remove_settings_signal (GtkFileChooserDefault *impl, + GdkScreen *screen) +{ + if (impl->settings_signal_id) + { + GtkSettings *settings; + + settings = gtk_settings_get_for_screen (screen); + g_signal_handler_disconnect (settings, + impl->settings_signal_id); + impl->settings_signal_id = 0; + } +} + +static void +gtk_file_chooser_default_dispose (GObject *object) +{ + GtkFileChooserDefault *impl = (GtkFileChooserDefault *) object; + + cancel_all_operations (impl); + + if (impl->extra_widget) + { + g_object_unref (impl->extra_widget); + impl->extra_widget = NULL; + } remove_settings_signal (impl, gtk_widget_get_screen (GTK_WIDGET (impl))); @@ -5658,17 +5664,10 @@ gtk_file_chooser_default_map (GtkWidget *widget) if (impl->operation_mode == OPERATION_MODE_BROWSE) { - GFile *folder; - switch (impl->reload_state) { case RELOAD_EMPTY: - /* The user didn't explicitly give us a folder to display, so we'll - * use the saved one from the last invocation of the file chooser - */ - folder = get_file_for_last_folder_opened (impl); - gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (impl), folder, NULL); - g_object_unref (folder); + recent_shortcut_handler (impl); break; case RELOAD_HAS_FOLDER: @@ -5699,6 +5698,9 @@ gtk_file_chooser_default_unmap (GtkWidget *widget) settings_save (impl); + cancel_all_operations (impl); + impl->reload_state = RELOAD_EMPTY; + GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->unmap (widget); } @@ -10004,8 +10006,7 @@ search_shortcut_handler (GtkFileChooserDefault *impl) static void recent_shortcut_handler (GtkFileChooserDefault *impl) { - if (impl->has_recent) - switch_to_shortcut (impl, shortcuts_get_index (impl, SHORTCUTS_RECENT)); + switch_to_shortcut (impl, shortcuts_get_index (impl, SHORTCUTS_RECENT)); } static void diff --git a/gtk/gtkfilechooserprivate.h b/gtk/gtkfilechooserprivate.h index 6461770154..ebecfcce71 100644 --- a/gtk/gtkfilechooserprivate.h +++ b/gtk/gtkfilechooserprivate.h @@ -293,7 +293,6 @@ struct _GtkFileChooserDefault guint has_home : 1; guint has_desktop : 1; guint has_search : 1; - guint has_recent : 1; guint show_size_column : 1; guint create_folders : 1;