1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 #include "gtkstylepropertiesprivate.h"
25 #include <gobject/gvaluecollector.h>
26 #include <cairo-gobject.h>
28 #include "gtkstyleprovider.h"
29 #include "gtksymboliccolor.h"
30 #include "gtkthemingengine.h"
31 #include "gtkanimationdescription.h"
32 #include "gtkgradient.h"
33 #include "gtkshadowprivate.h"
35 #include "gtkstylepropertyprivate.h"
39 * SECTION:gtkstyleproperties
40 * @Short_description: Store for style property information
41 * @Title: GtkStyleProperties
43 * GtkStyleProperties provides the storage for style information
44 * that is used by #GtkStyleContext and other #GtkStyleProvider
47 * Before style properties can be stored in GtkStyleProperties, they
48 * must be registered with gtk_style_properties_register_property().
50 * Unless you are writing a #GtkStyleProvider implementation, you
51 * are unlikely to use this API directly, as gtk_style_context_get()
52 * and its variants are the preferred way to access styling information
53 * from widget implementations and theming engine implementations
54 * should use the APIs provided by #GtkThemingEngine instead.
57 typedef struct GtkStylePropertiesPrivate GtkStylePropertiesPrivate;
58 typedef struct PropertyData PropertyData;
59 typedef struct ValueData ValueData;
72 struct GtkStylePropertiesPrivate
74 GHashTable *color_map;
75 GHashTable *properties;
78 static void gtk_style_properties_provider_init (GtkStyleProviderIface *iface);
79 static void gtk_style_properties_finalize (GObject *object);
82 G_DEFINE_TYPE_EXTENDED (GtkStyleProperties, gtk_style_properties, G_TYPE_OBJECT, 0,
83 G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
84 gtk_style_properties_provider_init));
87 gtk_style_properties_class_init (GtkStylePropertiesClass *klass)
89 GObjectClass *object_class = G_OBJECT_CLASS (klass);
91 object_class->finalize = gtk_style_properties_finalize;
93 g_type_class_add_private (object_class, sizeof (GtkStylePropertiesPrivate));
97 property_data_new (void)
101 data = g_slice_new0 (PropertyData);
102 data->values = g_array_new (FALSE, FALSE, sizeof (ValueData));
108 property_data_remove_values (PropertyData *data)
112 for (i = 0; i < data->values->len; i++)
114 ValueData *value_data;
116 value_data = &g_array_index (data->values, ValueData, i);
118 if (G_IS_VALUE (&value_data->value))
119 g_value_unset (&value_data->value);
122 if (data->values->len > 0)
123 g_array_remove_range (data->values, 0, data->values->len);
127 property_data_free (PropertyData *data)
129 property_data_remove_values (data);
130 g_array_free (data->values, TRUE);
131 g_slice_free (PropertyData, data);
135 property_data_find_position (PropertyData *data,
140 gboolean found = FALSE;
146 if (data->values->len == 0)
149 /* Find position for the given state, or the position where
150 * it would be if not found, the array is ordered by the
154 max = data->values->len - 1;
158 ValueData *value_data;
160 mid = (min + max) / 2;
161 value_data = &g_array_index (data->values, ValueData, mid);
163 if (value_data->state == state)
168 else if (value_data->state < state)
169 position = min = mid + 1;
176 while (!found && min <= max);
185 property_data_get_value (PropertyData *data,
191 if (!property_data_find_position (data, state, &pos))
193 ValueData new = { 0 };
196 g_array_insert_val (data->values, pos, new);
199 val_data = &g_array_index (data->values, ValueData, pos);
201 return &val_data->value;
205 property_data_match_state (PropertyData *data,
211 if (property_data_find_position (data, state, &pos))
216 val_data = &g_array_index (data->values, ValueData, pos);
217 return &val_data->value;
220 if (pos >= data->values->len)
221 pos = data->values->len - 1;
223 /* No exact match, go downwards the list to find
224 * the closest match to the given state flags, as
225 * a side effect, there is an implicit precedence
226 * of higher flags over the smaller ones.
228 for (i = pos; i >= 0; i--)
232 val_data = &g_array_index (data->values, ValueData, i);
234 /* Check whether any of the requested
235 * flags are set, and no other flags are.
237 * Also, no flags acts as a wildcard, such
238 * value should be always in the first position
239 * in the array (if present) anyways.
241 if (val_data->state == 0 ||
242 ((val_data->state & state) != 0 &&
243 (val_data->state & ~state) == 0))
244 return &val_data->value;
251 gtk_style_properties_init (GtkStyleProperties *props)
253 GtkStylePropertiesPrivate *priv;
255 priv = props->priv = G_TYPE_INSTANCE_GET_PRIVATE (props,
256 GTK_TYPE_STYLE_PROPERTIES,
257 GtkStylePropertiesPrivate);
259 priv->properties = g_hash_table_new_full (NULL, NULL, NULL,
260 (GDestroyNotify) property_data_free);
264 gtk_style_properties_finalize (GObject *object)
266 GtkStylePropertiesPrivate *priv;
267 GtkStyleProperties *props;
269 props = GTK_STYLE_PROPERTIES (object);
271 g_hash_table_destroy (priv->properties);
274 g_hash_table_destroy (priv->color_map);
276 G_OBJECT_CLASS (gtk_style_properties_parent_class)->finalize (object);
280 gtk_style_properties_get_style (GtkStyleProvider *provider,
283 /* Return style set itself */
284 return g_object_ref (provider);
288 gtk_style_properties_provider_init (GtkStyleProviderIface *iface)
290 iface->get_style = gtk_style_properties_get_style;
293 /* Property registration functions */
296 * gtk_style_properties_register_property: (skip)
297 * @parse_func: parsing function to use, or %NULL
298 * @pspec: the #GParamSpec for the new property
300 * Registers a property so it can be used in the CSS file format.
301 * This function is the low-level equivalent of
302 * gtk_theming_engine_register_property(), if you are implementing
303 * a theming engine, you want to use that function instead.
308 gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
311 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
313 _gtk_style_property_register (pspec,
318 * gtk_style_properties_lookup_property: (skip)
319 * @property_name: property name to look up
320 * @parse_func: (out): return location for the parse function
321 * @pspec: (out) (transfer none): return location for the #GParamSpec
323 * Returns %TRUE if a property has been registered, if @pspec or
324 * @parse_func are not %NULL, the #GParamSpec and parsing function
325 * will be respectively returned.
327 * Returns: %TRUE if the property is registered, %FALSE otherwise
332 gtk_style_properties_lookup_property (const gchar *property_name,
333 GtkStylePropertyParser *parse_func,
336 const GtkStyleProperty *node;
337 gboolean found = FALSE;
339 g_return_val_if_fail (property_name != NULL, FALSE);
341 node = _gtk_style_property_lookup (property_name);
346 *pspec = node->pspec;
349 *parse_func = node->parse_func;
357 /* GParamSpec functionality */
360 GTK_STYLE_PROPERTY_INHERIT = 1 << G_PARAM_USER_SHIFT
364 * gtk_style_param_set_inherit:
365 * @pspec: A style param
366 * @inherit: whether the @pspec value should be inherited
368 * Sets whether a param spec installed with function such as
369 * gtk_style_properties_register_property() or
370 * gtk_widget_class_install_style_property() should inherit their
371 * value from the parent widget if it is not set instead of using
372 * the default value of @pspec. See the
373 * <ulink url="http://www.w3.org/TR/CSS21/cascade.html#inheritance">
374 * CSS specification's description of inheritance</ulink> for a
375 * longer description of this concept.
377 * By default, param specs do not inherit their value.
380 gtk_style_param_set_inherit (GParamSpec *pspec,
384 pspec->flags |= GTK_STYLE_PROPERTY_INHERIT;
386 pspec->flags &= ~GTK_STYLE_PROPERTY_INHERIT;
390 * gtk_style_param_get_inherit:
391 * @pspec: a style param
393 * Checks if the value of this param should be inherited from the parent
394 * #GtkWidget instead of using the default value when it has not been
395 * specified. See gtk_style_param_set_inherit() for more details.
397 * Returns: %TRUE if the param should inherit its value
400 gtk_style_param_get_inherit (GParamSpec *pspec)
402 return (pspec->flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE;
405 /* GtkStyleProperties methods */
408 * gtk_style_properties_new:
410 * Returns a newly created #GtkStyleProperties
412 * Returns: a new #GtkStyleProperties
415 gtk_style_properties_new (void)
417 return g_object_new (GTK_TYPE_STYLE_PROPERTIES, NULL);
421 * gtk_style_properties_map_color:
422 * @props: a #GtkStyleProperties
424 * @color: #GtkSymbolicColor to map @name to
426 * Maps @color so it can be referenced by @name. See
427 * gtk_style_properties_lookup_color()
432 gtk_style_properties_map_color (GtkStyleProperties *props,
434 GtkSymbolicColor *color)
436 GtkStylePropertiesPrivate *priv;
438 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
439 g_return_if_fail (name != NULL);
440 g_return_if_fail (color != NULL);
444 if (G_UNLIKELY (!priv->color_map))
445 priv->color_map = g_hash_table_new_full (g_str_hash,
447 (GDestroyNotify) g_free,
448 (GDestroyNotify) gtk_symbolic_color_unref);
450 g_hash_table_replace (priv->color_map,
452 gtk_symbolic_color_ref (color));
456 * gtk_style_properties_lookup_color:
457 * @props: a #GtkStyleProperties
458 * @name: color name to lookup
460 * Returns the symbolic color that is mapped
463 * Returns: (transfer none): The mapped color
468 gtk_style_properties_lookup_color (GtkStyleProperties *props,
471 GtkStylePropertiesPrivate *priv;
473 g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), NULL);
474 g_return_val_if_fail (name != NULL, NULL);
478 if (!priv->color_map)
481 return g_hash_table_lookup (priv->color_map, name);
485 _gtk_style_properties_set_property_by_pspec (GtkStyleProperties *props,
490 GtkStylePropertiesPrivate *priv;
495 value_type = G_VALUE_TYPE (value);
497 if (pspec->value_type == GDK_TYPE_RGBA ||
498 pspec->value_type == GDK_TYPE_COLOR)
500 /* Allow GtkSymbolicColor as well */
501 g_return_if_fail (value_type == GDK_TYPE_RGBA ||
502 value_type == GDK_TYPE_COLOR ||
503 value_type == GTK_TYPE_SYMBOLIC_COLOR);
505 else if (pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN)
507 /* Allow GtkGradient as a substitute */
508 g_return_if_fail (value_type == CAIRO_GOBJECT_TYPE_PATTERN ||
509 value_type == GTK_TYPE_GRADIENT);
512 g_return_if_fail (pspec->value_type == value_type);
515 prop = g_hash_table_lookup (priv->properties, pspec);
519 prop = property_data_new ();
520 g_hash_table_insert (priv->properties, pspec, prop);
523 val = property_data_get_value (prop, state);
525 if (G_VALUE_TYPE (val) == value_type)
529 if (G_IS_VALUE (val))
532 g_value_init (val, value_type);
535 g_value_copy (value, val);
539 * gtk_style_properties_set_property:
540 * @props: a #GtkStyleProperties
541 * @property: styling property to set
542 * @state: state to set the value for
543 * @value: new value for the property
545 * Sets a styling property in @props.
550 gtk_style_properties_set_property (GtkStyleProperties *props,
551 const gchar *property,
555 const GtkStyleProperty *node;
557 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
558 g_return_if_fail (property != NULL);
559 g_return_if_fail (value != NULL);
561 node = _gtk_style_property_lookup (property);
565 g_warning ("Style property \"%s\" is not registered", property);
569 _gtk_style_properties_set_property_by_pspec (props,
576 * gtk_style_properties_set_valist:
577 * @props: a #GtkStyleProperties
578 * @state: state to set the values for
579 * @args: va_list of property name/value pairs, followed by %NULL
581 * Sets several style properties on @props.
586 gtk_style_properties_set_valist (GtkStyleProperties *props,
590 GtkStylePropertiesPrivate *priv;
591 const gchar *property_name;
593 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
596 property_name = va_arg (args, const gchar *);
598 while (property_name)
600 const GtkStyleProperty *node;
605 node = _gtk_style_property_lookup (property_name);
609 g_warning ("Style property \"%s\" is not registered", property_name);
613 prop = g_hash_table_lookup (priv->properties, node->pspec);
617 prop = property_data_new ();
618 g_hash_table_insert (priv->properties, node->pspec, prop);
621 val = property_data_get_value (prop, state);
623 if (G_IS_VALUE (val))
626 G_VALUE_COLLECT_INIT (val, node->pspec->value_type,
630 g_warning ("Could not set style property \"%s\": %s", property_name, error);
636 property_name = va_arg (args, const gchar *);
641 * gtk_style_properties_set:
642 * @props: a #GtkStyleProperties
643 * @state: state to set the values for
644 * @...: property name/value pairs, followed by %NULL
646 * Sets several style properties on @props.
651 gtk_style_properties_set (GtkStyleProperties *props,
657 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
659 va_start (args, state);
660 gtk_style_properties_set_valist (props, state, args);
665 resolve_color (GtkStyleProperties *props,
670 /* Resolve symbolic color to GdkRGBA */
671 if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), props, &color))
674 /* Store it back, this is where GdkRGBA caching happens */
675 g_value_unset (value);
676 g_value_init (value, GDK_TYPE_RGBA);
677 g_value_set_boxed (value, &color);
683 resolve_color_rgb (GtkStyleProperties *props,
686 GdkColor color = { 0 };
689 if (!gtk_symbolic_color_resolve (g_value_get_boxed (value), props, &rgba))
692 color.red = rgba.red * 65535. + 0.5;
693 color.green = rgba.green * 65535. + 0.5;
694 color.blue = rgba.blue * 65535. + 0.5;
696 g_value_unset (value);
697 g_value_init (value, GDK_TYPE_COLOR);
698 g_value_set_boxed (value, &color);
704 resolve_gradient (GtkStyleProperties *props,
707 cairo_pattern_t *gradient;
709 if (!gtk_gradient_resolve (g_value_get_boxed (value), props, &gradient))
712 /* Store it back, this is where cairo_pattern_t caching happens */
713 g_value_unset (value);
714 g_value_init (value, CAIRO_GOBJECT_TYPE_PATTERN);
715 g_value_take_boxed (value, gradient);
721 resolve_shadow (GtkStyleProperties *props,
724 GtkShadow *resolved, *base;
726 base = g_value_get_boxed (value);
731 if (_gtk_shadow_get_resolved (base))
734 resolved = _gtk_shadow_resolve (base, props);
735 if (resolved == NULL)
738 g_value_take_boxed (value, resolved);
744 style_properties_resolve_type (GtkStyleProperties *props,
745 const GtkStyleProperty *node,
748 if (G_VALUE_TYPE (val) == GTK_TYPE_SYMBOLIC_COLOR)
750 if (node->pspec->value_type == GDK_TYPE_RGBA)
752 if (!resolve_color (props, val))
755 else if (node->pspec->value_type == GDK_TYPE_COLOR)
757 if (!resolve_color_rgb (props, val))
763 else if (G_VALUE_TYPE (val) == GTK_TYPE_GRADIENT)
765 g_return_val_if_fail (node->pspec->value_type == CAIRO_GOBJECT_TYPE_PATTERN, FALSE);
767 if (!resolve_gradient (props, val))
770 else if (G_VALUE_TYPE (val) == GTK_TYPE_SHADOW)
772 if (!resolve_shadow (props, val))
780 lookup_default_value (const GtkStyleProperty *node,
783 if (node->pspec->value_type == GTK_TYPE_THEMING_ENGINE)
784 g_value_set_object (value, gtk_theming_engine_load (NULL));
785 else if (node->pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
786 g_value_take_boxed (value, pango_font_description_from_string ("Sans 10"));
787 else if (node->pspec->value_type == GDK_TYPE_RGBA)
790 gdk_rgba_parse (&color, "pink");
791 g_value_set_boxed (value, &color);
793 else if (node->pspec->value_type == GTK_TYPE_BORDER)
795 g_value_take_boxed (value, gtk_border_new ());
798 g_param_value_set_default (node->pspec, value);
802 _gtk_style_properties_peek_property (GtkStyleProperties *props,
803 const gchar *prop_name,
805 const GtkStyleProperty **property)
807 GtkStylePropertiesPrivate *priv;
808 const GtkStyleProperty *node;
812 g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), NULL);
813 g_return_val_if_fail (prop_name != NULL, NULL);
815 node = _gtk_style_property_lookup (prop_name);
821 g_warning ("Style property \"%s\" is not registered", prop_name);
826 prop = g_hash_table_lookup (priv->properties, node->pspec);
831 val = property_data_match_state (prop, state);
834 !style_properties_resolve_type (props, node, val))
841 * gtk_style_properties_get_property:
842 * @props: a #GtkStyleProperties
843 * @property: style property name
844 * @state: state to retrieve the property value for
845 * @value: (out) (transfer full): return location for the style property value.
847 * Gets a style property from @props for the given state. When done with @value,
848 * g_value_unset() needs to be called to free any allocated memory.
850 * Returns: %TRUE if the property exists in @props, %FALSE otherwise
855 gtk_style_properties_get_property (GtkStyleProperties *props,
856 const gchar *property,
860 const GtkStyleProperty *node;
863 g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
864 g_return_val_if_fail (property != NULL, FALSE);
865 g_return_val_if_fail (value != NULL, FALSE);
867 val = _gtk_style_properties_peek_property (props, property, state, &node);
872 g_value_init (value, node->pspec->value_type);
876 g_value_copy (val, value);
877 g_param_value_validate (node->pspec, value);
880 lookup_default_value (node, value);
886 * gtk_style_properties_get_valist:
887 * @props: a #GtkStyleProperties
888 * @state: state to retrieve the property values for
889 * @args: va_list of property name/return location pairs, followed by %NULL
891 * Retrieves several style property values from @props for a given state.
896 gtk_style_properties_get_valist (GtkStyleProperties *props,
900 GtkStylePropertiesPrivate *priv;
901 const gchar *property_name;
903 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
906 property_name = va_arg (args, const gchar *);
908 while (property_name)
910 const GtkStyleProperty *node;
915 node = _gtk_style_property_lookup (property_name);
919 g_warning ("Style property \"%s\" is not registered", property_name);
923 prop = g_hash_table_lookup (priv->properties, node->pspec);
926 val = property_data_match_state (prop, state);
929 !style_properties_resolve_type (props, node, val))
934 g_param_value_validate (node->pspec, val);
935 G_VALUE_LCOPY (val, args, 0, &error);
939 GValue default_value = { 0 };
941 g_value_init (&default_value, node->pspec->value_type);
942 lookup_default_value (node, &default_value);
943 G_VALUE_LCOPY (&default_value, args, 0, &error);
944 g_value_unset (&default_value);
949 g_warning ("Could not get style property \"%s\": %s", property_name, error);
954 property_name = va_arg (args, const gchar *);
959 * gtk_style_properties_get:
960 * @props: a #GtkStyleProperties
961 * @state: state to retrieve the property values for
962 * @...: property name /return value pairs, followed by %NULL
964 * Retrieves several style property values from @props for a
970 gtk_style_properties_get (GtkStyleProperties *props,
976 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
978 va_start (args, state);
979 gtk_style_properties_get_valist (props, state, args);
984 * gtk_style_properties_unset_property:
985 * @props: a #GtkStyleProperties
986 * @property: property to unset
987 * @state: state to unset
989 * Unsets a style property in @props.
994 gtk_style_properties_unset_property (GtkStyleProperties *props,
995 const gchar *property,
998 GtkStylePropertiesPrivate *priv;
999 const GtkStyleProperty *node;
1003 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
1004 g_return_if_fail (property != NULL);
1006 node = _gtk_style_property_lookup (property);
1010 g_warning ("Style property \"%s\" is not registered", property);
1015 prop = g_hash_table_lookup (priv->properties, node->pspec);
1020 if (property_data_find_position (prop, state, &pos))
1024 data = &g_array_index (prop->values, ValueData, pos);
1026 if (G_IS_VALUE (&data->value))
1027 g_value_unset (&data->value);
1029 g_array_remove_index (prop->values, pos);
1034 * gtk_style_properties_clear:
1035 * @props: a #GtkStyleProperties
1037 * Clears all style information from @props.
1040 gtk_style_properties_clear (GtkStyleProperties *props)
1042 GtkStylePropertiesPrivate *priv;
1044 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
1047 g_hash_table_remove_all (priv->properties);
1051 * gtk_style_properties_merge:
1052 * @props: a #GtkStyleProperties
1053 * @props_to_merge: a second #GtkStyleProperties
1054 * @replace: whether to replace values or not
1056 * Merges into @props all the style information contained
1057 * in @props_to_merge. If @replace is %TRUE, the values
1058 * will be overwritten, if it is %FALSE, the older values
1064 gtk_style_properties_merge (GtkStyleProperties *props,
1065 const GtkStyleProperties *props_to_merge,
1068 GtkStylePropertiesPrivate *priv, *priv_to_merge;
1069 GHashTableIter iter;
1070 gpointer key, value;
1072 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
1073 g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props_to_merge));
1076 priv_to_merge = props_to_merge->priv;
1078 /* Merge symbolic color map */
1079 if (priv_to_merge->color_map)
1081 g_hash_table_iter_init (&iter, priv_to_merge->color_map);
1083 while (g_hash_table_iter_next (&iter, &key, &value))
1086 GtkSymbolicColor *color;
1092 g_hash_table_lookup (priv->color_map, name))
1095 gtk_style_properties_map_color (props, name, color);
1099 /* Merge symbolic style properties */
1100 g_hash_table_iter_init (&iter, priv_to_merge->properties);
1102 while (g_hash_table_iter_next (&iter, &key, &value))
1104 PropertyData *prop_to_merge = value;
1108 prop = g_hash_table_lookup (priv->properties, key);
1112 prop = property_data_new ();
1113 g_hash_table_insert (priv->properties, key, prop);
1116 for (i = 0; i < prop_to_merge->values->len; i++)
1121 data = &g_array_index (prop_to_merge->values, ValueData, i);
1123 if (replace && data->state == GTK_STATE_FLAG_NORMAL &&
1124 G_VALUE_TYPE (&data->value) != PANGO_TYPE_FONT_DESCRIPTION)
1126 /* Let normal state override all states
1127 * previously set in the original set
1129 property_data_remove_values (prop);
1132 value = property_data_get_value (prop, data->state);
1134 if (G_VALUE_TYPE (&data->value) == PANGO_TYPE_FONT_DESCRIPTION &&
1137 PangoFontDescription *font_desc;
1138 PangoFontDescription *font_desc_to_merge;
1140 /* Handle merging of font descriptions */
1141 font_desc = g_value_get_boxed (value);
1142 font_desc_to_merge = g_value_get_boxed (&data->value);
1144 pango_font_description_merge (font_desc, font_desc_to_merge, replace);
1146 else if (G_VALUE_TYPE (&data->value) == G_TYPE_PTR_ARRAY &&
1149 GPtrArray *array, *array_to_merge;
1152 /* Append the array, mainly thought
1153 * for the gtk-key-bindings property
1155 array = g_value_get_boxed (value);
1156 array_to_merge = g_value_get_boxed (&data->value);
1158 for (i = 0; i < array_to_merge->len; i++)
1159 g_ptr_array_add (array, g_ptr_array_index (array_to_merge, i));
1161 else if (replace || !G_IS_VALUE (value))
1163 if (!G_IS_VALUE (value))
1164 g_value_init (value, G_VALUE_TYPE (&data->value));
1165 else if (G_VALUE_TYPE (value) != G_VALUE_TYPE (&data->value))
1167 g_value_unset (value);
1168 g_value_init (value, G_VALUE_TYPE (&data->value));
1171 g_value_copy (&data->value, value);