From 997dd272496ef0071c227448a5320d42e437c421 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 24 Sep 2009 01:27:22 -0500 Subject: sort users --- src/users-service.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/users-service.c b/src/users-service.c index 9e940ed..1fb8d36 100644 --- a/src/users-service.c +++ b/src/users-service.c @@ -166,6 +166,16 @@ remove_menu_item (DbusmenuMenuitem *root, gpointer user_data) dbusmenu_menuitem_child_delete (root, child); } +static gint +compare_users_by_username (const gchar *a, + const gchar *b) +{ + UserData *user1 = (UserData *)a; + UserData *user2 = (UserData *)b; + + return g_strcmp0 (user1->user_name, user2->user_name); +} + static void rebuild_items (DbusmenuMenuitem *root, UsersServiceDbus *service) @@ -208,6 +218,8 @@ rebuild_items (DbusmenuMenuitem *root, users = users_service_dbus_get_user_list (service); } + users = g_list_sort (users, (GCompareFunc)compare_users_by_username); + for (u = users; u != NULL; u = g_list_next (u)) { user = u->data; -- cgit v1.2.3