[gtk+/gtk-3-20] combobox: popdown() the menu during unmap()



commit 495456c3d1431371bf9473e21a98b9c46c7dc2d9
Author: Daniel Boles <dboles src gnome org>
Date:   Fri Jan 20 03:23:00 2017 +0000

    combobox: popdown() the menu during unmap()
    
    combo_box_popdown() of course doesn’t popdown our menu if it is NULL.
    But the required call to this at end-of-life was in destroy(), by which
    point dispose() already NULLed the menu, so Menu::popdown() would never
    run, even if it should. Fix this by trying popdown() earlier in unmap().
    Also, add a converse assurance that we don’t popup() while not mapped.

 gtk/gtkcombobox.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 268653a..7954bab 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -276,6 +276,7 @@ static void     gtk_combo_box_cell_editable_init   (GtkCellEditableIface *iface)
 static void     gtk_combo_box_constructed          (GObject          *object);
 static void     gtk_combo_box_dispose              (GObject          *object);
 static void     gtk_combo_box_finalize             (GObject          *object);
+static void     gtk_combo_box_unmap                (GtkWidget        *widget);
 static void     gtk_combo_box_destroy              (GtkWidget        *widget);
 
 static void     gtk_combo_box_set_property         (GObject         *object,
@@ -705,6 +706,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
   widget_class->get_preferred_height = gtk_combo_box_get_preferred_height;
   widget_class->get_preferred_height_for_width = gtk_combo_box_get_preferred_height_for_width;
   widget_class->get_preferred_width_for_height = gtk_combo_box_get_preferred_width_for_height;
+  widget_class->unmap = gtk_combo_box_unmap;
   widget_class->destroy = gtk_combo_box_destroy;
   widget_class->compute_expand = gtk_combo_box_compute_expand;
 
@@ -2385,6 +2387,8 @@ gtk_combo_box_grab_broken_event (GtkWidget          *widget,
  * This function is mostly intended for use by accessibility technologies;
  * applications should have little use for it.
  *
+ * Before calling this, @combo_box must be mapped, or nothing will happen.
+ *
  * Since: 2.4
  */
 void
@@ -2392,7 +2396,8 @@ gtk_combo_box_popup (GtkComboBox *combo_box)
 {
   g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
 
-  g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
+  if (gtk_widget_get_mapped (GTK_WIDGET (combo_box)))
+    g_signal_emit (combo_box, combo_box_signals[POPUP], 0);
 }
 
 /**
@@ -4274,6 +4279,14 @@ gtk_combo_box_grab_focus (GtkWidget *widget)
 }
 
 static void
+gtk_combo_box_unmap (GtkWidget *widget)
+{
+  gtk_combo_box_popdown (GTK_COMBO_BOX (widget));
+
+  GTK_WIDGET_CLASS (gtk_combo_box_parent_class)->unmap (widget);
+}
+
+static void
 gtk_combo_box_destroy (GtkWidget *widget)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
@@ -4298,8 +4311,6 @@ gtk_combo_box_destroy (GtkWidget *widget)
       _gtk_bin_set_child (GTK_BIN (combo_box), NULL);
     }
 
-  gtk_combo_box_popdown (combo_box);
-
   if (priv->row_separator_destroy)
     priv->row_separator_destroy (priv->row_separator_data);
 


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