From 24cd5919a5de12b2309ba6f9fa48f402e3d2ae11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 19 Aug 2009 16:47:04 -0500 Subject: Go through the launchers and start building items --- src/messages-service.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index 93c926b..ce3fcdb 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -30,9 +30,11 @@ with this program. If not, see . #include "app-menu-item.h" #include "launcher-menu-item.h" #include "dbus-data.h" +#include "dirs.h" static IndicateListener * listener; -static GList * serverList; +static GList * serverList = NULL; +static GList * launcherList = NULL; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; @@ -489,9 +491,29 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server, gboolean build_launchers (gpointer data) { + if (!g_file_test(SYSTEM_APPS_DIR, G_FILE_TEST_IS_DIR)) { + return FALSE; + } + GError * error = NULL; + GDir * dir = g_dir_open(SYSTEM_APPS_DIR, 0, &error); + if (dir == NULL) { + g_warning("Unable to open system apps directory: %s", error->message); + g_error_free(error); + return FALSE; + } + const gchar * filename = NULL; + while ((filename = g_dir_read_name(dir)) != NULL) { + gchar * path = g_build_filename(SYSTEM_APPS_DIR, filename, NULL); + launcherList_t * ll = g_new0(launcherList_t, 1); + ll->menuitem = launcher_menu_item_new(path); + g_free(path); + launcherList = g_list_append(launcherList, ll); + } + g_dir_close(dir); + launcherList = g_list_sort(launcherList, launcherList_sort); return FALSE; } -- cgit v1.2.3