filechooserbutton: Restore to an empty previous selection properly

If no file was originally selected in the GtkFileChooserButton, then its
internal dialog is brought up and cancelled, then we need to restore the
selection back to none.  GtkFileChooser, though, doesn't like to
select a NULL file, so call _unselect_all() in that condition.

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
This commit is contained in:
Federico Mena Quintero 2013-02-13 11:01:50 -06:00
parent e65cf0b70d
commit cf921c353b

View File

@ -2555,6 +2555,17 @@ fs_bookmarks_changed_cb (GtkFileSystem *fs,
update_combo_box (user_data);
}
static void
restore_inactive_selection (GtkFileChooserButton *button)
{
GtkFileChooserButtonPrivate *priv = button->priv;
if (priv->selection_while_inactive)
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (priv->dialog), priv->selection_while_inactive, NULL);
else
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (priv->dialog));
}
/* Dialog */
static void
open_dialog (GtkFileChooserButton *button)
@ -2589,7 +2600,7 @@ open_dialog (GtkFileChooserButton *button)
g_signal_handler_block (priv->dialog,
priv->dialog_selection_changed_id);
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (priv->dialog), priv->selection_while_inactive, NULL);
restore_inactive_selection (button);
priv->active = TRUE;
}
@ -2772,12 +2783,10 @@ dialog_response_cb (GtkDialog *dialog,
update_label_and_image (button);
update_combo_box (button);
}
else if (priv->selection_while_inactive)
{
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (dialog), priv->selection_while_inactive, NULL);
}
else
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (dialog));
{
restore_inactive_selection (button);
}
if (priv->active)
{