[planner] Port GValueArray to GArray



commit 920af8481fdc030789d5c92bb31d6cf2ba2feba0
Author: Gilles Dartiguelongue <eva gentoo org>
Date:   Sat Dec 29 00:13:07 2012 +0100

    Port GValueArray to GArray
    
    GValueArray has been deprecated since glib-2.32.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690863

 libplanner/mrp-old-xml.c |   13 +++++++------
 libplanner/mrp-parser.c  |   10 +++++-----
 2 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/libplanner/mrp-old-xml.c b/libplanner/mrp-old-xml.c
index be4b9c7..8b79bc2 100644
--- a/libplanner/mrp-old-xml.c
+++ b/libplanner/mrp-old-xml.c
@@ -774,11 +774,11 @@ old_xml_read_project_properties (MrpParser *parser)
        g_free (phase);
 }
 
-static GValueArray *
+static GArray *
 old_xml_read_string_list (xmlNodePtr  node,
                          MrpObject  *object)
 {
-       GValueArray *array;
+       GArray      *array;
        GValue       value = { 0 };
        xmlNodePtr   child;
        gchar       *str;
@@ -787,7 +787,8 @@ old_xml_read_string_list (xmlNodePtr  node,
                return NULL;
        }
 
-       array = g_value_array_new (0);
+       array = g_array_new (TRUE, TRUE, sizeof(GValue *));
+       g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
 
        g_value_init (&value, G_TYPE_STRING);
 
@@ -798,7 +799,7 @@ old_xml_read_string_list (xmlNodePtr  node,
 
                        if (str && str[0]) {
                                g_value_set_string (&value, str);
-                               g_value_array_append (array, &value);
+                               g_array_append_val (array, value);
                        }
 
                        g_free (str);
@@ -1352,7 +1353,7 @@ old_xml_set_property_from_node (MrpProject *project,
        gfloat           f;
        gchar           *name;
        gchar           *str;
-       GValueArray     *array;
+       GArray          *array;
        GList           *phases;
 
        name  = old_xml_get_string (node, "name");
@@ -1401,7 +1402,7 @@ old_xml_set_property_from_node (MrpProject *project,
                array = old_xml_read_string_list (node, object);
                if (array) {
                        mrp_object_set (object, name, array, NULL);
-                       g_value_array_free (array);
+                       g_array_free (array, TRUE);
                }
                break;
        case MRP_PROPERTY_TYPE_INT:
diff --git a/libplanner/mrp-parser.c b/libplanner/mrp-parser.c
index 81099a7..f4448e3 100644
--- a/libplanner/mrp-parser.c
+++ b/libplanner/mrp-parser.c
@@ -178,7 +178,7 @@ mpp_property_to_string (MrpObject   *object,
        gint         i;
        gfloat       f;
        mrptime      date;
-       GValueArray *array;
+       GArray      *array;
 
        name = mrp_property_get_name (property);
 
@@ -411,7 +411,7 @@ mpp_write_string_list (xmlNodePtr   node,
                       MrpObject   *object)
 {
        xmlNodePtr   child;
-       GValueArray *array;
+       GArray      *array;
        GValue      *value;
        gint         i;
 
@@ -420,14 +420,14 @@ mpp_write_string_list (xmlNodePtr   node,
                return;
        }
 
-       for (i = 0; i < array->n_values; i++) {
-               value = g_value_array_get_nth (array, i);
+       for (i = 0; i < array->len; i++) {
+               value = g_array_index (array, GValue *, i);
 
                child = xmlNewChild (node, NULL, "list-item", NULL);
                xmlSetProp (child, "value", g_value_get_string (value));
        }
 
-       g_value_array_free (array);
+       g_array_free (array, TRUE);
 }
 
 static void


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