Better warnings for failed icons
As the get_pixbuf_from_file should retrieve a file's content, it shouldn't fail silently, if the file isn't there. For codepaths, which don't use the `icon_path` to search for a given icon, it gives a clearer error message.
This commit is contained in:
parent
ae370e7289
commit
8399ef2d7c
15
src/icon.c
15
src/icon.c
@ -60,17 +60,15 @@ cairo_surface_t *gdk_pixbuf_to_cairo_surface(GdkPixbuf *pixbuf)
|
|||||||
|
|
||||||
GdkPixbuf *get_pixbuf_from_file(const char *filename)
|
GdkPixbuf *get_pixbuf_from_file(const char *filename)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf = NULL;
|
|
||||||
char *path = string_to_path(g_strdup(filename));
|
char *path = string_to_path(g_strdup(filename));
|
||||||
|
|
||||||
if (is_readable_file(path)) {
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
pixbuf = gdk_pixbuf_new_from_file(path, &error);
|
|
||||||
if (!pixbuf) {
|
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &error);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
LOG_W("%s", error->message);
|
LOG_W("%s", error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_free(path);
|
g_free(path);
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
@ -106,6 +104,7 @@ GdkPixbuf *get_pixbuf_from_icon(const char *iconname)
|
|||||||
|
|
||||||
for (const char **suf = suffixes; *suf; suf++) {
|
for (const char **suf = suffixes; *suf; suf++) {
|
||||||
maybe_icon_path = g_strconcat(current_folder, "/", iconname, *suf, NULL);
|
maybe_icon_path = g_strconcat(current_folder, "/", iconname, *suf, NULL);
|
||||||
|
if (is_readable_file(maybe_icon_path))
|
||||||
pixbuf = get_pixbuf_from_file(maybe_icon_path);
|
pixbuf = get_pixbuf_from_file(maybe_icon_path);
|
||||||
g_free(maybe_icon_path);
|
g_free(maybe_icon_path);
|
||||||
|
|
||||||
@ -119,9 +118,9 @@ GdkPixbuf *get_pixbuf_from_icon(const char *iconname)
|
|||||||
|
|
||||||
start = end + 1;
|
start = end + 1;
|
||||||
} while (*(end) != '\0');
|
} while (*(end) != '\0');
|
||||||
}
|
|
||||||
if (!pixbuf)
|
if (!pixbuf)
|
||||||
LOG_W("No icon found for: '%s'", iconname);
|
LOG_W("No icon found in path: '%s'", iconname);
|
||||||
|
}
|
||||||
|
|
||||||
g_free(uri_path);
|
g_free(uri_path);
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user