From ee2d49de66b56e83ee069ff5edc66a145081ae02 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 16 Jun 2015 15:58:24 +0100 Subject: When building metadata with the use-fallback flag accept legacy icon names --- libappstream-glib/as-app-desktop.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'libappstream-glib/as-app-desktop.c') diff --git a/libappstream-glib/as-app-desktop.c b/libappstream-glib/as-app-desktop.c index f2b3690..cb7851c 100644 --- a/libappstream-glib/as-app-desktop.c +++ b/libappstream-glib/as-app-desktop.c @@ -97,6 +97,27 @@ as_app_infer_file_key (AsApp *app, return TRUE; } +/** + * _as_utils_is_stock_icon_name_fallback: + **/ +static gboolean +_as_utils_is_stock_icon_name_fallback (const gchar *name) +{ + guint i; + const gchar *names[] = { + "fedora-logo-sprite", + "gtk-preferences", + "hwinfo", + "trash-empty", + "utilities-log-viewer", + NULL }; + for (i = 0; names[i] != NULL; i++) { + if (g_strcmp0 (name, names[i]) == 0) + return TRUE; + } + return FALSE; +} + /** * as_app_parse_file_key: **/ @@ -104,6 +125,7 @@ static gboolean as_app_parse_file_key (AsApp *app, GKeyFile *kf, const gchar *key, + AsAppParseFlags flags, GError **error) { gchar *dot = NULL; @@ -152,6 +174,10 @@ as_app_parse_file_key (AsApp *app, if (as_utils_is_stock_icon_name (tmp)) { as_icon_set_name (icon, tmp, -1); as_icon_set_kind (icon, AS_ICON_KIND_STOCK); + } else if ((flags & AS_APP_PARSE_FLAG_USE_FALLBACKS) > 0 && + _as_utils_is_stock_icon_name_fallback (tmp)) { + as_icon_set_name (icon, tmp, -1); + as_icon_set_kind (icon, AS_ICON_KIND_STOCK); } else { as_icon_set_kind (icon, AS_ICON_KIND_LOCAL); } @@ -406,7 +432,7 @@ as_app_parse_desktop_file (AsApp *app, if (keys == NULL) return FALSE; for (i = 0; keys[i] != NULL; i++) { - if (!as_app_parse_file_key (app, kf, keys[i], error)) + if (!as_app_parse_file_key (app, kf, keys[i], flags, error)) return FALSE; if ((flags & AS_APP_PARSE_FLAG_USE_HEURISTICS) > 0) { if (!as_app_infer_file_key (app, kf, keys[i], error)) -- cgit v1.2.1