[gtk+] menubutton: make it work with custom content in .ui file
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] menubutton: make it work with custom content in .ui file
- Date: Sat, 1 Sep 2012 03:02:52 +0000 (UTC)
commit 6e6487b461adf2628f49fc257a7a30a2346e5a25
Author: David Zeuthen <zeuthen gmail com>
Date: Tue Aug 21 12:49:02 2012 -0400
menubutton: make it work with custom content in .ui file
This was reported in bug 682291.
https://bugzilla.gnome.org/show_bug.cgi?id=682291
Signed-off-by: David Zeuthen <zeuthen gmail com>
gtk/gtkmenubutton.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index b324de5..c847482 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -173,6 +173,7 @@ enum
G_DEFINE_TYPE(GtkMenuButton, gtk_menu_button, GTK_TYPE_TOGGLE_BUTTON)
+static void gtk_menu_button_constructed (GObject *object);
static void gtk_menu_button_dispose (GObject *object);
static void
@@ -449,6 +450,7 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass)
gobject_class->set_property = gtk_menu_button_set_property;
gobject_class->get_property = gtk_menu_button_get_property;
+ gobject_class->constructed = gtk_menu_button_constructed;
gobject_class->dispose = gtk_menu_button_dispose;
widget_class->state_flags_changed = gtk_menu_button_state_flags_changed;
@@ -531,7 +533,7 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass)
P_("The direction the arrow should point."),
GTK_TYPE_ARROW_TYPE,
GTK_ARROW_DOWN,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void
@@ -554,8 +556,6 @@ gtk_menu_button_init (GtkMenuButton *menu_button)
menu_button->priv = priv;
priv->arrow_type = GTK_ARROW_DOWN;
- add_arrow (menu_button);
-
gtk_widget_set_sensitive (GTK_WIDGET (menu_button), FALSE);
}
@@ -856,8 +856,11 @@ gtk_menu_button_set_direction (GtkMenuButton *menu_button,
priv->arrow_type = direction;
- /* Is it custom content? We don't change that */
child = gtk_bin_get_child (GTK_BIN (menu_button));
+ if (child == NULL)
+ return;
+
+ /* Is it custom content? We don't change that */
if (priv->arrow_widget != child)
return;
@@ -883,6 +886,17 @@ gtk_menu_button_get_direction (GtkMenuButton *menu_button)
}
static void
+gtk_menu_button_constructed (GObject *object)
+{
+ GtkMenuButton *button = GTK_MENU_BUTTON (object);
+
+ if (button->priv->arrow_type != GTK_ARROW_NONE)
+ add_arrow (button);
+
+ G_OBJECT_CLASS (gtk_menu_button_parent_class)->constructed (object);
+}
+
+static void
gtk_menu_button_dispose (GObject *object)
{
GtkMenuButtonPrivate *priv = GTK_MENU_BUTTON (object)->priv;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]