Commit cfa08841 authored by Matthias Clasen's avatar Matthias Clasen

Improve formatting of CSS style prints

Add a newline after CSS properties, so things don't run into
each other.
parent 12be432d
......@@ -1529,7 +1529,7 @@ gtk_css_node_print (GtkCssNode *cssnode,
GString *string,
guint indent)
{
GtkCssNode *node;
gboolean need_newline = FALSE;
g_string_append_printf (string, "%*s", indent, "");
......@@ -1544,10 +1544,15 @@ gtk_css_node_print (GtkCssNode *cssnode,
g_string_append_c (string, '\n');
if (flags & GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE)
gtk_css_style_print (gtk_css_node_get_style (cssnode), string, indent + 2, TRUE);
need_newline = gtk_css_style_print (gtk_css_node_get_style (cssnode), string, indent + 2, TRUE);
if (flags & GTK_STYLE_CONTEXT_PRINT_RECURSE)
{
GtkCssNode *node;
if (need_newline && gtk_css_node_get_first_child (cssnode))
g_string_append_c (string, '\n');
for (node = gtk_css_node_get_first_child (cssnode); node; node = gtk_css_node_get_next_sibling (node))
gtk_css_node_print (node, flags, string, indent + 2);
}
......
......@@ -114,13 +114,28 @@ gtk_css_style_is_static (GtkCssStyle *style)
return GTK_CSS_STYLE_GET_CLASS (style)->is_static (style);
}
void
/*
* gtk_css_style_print:
* @style: a #GtkCssStyle
* @string: the #GString to print to
* @indent: level of indentation to use
* @skip_initial: %TRUE to skip properties that have their initial value
*
* Print the @style to @string, in CSS format. Every property is printed
* on a line by itself, indented by @indent spaces. If @skip_initial is
* %TRUE, properties are only printed if their value in @style is different
* from the initial value of the property.
*
* Returns: %TRUE is any properties have been printed
*/
gboolean
gtk_css_style_print (GtkCssStyle *style,
GString *string,
guint indent,
gboolean skip_initial)
{
guint i;
gboolean retval = FALSE;
g_return_if_fail (GTK_IS_CSS_STYLE (style));
g_return_if_fail (string != NULL);
......@@ -152,7 +167,11 @@ gtk_css_style_print (GtkCssStyle *style,
}
g_string_append_c (string, '\n');
retval = TRUE;
}
return retval;
}
char *
......
......@@ -70,7 +70,7 @@ GtkBitmask * gtk_css_style_add_difference (GtkBitmask
gboolean gtk_css_style_is_static (GtkCssStyle *style);
char * gtk_css_style_to_string (GtkCssStyle *style);
void gtk_css_style_print (GtkCssStyle *style,
gboolean gtk_css_style_print (GtkCssStyle *style,
GString *string,
guint indent,
gboolean skip_initial);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment