summaryrefslogtreecommitdiff
path: root/gtk/gtkmenutoolbutton.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2011-01-09 13:10:40 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2011-01-10 18:48:07 +0900
commit03975b8e7439bc124a0d4ad3bdaa7f2af1765abb (patch)
tree0f0815e0d480aa0058137dbd7635258908a71f9a /gtk/gtkmenutoolbutton.c
parent1fa280938b62a489317934ea7db8114a649dfc87 (diff)
downloadgtk+-03975b8e7439bc124a0d4ad3bdaa7f2af1765abb.tar.gz
Added GtkBuilder support for "menu" child type of GtkMenuToolButton
Diffstat (limited to 'gtk/gtkmenutoolbutton.c')
-rw-r--r--gtk/gtkmenutoolbutton.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c
index f657805d70..e63d795317 100644
--- a/gtk/gtkmenutoolbutton.c
+++ b/gtk/gtkmenutoolbutton.c
@@ -30,6 +30,7 @@
#include "gtkmenu.h"
#include "gtkmain.h"
#include "gtksizerequest.h"
+#include "gtkbuildable.h"
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -49,6 +50,12 @@ static void gtk_menu_tool_button_destroy (GtkWidget *widget);
static int menu_deactivate_cb (GtkMenuShell *menu_shell,
GtkMenuToolButton *button);
+static void gtk_menu_tool_button_buildable_interface_init (GtkBuildableIface *iface);
+static void gtk_menu_tool_button_buildable_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type);
+
enum
{
SHOW_MENU,
@@ -63,7 +70,11 @@ enum
static gint signals[LAST_SIGNAL];
-G_DEFINE_TYPE (GtkMenuToolButton, gtk_menu_tool_button, GTK_TYPE_TOOL_BUTTON)
+static GtkBuildableIface *parent_buildable_iface;
+
+G_DEFINE_TYPE_WITH_CODE (GtkMenuToolButton, gtk_menu_tool_button, GTK_TYPE_TOOL_BUTTON,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+ gtk_menu_tool_button_buildable_interface_init))
static void
gtk_menu_tool_button_construct_contents (GtkMenuToolButton *button)
@@ -453,6 +464,26 @@ gtk_menu_tool_button_destroy (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_menu_tool_button_parent_class)->destroy (widget);
}
+static void
+gtk_menu_tool_button_buildable_add_child (GtkBuildable *buildable,
+ GtkBuilder *builder,
+ GObject *child,
+ const gchar *type)
+{
+ if (type && strcmp (type, "menu") == 0)
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (buildable),
+ GTK_WIDGET (child));
+ else
+ parent_buildable_iface->add_child (buildable, builder, child, type);
+}
+
+static void
+gtk_menu_tool_button_buildable_interface_init (GtkBuildableIface *iface)
+{
+ parent_buildable_iface = g_type_interface_peek_parent (iface);
+ iface->add_child = gtk_menu_tool_button_buildable_add_child;
+}
+
/**
* gtk_menu_tool_button_new:
* @icon_widget: (allow-none): a widget that will be used as icon widget, or %NULL