* mu-widget-util.c: improve error reporting
This commit is contained in:
@ -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
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -45,27 +45,34 @@ get_icon_pixbuf_for_content_type (const char *ctype, size_t size)
|
|||||||
{
|
{
|
||||||
GIcon *icon;
|
GIcon *icon;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
GError *err;
|
||||||
|
|
||||||
icon = g_content_type_get_icon (ctype);
|
icon = g_content_type_get_icon (ctype);
|
||||||
pixbuf = NULL;
|
pixbuf = NULL;
|
||||||
|
err = NULL;
|
||||||
|
|
||||||
/* based on a snippet from http://www.gtkforums.com/about4721.html */
|
/* based on a snippet from http://www.gtkforums.com/about4721.html */
|
||||||
if (G_IS_THEMED_ICON(icon)) {
|
if (G_IS_THEMED_ICON(icon)) {
|
||||||
gchar const * const *names;
|
gchar const * const *names;
|
||||||
names = g_themed_icon_get_names (G_THEMED_ICON(icon));
|
names = g_themed_icon_get_names (G_THEMED_ICON(icon));
|
||||||
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default(),
|
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)) {
|
} else if (G_IS_FILE_ICON(icon)) {
|
||||||
GFile *icon_file;
|
GFile *icon_file;
|
||||||
gchar *path;
|
gchar *path;
|
||||||
icon_file = g_file_icon_get_file (G_FILE_ICON(icon));
|
icon_file = g_file_icon_get_file (G_FILE_ICON(icon));
|
||||||
path = g_file_get_path (icon_file);
|
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_free (path);
|
||||||
g_object_unref(icon_file);
|
g_object_unref(icon_file);
|
||||||
}
|
}
|
||||||
g_object_unref(icon);
|
g_object_unref(icon);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
g_warning ("error: %s\n", err->message);
|
||||||
|
g_clear_error (&err);
|
||||||
|
}
|
||||||
|
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,5 +92,3 @@ mu_widget_util_get_icon_pixbuf_for_content_type (const char *ctype, size_t size)
|
|||||||
|
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user