[gtk/fix-aspect-frame] aspectframe: Fix use in ui files
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-aspect-frame] aspectframe: Fix use in ui files
- Date: Wed, 5 Aug 2020 18:09:49 +0000 (UTC)
commit 6dfd92b191bf68b18169c9852a7f9fdc9f73e353
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 5 14:04:17 2020 -0400
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
gtk/gtkaspectframe.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c
index ba035c4e42..b7c2cef769 100644
--- a/gtk/gtkaspectframe.c
+++ b/gtk/gtkaspectframe.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]