Codebase list gnome-software / b70f65a
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
3 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
18271827 * lazily created. */
18281828 for (guint i = 0; priv->icons != NULL && i < priv->icons->len; i++) {
18291829 GIcon *icon = priv->icons->pdata[i];
1830 g_autofree gchar *icon_str = g_icon_to_string (icon);
18301831 guint icon_width = gs_icon_get_width (icon);
18311832 guint icon_scale = gs_icon_get_scale (icon);
18321833
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);
18351836
18361837 /* Ignore icons with unknown width and skip over ones which
18371838 * are too small. */
199199 {
200200 const gchar *filename = as_icon_get_filename (icon);
201201 const gchar *name = as_icon_get_name (icon);
202 g_autofree gchar *name_allocated = NULL;
202203 g_autofree gchar *full_filename = NULL;
203204 g_autoptr(GFile) file = NULL;
204205
205206 if (filename == NULL || name == NULL)
206207 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/"));
207217
208218 if (!g_str_has_suffix (filename, name)) {
209219 /* Spec: https://www.freedesktop.org/software/appstream/docs/sect-AppStream-IconCache.html#spec-iconcache-location */
148148 default:
149149 as_icon_set_name (icon, xb_node_get_text (n));
150150 }
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
153157 if (sz > 0) {
154158 as_icon_set_width (icon, sz);
155159 as_icon_set_height (icon, sz);