From e36075a13c2e270b9a240032f8fca244614d6367 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 8 Aug 2009 06:04:11 -0600 Subject: Brining in the concept of global status --- src/status-service.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/status-service.c') diff --git a/src/status-service.c b/src/status-service.c index 4c48c72..3f25c4f 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -67,6 +67,27 @@ static DbusmenuMenuitem * root_menuitem = NULL; static DbusmenuMenuitem * status_menuitem = NULL; static GMainLoop * mainloop = NULL; static StatusServiceDbus * dbus_interface = NULL; +static StatusProviderStatus global_status = STATUS_PROVIDER_STATUS_OFFLINE; + +static void +status_update (void) { + StatusProviderStatus oldglobal = global_status; + global_status = STATUS_PROVIDER_STATUS_ONLINE; + + int i; + for (i = 0; i < STATUS_PROVIDER_CNT; i++) { + StatusProviderStatus localstatus = status_provider_get_status(status_providers[i]); + if (localstatus > global_status) { + global_status = localstatus; + } + } + + if (global_status != oldglobal) { + g_debug("Global status changed to: %s", _(status_strings[global_status])); + } + + return; +} /* A fun little function to actually lock the screen. If, that's what you want, let's do it! */ -- cgit v1.2.3 From 0788baad4bd4714e8361a99150046ba4fdb4513a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 8 Aug 2009 06:24:04 -0600 Subject: Global status being used and thrown over d' bus --- src/status-service.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/status-service.c') diff --git a/src/status-service.c b/src/status-service.c index 3f25c4f..c1f06f5 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -84,6 +84,9 @@ status_update (void) { if (global_status != oldglobal) { g_debug("Global status changed to: %s", _(status_strings[global_status])); + + dbusmenu_menuitem_property_set(status_menuitem, "label", _(status_strings[global_status])); + status_service_dbus_set_status(dbus_interface, status_icons[global_status]); } return; @@ -175,7 +178,7 @@ build_menu (gpointer data) build_user_item(root); status_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(status_menuitem, "label", "Status"); + dbusmenu_menuitem_property_set(status_menuitem, "label", _(status_strings[global_status])); dbusmenu_menuitem_child_append(root, status_menuitem); StatusProviderStatus i; -- cgit v1.2.3 From 255ccc8a16afc58cd56bca5880a706ac494c00ba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 8 Aug 2009 06:33:22 -0600 Subject: Setting up signal handlers for the signal changing. We still ask everyone, they better cache a value :) --- src/status-service.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/status-service.c') diff --git a/src/status-service.c b/src/status-service.c index c1f06f5..0c7b7b2 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -138,8 +138,14 @@ build_providers (gpointer data) int i; for (i = 0; i < STATUS_PROVIDER_CNT; i++) { status_providers[i] = status_provider_newfuncs[i](); + + if (status_providers[i] != NULL) { + g_signal_connect(G_OBJECT(status_providers[i]), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, G_CALLBACK(status_update), NULL); + } } + status_update(); + return FALSE; } -- cgit v1.2.3 From 77c213e6d61847659df1271312e7398c696f9015 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 8 Aug 2009 06:46:28 -0600 Subject: Adding unistd.h header --- src/status-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/status-service.c') diff --git a/src/status-service.c b/src/status-service.c index 0c7b7b2..5a9d9b5 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -23,6 +23,7 @@ with this program. If not, see . #include #include +#include #include -- cgit v1.2.3