summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2012-01-01 18:28:27 +0100
committerBenjamin Otte <otte@redhat.com>2012-01-09 18:37:53 +0100
commitb904679a111224039a92e6f50acd97f6218a2d3a (patch)
tree13a8766be3e403bec0a22e762461ea109af2ab6c /gtk
parent078fc725e0a83250ea7e1bf37dfc4f5f95b990c8 (diff)
downloadgtk+-b904679a111224039a92e6f50acd97f6218a2d3a.tar.gz
styleproperty: Move value printing to real properties
We can't print shorthands, so don't try. In particular, I want to get away from shorthands being representable using GValue, and this function kinda requires that.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcssprovider.c6
-rw-r--r--gtk/gtkcssstyleproperty.c40
-rw-r--r--gtk/gtkcssstylepropertyprivate.h4
-rw-r--r--gtk/gtkstyleproperty.c29
-rw-r--r--gtk/gtkstylepropertyprivate.h3
5 files changed, 47 insertions, 35 deletions
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index d25fba6a10..f24ef0d098 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -3282,13 +3282,13 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
for (walk = keys; walk; walk = walk->next)
{
- GtkStyleProperty *prop = walk->data;
+ GtkCssStyleProperty *prop = walk->data;
const PropertyValue *value = g_hash_table_lookup (ruleset->style, prop);
g_string_append (str, " ");
- g_string_append (str, _gtk_style_property_get_name (prop));
+ g_string_append (str, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
g_string_append (str, ": ");
- _gtk_style_property_print_value (prop, &value->value, str);
+ _gtk_css_style_property_print_value (prop, &value->value, str);
g_string_append (str, ";\n");
}
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c
index 66ce7ff020..da90227814 100644
--- a/gtk/gtkcssstyleproperty.c
+++ b/gtk/gtkcssstyleproperty.c
@@ -22,7 +22,10 @@
#include "gtkcssstylepropertyprivate.h"
+#include "gtkcssstylefuncsprivate.h"
+#include "gtkcsstypesprivate.h"
#include "gtkintl.h"
+#include "gtkprivatetypebuiltins.h"
enum {
PROP_0,
@@ -227,3 +230,40 @@ _gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property)
return &property->initial_value;
}
+/**
+ * _gtk_css_style_property_print_value:
+ * @property: the property
+ * @value: the value to print
+ * @string: the string to print to
+ *
+ * Prints @value to the given @string in CSS format. The @value must be a
+ * valid specified value as parsed using the parse functions or as assigned
+ * via _gtk_style_property_assign().
+ **/
+void
+_gtk_css_style_property_print_value (GtkCssStyleProperty *property,
+ const GValue *value,
+ GString *string)
+{
+ g_return_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property));
+ g_return_if_fail (value != NULL);
+ g_return_if_fail (string != NULL);
+
+ if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE))
+ {
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ enum_class = g_type_class_ref (GTK_TYPE_CSS_SPECIAL_VALUE);
+ enum_value = g_enum_get_value (enum_class, g_value_get_enum (value));
+
+ g_string_append (string, enum_value->value_nick);
+
+ g_type_class_unref (enum_class);
+ }
+ else if (GTK_STYLE_PROPERTY (property)->print_func)
+ (* GTK_STYLE_PROPERTY (property)->print_func) (value, string);
+ else
+ _gtk_css_style_print_value (value, string);
+}
+
diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h
index 32ab48dfdd..aba791c666 100644
--- a/gtk/gtkcssstylepropertyprivate.h
+++ b/gtk/gtkcssstylepropertyprivate.h
@@ -61,6 +61,10 @@ guint _gtk_css_style_property_get_id (GtkCssStyleProp
const GValue * _gtk_css_style_property_get_initial_value
(GtkCssStyleProperty *property);
+void _gtk_css_style_property_print_value (GtkCssStyleProperty *property,
+ const GValue *value,
+ GString *string);
+
G_END_DECLS
#endif /* __GTK_CSS_STYLE_PROPERTY_PRIVATE_H__ */
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 204e1e8d0d..25556a7fbc 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -201,22 +201,6 @@ string_append_string (GString *str,
/*** IMPLEMENTATIONS ***/
-static void
-enum_print (int value,
- GType type,
- GString *string)
-{
- GEnumClass *enum_class;
- GEnumValue *enum_value;
-
- enum_class = g_type_class_ref (type);
- enum_value = g_enum_get_value (enum_class, value);
-
- g_string_append (string, enum_value->value_nick);
-
- g_type_class_unref (enum_class);
-}
-
static gboolean
font_family_parse (GtkCssParser *parser,
GFile *base,
@@ -453,19 +437,6 @@ _gtk_style_property_parse_value (GtkStyleProperty *property,
return _gtk_css_style_parse_value (value, parser, base);
}
-void
-_gtk_style_property_print_value (GtkStyleProperty *property,
- const GValue *value,
- GString *string)
-{
- if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE))
- enum_print (g_value_get_enum (value), GTK_TYPE_CSS_SPECIAL_VALUE, string);
- else if (property && property->print_func)
- (* property->print_func) (value, string);
- else
- _gtk_css_style_print_value (value, string);
-}
-
static void
_gtk_style_property_default_value (GtkStyleProperty *property,
GtkStyleProperties *properties,
diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h
index e8d6e583d4..92c3fea180 100644
--- a/gtk/gtkstylepropertyprivate.h
+++ b/gtk/gtkstylepropertyprivate.h
@@ -95,9 +95,6 @@ gboolean _gtk_style_property_parse_value (GtkStyleProperty *
GValue *value,
GtkCssParser *parser,
GFile *base);
-void _gtk_style_property_print_value (GtkStyleProperty * property,
- const GValue *value,
- GString *string);
GType _gtk_style_property_get_value_type(GtkStyleProperty * property);
void _gtk_style_property_query (GtkStyleProperty * property,