[gtk+/wip/resources] Ensure we can load images via resource:// uris from CSS
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/resources] Ensure we can load images via resource:// uris from CSS
- Date: Mon, 16 Jan 2012 10:19:20 +0000 (UTC)
commit 6e3cdda731eba8c2ad9f87ae9f44964982558ff2
Author: Alexander Larsson <alexl redhat com>
Date: Mon Jan 16 11:18:42 2012 +0100
Ensure we can load images via resource:// uris from CSS
gtk/gtkcssimageurl.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c
index cc0509f..3593b34 100644
--- a/gtk/gtkcssimageurl.c
+++ b/gtk/gtkcssimageurl.c
@@ -64,6 +64,7 @@ gtk_css_parse_url (GtkCssParser *parser,
GFile *base)
{
gchar *path;
+ char *scheme;
GFile *file;
if (_gtk_css_parser_try (parser, "url", FALSE))
@@ -98,6 +99,15 @@ gtk_css_parse_url (GtkCssParser *parser,
g_free (path);
return NULL;
}
+
+ scheme = g_uri_parse_scheme (path);
+ if (scheme != NULL)
+ {
+ file = g_file_new_for_uri (path);
+ g_free (path);
+ g_free (scheme);
+ return file;
+ }
}
else
{
@@ -123,19 +133,25 @@ gtk_css_image_url_parse (GtkCssImage *image,
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
GdkPixbuf *pixbuf;
GFile *file;
- char *path;
cairo_t *cr;
GError *error = NULL;
+ GFileInputStream *input;
file = gtk_css_parse_url (parser, base);
if (file == NULL)
return FALSE;
- path = g_file_get_path (file);
+ input = g_file_read (file, NULL, &error);
+ if (input == NULL)
+ {
+ _gtk_css_parser_take_error (parser, error);
+ return FALSE;
+ }
g_object_unref (file);
- pixbuf = gdk_pixbuf_new_from_file (path, &error);
- g_free (path);
+ pixbuf = gdk_pixbuf_new_from_stream (G_INPUT_STREAM (input), NULL, &error);
+ g_object_unref (input);
+
if (pixbuf == NULL)
{
_gtk_css_parser_take_error (parser, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]