[gtk/prop-list: 123/154] builder: Make gtk_builder_extend_with_template() work with objects



commit 2096b7a12e644adb33db0b63f15bdaf1d0e1343c
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 1eb8ca05bd..19e6215d8f 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -1273,7 +1273,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)
@@ -1289,7 +1289,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,
@@ -1299,9 +1299,9 @@ gtk_builder_extend_with_template (GtkBuilder   *builder,
   GError *tmp_error;
 
   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;
@@ -1312,7 +1312,7 @@ gtk_builder_extend_with_template (GtkBuilder   *builder,
   priv->resource_prefix = NULL;
   priv->template_type = template_type;
 
-  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, "<input>",
                                     buffer, length,
                                     NULL,
diff --git a/gtk/gtkbuilder.h b/gtk/gtkbuilder.h
index 3bc752852b..697a301405 100644
--- a/gtk/gtkbuilder.h
+++ b/gtk/gtkbuilder.h
@@ -210,7 +210,7 @@ GClosure *   gtk_builder_create_cclosure         (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 4c78043556..0c681142c8 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -12195,7 +12195,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 a64bb2d3e1..19bf01a367 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]