Add a GtkBuildable implementation to GtkAssistant

Expose the action area as internal child, and support child
properties.
This commit is contained in:
Matthias Clasen
2009-04-18 01:23:20 -04:00
parent 24fde41c85
commit cedc4415b4
3 changed files with 141 additions and 62 deletions

View File

@ -10,6 +10,16 @@ A #GtkAssistant is a widget used to represent a generally complex
operation splitted in several steps, guiding the user through its pages operation splitted in several steps, guiding the user through its pages
and controlling the page flow to collect the necessary data. and controlling the page flow to collect the necessary data.
</para> </para>
<refsect2 id="GtkAssistant-BUILDER-UI"><title>GtkAssistant as GtkBuildable</title>
<para>
The GtkAssistant implementation of the GtkBuildable interface exposes the
@action_area as internal children with the name "action_area".
</para>
<para>
To add pages to an assistant in GtkBuilder, simply add it as a &lt;child&gt;
to the GtkAssistant object, and set its child properties as necessary.
</para>
</refsect2>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>

View File

@ -228,7 +228,8 @@ respective objects, see
<link linkend="GtkTreeView-BUILDER-UI">GtkTreeView</link>, <link linkend="GtkTreeView-BUILDER-UI">GtkTreeView</link>,
<link linkend="GtkUIManager-BUILDER-UI">GtkUIManager</link>, <link linkend="GtkUIManager-BUILDER-UI">GtkUIManager</link>,
<link linkend="GtkActionGroup-BUILDER-UI">GtkActionGroup</link>. <link linkend="GtkActionGroup-BUILDER-UI">GtkActionGroup</link>.
<link linkend="GtkMenuItem-BUILDER-UI">GtkMenuItem</link>. <link linkend="GtkMenuItem-BUILDER-UI">GtkMenuItem</link>,
<link linkend="GtkAssistant-BUILDER-UI">GtkAssistant</link>.
</para> </para>
</refsect2> </refsect2>

View File

@ -40,6 +40,7 @@
#include "gtkintl.h" #include "gtkintl.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkbuildable.h"
#include "gtkalias.h" #include "gtkalias.h"
@ -119,6 +120,23 @@ static void gtk_assistant_get_child_property (GtkContainer *container,
static AtkObject *gtk_assistant_get_accessible (GtkWidget *widget); static AtkObject *gtk_assistant_get_accessible (GtkWidget *widget);
static void gtk_assistant_buildable_interface_init (GtkBuildableIface *iface);
static GObject *gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *childname);
static gboolean gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
GMarkupParser *parser,
gpointer *data);
static void gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
gpointer user_data);
enum enum
{ {
CHILD_PROP_0, CHILD_PROP_0,
@ -141,7 +159,9 @@ enum
static guint signals [LAST_SIGNAL] = { 0 }; static guint signals [LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GtkAssistant, gtk_assistant, GTK_TYPE_WINDOW) G_DEFINE_TYPE_WITH_CODE (GtkAssistant, gtk_assistant, GTK_TYPE_WINDOW,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_assistant_buildable_interface_init))
static void static void
@ -2233,7 +2253,7 @@ gtk_assistant_accessible_ref_child (AtkObject *accessible,
GtkWidget *widget, *child; GtkWidget *widget, *child;
gint n_pages; gint n_pages;
AtkObject *obj; AtkObject *obj;
gchar *title; const gchar *title;
widget = GTK_ACCESSIBLE (accessible)->widget; widget = GTK_ACCESSIBLE (accessible)->widget;
if (!widget) if (!widget)
@ -2394,5 +2414,53 @@ gtk_assistant_get_accessible (GtkWidget *widget)
} }
static GtkBuildableIface *parent_buildable_iface;
static void
gtk_assistant_buildable_interface_init (GtkBuildableIface *iface)
{
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->get_internal_child = gtk_assistant_buildable_get_internal_child;
iface->custom_tag_start = gtk_assistant_buildable_custom_tag_start;
iface->custom_finished = gtk_assistant_buildable_custom_finished;
}
static GObject *
gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
GtkBuilder *builder,
const gchar *childname)
{
if (strcmp (childname, "action_area") == 0)
return G_OBJECT (GTK_ASSISTANT (buildable)->priv->action_area);
return parent_buildable_iface->get_internal_child (buildable,
builder,
childname);
}
gboolean
gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
GMarkupParser *parser,
gpointer *data)
{
return parent_buildable_iface->custom_tag_start (buildable, builder, child,
tagname, parser, data);
}
static void
gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
gpointer user_data)
{
parent_buildable_iface->custom_finished (buildable, builder, child,
tagname, user_data);
}
#define __GTK_ASSISTANT_C__ #define __GTK_ASSISTANT_C__
#include "gtkaliasdef.c" #include "gtkaliasdef.c"