[gdm/for-gnome-40: 12/14] libgdm: Sort session list




commit 304acc15802e8e739a1961ee96fec5b2ceb2f809
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]