summaryrefslogtreecommitdiff
path: root/applets/clock/clock-utils.c
diff options
context:
space:
mode:
authorVincent Untz <[email protected]>2012-02-02 14:04:27 +0100
committerraveit65 <[email protected]>2018-04-26 13:01:37 +0200
commitcfe060300ff10557f8805eee176604095c48cc2d (patch)
treec52c7f5d23819a981635089f021a9de032461c14 /applets/clock/clock-utils.c
parentc61d3711954a959ebc7c957ac4f39c8ca3b783e9 (diff)
downloadmate-panel-cfe060300ff10557f8805eee176604095c48cc2d.tar.bz2
mate-panel-cfe060300ff10557f8805eee176604095c48cc2d.tar.xz
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
Diffstat (limited to 'applets/clock/clock-utils.c')
-rw-r--r--applets/clock/clock-utils.c22
1 files changed, 18 insertions, 4 deletions
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;
}