[gdm/for-gnome-40: 7/9] libgdm: Sort session list
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/for-gnome-40: 7/9] libgdm: Sort session list
- Date: Fri, 23 Jul 2021 15:01:09 +0000 (UTC)
commit 0fbf361f36aee02ed8c2b3b3f9c19abe02855fc6
Author: Ray Strode <rstrode redhat com>
Date: Tue Jul 20 13:36:45 2021 -0400
libgdm: Sort session list
Right now the session list comes out in hash table order.
This commit changes the code to sort by description.
libgdm/gdm-sessions.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index 75d442eeb..a13225050 100644
--- a/libgdm/gdm-sessions.c
+++ b/libgdm/gdm-sessions.c
@@ -306,6 +306,23 @@ out:
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:
*
@@ -338,6 +355,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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]