diff options
author | Richard Hughes <richard@hughsie.com> | 2015-06-24 11:59:03 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-06-24 12:00:52 +0100 |
commit | 4142ee9b0c0e736debf2a3d64d2972fb3b949285 (patch) | |
tree | 83c7aabb3ab55ee1af6b22dd14a95f60164ec8c2 | |
parent | b3763a9348ff169c3cd4c3fd48394fe4be29de29 (diff) | |
download | appstream-glib-4142ee9b0c0e736debf2a3d64d2972fb3b949285.tar.gz |
Sort multiple <icon> entries by name
This keeps the logs consistent.
-rw-r--r-- | libappstream-glib/as-app.c | 12 | ||||
-rw-r--r-- | libappstream-glib/as-self-test.c | 7 |
2 files changed, 16 insertions, 3 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index 6cf7653..8dbd814 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -2995,6 +2995,17 @@ as_app_releases_sort_cb (gconstpointer a, gconstpointer b) } /** + * as_app_icons_sort_cb: + **/ +static gint +as_app_icons_sort_cb (gconstpointer a, gconstpointer b) +{ + AsIcon **ic1 = (AsIcon **) a; + AsIcon **ic2 = (AsIcon **) b; + return g_strcmp0 (as_icon_get_name (*ic1), as_icon_get_name (*ic2)); +} + +/** * as_app_list_sort_cb: **/ static gint @@ -3191,6 +3202,7 @@ as_app_node_insert (AsApp *app, GNode *parent, AsNodeContext *ctx) } /* <icon> */ + g_ptr_array_sort (priv->icons, as_app_icons_sort_cb); for (i = 0; i < priv->icons->len; i++) { AsIcon *ic = g_ptr_array_index (priv->icons, i); as_icon_node_insert (ic, node_app, ctx); diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 27004a0..74ddc43 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -852,7 +852,8 @@ as_test_app_func (void) "<developer_name>GNOME Foundation</developer_name>\n" "<description><p>Software allows you to find stuff</p></description>\n" "<description xml:lang=\"pt_BR\"><p>O aplicativo Software.</p></description>\n" - "<icon height=\"64\" width=\"64\" type=\"cached\">org.gnome.Software.png</icon>\n" + "<icon height=\"64\" width=\"64\" type=\"cached\">org.gnome.Software1.png</icon>\n" + "<icon height=\"64\" width=\"64\" type=\"cached\">org.gnome.Software2.png</icon>\n" "<categories>\n" "<category>System</category>\n" "</categories>\n" @@ -951,7 +952,7 @@ as_test_app_func (void) /* check icons */ icons = as_app_get_icons (app); g_assert (icons != NULL); - g_assert_cmpint (icons->len, ==, 1); + g_assert_cmpint (icons->len, ==, 2); /* check bundle */ bu = as_app_get_bundle_default (app); @@ -964,7 +965,7 @@ as_test_app_func (void) g_assert (ic == NULL); ic = as_app_get_icon_for_size (app, 64, 64); g_assert (ic != NULL); - g_assert_cmpstr (as_icon_get_name (ic), ==, "org.gnome.Software.png"); + g_assert_cmpstr (as_icon_get_name (ic), ==, "org.gnome.Software1.png"); g_assert_cmpint (as_icon_get_kind (ic), ==, AS_ICON_KIND_CACHED); /* we can't extend ourself */ |