[GtkFileChooserButton] bgo#645065 - Restore the previously-selected file when the button's GtkFileChooserDialog is canceled
The file chooser is asynchronous, so doing 'select_file (old_file)' and subsequently querying the file for updating the labels is not going to work. However, the underlying file chooser will emit 'selection-changed' as appropriate when it finishes restoring the old file. So, we only need to update the labels when the file chooser dialog is confirmed, not cancelled.
This commit is contained in:

committed by
Federico Mena Quintero

parent
e0cfc911fd
commit
71505d982b
@ -2662,8 +2662,11 @@ dialog_response_cb (GtkDialog *dialog,
|
||||
if (response == GTK_RESPONSE_ACCEPT ||
|
||||
response == GTK_RESPONSE_OK)
|
||||
{
|
||||
g_signal_emit_by_name (user_data, "current-folder-changed");
|
||||
g_signal_emit_by_name (user_data, "selection-changed");
|
||||
g_signal_emit_by_name (button, "current-folder-changed");
|
||||
g_signal_emit_by_name (button, "selection-changed");
|
||||
|
||||
update_label_and_image (button);
|
||||
update_combo_box (button);
|
||||
}
|
||||
else if (priv->old_file)
|
||||
{
|
||||
@ -2691,9 +2694,6 @@ dialog_response_cb (GtkDialog *dialog,
|
||||
priv->old_file = NULL;
|
||||
}
|
||||
|
||||
update_label_and_image (user_data);
|
||||
update_combo_box (user_data);
|
||||
|
||||
if (priv->active)
|
||||
{
|
||||
g_signal_handler_unblock (priv->dialog,
|
||||
@ -2710,7 +2710,7 @@ dialog_response_cb (GtkDialog *dialog,
|
||||
|
||||
if (response == GTK_RESPONSE_ACCEPT ||
|
||||
response == GTK_RESPONSE_OK)
|
||||
g_signal_emit (user_data, file_chooser_button_signals[FILE_SET], 0);
|
||||
g_signal_emit (button, file_chooser_button_signals[FILE_SET], 0);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user