Merge branch '1171-packagekit-icon-fixes' into 'master'
Resolve "gnome-software-40 Icons for packagekit and snap not loading"
Closes #1171
See merge request GNOME/gnome-software!653
Phaedrus Leeds
3 years ago
1827 | 1827 |
* lazily created. */
|
1828 | 1828 |
for (guint i = 0; priv->icons != NULL && i < priv->icons->len; i++) {
|
1829 | 1829 |
GIcon *icon = priv->icons->pdata[i];
|
|
1830 |
g_autofree gchar *icon_str = g_icon_to_string (icon);
|
1830 | 1831 |
guint icon_width = gs_icon_get_width (icon);
|
1831 | 1832 |
guint icon_scale = gs_icon_get_scale (icon);
|
1832 | 1833 |
|
1833 | |
g_debug ("\tConsidering icon of type %s, width %u×%u",
|
1834 | |
G_OBJECT_TYPE_NAME (icon), icon_width, icon_scale);
|
|
1834 |
g_debug ("\tConsidering icon of type %s (%s), width %u×%u",
|
|
1835 |
G_OBJECT_TYPE_NAME (icon), icon_str, icon_width, icon_scale);
|
1835 | 1836 |
|
1836 | 1837 |
/* Ignore icons with unknown width and skip over ones which
|
1837 | 1838 |
* are too small. */
|
199 | 199 |
{
|
200 | 200 |
const gchar *filename = as_icon_get_filename (icon);
|
201 | 201 |
const gchar *name = as_icon_get_name (icon);
|
|
202 |
g_autofree gchar *name_allocated = NULL;
|
202 | 203 |
g_autofree gchar *full_filename = NULL;
|
203 | 204 |
g_autoptr(GFile) file = NULL;
|
204 | 205 |
|
205 | 206 |
if (filename == NULL || name == NULL)
|
206 | 207 |
return NULL;
|
|
208 |
|
|
209 |
/* FIXME: Work around https://github.com/hughsie/appstream-glib/pull/390
|
|
210 |
* where appstream files generated with appstream-builder from
|
|
211 |
* appstream-glib, with its hidpi option enabled, will contain an
|
|
212 |
* unnecessary size subdirectory in the icon name. */
|
|
213 |
if (g_str_has_prefix (name, "64x64/"))
|
|
214 |
name = name_allocated = g_strdup (name + strlen ("64x64/"));
|
|
215 |
else if (g_str_has_prefix (name, "128x128/"))
|
|
216 |
name = name_allocated = g_strdup (name + strlen ("128x128/"));
|
207 | 217 |
|
208 | 218 |
if (!g_str_has_suffix (filename, name)) {
|
209 | 219 |
/* Spec: https://www.freedesktop.org/software/appstream/docs/sect-AppStream-IconCache.html#spec-iconcache-location */
|
148 | 148 |
default:
|
149 | 149 |
as_icon_set_name (icon, xb_node_get_text (n));
|
150 | 150 |
}
|
151 | |
if (sz == 0)
|
152 | |
sz = xb_node_get_attr_as_uint (n, "width");
|
|
151 |
if (sz == 0) {
|
|
152 |
guint64 width = xb_node_get_attr_as_uint (n, "width");
|
|
153 |
if (width > 0 && width < G_MAXUINT)
|
|
154 |
sz = width;
|
|
155 |
}
|
|
156 |
|
153 | 157 |
if (sz > 0) {
|
154 | 158 |
as_icon_set_width (icon, sz);
|
155 | 159 |
as_icon_set_height (icon, sz);
|