From 1d5da7c094ae4d9ed4e827be7ddae1ef4e3fa967 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 15 Oct 2020 16:39:34 +0100 Subject: [PATCH] libmalcontent-ui: Adjust the app list sort to be more stable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This doesn’t achieve anything by itself, but makes some upcoming commits to diff the new/old app lists work properly. Signed-off-by: Philip Withnall Helps: #18, #28 --- libmalcontent-ui/restrict-applications-selector.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libmalcontent-ui/restrict-applications-selector.c b/libmalcontent-ui/restrict-applications-selector.c index ef55d9f..4be7c07 100644 --- a/libmalcontent-ui/restrict-applications-selector.c +++ b/libmalcontent-ui/restrict-applications-selector.c @@ -372,6 +372,7 @@ app_compare_id_length_cb (gconstpointer a, { GAppInfo *info_a = (GAppInfo *) a, *info_b = (GAppInfo *) b; const gchar *id_a, *id_b; + gsize id_a_len, id_b_len; id_a = g_app_info_get_id (info_a); id_b = g_app_info_get_id (info_b); @@ -383,7 +384,12 @@ app_compare_id_length_cb (gconstpointer a, else if (id_b == NULL) return 1; - return strlen (id_a) - strlen (id_b); + id_a_len = strlen (id_a); + id_b_len = strlen (id_b); + if (id_a_len == id_b_len) + return strcmp (id_a, id_b); + else + return id_a_len - id_b_len; } static void