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
This commit is contained in:
Matthias Clasen 2012-08-24 23:32:41 -04:00
parent 6e6487b461
commit 9e4b550c98

View File

@ -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;
/**