[gtk/matthiasc/for-master: 2/2] Allow inserting newlines in css strings
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/2] Allow inserting newlines in css strings
- Date: Sat, 3 Oct 2020 03:40:27 +0000 (UTC)
commit a9809b0f67d71cd7bfb1815d368a1fdfd1b3ba8b
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 2 22:31:29 2020 -0400
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.
gsk/gskrendernodeparser.c | 2 +-
gtk/css/gtkcssserializer.c | 10 +++++++---
gtk/css/gtkcssserializerprivate.h | 5 +++--
gtk/gtkcssimageicontheme.c | 2 +-
gtk/gtkcssstringvalue.c | 2 +-
5 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c
index 06d1bdb4d2..c07b749bf6 100644
--- a/gsk/gskrendernodeparser.c
+++ b/gsk/gskrendernodeparser.c
@@ -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');
}
diff --git a/gtk/css/gtkcssserializer.c b/gtk/css/gtkcssserializer.c
index 838a7fb3f4..d939f38cb6 100644
--- a/gtk/css/gtkcssserializer.c
+++ b/gtk/css/gtkcssserializer.c
@@ -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 ");
diff --git a/gtk/css/gtkcssserializerprivate.h b/gtk/css/gtkcssserializerprivate.h
index 2d1a16949f..86f9934faa 100644
--- a/gtk/css/gtkcssserializerprivate.h
+++ b/gtk/css/gtkcssserializerprivate.h
@@ -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
diff --git a/gtk/gtkcssimageicontheme.c b/gtk/gtkcssimageicontheme.c
index debde7ee00..109b0abd83 100644
--- a/gtk/gtkcssimageicontheme.c
+++ b/gtk/gtkcssimageicontheme.c
@@ -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, ")");
}
diff --git a/gtk/gtkcssstringvalue.c b/gtk/gtkcssstringvalue.c
index 269a86e717..b72427de11 100644
--- a/gtk/gtkcssstringvalue.c
+++ b/gtk/gtkcssstringvalue.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]