[gtk+] filechooserbutton: Simplify the code to preserve the selection while the dialog is running
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] filechooserbutton: Simplify the code to preserve the selection while the dialog is running
- Date: Thu, 14 Feb 2013 00:13:31 +0000 (UTC)
commit cef1465e88a3d87e1dd157099217db710a8f017b
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Feb 11 19:33:17 2013 -0600
filechooserbutton: Simplify the code to preserve the selection while the dialog is running
It used to fetch a possibly multiple selection from the GtkFileChooserDialog, and then
pick just the first item from the selection list. But since GtkFileChooserButton
operates in single-selection mode only, it can simply use gtk_file_chooser_get_file()
instead.
Also, the right way to reset the selection for GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
is with gtk_file_chooser_select_file(), not with _set_current_folder_file().
Signed-off-by: Federico Mena Quintero <federico gnome org>
gtk/gtkfilechooserbutton.c | 30 +++---------------------------
1 files changed, 3 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 32f3c62..a0933c8 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -669,7 +669,6 @@ gtk_file_chooser_button_constructor (GType type,
GtkFileChooserButton *button;
GtkFileChooserButtonPrivate *priv;
GSList *list;
- char *current_folder;
object = G_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->constructor (type,
n_params,
@@ -1161,8 +1160,6 @@ gtk_file_chooser_button_hide (GtkWidget *widget)
static void
gtk_file_chooser_button_map (GtkWidget *widget)
{
- GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
-
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->map (widget);
}
@@ -2470,23 +2467,15 @@ open_dialog (GtkFileChooserButton *button)
if (!priv->active)
{
- GSList *files;
-
g_signal_handler_block (priv->dialog,
priv->dialog_folder_changed_id);
g_signal_handler_block (priv->dialog,
priv->dialog_file_activated_id);
g_signal_handler_block (priv->dialog,
priv->dialog_selection_changed_id);
- files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (priv->dialog));
- if (files)
- {
- if (files->data)
- priv->old_file = g_object_ref (files->data);
- g_slist_foreach (files, (GFunc) g_object_unref, NULL);
- g_slist_free (files);
- }
+ g_assert (priv->old_file == NULL);
+ priv->old_file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (priv->dialog));
priv->active = TRUE;
}
@@ -2666,20 +2655,7 @@ dialog_response_cb (GtkDialog *dialog,
}
else if (priv->old_file)
{
- switch (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)))
- {
- case GTK_FILE_CHOOSER_ACTION_OPEN:
- gtk_file_chooser_select_file (GTK_FILE_CHOOSER (dialog), priv->old_file,
- NULL);
- break;
- case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
- gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog),
- priv->old_file, NULL);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
+ gtk_file_chooser_select_file (GTK_FILE_CHOOSER (dialog), priv->old_file, NULL);
}
else
gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (dialog));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]