[gtk/wip/otte/listview: 1005/1040] builder: Make gtk_builder_extend_with_template() work with objects



commit 1b7e3c846f30da8ff0c9d763fc4d468425d2d489
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/gtkwidget.c                       |  2 +-
 gtk/tools/gtk-builder-tool-validate.c |  8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index a26e172182..149d124c85 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -1247,7 +1247,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)
@@ -1263,7 +1263,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,
@@ -1274,9 +1274,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;
@@ -1288,7 +1288,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 df49e7a4cf..b88731cb3c 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/gtkwidget.c b/gtk/gtkwidget.c
index 9c4253bc3e..2808cf7484 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11570,7 +11570,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 ab74e507b8..89649fe20f 100644
--- a/gtk/tools/gtk-builder-tool-validate.c
+++ b/gtk/tools/gtk-builder-tool-validate.c
@@ -57,7 +57,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;
@@ -69,15 +69,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]