[gtk+/wip/dboles/combobox-cleanup: 2/5] combobox: popdown() the menu during unmap()
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/dboles/combobox-cleanup: 2/5] combobox: popdown() the menu during unmap()
- Date: Fri, 20 Jan 2017 12:35:48 +0000 (UTC)
commit 6055184af62f5b27a3e02c696bc0d42729a9d90b
Author: Daniel Boles <dboles src gnome org>
Date: Fri Jan 20 03:30:36 2017 +0000
combobox: popdown() the menu during unmap()
The end-of-life popdown() was called in destroy(), after dispose() had
already called menu_destroy(), which leads to our detacher NULLing out
popup_widget, so Menu::popdown() was always skipped. That’s not right.
As Benjamin pointed out, a far better place to call popdown() is in
unmap(). Now it actually works! Also, add an equal and opposite
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 6623003..3e141fe 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -228,6 +228,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,
@@ -525,6 +526,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
widget_class->grab_focus = gtk_combo_box_grab_focus;
widget_class->measure = gtk_combo_box_measure_;
+ widget_class->unmap = gtk_combo_box_unmap;
widget_class->destroy = gtk_combo_box_destroy;
widget_class->compute_expand = gtk_combo_box_compute_expand;
@@ -1683,6 +1685,8 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
* 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
@@ -1690,7 +1694,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);
}
/**
@@ -2971,6 +2976,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);
@@ -2997,8 +3010,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]