diff options
author | Richard Hughes <richard@hughsie.com> | 2016-02-01 15:46:56 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-02-01 15:47:45 +0000 |
commit | 9bae8623a53f9e8628c99dbcd023b1909cf6ea32 (patch) | |
tree | b72a95a7e11ce4c7378e59f44e5aecec5f9bb9fe | |
parent | f0a450d7340b827e129509e516c245da00784d76 (diff) | |
download | appstream-glib-9bae8623a53f9e8628c99dbcd023b1909cf6ea32.tar.gz |
trivial: Prefer the xmls icon rule over the xdg-app one
-rw-r--r-- | libappstream-glib/as-self-test.c | 5 | ||||
-rw-r--r-- | libappstream-glib/as-store.c | 32 |
2 files changed, 22 insertions, 15 deletions
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 7142928..2aed741 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -2661,7 +2661,7 @@ as_test_store_embedded_func (void) g_assert (icon != NULL); g_assert_cmpint (as_icon_get_kind (icon), ==, AS_ICON_KIND_EMBEDDED); g_assert_cmpstr (as_icon_get_name (icon), ==, "eog.png"); - g_assert_cmpstr (as_icon_get_prefix (icon), ==, "/tmp/icons/origin"); + g_assert_cmpstr (as_icon_get_prefix (icon), ==, "/tmp/origin/icons"); /* convert back to a file */ xml = as_store_to_xml (store, AS_NODE_TO_XML_FLAG_NONE); @@ -3396,7 +3396,8 @@ as_test_store_origin_func (void) g_assert_cmpint (as_store_get_size (store), ==, 1); app = as_store_get_app_by_id (store, "test.desktop"); g_assert (app != NULL); - g_assert (g_str_has_suffix (as_app_get_icon_path (app), "icons/fedora-21")); + g_assert_cmpstr (as_app_get_icon_path (app), !=, NULL); + g_assert (g_str_has_suffix (as_app_get_icon_path (app), "icons")); g_assert_cmpstr (as_app_get_origin (app), ==, "fedora-21"); g_assert_cmpstr (as_app_get_source_file (app), ==, filename); } diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c index 683935f..a1674d1 100644 --- a/libappstream-glib/as-store.c +++ b/libappstream-glib/as-store.c @@ -917,22 +917,28 @@ as_store_from_root (AsStore *store, /* special case xdg-apps */ if (g_strcmp0 (priv->origin, "xdg-app") == 0) { origin_app = as_store_get_origin_for_xdg_app (source_filename); - g_debug ("using app origin of %s rather than 'xdg-app'", - origin_app); - icon_path = g_build_filename (icon_prefix, "icons", NULL); - } else if (icon_prefix != NULL && priv->origin != NULL) { - g_autofree gchar *dirname = NULL; - - /* look for ../icons/$origin */ - dirname = g_path_get_dirname (icon_prefix); - icon_path = g_build_filename (dirname, - "icons", - priv->origin, - NULL); + g_debug ("using app origin of '%s' rather than '%s'", + origin_app, priv->origin); + } else { origin_app = g_strdup (priv->origin); } - /* we can only guess the icon path after we've read the origin */ + /* guess the icon path after we've read the origin and then look for + * ../icons/$origin if the topdir is 'xmls', falling back to ./icons */ + if (icon_prefix != NULL) { + g_autofree gchar *topdir = NULL; + topdir = g_path_get_basename (icon_prefix); + if (g_strcmp0 (topdir, "xmls") == 0 && priv->origin != NULL) { + g_autofree gchar *dirname = NULL; + dirname = g_path_get_dirname (icon_prefix); + icon_path = g_build_filename (dirname, + "icons", + priv->origin, + NULL); + } else { + icon_path = g_build_filename (icon_prefix, "icons", NULL); + } + } g_debug ("using icon path %s", icon_path); /* set in the XML file */ |