[gtk/wip/otte/listview: 93/149] builder: Autofill scope property of listitemfactory
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 93/149] builder: Autofill scope property of listitemfactory
- Date: Sun, 8 Dec 2019 04:43:51 +0000 (UTC)
commit c5f6f7c3c10bf801cda7ca0da8d02a81848faf3b
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 3 07:37:24 2019 +0100
builder: Autofill scope property of listitemfactory
I couldn't come up with a better way to automatically inherit the scope
in the builder list item factory that didn't involve a magic
incantation in the XML file. And I do not want developers to know magic
incantations to do a thing that should pretty much always be done.
gtk/gtkbuilder.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index efc47863d4..27be41c4e4 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -216,6 +216,7 @@
#include "gtkbuilderprivate.h"
#include "gtkbuildable.h"
+#include "gtkbuilderlistitemfactory.h"
#include "gtkbuilderscopeprivate.h"
#include "gtkdebug.h"
#include "gtkexpression.h"
@@ -698,6 +699,23 @@ gtk_builder_take_bindings (GtkBuilder *builder,
priv->bindings = g_slist_concat (priv->bindings, bindings);
}
+static void
+ensure_special_construct_parameters (GtkBuilder *builder,
+ GType object_type,
+ ObjectProperties *construct_parameters)
+{
+ GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
+ GValue value = G_VALUE_INIT;
+
+ if (g_type_is_a (object_type, GTK_TYPE_BUILDER_LIST_ITEM_FACTORY))
+ {
+ g_value_init (&value, GTK_TYPE_BUILDER_SCOPE);
+ g_value_set_object (&value, priv->scope);
+ object_properties_add (construct_parameters, "scope", &value);
+ g_value_unset (&value);
+ }
+}
+
GObject *
_gtk_builder_construct (GtkBuilder *builder,
ObjectInfo *info,
@@ -795,6 +813,8 @@ _gtk_builder_construct (GtkBuilder *builder,
}
else
{
+ ensure_special_construct_parameters (builder, info->type, construct_parameters);
+
obj = g_object_new_with_properties (info->type,
construct_parameters->len,
(const char **) construct_parameters->names->pdata,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]