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's avatarFederico Mena Quintero <federico@gnome.org>
parent 76c24a4a
......@@ -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
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment