diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-08-16 18:57:21 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-08-16 22:05:38 -0400 |
commit | 7b4f82ccc6c180b809cd3b7b6582394ce741a14e (patch) | |
tree | 2dc9a7f459f5d4079caf53778b7d9614d89f287f /gtk/gtkicontheme.c | |
parent | 08042ea830da88aa192e3e8d99aa7af8863aeb16 (diff) | |
download | gtk+-7b4f82ccc6c180b809cd3b7b6582394ce741a14e.tar.gz |
Make symbolic icons work with the current rsvg
The rsvg loader now restricts what external files it will
allow to load from an svg. Thus our xinclude trick doesn't work
anymore. To work around that, embed the payload in a data: uri.
This is somewhat ugly, but the best we could come up with.
Diffstat (limited to 'gtk/gtkicontheme.c')
-rw-r--r-- | gtk/gtkicontheme.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 5d85fe92f5..7b9faf10b7 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -4128,7 +4128,9 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, gchar *css_warning; gchar *css_error; gchar *data; - gchar *width, *height, *uri; + gchar *width, *height; + gchar *file_data, *escaped_file_data; + gsize file_len; SymbolicPixbufCache *symbolic_cache; if (use_cache) @@ -4172,14 +4174,13 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, css_error = gdk_color_to_css (&error_default_color); } + if (!g_file_get_contents (icon_info->filename, &file_data, &file_len, NULL)) + return NULL; + if (!icon_info->symbolic_pixbuf_size) { - stream = G_INPUT_STREAM (g_file_read (icon_info->icon_file, NULL, error)); - - if (!stream) - return NULL; - /* Fetch size from the original icon */ + stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL); pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error); g_object_unref (stream); @@ -4194,7 +4195,9 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, width = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->width); height = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->height); - uri = g_file_get_uri (icon_info->icon_file); + + escaped_file_data = g_markup_escape_text (file_data, file_len); + g_free (file_data); data = g_strconcat ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" "<svg version=\"1.1\"\n" @@ -4216,16 +4219,16 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, " fill: ", css_success, " !important;\n" " }\n" " </style>\n" - " <xi:include href=\"", uri, "\"/>\n" + " <xi:include href=\"data:text/xml,", escaped_file_data, "\"/>\n" "</svg>", NULL); + g_free (escaped_file_data); g_free (css_fg); g_free (css_warning); g_free (css_error); g_free (css_success); g_free (width); g_free (height); - g_free (uri); stream = g_memory_input_stream_new_from_data (data, -1, g_free); pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, |