From cfe060300ff10557f8805eee176604095c48cc2d Mon Sep 17 00:00:00 2001 From: Vincent Untz Date: Thu, 2 Feb 2012 14:04:27 +0100 Subject: clock: Convert to GResource origin commits: https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=aa2895d https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=695d30c https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=00f9870 https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=9ade365 --- applets/clock/clock-utils.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'applets/clock/clock-utils.c') diff --git a/applets/clock/clock-utils.c b/applets/clock/clock-utils.c index 5b15fe5f..19cf74fe 100644 --- a/applets/clock/clock-utils.c +++ b/applets/clock/clock-utils.c @@ -128,8 +128,11 @@ clock_utils_display_help (GtkWidget *widget, } GdkPixbuf * -clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int height) +clock_utils_pixbuf_from_svg_resource_at_size (const char *resource, + int width, + int height) { + GInputStream *stream = NULL; RsvgHandle *handle = NULL; RsvgDimensionData svg_dimensions; GdkPixbuf *pixbuf = NULL; @@ -137,9 +140,16 @@ clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int heigh cairo_matrix_t matrix; cairo_t *cr = NULL; - handle = rsvg_handle_new_from_file (name, NULL); + stream = g_resources_open_stream (resource, 0, NULL); + if (!stream) + goto out; + + handle = rsvg_handle_new (); if (!handle) - return NULL; + goto out; + + if (!rsvg_handle_read_stream_sync (handle, stream, NULL, NULL)) + goto out; rsvg_handle_get_dimensions (handle, &svg_dimensions); @@ -155,7 +165,11 @@ clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int heigh pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height); cairo_surface_destroy (surface); - rsvg_handle_close (handle, NULL); +out: + if (handle) + rsvg_handle_close (handle, NULL); + if (stream) + g_object_unref (stream); return pixbuf; } -- cgit v1.2.1