From cb771e5da44cda7b8fc6ca07be44aa1d5048660b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Mar 2011 15:04:33 -0600 Subject: Sort the launchers --- src/session-service.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/session-service.c') diff --git a/src/session-service.c b/src/session-service.c index 28284ff..c76865d 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -517,6 +517,28 @@ desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data) return; } +/* Look at the GAppInfo structures and sort based on + the application names */ +static gint +sort_app_infos (gconstpointer a, gconstpointer b) +{ + GAppInfo * appa = G_APP_INFO(a); + GAppInfo * appb = G_APP_INFO(b); + + const gchar * namea = NULL; + const gchar * nameb = NULL; + + if (appa != NULL) { + namea = g_app_info_get_name(appa); + } + + if (appb != NULL) { + nameb = g_app_info_get_name(appb); + } + + return g_strcmp0(namea, nameb); +} + static void add_extra_separator_once (DbusmenuMenuitem *menu) { @@ -749,6 +771,8 @@ rebuild_items (DbusmenuMenuitem *root, } g_dir_close(extra_launchers_dir); + launchers = g_list_sort(launchers, sort_app_infos); + GList * launcher = NULL; for (launcher = launchers; launcher != NULL; launcher = g_list_next(launcher)) { GAppInfo * appinfo = G_APP_INFO(launcher->data); -- cgit v1.2.3