[gnome-color-manager] Do not use gtk_image_set_from_file() as we want to see the error if it fails
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Do not use gtk_image_set_from_file() as we want to see the error if it fails
- Date: Tue, 12 Feb 2013 12:27:59 +0000 (UTC)
commit 9b05534e3d0073a0c09fdb14f656fc000cf035b3
Author: Richard Hughes <richard hughsie com>
Date: Tue Feb 12 12:25:50 2013 +0000
Do not use gtk_image_set_from_file() as we want to see the error if it fails
src/gcm-viewer.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index 9b366d9..ce1868c 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -124,9 +124,24 @@ static void
gcm_viewer_set_example_image (GcmViewerPrivate *viewer, GtkImage *image)
{
gchar *filename;
- filename = g_strdup_printf ("%s/figures/viewer-example-%02i.png", GCM_DATA, viewer->example_index);
- gtk_image_set_from_file (image, filename);
+ gchar *path;
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+
+ filename = g_strdup_printf ("viewer-example-%02i.png", viewer->example_index);
+ path = g_build_filename (GCM_DATA, "figures", filename, NULL);
+ pixbuf = gdk_pixbuf_new_from_file (path, &error);
+ if (pixbuf == NULL) {
+ g_warning ("failed to load %s: %s", filename, error->message);
+ g_error_free (error);
+ goto out;
+ }
+ gtk_image_set_from_pixbuf (image, pixbuf);
+out:
g_free (filename);
+ g_free (path);
+ if (pixbuf != NULL)
+ g_object_unref (pixbuf);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]