[gtk+/gtk-2-24] filechooserbutton: Restore to an empty previous selection properly



commit bfcaa4228c35d994bccb91c7369fa152d1df5d75
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 13 11:01:50 2013 -0600

    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>

 gtk/gtkfilechooserbutton.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index d381bd8..6a08183 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -2532,6 +2532,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)
@@ -2566,7 +2577,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;
     }
@@ -2749,12 +2760,10 @@ dialog_response_cb (GtkDialog *dialog,
       update_label_and_image (button);
       update_combo_box (button);
     }
-  else if (priv->selection_while_inactive)
+  else
     {
-      gtk_file_chooser_select_file (GTK_FILE_CHOOSER (dialog), priv->selection_while_inactive, NULL);
+      restore_inactive_selection (button);
     }
-  else
-    gtk_file_chooser_unselect_all (GTK_FILE_CHOOSER (dialog));
 
   if (priv->active)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]