mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-18 09:00:34 +00:00
Save selection to recent-files in the asynchronous Save cases
Various paths in SAVE or CREATE_FOLDER return from ::should_respond() but leave an asynchronous process running. This process checks some things in the user's selection, for example, 'does the file exist, and if so do we need to bring up an overwrite-confirmation dialog?'. When these async processes complete *and* it is indeed time for the dialog to be terminated (via the response-requested signal), we also need to save the selection to the recently-used list - as ::should_respond() does by itself in the cases when it can request a response immediately. Signed-off-by: Federico Mena Quintero <federico@gnome.org>
This commit is contained in:
parent
1a3605a23f
commit
119df7415e
@ -322,6 +322,8 @@ static void gtk_file_chooser_default_get_default_size (GtkFileCh
|
||||
static gboolean gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed);
|
||||
static void gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed);
|
||||
|
||||
static void add_selection_to_recent_list (GtkFileChooserDefault *impl);
|
||||
|
||||
static void location_popup_handler (GtkFileChooserDefault *impl,
|
||||
const gchar *path);
|
||||
static void location_popup_on_paste_handler (GtkFileChooserDefault *impl);
|
||||
@ -8096,6 +8098,16 @@ struct GetDisplayNameData
|
||||
gchar *file_part;
|
||||
};
|
||||
|
||||
/* Every time we request a response explicitly, we need to save the selection to the recently-used list,
|
||||
* as requesting a response means, "the dialog is confirmed".
|
||||
*/
|
||||
static void
|
||||
request_response_and_add_to_recent_list (GtkFileChooserDefault *impl)
|
||||
{
|
||||
g_signal_emit_by_name (impl, "response-requested");
|
||||
add_selection_to_recent_list (impl);
|
||||
}
|
||||
|
||||
static void
|
||||
confirmation_confirm_get_info_cb (GCancellable *cancellable,
|
||||
GFileInfo *info,
|
||||
@ -8122,7 +8134,7 @@ confirmation_confirm_get_info_cb (GCancellable *cancellable,
|
||||
|
||||
set_busy_cursor (data->impl, FALSE);
|
||||
if (should_respond)
|
||||
g_signal_emit_by_name (data->impl, "response-requested");
|
||||
request_response_and_add_to_recent_list (data->impl);
|
||||
|
||||
out:
|
||||
g_object_unref (data->impl);
|
||||
@ -8222,7 +8234,7 @@ name_entry_get_parent_info_cb (GCancellable *cancellable,
|
||||
{
|
||||
if (data->impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
|
||||
{
|
||||
g_signal_emit_by_name (data->impl, "response-requested"); /* even if the file doesn't exist, apps can make good use of that (e.g. Emacs) */
|
||||
request_response_and_add_to_recent_list (data->impl); /* even if the file doesn't exist, apps can make good use of that (e.g. Emacs) */
|
||||
}
|
||||
else if (data->impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
|
||||
{
|
||||
@ -8240,10 +8252,10 @@ name_entry_get_parent_info_cb (GCancellable *cancellable,
|
||||
g_free (file_part);
|
||||
|
||||
if (retval)
|
||||
g_signal_emit_by_name (data->impl, "response-requested");
|
||||
request_response_and_add_to_recent_list (data->impl);
|
||||
}
|
||||
else
|
||||
g_signal_emit_by_name (data->impl, "response-requested");
|
||||
request_response_and_add_to_recent_list (data->impl);
|
||||
}
|
||||
else if (data->impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
|
||||
|| data->impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
|
||||
@ -8259,7 +8271,7 @@ name_entry_get_parent_info_cb (GCancellable *cancellable,
|
||||
set_busy_cursor (data->impl, FALSE);
|
||||
|
||||
if (!mkdir_error)
|
||||
g_signal_emit_by_name (data->impl, "response-requested");
|
||||
request_response_and_add_to_recent_list (data->impl);
|
||||
else
|
||||
error_creating_folder_dialog (data->impl, data->file, mkdir_error);
|
||||
}
|
||||
@ -8326,7 +8338,7 @@ file_exists_get_info_cb (GCancellable *cancellable,
|
||||
else
|
||||
{
|
||||
if (file_exists)
|
||||
g_signal_emit_by_name (data->impl, "response-requested"); /* user typed an existing filename; we are done */
|
||||
request_response_and_add_to_recent_list (data->impl); /* user typed an existing filename; we are done */
|
||||
else
|
||||
needs_parent_check = TRUE; /* file doesn't exist; see if its parent exists */
|
||||
}
|
||||
@ -8357,7 +8369,7 @@ file_exists_get_info_cb (GCancellable *cancellable,
|
||||
if (is_folder)
|
||||
{
|
||||
/* User typed a folder; we are done */
|
||||
g_signal_emit_by_name (data->impl, "response-requested");
|
||||
request_response_and_add_to_recent_list (data->impl);
|
||||
}
|
||||
else
|
||||
error_selecting_folder_over_existing_file_dialog (data->impl, data->file);
|
||||
|
Loading…
Reference in New Issue
Block a user