summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-09-05 09:16:21 +0100
committerRichard Hughes <richard@hughsie.com>2016-09-05 09:57:56 +0100
commit0076c8b8b79faea1c435bf8c5c34b481a53733a2 (patch)
tree1cd8973b7a915fdc30479b88f9a60f1c4f4f14e2
parentdfe2de8965b9e0d9d5f18d374c712a0ac2b23e4f (diff)
downloadappstream-glib-0076c8b8b79faea1c435bf8c5c34b481a53733a2.tar.gz
Convert the built unknown icons to the correct kind depending on the action
For building we want ->CACHED, for parsing local files we want ->STOCK. Fixes the other half of https://github.com/hughsie/appstream-glib/pull/128
-rw-r--r--libappstream-builder/plugins/asb-plugin-desktop.c10
-rw-r--r--libappstream-glib/as-app-desktop.c3
-rw-r--r--libappstream-glib/as-store.c10
3 files changed, 21 insertions, 2 deletions
diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c
index 74ed620..628430d 100644
--- a/libappstream-builder/plugins/asb-plugin-desktop.c
+++ b/libappstream-builder/plugins/asb-plugin-desktop.c
@@ -176,7 +176,9 @@ asb_plugin_desktop_refine (AsbPlugin *plugin,
AsIcon *icon;
AsAppParseFlags parse_flags = AS_APP_PARSE_FLAG_USE_HEURISTICS |
AS_APP_PARSE_FLAG_ALLOW_VETO;
+ GPtrArray *icons;
gboolean ret;
+ guint i;
g_autoptr(AsApp) desktop_app = NULL;
g_autoptr(GdkPixbuf) pixbuf = NULL;
@@ -189,6 +191,14 @@ asb_plugin_desktop_refine (AsbPlugin *plugin,
if (!as_app_parse_file (desktop_app, filename, parse_flags, error))
return FALSE;
+ /* convert any UNKNOWN icons to CACHED */
+ icons = as_app_get_icons (AS_APP (desktop_app));
+ for (i = 0; i < icons->len; i++) {
+ icon = g_ptr_array_index (icons, i);
+ if (as_icon_get_kind (icon) == AS_ICON_KIND_UNKNOWN)
+ as_icon_set_kind (icon, AS_ICON_KIND_CACHED);
+ }
+
/* copy all metadata */
as_app_subsume_full (AS_APP (app), desktop_app,
AS_APP_SUBSUME_FLAG_NO_OVERWRITE |
diff --git a/libappstream-glib/as-app-desktop.c b/libappstream-glib/as-app-desktop.c
index 0852c55..0f78b5b 100644
--- a/libappstream-glib/as-app-desktop.c
+++ b/libappstream-glib/as-app-desktop.c
@@ -177,8 +177,7 @@ as_app_desktop_create_icon (AsApp *app, const gchar *name, AsAppParseFlags flags
return icon;
}
- /* just use default: FIXME, this is the wrong kind, use UNKNOWN */
- as_icon_set_kind (icon, AS_ICON_KIND_LOCAL);
+ /* just use default of UNKNOWN */
as_icon_set_name (icon, name_fixed);
return icon;
}
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 7ac5d2f..33278a8 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -2532,6 +2532,8 @@ as_store_load_installed (AsStore *store,
while ((tmp = g_dir_read_name (dir)) != NULL) {
AsApp *app_tmp;
+ GPtrArray *icons;
+ guint i;
g_autofree gchar *filename = NULL;
g_autoptr(AsApp) app = NULL;
filename = g_build_filename (path, tmp, NULL);
@@ -2562,6 +2564,14 @@ as_store_load_installed (AsStore *store,
return FALSE;
}
+ /* convert any UNKNOWN icons to LOCAL */
+ icons = as_app_get_icons (app);
+ for (i = 0; i < icons->len; i++) {
+ AsIcon *icon = g_ptr_array_index (icons, i);
+ if (as_icon_get_kind (icon) == AS_ICON_KIND_UNKNOWN)
+ as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+ }
+
/* don't match against non-package apps in the store */
if (scope == AS_APP_SCOPE_SYSTEM &&
g_str_has_prefix (path, "/usr/share")) {