forked from AuroraMiddleware/gtk
aspectframe: Fix use in ui files
GtkAspectFrame code assumes that its child will be in self->child, but that is only the case if we arrange for <child> in ui files to end up calling gtk_aspect_frame_set_child(). Therefore, implement GtkBuildable. Fixes: #3020
This commit is contained in:
parent
d7c4f93c76
commit
6dfd92b191
@ -51,6 +51,8 @@
|
||||
|
||||
#include "gtksizerequest.h"
|
||||
|
||||
#include "gtkbuildable.h"
|
||||
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
@ -110,11 +112,16 @@ static void gtk_aspect_frame_compute_expand (GtkWidget *widget,
|
||||
static GtkSizeRequestMode
|
||||
gtk_aspect_frame_get_request_mode (GtkWidget *widget);
|
||||
|
||||
static void gtk_aspect_frame_buildable_init (GtkBuildableIface *iface);
|
||||
|
||||
#define MAX_RATIO 10000.0
|
||||
#define MIN_RATIO 0.0001
|
||||
|
||||
G_DEFINE_TYPE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_WIDGET)
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_WIDGET,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_aspect_frame_buildable_init))
|
||||
|
||||
|
||||
static void
|
||||
gtk_aspect_frame_class_init (GtkAspectFrameClass *class)
|
||||
@ -253,6 +260,28 @@ gtk_aspect_frame_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static GtkBuildableIface *parent_buildable_iface;
|
||||
|
||||
static void
|
||||
gtk_aspect_frame_buildable_add_child (GtkBuildable *buildable,
|
||||
GtkBuilder *builder,
|
||||
GObject *child,
|
||||
const char *type)
|
||||
{
|
||||
if (GTK_IS_WIDGET (child))
|
||||
gtk_aspect_frame_set_child (GTK_ASPECT_FRAME (buildable), GTK_WIDGET (child));
|
||||
else
|
||||
parent_buildable_iface->add_child (buildable, builder, child, type);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_aspect_frame_buildable_init (GtkBuildableIface *iface)
|
||||
{
|
||||
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->add_child = gtk_aspect_frame_buildable_add_child;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_aspect_frame_new:
|
||||
* @xalign: Horizontal alignment of the child within the allocation of
|
||||
|
Loading…
Reference in New Issue
Block a user