summaryrefslogtreecommitdiff
path: root/libgdm
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2021-07-20 13:36:45 -0400
committerRay Strode <rstrode@redhat.com>2021-07-22 13:33:18 -0400
commitae81d9bdd1e378598cf805c84af4313f8e10b3ed (patch)
treebc29f48c6e34a022692f6d5a736632610b2165b2 /libgdm
parent04853a3b8c17712cc7f74c3c405ef47af53151c1 (diff)
downloadgdm-ae81d9bdd1e378598cf805c84af4313f8e10b3ed.tar.gz
libgdm: Sort session list
Right now the session list comes out in hash table order. This commit changes the code to sort by description.
Diffstat (limited to 'libgdm')
-rw-r--r--libgdm/gdm-sessions.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index 97ed5ef3..f078e04b 100644
--- a/libgdm/gdm-sessions.c
+++ b/libgdm/gdm-sessions.c
@@ -338,6 +338,23 @@ collect_sessions (void)
names_seen_before);
}
+static gint
+compare_session_ids (gconstpointer a,
+ gconstpointer b)
+{
+ GdmSessionFile *session_a, *session_b;
+ session_a = (GdmSessionFile *) g_hash_table_lookup (gdm_available_sessions_map, a);
+ session_b = (GdmSessionFile *) g_hash_table_lookup (gdm_available_sessions_map, b);
+
+ if (session_a == NULL)
+ return -1;
+
+ if (session_b == NULL)
+ return 1;
+
+ return g_strcmp0 (session_a->translated_name, session_b->translated_name);
+}
+
/**
* gdm_get_session_ids:
*
@@ -370,6 +387,8 @@ gdm_get_session_ids (void)
}
g_ptr_array_add (array, NULL);
+ g_ptr_array_sort (array, compare_session_ids);
+
return (char **) g_ptr_array_free (array, FALSE);
}