summaryrefslogtreecommitdiff
path: root/gtk/gtkcssstyle.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-01-03 15:34:08 -0500
committerMatthias Clasen <mclasen@redhat.com>2016-01-03 15:36:48 -0500
commit2e921691d97c203e172cddd18aead9eb90904770 (patch)
tree1b520c89e048225fd5a2875e297f231a9743bd33 /gtk/gtkcssstyle.c
parentd0e648d4f67ae485727c0452921c18f7642b80de (diff)
downloadgtk+-2e921691d97c203e172cddd18aead9eb90904770.tar.gz
Redo CSS style printing
Drop the custom style printing implementation in gtkcssnode.c and instead reuse the existing gtk_css_style_print function, extending it a bit to suit our needs. Instead of computing values, just recognize initial values by having no CSS section. Also do away with the show-initial flag, and just always filter out initial values. The flag can come back when it is needed.
Diffstat (limited to 'gtk/gtkcssstyle.c')
-rw-r--r--gtk/gtkcssstyle.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index d577dc79d3..812c8dc75a 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -114,10 +114,11 @@ gtk_css_style_is_static (GtkCssStyle *style)
return GTK_CSS_STYLE_GET_CLASS (style)->is_static (style);
}
-
void
gtk_css_style_print (GtkCssStyle *style,
- GString *string)
+ GString *string,
+ guint indent,
+ gboolean skip_initial)
{
guint i;
@@ -126,18 +127,31 @@ gtk_css_style_print (GtkCssStyle *style,
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
{
- GtkCssSection *section = gtk_css_style_get_section (style, i);
- g_string_append (string, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (i))));
- g_string_append (string, ": ");
- _gtk_css_value_print (gtk_css_style_get_value (style, i), string);
- g_string_append (string, ";");
+ GtkCssSection *section;
+ GtkCssStyleProperty *prop;
+ GtkCssValue *value;
+ const char *name;
+
+ section = gtk_css_style_get_section (style, i);
+ if (!section && skip_initial)
+ continue;
+
+ prop = _gtk_css_style_property_lookup_by_id (i);
+ name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop));
+ value = gtk_css_style_get_value (style, i);
+
+ g_string_append_printf (string, "%*s%s: ", indent, "", name);
+ _gtk_css_value_print (value, string);
+ g_string_append_c (string, ';');
+
if (section)
{
g_string_append (string, " /* ");
_gtk_css_section_print (section, string);
g_string_append (string, " */");
}
- g_string_append (string, "\n");
+
+ g_string_append_c (string, '\n');
}
}
@@ -150,7 +164,7 @@ gtk_css_style_to_string (GtkCssStyle *style)
string = g_string_new ("");
- gtk_css_style_print (style, string);
+ gtk_css_style_print (style, string, 0, FALSE);
return g_string_free (string, FALSE);
}