From 15468aef1b10907846c3a104c09ef4fb7addf9fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Jun 2011 16:13:43 -0500 Subject: Turning a directory into a bunch of idles loading status providers --- src/status-items.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/status-items.c b/src/status-items.c index e5e0d71..885b2a7 100644 --- a/src/status-items.c +++ b/src/status-items.c @@ -1,6 +1,7 @@ #include #include +#include #include #include "status-items.h" @@ -44,6 +45,7 @@ static const gchar * panel_active_icons[STATUS_PROVIDER_STATUS_LAST] = { /* Prototypes */ static gboolean provider_directory_parse (gpointer dir); +static gboolean load_status_provider (gpointer dir); /* Globals */ static StatusProviderStatus current_status = STATUS_PROVIDER_STATUS_DISCONNECTED; @@ -90,12 +92,33 @@ status_current_panel_icon (gboolean alert) static gboolean provider_directory_parse (gpointer directory) { - const gchar * dir = (const gchar *)directory; + const gchar * dirname = (const gchar *)directory; - if (!g_file_test(dir, G_FILE_TEST_EXISTS)) { + if (!g_file_test(dirname, G_FILE_TEST_EXISTS)) { return FALSE; } + GDir * dir = g_dir_open(dirname, 0, NULL); + if (dir == NULL) { + return FALSE; + } + + const gchar * name; + while ((name = g_dir_read_name(dir)) != NULL) { + gchar * fullname = g_build_filename(dirname, name, NULL); + g_idle_add(load_status_provider, fullname); + } + + g_dir_close(dir); return FALSE; } + +/* Load a particular status provider */ +static gboolean +load_status_provider (gpointer dir) +{ + gchar * provider = (gchar *)dir; + g_free(provider); + return FALSE; +} -- cgit v1.2.3