summaryrefslogtreecommitdiff
path: root/gtk/gtkcssparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/gtkcssparser.c')
-rw-r--r--gtk/gtkcssparser.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c
index a136466ee5..fc6dc3e95a 100644
--- a/gtk/gtkcssparser.c
+++ b/gtk/gtkcssparser.c
@@ -917,6 +917,62 @@ _gtk_css_parser_read_symbolic_color (GtkCssParser *parser)
return NULL;
}
+GFile *
+_gtk_css_parser_read_url (GtkCssParser *parser,
+ GFile *base)
+{
+ gchar *path;
+ GFile *file;
+
+ if (_gtk_css_parser_try (parser, "url", FALSE))
+ {
+ if (!_gtk_css_parser_try (parser, "(", TRUE))
+ {
+ _gtk_css_parser_skip_whitespace (parser);
+ if (_gtk_css_parser_try (parser, "(", TRUE))
+ {
+ GError *error;
+
+ error = g_error_new_literal (GTK_CSS_PROVIDER_ERROR,
+ GTK_CSS_PROVIDER_ERROR_DEPRECATED,
+ "Whitespace between 'url' and '(' is deprecated");
+
+ _gtk_css_parser_take_error (parser, error);
+ }
+ else
+ {
+ _gtk_css_parser_error (parser, "Expected '(' after 'url'");
+ return NULL;
+ }
+ }
+
+ path = _gtk_css_parser_read_string (parser);
+ if (path == NULL)
+ return NULL;
+
+ if (!_gtk_css_parser_try (parser, ")", TRUE))
+ {
+ _gtk_css_parser_error (parser, "No closing ')' found for 'url'");
+ g_free (path);
+ return NULL;
+ }
+ }
+ else
+ {
+ path = _gtk_css_parser_try_name (parser, TRUE);
+ if (path == NULL)
+ {
+ _gtk_css_parser_error (parser, "Not a valid url");
+ return NULL;
+ }
+ }
+
+ file = g_file_resolve_relative_path (base, path);
+ g_free (path);
+
+ return file;
+}
+
void
_gtk_css_parser_resync_internal (GtkCssParser *parser,
gboolean sync_at_semicolon,