[gtk+] builder: Minor refactoring



commit 20079a9960778e320a0028316a565fd2cffc3c38
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 7 12:25:29 2015 -0400

    builder: Minor refactoring
    
    Keep the GString in PropertyInfo around, instead of throwing it
    away and just keeping the char*.

 gtk/gtkbuilder.c        |   12 ++++++------
 gtk/gtkbuilderparser.c  |    5 +----
 gtk/gtkbuilderprivate.h |    1 -
 3 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 5849cbe..caf7610 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -480,7 +480,7 @@ gtk_builder_get_parameters (GtkBuilder  *builder,
       if (G_IS_PARAM_SPEC_OBJECT (prop->pspec) &&
           (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PIXBUF))
         {
-          GObject *object = gtk_builder_get_object (builder, prop->data);
+          GObject *object = gtk_builder_get_object (builder, prop->text->str);
 
           if (object)
             {
@@ -493,14 +493,14 @@ gtk_builder_get_parameters (GtkBuilder  *builder,
                 {
                   g_warning ("Failed to get construct only property "
                              "%s of %s with value `%s'",
-                             prop->pspec->name, object_name, prop->data);
+                             prop->pspec->name, object_name, prop->text->str);
                   continue;
                 }
               /* Delay setting property */
               property = g_slice_new (DelayedProperty);
               property->pspec = prop->pspec;
               property->object = g_strdup (object_name);
-              property->value = g_strdup (prop->data);
+              property->value = g_strdup (prop->text->str);
               property->line = prop->line;
               property->col = prop->col;
               builder->priv->delayed_properties =
@@ -508,7 +508,7 @@ gtk_builder_get_parameters (GtkBuilder  *builder,
               continue;
             }
         }
-      else if (prop->bound && (!prop->data || *prop->data == '\0'))
+      else if (prop->bound && (!prop->text || prop->text->len == 0))
         {
           /* Ignore properties with a binding and no value since they are
            * only there for to express the binding.
@@ -516,10 +516,10 @@ gtk_builder_get_parameters (GtkBuilder  *builder,
           continue;
         }
       else if (!gtk_builder_value_from_string (builder, prop->pspec,
-                                               prop->data, &parameter.value, &error))
+                                               prop->text->str, &parameter.value, &error))
         {
           g_warning ("Failed to set property %s.%s to %s: %s",
-                     g_type_name (object_type), prop->pspec->name, prop->data,
+                     g_type_name (object_type), prop->pspec->name, prop->text->str,
                      error->message);
           g_error_free (error);
           error = NULL;
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index decbdb0..0f34d3a 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -681,9 +681,8 @@ parse_property (ParserData   *data,
 static void
 free_property_info (PropertyInfo *info)
 {
-  g_free (info->data);
+  g_string_free (info->text, TRUE);
   g_free (info->context);
-  /* info->text is already freed */
   g_slice_free (PropertyInfo, info);
 }
 
@@ -1157,8 +1156,6 @@ end_element (GMarkupParseContext  *context,
               g_string_assign (prop_info->text, translated);
             }
 
-          prop_info->data = g_string_free (prop_info->text, FALSE);
-
           object_info->properties = g_slist_prepend (object_info->properties, prop_info);
         }
       else
diff --git a/gtk/gtkbuilderprivate.h b/gtk/gtkbuilderprivate.h
index 0e3ad8a..235c8fe 100644
--- a/gtk/gtkbuilderprivate.h
+++ b/gtk/gtkbuilderprivate.h
@@ -62,7 +62,6 @@ typedef struct {
   TagInfo tag;
   GParamSpec *pspec;
   GString *text;
-  gchar *data;
   gboolean translatable:1;
   gboolean bound:1;
   gchar *context;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]