[gtk+/wip/cssvalue: 73/142] cssstyleproperty: Make assign_value a vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 73/142] cssstyleproperty: Make assign_value a vfunc
- Date: Sat, 7 Apr 2012 19:52:30 +0000 (UTC)
commit 219dce066e50e64c52e85f48ed40144bd09543ac
Author: Benjamin Otte <otte redhat com>
Date: Wed Mar 28 06:20:47 2012 +0200
cssstyleproperty: Make assign_value a vfunc
gtk/gtkcssstyleproperty.c | 9 +++-
gtk/gtkcssstylepropertyimpl.c | 76 ++++++++++++++++++++++++++++++++++++++
gtk/gtkcssstylepropertyprivate.h | 3 +
3 files changed, 86 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index 338f256..05a80f0 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -109,9 +109,14 @@ _gtk_css_style_property_assign (GtkStyleProperty *property,
GtkStateFlags state,
const GValue *value)
{
- GtkCssValue *css_value = _gtk_css_value_new_from_gvalue (value);
+ GtkCssStyleProperty *style;
+ GtkCssValue *css_value;
+
+ style = GTK_CSS_STYLE_PROPERTY (property);
+ css_value = style->assign_value (style, value);
+
_gtk_style_properties_set_property_by_property (props,
- GTK_CSS_STYLE_PROPERTY (property),
+ style,
state,
css_value);
_gtk_css_value_unref (css_value);
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 517f320..a5a8125 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -61,6 +61,7 @@ gtk_css_style_property_register (const char * name,
GtkCssStylePropertyPrintFunc print_value,
GtkCssStylePropertyComputeFunc compute_value,
GtkCssStylePropertyQueryFunc query_value,
+ GtkCssStylePropertyAssignFunc assign_value,
GtkCssStylePropertyEqualFunc equal_func,
GtkCssValue * initial_value)
{
@@ -69,6 +70,7 @@ gtk_css_style_property_register (const char * name,
g_assert (initial_value != NULL);
g_assert (parse_value != NULL);
g_assert (value_type == G_TYPE_NONE || query_value != NULL);
+ g_assert (value_type == G_TYPE_NONE || assign_value != NULL);
node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
"value-type", value_type,
@@ -83,6 +85,7 @@ gtk_css_style_property_register (const char * name,
if (compute_value)
node->compute_value = compute_value;
node->query_value = query_value;
+ node->assign_value = assign_value;
if (equal_func)
node->equal_func = equal_func;
@@ -138,6 +141,13 @@ query_simple (GtkCssStyleProperty *property,
_gtk_css_value_init_gvalue (css_value, value);
}
+static GtkCssValue *
+assign_simple (GtkCssStyleProperty *property,
+ const GValue *value)
+{
+ return _gtk_css_value_new_from_gvalue (value);
+}
+
static void
query_length_as_int (GtkCssStyleProperty *property,
const GtkCssValue *css_value,
@@ -148,6 +158,13 @@ query_length_as_int (GtkCssStyleProperty *property,
}
static GtkCssValue *
+assign_length_from_int (GtkCssStyleProperty *property,
+ const GValue *value)
+{
+ return _gtk_css_number_value_new (g_value_get_int (value), GTK_CSS_PX);
+}
+
+static GtkCssValue *
color_parse (GtkCssStyleProperty *property,
GtkCssParser *parser,
GFile *base)
@@ -553,6 +570,14 @@ css_image_value_query (GtkCssStyleProperty *property,
}
static GtkCssValue *
+css_image_value_assign (GtkCssStyleProperty *property,
+ const GValue *value)
+{
+ g_warning ("FIXME: assigning images is not implemented");
+ return _gtk_css_value_new_take_image (NULL);
+}
+
+static GtkCssValue *
font_size_parse (GtkCssStyleProperty *property,
GtkCssParser *parser,
GFile *base)
@@ -1129,6 +1154,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
color_compute,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (1, 1, 1, 1)));
@@ -1139,6 +1165,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_double (10.0));
@@ -1151,6 +1178,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
color_compute,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_new_rgba (0, 0, 0, 0)));
@@ -1162,6 +1190,7 @@ _gtk_css_style_property_init_properties (void)
font_family_value_print,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_strv (g_strdupv (default_font_family)));
gtk_css_style_property_register ("font-style",
@@ -1171,6 +1200,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_enum (PANGO_TYPE_STYLE,
PANGO_STYLE_NORMAL));
@@ -1181,6 +1211,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_enum (PANGO_TYPE_VARIANT,
PANGO_VARIANT_NORMAL));
@@ -1192,6 +1223,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_enum (PANGO_TYPE_WEIGHT,
PANGO_WEIGHT_NORMAL));
@@ -1204,6 +1236,7 @@ _gtk_css_style_property_init_properties (void)
shadow_value_compute,
NULL,
NULL,
+ NULL,
_gtk_css_shadow_value_new_none ());
gtk_css_style_property_register ("icon-shadow",
@@ -1214,6 +1247,7 @@ _gtk_css_style_property_init_properties (void)
shadow_value_compute,
NULL,
NULL,
+ NULL,
_gtk_css_shadow_value_new_none ());
gtk_css_style_property_register ("box-shadow",
@@ -1224,6 +1258,7 @@ _gtk_css_style_property_init_properties (void)
shadow_value_compute,
NULL,
NULL,
+ NULL,
_gtk_css_shadow_value_new_none ());
gtk_css_style_property_register ("margin-top",
@@ -1233,6 +1268,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_margin,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("margin-left",
@@ -1242,6 +1278,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_margin,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("margin-bottom",
@@ -1251,6 +1288,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_margin,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("margin-right",
@@ -1260,6 +1298,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_margin,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-top",
@@ -1269,6 +1308,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_padding,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-left",
@@ -1278,6 +1318,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_padding,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-bottom",
@@ -1287,6 +1328,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_padding,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("padding-right",
@@ -1296,6 +1338,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_padding,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
/* IMPORTANT: compute_border_width() requires that the border-width
@@ -1308,6 +1351,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_style (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-top-width",
@@ -1317,6 +1361,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_border_width,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("border-left-style",
@@ -1326,6 +1371,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_style (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-left-width",
@@ -1335,6 +1381,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_border_width,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("border-bottom-style",
@@ -1344,6 +1391,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_style (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-bottom-width",
@@ -1353,6 +1401,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_border_width,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("border-right-style",
@@ -1362,6 +1411,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_style (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("border-right-width",
@@ -1371,6 +1421,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_border_width,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
@@ -1381,6 +1432,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_print,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
gtk_css_style_property_register ("border-top-right-radius",
@@ -1390,6 +1442,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_print,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
gtk_css_style_property_register ("border-bottom-right-radius",
@@ -1399,6 +1452,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_print,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
gtk_css_style_property_register ("border-bottom-left-radius",
@@ -1408,6 +1462,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_print,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_corner_radius (&no_corner_radius));
@@ -1418,6 +1473,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_style (GTK_BORDER_STYLE_NONE));
gtk_css_style_property_register ("outline-width",
@@ -1427,6 +1483,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
compute_border_width,
query_length_as_int,
+ assign_length_from_int,
NULL,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
gtk_css_style_property_register ("outline-offset",
@@ -1436,6 +1493,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_int (0));
@@ -1446,6 +1504,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_enum (GTK_TYPE_CSS_AREA, GTK_CSS_AREA_BORDER_BOX));
gtk_css_style_property_register ("background-origin",
@@ -1455,6 +1514,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_enum (GTK_TYPE_CSS_AREA, GTK_CSS_AREA_PADDING_BOX));
gtk_css_style_property_register ("background-size",
@@ -1465,6 +1525,7 @@ _gtk_css_style_property_init_properties (void)
background_size_compute,
NULL,
NULL,
+ NULL,
_gtk_css_value_new_from_background_size (&default_background_size));
gtk_css_style_property_register ("background-position",
G_TYPE_NONE,
@@ -1474,6 +1535,7 @@ _gtk_css_style_property_init_properties (void)
background_position_compute,
NULL,
NULL,
+ NULL,
_gtk_css_value_new_from_background_position (&default_background_position));
gtk_css_style_property_register ("border-top-color",
@@ -1483,6 +1545,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
color_compute,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
@@ -1494,6 +1557,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
color_compute,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
@@ -1505,6 +1569,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
color_compute,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
@@ -1516,6 +1581,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
color_compute,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
@@ -1527,6 +1593,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
color_compute,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_symbolic_color (
gtk_symbolic_color_ref (
@@ -1539,6 +1606,7 @@ _gtk_css_style_property_init_properties (void)
background_repeat_value_print,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_enum (GTK_TYPE_CSS_BACKGROUND_REPEAT,
GTK_CSS_BACKGROUND_REPEAT |
@@ -1550,6 +1618,7 @@ _gtk_css_style_property_init_properties (void)
css_image_value_print,
css_image_value_compute,
css_image_value_query,
+ css_image_value_assign,
NULL,
_gtk_css_value_new_take_image (NULL));
@@ -1560,6 +1629,7 @@ _gtk_css_style_property_init_properties (void)
css_image_value_print,
css_image_value_compute,
css_image_value_query,
+ css_image_value_assign,
NULL,
_gtk_css_value_new_take_image (NULL));
gtk_css_style_property_register ("border-image-repeat",
@@ -1569,6 +1639,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_border_image_repeat (&border_image_repeat));
@@ -1580,6 +1651,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_boxed (GTK_TYPE_BORDER, &border_of_ones));
gtk_css_style_property_register ("border-image-width",
@@ -1589,6 +1661,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_boxed (GTK_TYPE_BORDER, NULL));
gtk_css_style_property_register ("engine",
@@ -1598,6 +1671,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_theming_engine (gtk_theming_engine_load (NULL)));
gtk_css_style_property_register ("transition",
@@ -1607,6 +1681,7 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_from_boxed (GTK_TYPE_ANIMATION_DESCRIPTION, NULL));
@@ -1618,6 +1693,7 @@ _gtk_css_style_property_init_properties (void)
bindings_value_print,
NULL,
query_simple,
+ assign_simple,
NULL,
_gtk_css_value_new_take_binding_sets (NULL));
}
diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h
index f16ece4..b17d2fa 100644
--- a/gtk/gtkcssstylepropertyprivate.h
+++ b/gtk/gtkcssstylepropertyprivate.h
@@ -46,6 +46,8 @@ typedef GtkCssValue * (* GtkCssStylePropertyComputeFunc)(GtkCssStyleProperty
typedef void (* GtkCssStylePropertyQueryFunc) (GtkCssStyleProperty *property,
const GtkCssValue *cssvalue,
GValue *value);
+typedef GtkCssValue * (* GtkCssStylePropertyAssignFunc) (GtkCssStyleProperty *property,
+ const GValue *value);
typedef gboolean (* GtkCssStylePropertyEqualFunc) (GtkCssStyleProperty *property,
GtkCssValue *value1,
GtkCssValue *value2);
@@ -61,6 +63,7 @@ struct _GtkCssStyleProperty
GtkCssStylePropertyPrintFunc print_value;
GtkCssStylePropertyComputeFunc compute_value;
GtkCssStylePropertyQueryFunc query_value;
+ GtkCssStylePropertyAssignFunc assign_value;
GtkCssStylePropertyEqualFunc equal_func;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]