summaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authordjcb <djcb@djcbsoftware.nl>2012-10-14 17:01:28 +0300
committerdjcb <djcb@djcbsoftware.nl>2012-10-14 17:01:28 +0300
commitf460d7c2414c7eea4cbc4af4fa1e4534781f0fe5 (patch)
tree89320d7b65034ea870ccc3c602b8087d2fd45b57 /toys
parent51f5f5ed5d6937d84a1d80018a49eb058ee828ac (diff)
* mu-widget-util.c: improve error reporting
Diffstat (limited to 'toys')
-rw-r--r--toys/mug/mu-widget-util.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/toys/mug/mu-widget-util.c b/toys/mug/mu-widget-util.c
index 32e527d..7af476a 100644
--- a/toys/mug/mu-widget-util.c
+++ b/toys/mug/mu-widget-util.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+** Copyright (C) 2011-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
@@ -30,7 +30,7 @@ second_guess_content_type (const char *ctype)
const char *orig, *subst;
} substtable [] = {
{"text", "text/plain"},
- {"image/pjpeg", "image/jpeg" }
+ {"image/pjpeg", "image/jpeg" }
};
for (i = 0; i != G_N_ELEMENTS(substtable); ++i)
@@ -45,27 +45,34 @@ get_icon_pixbuf_for_content_type (const char *ctype, size_t size)
{
GIcon *icon;
GdkPixbuf *pixbuf;
-
+ GError *err;
+
icon = g_content_type_get_icon (ctype);
pixbuf = NULL;
-
+ err = NULL;
+
/* based on a snippet from http://www.gtkforums.com/about4721.html */
if (G_IS_THEMED_ICON(icon)) {
gchar const * const *names;
names = g_themed_icon_get_names (G_THEMED_ICON(icon));
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
- *names, size, 0, NULL);
+ *names, size, 0, &err);
} else if (G_IS_FILE_ICON(icon)) {
GFile *icon_file;
- gchar *path;
+ gchar *path;
icon_file = g_file_icon_get_file (G_FILE_ICON(icon));
path = g_file_get_path (icon_file);
- pixbuf = gdk_pixbuf_new_from_file_at_size (path, size, size, NULL);
+ pixbuf = gdk_pixbuf_new_from_file_at_size (path, size, size, &err);
g_free (path);
g_object_unref(icon_file);
}
g_object_unref(icon);
-
+
+ if (err) {
+ g_warning ("error: %s\n", err->message);
+ g_clear_error (&err);
+ }
+
return pixbuf;
}
@@ -79,11 +86,9 @@ mu_widget_util_get_icon_pixbuf_for_content_type (const char *ctype, size_t size)
g_return_val_if_fail (size > 0, NULL);
pixbuf = get_icon_pixbuf_for_content_type (ctype, size);
- if (!pixbuf)
+ if (!pixbuf)
pixbuf = get_icon_pixbuf_for_content_type
- (second_guess_content_type (ctype), size);
-
+ (second_guess_content_type (ctype), size);
+
return pixbuf;
}
-
-