From 99e399e52380dfff192fce779c57c71c82b2f7cd Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 6 Aug 2007 08:57:25 +0000 Subject: [PATCH] set the base URI so that librsvg can resolve relative paths. 2007-08-06 Sven Neumann * plug-ins/common/svg.c (load_rsvg_pixbuf): set the base URI so that librsvg can resolve relative paths. svn path=/trunk/; revision=23122 --- ChangeLog | 5 +++++ plug-ins/common/svg.c | 23 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee88811056..72fcb83a69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-08-06 Sven Neumann + + * plug-ins/common/svg.c (load_rsvg_pixbuf): set the base URI so + that librsvg can resolve relative paths. + 2007-08-05 Sven Neumann * configure.in: don't build linux-input controller module if diff --git a/plug-ins/common/svg.c b/plug-ins/common/svg.c index 997f792030..aefd472e2c 100644 --- a/plug-ins/common/svg.c +++ b/plug-ins/common/svg.c @@ -314,6 +314,7 @@ load_image (const gchar *filename) GError *error = NULL; pixbuf = load_rsvg_pixbuf (filename, &load_vals, &error); + if (!pixbuf) { /* Do not rely on librsvg setting GError on failure! */ @@ -421,6 +422,7 @@ load_rsvg_pixbuf (const gchar *filename, GdkPixbuf *pixbuf = NULL; RsvgHandle *handle; GIOChannel *io; + gchar *uri; GIOStatus status = G_IO_STATUS_NORMAL; gboolean success = TRUE; @@ -432,6 +434,19 @@ load_rsvg_pixbuf (const gchar *filename, handle = load_rsvg_handle_new (vals->resolution, vals->resolution); + /* set the base URI so that librsvg can resolve relative paths */ + uri = g_filename_to_uri (filename, NULL, NULL); + if (uri) + { + gchar *p = strrchr (uri, '/'); + + if (p) + *p = '\0'; + + rsvg_handle_set_base_uri (handle, uri); + g_free (uri); + } + rsvg_handle_set_size_callback (handle, load_set_size_callback, vals, NULL); while (success && status != G_IO_STATUS_EOF) @@ -672,8 +687,12 @@ load_dialog (const gchar *filename) gboolean run; GError *error = NULL; - SvgLoadVals vals = { SVG_DEFAULT_RESOLUTION, - - SVG_PREVIEW_SIZE, - SVG_PREVIEW_SIZE }; + SvgLoadVals vals = + { + SVG_DEFAULT_RESOLUTION, + - SVG_PREVIEW_SIZE, + - SVG_PREVIEW_SIZE + }; preview = load_rsvg_pixbuf (filename, &vals, &error);