mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
Improve formatting of CSS style prints
Add a newline after CSS properties, so things don't run into each other.
This commit is contained in:
parent
12be432df7
commit
cfa0884165
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user