Allow inserting newlines in css strings

Rename _gtk_css_print_string to strip the _ and add
an insert_newlines argument to it. Update all callers,
and make the render node serializer insert newlines.
This commit is contained in:
Matthias Clasen 2020-10-02 22:31:29 -04:00
parent 9033336a23
commit a9809b0f67
5 changed files with 13 additions and 8 deletions

View File

@ -2126,7 +2126,7 @@ append_string_param (Printer *p,
{
_indent (p);
g_string_append_printf (p->str, "%s: ", param_name);
_gtk_css_print_string (p->str, value);
gtk_css_print_string (p->str, value, TRUE);
g_string_append_c (p->str, ';');
g_string_append_c (p->str, '\n');
}

View File

@ -23,8 +23,9 @@
* as a css string again.
*/
void
_gtk_css_print_string (GString *str,
const char *string)
gtk_css_print_string (GString *str,
const char *string,
gboolean multiline)
{
gsize len;
@ -42,7 +43,10 @@ _gtk_css_print_string (GString *str,
case '\0':
goto out;
case '\n':
g_string_append (str, "\\A ");
if (multiline)
g_string_append (str, "\\A\\\n");
else
g_string_append (str, "\\A ");
break;
case '\r':
g_string_append (str, "\\D ");

View File

@ -25,8 +25,9 @@
G_BEGIN_DECLS
void _gtk_css_print_string (GString *str,
const char *string);
void gtk_css_print_string (GString *str,
const char *string,
gboolean multiline);
G_END_DECLS

View File

@ -133,7 +133,7 @@ gtk_css_image_icon_theme_print (GtkCssImage *image,
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
g_string_append (string, "-gtk-icontheme(");
_gtk_css_print_string (string, icon_theme->name);
gtk_css_print_string (string, icon_theme->name, FALSE);
g_string_append (string, ")");
}

View File

@ -70,7 +70,7 @@ gtk_css_value_string_print (const GtkCssValue *value,
return;
}
_gtk_css_print_string (str, value->string);
gtk_css_print_string (str, value->string, FALSE);
}
static void