[gtk+/gtk-2-24] ComboBox: Really set list-mode popup transient-for



commit 2759e8961152f734fc1596727094224f71c70709
Author: Daniel Boles <dboles src gnome org>
Date:   Mon Aug 28 00:12:02 2017 +0100

    ComboBox: Really set list-mode popup transient-for
    
    set_transient_for(toplevel) was only called in list_setup(). It was easy
    to make a test showing a NULL :transient-for instead of the correct one.
    
    So, move the call from list_setup() to real_popup(). Also do the same
    for window_group_add_window(), which means not calling it redundantly.
    
    (I tried using a ComboBox:parent-set handler, but the Inspector’s CB
    didn’t like that: it calls popup_for_device() twice and closes on button
    release. Anyway, using popup() is much more concise than a new handler.)

 gtk/gtkcombobox.c |   19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index ee4daf7..6e660e7 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1574,8 +1574,6 @@ gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
     {
       if (!priv->popup_window)
         {
-         GtkWidget *toplevel;
-         
           priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
           gtk_widget_set_name (priv->popup_window, "gtk-combobox-popup-window");
 
@@ -1589,15 +1587,6 @@ gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
                            G_CALLBACK (gtk_combo_box_child_hide),
                            combo_box);
          
-         toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
-         if (GTK_IS_WINDOW (toplevel))
-           {
-             gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), 
-                                          GTK_WINDOW (priv->popup_window));
-             gtk_window_set_transient_for (GTK_WINDOW (priv->popup_window),
-                                           GTK_WINDOW (toplevel));
-           }
-
          gtk_window_set_resizable (GTK_WINDOW (priv->popup_window), FALSE);
 
          priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
@@ -2094,8 +2083,12 @@ gtk_combo_box_real_popup (GtkComboBox *combo_box)
 
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
   if (GTK_IS_WINDOW (toplevel))
-    gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), 
-                                GTK_WINDOW (priv->popup_window));
+    {
+      gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
+                                   GTK_WINDOW (priv->popup_window));
+      gtk_window_set_transient_for (GTK_WINDOW (priv->popup_window),
+                                    GTK_WINDOW (toplevel));
+    }
 
   gtk_widget_show_all (priv->scrolled_window);
   gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);


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