[gtk+/bgo593793-filechooser-recent-folders: 6/10] Start in recently-used mode when no folder is set
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/bgo593793-filechooser-recent-folders: 6/10] Start in recently-used mode when no folder is set
- Date: Wed, 29 Jun 2011 18:46:43 +0000 (UTC)
commit ecdc08e2ec4f883fc79554d98a979218bdb6a98a
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Jun 28 17:17:22 2011 -0500
Start in recently-used mode when no folder is set
In RELOAD_EMPTY mode, when no folder has been selected by the calling app, we now
start showing the recently-used list. The rationale is as follows:
- In Open mode, the user is likely to pick a file he has used recently.
- In Save mode, the user is likely to want a destination folder which
he has used recently.
For the Save case, where we want to present the user with recent folders instead
of recent files, we will make the recent-list do so in subsequent commits.
Signed-off-by: Federico Mena Quintero <federico gnome org>
gtk/gtkfilechooserdefault.c | 77 ++++++++++++++++++++++---------------------
gtk/gtkfilechooserprivate.h | 1 -
2 files changed, 39 insertions(+), 39 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index daaec60..e45f8d3 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -1755,8 +1755,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 */
@@ -1872,12 +1870,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;
@@ -5226,33 +5224,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);
@@ -5322,6 +5298,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)));
@@ -5677,17 +5683,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:
@@ -5718,6 +5717,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);
}
@@ -10026,8 +10028,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 7b4b06f..74902ae 100644
--- a/gtk/gtkfilechooserprivate.h
+++ b/gtk/gtkfilechooserprivate.h
@@ -295,7 +295,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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]