diff options
author | Christian Persch <chpe@gnome.org> | 2012-01-12 23:26:39 +0100 |
---|---|---|
committer | Christian Persch <chpe@gnome.org> | 2012-01-13 00:08:40 +0100 |
commit | 80391e1019fa1a938aefef61eab27dca94bce2a2 (patch) | |
tree | 470205fbb27b548e5045867ad30f3bd7515b4a9b | |
parent | 4f2c17460b1239ffd69dc5c2d9554112e620657f (diff) | |
download | librsvg-80391e1019fa1a938aefef61eab27dca94bce2a2.tar.gz |
rsvg-view: Re-implement .svgz support
-rw-r--r-- | test-display.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test-display.c b/test-display.c index a71ad0f7..1676fa3f 100644 --- a/test-display.c +++ b/test-display.c @@ -616,6 +616,8 @@ main (int argc, char **argv) gboolean keep_aspect_ratio = FALSE; char *id = NULL; GInputStream *input; + GFileInfo *file_info; + gboolean compressed; GFile *file, *base_file; cairo_surface_t *surface; @@ -697,6 +699,8 @@ main (int argc, char **argv) "Reading from stdin not supported"); #endif base_file = NULL; + + compressed = FALSE; } else { file = g_file_new_for_commandline_arg (args[0]); input = (GInputStream *) g_file_read (file, NULL, &err); @@ -706,6 +710,21 @@ main (int argc, char **argv) else base_file = g_object_ref (file); + if ((file_info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, + G_FILE_QUERY_INFO_NONE, + NULL, + NULL))) { + const char *content_type; + char *gz_content_type; + + content_type = g_file_info_get_content_type (file_info); + gz_content_type = g_content_type_from_mime_type ("application/x-gzip"); + compressed = (content_type != NULL && g_content_type_is_a (content_type, gz_content_type)); + g_free (gz_content_type); + g_object_unref (file_info); + } + g_object_unref (file); } @@ -717,6 +736,16 @@ main (int argc, char **argv) return 1; } + if (compressed) { + GZlibDecompressor *decompressor; + GInputStream *converter_stream; + + decompressor = g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP); + converter_stream = g_converter_input_stream_new (input, G_CONVERTER (decompressor)); + g_object_unref (input); + input = converter_stream; + } + info.base_uri = base_file ? g_file_get_uri (base_file) : g_strdup (""); info.id = id; info.x_zoom = x_zoom; @@ -732,7 +761,6 @@ main (int argc, char **argv) if (info.handle == NULL) { g_printerr ("Failed to load SVG: %s\n", err->message); g_error_free (err); - g_object_unref (info.handle); return 1; } |