From 9e4b550c98bdfba26c27a24c1e7b3731fc0f5cb6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 24 Aug 2012 23:32:41 -0400 Subject: [PATCH] GtkMenuButton: Override add By removing an existing child in add, if it is our own arrow, we can make things work better in GtkBuilder. https://bugzilla.gnome.org/show_bug.cgi?id=682291 --- gtk/gtkmenubutton.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c index c84748269b..e240fdd7bd 100644 --- a/gtk/gtkmenubutton.c +++ b/gtk/gtkmenubutton.c @@ -439,11 +439,27 @@ gtk_menu_button_button_press_event (GtkWidget *widget, return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->button_press_event (widget, event); } +static void +gtk_menu_button_add (GtkContainer *container, + GtkWidget *child) +{ + GtkMenuButton *button = GTK_MENU_BUTTON (container); + + if (button->priv->arrow_widget) + { + gtk_container_remove (container, button->priv->arrow_widget); + button->priv->arrow_widget = NULL; + } + + GTK_CONTAINER_CLASS (gtk_menu_button_parent_class)->add (container, child); +} + static void gtk_menu_button_class_init (GtkMenuButtonClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkToggleButtonClass *toggle_button_class = GTK_TOGGLE_BUTTON_CLASS (klass); g_type_class_add_private (klass, sizeof (GtkMenuButtonPrivate)); @@ -456,6 +472,8 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass) widget_class->state_flags_changed = gtk_menu_button_state_flags_changed; widget_class->button_press_event = gtk_menu_button_button_press_event; + container_class->add = gtk_menu_button_add; + toggle_button_class->toggled = gtk_menu_button_toggled; /**