[gtk+/builder-details] Added GtkBuilder support for "menu" child type of GtkMenuToolButton
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/builder-details] Added GtkBuilder support for "menu" child type of GtkMenuToolButton
- Date: Sun, 9 Jan 2011 04:04:11 +0000 (UTC)
commit af1a1f54b9fe55149c34be43674d9eba50232169
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sun Jan 9 13:10:40 2011 +0900
Added GtkBuilder support for "menu" child type of GtkMenuToolButton
docs/reference/gtk/tmpl/gtkmenutoolbutton.sgml | 18 +++++++++++++
gtk/gtkmenutoolbutton.c | 33 +++++++++++++++++++++++-
2 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gtk/tmpl/gtkmenutoolbutton.sgml b/docs/reference/gtk/tmpl/gtkmenutoolbutton.sgml
index c56eab0..5326d02 100644
--- a/docs/reference/gtk/tmpl/gtkmenutoolbutton.sgml
+++ b/docs/reference/gtk/tmpl/gtkmenutoolbutton.sgml
@@ -16,6 +16,24 @@ A GtkToolItem containing a button with an additional dropdown menu
#GtkMenuToolButton. Use gtk_menu_tool_button_new_from_stock() to
create a new #GtkMenuToolButton containing a stock item.
</para>
+<refsect2 id="GtkMenuToolButton-BUILDER-UI">
+<title>GtkMenuToolButton as GtkBuildable</title>
+<para>
+The GtkMenuToolButton implementation of the GtkBuildable interface
+supports adding a menu by specifying "menu" as the "type"
+attribute of a <child> element.
+</para>
+<example>
+<title>A UI definition fragment with menus</title>
+<programlisting><![CDATA[
+<object class="GtkMenuToolButton">
+ <child type="menu">
+ <object class="GtkMenu"/>
+ </child>
+</object>
+]]></programlisting>
+</example>
+</refsect2>
<!-- ##### SECTION See_Also ##### -->
<para>
diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c
index f657805..e63d795 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]