diff options
author | Richard Hughes <richard@hughsie.com> | 2015-06-29 15:52:13 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-06-29 15:52:13 +0100 |
commit | 52502ba9bcf4aaa68f660814a83244f88d5b32a4 (patch) | |
tree | f8bc06cbdd0e7d74b6a79b5c10a833b31523b8fe | |
parent | 8073a2a5ce77915842522542c7eda97a9fdf620e (diff) | |
download | appstream-glib-52502ba9bcf4aaa68f660814a83244f88d5b32a4.tar.gz |
Search harder when using AS_ICON_LOAD_FLAG_SEARCH_SIZE
Fixes https://github.com/hughsie/appstream-glib/issues/55
-rw-r--r-- | libappstream-glib/as-icon.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/libappstream-glib/as-icon.c b/libappstream-glib/as-icon.c index fcab31a..41dd8d8 100644 --- a/libappstream-glib/as-icon.c +++ b/libappstream-glib/as-icon.c @@ -742,8 +742,6 @@ as_icon_load (AsIcon *icon, AsIconLoadFlags flags, GError **error) { AsIconPrivate *priv = GET_PRIVATE (icon); _cleanup_free_ gchar *fn_fallback = NULL; - _cleanup_free_ gchar *fn_size = NULL; - _cleanup_free_ gchar *size_str = NULL; _cleanup_object_unref_ GdkPixbuf *pixbuf = NULL; /* absolute filename */ @@ -778,14 +776,21 @@ as_icon_load (AsIcon *icon, AsIconLoadFlags flags, GError **error) /* try getting a pixbuf of the right size */ if (flags & AS_ICON_LOAD_FLAG_SEARCH_SIZE) { - size_str = g_strdup_printf ("%ix%i", priv->width, priv->height); - fn_size = g_build_filename (priv->prefix, size_str, priv->name, NULL); - if (g_file_test (fn_size, G_FILE_TEST_EXISTS)) { - pixbuf = gdk_pixbuf_new_from_file (fn_size, error); - if (pixbuf == NULL) - return FALSE; - as_icon_set_pixbuf (icon, pixbuf); - return TRUE; + guint widths[] = { priv->width, 64, 128, 0 }; + guint height[] = { priv->height, 64, 128, 0 }; + guint i; + for (i = 0; widths[i] != 0; i++) { + _cleanup_free_ gchar *fn_size = NULL; + _cleanup_free_ gchar *size_str = NULL; + size_str = g_strdup_printf ("%ix%i", widths[i], height[i]); + fn_size = g_build_filename (priv->prefix, size_str, priv->name, NULL); + if (g_file_test (fn_size, G_FILE_TEST_EXISTS)) { + pixbuf = gdk_pixbuf_new_from_file (fn_size, error); + if (pixbuf == NULL) + return FALSE; + as_icon_set_pixbuf (icon, pixbuf); + return TRUE; + } } } |