]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssshorthandproperty.c
Change FSF Address
[~andy/gtk] / gtk / gtkcssshorthandproperty.c
index c47b5305a186081cecebc25110c1684cd955651c..157c946ef4ae939918b0ad7461718dadb4f50347 100644 (file)
@@ -12,8 +12,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  * Authors: Benjamin Otte <otte@gnome.org>
  */
@@ -84,6 +83,13 @@ _gtk_css_shorthand_property_query (GtkStyleProperty   *property,
   shorthand->query (shorthand, value, query_func, query_data);
 }
 
+static void
+gtk_css_shorthand_property_unset_value (gpointer value)
+{
+  if (G_IS_VALUE (value))
+    g_value_unset (value);
+}
+
 static gboolean
 gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
                                         GValue           *value,
@@ -91,12 +97,12 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
                                         GFile            *base)
 {
   GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
-  GValueArray *array;
+  GArray *array;
   guint i;
 
-  array = g_value_array_new (shorthand->subproperties->len);
-  for (i = 0; i < shorthand->subproperties->len; i++)
-    g_value_array_append (array, NULL);
+  array = g_array_new (FALSE, TRUE, sizeof (GValue));
+  g_array_set_clear_func (array, gtk_css_shorthand_property_unset_value);
+  g_array_set_size (array, shorthand->subproperties->len);
 
   if (_gtk_css_parser_try (parser, "initial", TRUE))
     {
@@ -105,7 +111,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
        */
       for (i = 0; i < shorthand->subproperties->len; i++)
         {
-          GValue *val = g_value_array_get_nth (array, i);
+          GValue *val = &g_array_index (array, GValue, i);
           g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
           g_value_set_enum (val, GTK_CSS_INITIAL);
         }
@@ -120,14 +126,14 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
        */
       for (i = 0; i < shorthand->subproperties->len; i++)
         {
-          GValue *val = g_value_array_get_nth (array, i);
+          GValue *val = &g_array_index (array, GValue, i);
           g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
           g_value_set_enum (val, GTK_CSS_INHERIT);
         }
     }
-  else if (!shorthand->parse (shorthand, array->values, parser, base))
+  else if (!shorthand->parse (shorthand, (GValue *) array->data, parser, base))
     {
-      g_value_array_free (array);
+      g_array_free (array, TRUE);
       return FALSE;
     }
 
@@ -136,15 +142,15 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
    * XXX: Is the default always initial or can it be inherit? */
   for (i = 0; i < shorthand->subproperties->len; i++)
     {
-      GValue *val = g_value_array_get_nth (array, i);
+      GValue *val = &g_array_index (array, GValue, i);
       if (G_IS_VALUE (val))
         continue;
       g_value_init (val, GTK_TYPE_CSS_SPECIAL_VALUE);
       g_value_set_enum (val, GTK_CSS_INITIAL);
     }
 
-  g_value_init (value, G_TYPE_VALUE_ARRAY);
-  g_value_set_boxed (value, array);
+  g_value_init (value, G_TYPE_ARRAY);
+  g_value_take_boxed (value, array);
   return TRUE;
 }