[gtk/wip/otte/listview: 118/152] builder: Make gtk_builder_extend_with_template() work with objects
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 118/152] builder: Make gtk_builder_extend_with_template() work with objects
- Date: Sun, 24 May 2020 18:52:01 +0000 (UTC)
commit d0e80e7816507652223e2973832e89521882e1f9
Author: Benjamin Otte <otte redhat com>
Date: Fri Nov 1 07:30:32 2019 +0100
builder: Make gtk_builder_extend_with_template() work with objects
This will be relevant later when we introduce GtkListItem which is not a
GtkWidget.
gtk/gtkbuilder.c | 10 +++++-----
gtk/gtkbuilder.h | 2 +-
gtk/gtkbuilderlistitemfactory.c | 2 +-
gtk/gtkwidget.c | 2 +-
gtk/tools/gtk-builder-tool-validate.c | 8 ++++----
5 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 1d54c758cd..f1fdb08d74 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -1256,7 +1256,7 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
/**
* gtk_builder_extend_with_template:
* @builder: a #GtkBuilder
- * @widget: the widget that is being extended
+ * @object: the object that is being extended
* @template_type: the type that the template is for
* @buffer: the string to parse
* @length: the length of @buffer (may be -1 if @buffer is nul-terminated)
@@ -1272,7 +1272,7 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
*/
gboolean
gtk_builder_extend_with_template (GtkBuilder *builder,
- GtkWidget *widget,
+ GObject *object,
GType template_type,
const gchar *buffer,
gssize length,
@@ -1283,9 +1283,9 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
char *filename;
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
- g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
+ g_return_val_if_fail (G_IS_OBJECT (object), 0);
g_return_val_if_fail (g_type_name (template_type) != NULL, 0);
- g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (widget), template_type), 0);
+ g_return_val_if_fail (g_type_is_a (G_OBJECT_TYPE (object), template_type), 0);
g_return_val_if_fail (buffer && buffer[0], 0);
tmp_error = NULL;
@@ -1297,7 +1297,7 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
priv->template_type = template_type;
filename = g_strconcat ("<", g_type_name (template_type), " template>", NULL);
- gtk_builder_expose_object (builder, g_type_name (template_type), G_OBJECT (widget));
+ gtk_builder_expose_object (builder, g_type_name (template_type), object);
_gtk_builder_parser_parse_buffer (builder, filename,
buffer, length,
NULL,
diff --git a/gtk/gtkbuilder.h b/gtk/gtkbuilder.h
index 94e8ed292b..6aa627e194 100644
--- a/gtk/gtkbuilder.h
+++ b/gtk/gtkbuilder.h
@@ -197,7 +197,7 @@ GClosure * gtk_builder_create_closure (GtkBuilder *builder,
GDK_AVAILABLE_IN_ALL
gboolean gtk_builder_extend_with_template (GtkBuilder *builder,
- GtkWidget *widget,
+ GObject *object,
GType template_type,
const gchar *buffer,
gssize length,
diff --git a/gtk/gtkbuilderlistitemfactory.c b/gtk/gtkbuilderlistitemfactory.c
index 226d3a7ea1..12048d61e7 100644
--- a/gtk/gtkbuilderlistitemfactory.c
+++ b/gtk/gtkbuilderlistitemfactory.c
@@ -98,7 +98,7 @@ gtk_builder_list_item_factory_setup (GtkListItemFactory *factory,
if (self->scope)
gtk_builder_set_scope (builder, self->scope);
- if (!gtk_builder_extend_with_template (builder, GTK_WIDGET (list_item), G_OBJECT_TYPE (list_item),
+ if (!gtk_builder_extend_with_template (builder, G_OBJECT (list_item), G_OBJECT_TYPE (list_item),
(const gchar *)g_bytes_get_data (self->bytes, NULL),
g_bytes_get_size (self->bytes),
&error))
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index ff18698fad..147650e09e 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -10959,7 +10959,7 @@ gtk_widget_init_template (GtkWidget *widget)
* will validate that the template is created for the correct GType and assert that
* there is no infinite recursion.
*/
- if (!gtk_builder_extend_with_template (builder, widget, class_type,
+ if (!gtk_builder_extend_with_template (builder, G_OBJECT (widget), class_type,
(const gchar *)g_bytes_get_data (template->data, NULL),
g_bytes_get_size (template->data),
&error))
diff --git a/gtk/tools/gtk-builder-tool-validate.c b/gtk/tools/gtk-builder-tool-validate.c
index 38fdcdcc91..9b6132e64f 100644
--- a/gtk/tools/gtk-builder-tool-validate.c
+++ b/gtk/tools/gtk-builder-tool-validate.c
@@ -58,7 +58,7 @@ do_validate_template (const gchar *filename,
const gchar *parent_name)
{
GType template_type;
- GtkWidget *widget;
+ GObject *object;
GtkBuilder *builder;
GError *error = NULL;
gint ret;
@@ -70,15 +70,15 @@ do_validate_template (const gchar *filename,
if (template_type == G_TYPE_INVALID)
template_type = make_fake_type (type_name, parent_name);
- widget = g_object_new (template_type, NULL);
- if (!widget)
+ object = g_object_new (template_type, NULL);
+ if (!object)
{
g_printerr ("Failed to create an instance of the template type %s\n", type_name);
exit (1);
}
builder = gtk_builder_new ();
- ret = gtk_builder_extend_with_template (builder, widget, template_type, " ", 1, &error);
+ ret = gtk_builder_extend_with_template (builder, object , template_type, " ", 1, &error);
if (ret)
ret = gtk_builder_add_from_file (builder, filename, &error);
g_object_unref (builder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]