Commit 60cd5b9b authored by Matthias Clasen's avatar Matthias Clasen

center box: implement GtkBuildable

Make it possible to fill the slots by using the
type attribute on child nodes. This is necessary
since GtkCenterBox does not derive from GtkContainer.
parent b4cb05ac
......@@ -46,6 +46,7 @@
#include "gtkcenterbox.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkbuildable.h"
struct _GtkCenterBox
{
......@@ -63,8 +64,33 @@ struct _GtkCenterBoxClass
};
G_DEFINE_TYPE (GtkCenterBox, gtk_center_box, GTK_TYPE_WIDGET);
static void gtk_center_box_buildable_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkCenterBox, gtk_center_box, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_center_box_buildable_init))
static void
gtk_center_box_buildable_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *type)
{
if (g_strcmp0 (type, "start") == 0)
gtk_center_box_set_start_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
else if (g_strcmp0 (type, "center") == 0)
gtk_center_box_set_center_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
else if (g_strcmp0 (type, "end") == 0)
gtk_center_box_set_end_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
else
GTK_BUILDER_WARN_INVALID_CHILD_TYPE (GTK_CENTER_BOX (buildable), type);
}
static void
gtk_center_box_buildable_init (GtkBuildableIface *iface)
{
iface->add_child = gtk_center_box_buildable_add_child;
}
static void
gtk_center_box_measure (GtkWidget *widget,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment