diff options
author | Ted Gould <ted@canonical.com> | 2009-09-10 12:10:07 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-09-10 12:10:07 -0500 |
commit | 935d113e94596808eb0db0cf1719905b68c237d3 (patch) | |
tree | 12bc3a045eab116728a14a0ecfc8126a0a510d44 /src/status-service.c | |
parent | 3211a5e810fbbe830a237127092d221018f4f6a2 (diff) | |
download | ayatana-indicator-session-935d113e94596808eb0db0cf1719905b68c237d3.tar.gz ayatana-indicator-session-935d113e94596808eb0db0cf1719905b68c237d3.tar.bz2 ayatana-indicator-session-935d113e94596808eb0db0cf1719905b68c237d3.zip |
Adding in a disconnected status value and making it so that when it is the global status we should make the menu items to set status insensitive.
Diffstat (limited to 'src/status-service.c')
-rw-r--r-- | src/status-service.c | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/src/status-service.c b/src/status-service.c index b210dcd..195529b 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -55,7 +55,8 @@ static const gchar * status_strings [STATUS_PROVIDER_STATUS_LAST] = { /* STATUS_PROVIDER_STATUS_AWAY, */ N_("Away"), /* STATUS_PROVIDER_STATUS_DND */ N_("Busy"), /* STATUS_PROVIDER_STATUS_INVISIBLE */ N_("Invisible"), - /* STATUS_PROVIDER_STATUS_OFFLINE, */ N_("Offline") + /* STATUS_PROVIDER_STATUS_OFFLINE, */ N_("Offline"), + /* STATUS_PROVIDER_STATUS_DISCONNECTED*/ N_("Offline") }; static const gchar * status_icons[STATUS_PROVIDER_STATUS_LAST] = { @@ -63,21 +64,25 @@ static const gchar * status_icons[STATUS_PROVIDER_STATUS_LAST] = { /* STATUS_PROVIDER_STATUS_AWAY, */ "user-away", /* STATUS_PROVIDER_STATUS_DND, */ "user-busy", /* STATUS_PROVIDER_STATUS_INVISIBLE, */ "user-invisible", - /* STATUS_PROVIDER_STATUS_OFFLINE */ "user-offline" + /* STATUS_PROVIDER_STATUS_OFFLINE */ "user-offline", + /* STATUS_PROVIDER_STATUS_DISCONNECTED */"user-offline" }; static DbusmenuMenuitem * root_menuitem = NULL; static DbusmenuMenuitem * status_menuitem = NULL; +static DbusmenuMenuitem * status_menuitems[STATUS_PROVIDER_STATUS_LAST] = {0}; static GMainLoop * mainloop = NULL; static StatusServiceDbus * dbus_interface = NULL; -static StatusProviderStatus global_status = STATUS_PROVIDER_STATUS_OFFLINE; +static StatusProviderStatus global_status = STATUS_PROVIDER_STATUS_DISCONNECTED; static void status_update (void) { StatusProviderStatus oldglobal = global_status; - global_status = STATUS_PROVIDER_STATUS_OFFLINE; + global_status = STATUS_PROVIDER_STATUS_DISCONNECTED; + /* Ask everyone what they think the status should be, if + they're more connected, up the global level */ int i; for (i = 0; i < STATUS_PROVIDER_CNT; i++) { StatusProviderStatus localstatus = status_provider_get_status(status_providers[i]); @@ -86,11 +91,34 @@ status_update (void) { } } + /* If changed */ if (global_status != oldglobal) { g_debug("Global status changed to: %s", _(status_strings[global_status])); + /* Set the status name on the menu item */ dbusmenu_menuitem_property_set(status_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(status_strings[global_status])); + /* Configure the icon on the panel */ status_service_dbus_set_status(dbus_interface, status_icons[global_status]); + + /* If we're now disconnected, make setting the statuses + insensitive. */ + if (global_status == STATUS_PROVIDER_STATUS_DISCONNECTED) { + StatusProviderStatus i; + for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_LAST; i++) { + if (status_menuitems[i] == NULL) continue; + dbusmenu_menuitem_property_set(status_menuitems[i], DBUSMENU_MENUITEM_PROP_SENSITIVE, "false"); + } + } + + /* If we're now back to a state where we have an IM client + connected then we need to resensitize the items. */ + if (oldglobal == STATUS_PROVIDER_STATUS_DISCONNECTED) { + StatusProviderStatus i; + for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_LAST; i++) { + if (status_menuitems[i] == NULL) continue; + dbusmenu_menuitem_property_set(status_menuitems[i], DBUSMENU_MENUITEM_PROP_SENSITIVE, "true"); + } + } } return; @@ -195,14 +223,21 @@ build_menu (gpointer data) StatusProviderStatus i; for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_LAST; i++) { - DbusmenuMenuitem * mi = dbusmenu_menuitem_new(); + if (i == STATUS_PROVIDER_STATUS_DISCONNECTED) { + /* We don't want an item for the disconnected status. Users + can't set that value through the menu :) */ + continue; + } + + status_menuitems[i] = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(mi, "type", DBUSMENU_CLIENT_TYPES_IMAGE); - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _(status_strings[i])); - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_ICON, status_icons[i]); - g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(status_menu_click), GINT_TO_POINTER(i)); + dbusmenu_menuitem_property_set(status_menuitems[i], "type", DBUSMENU_CLIENT_TYPES_IMAGE); + dbusmenu_menuitem_property_set(status_menuitems[i], DBUSMENU_MENUITEM_PROP_LABEL, _(status_strings[i])); + dbusmenu_menuitem_property_set(status_menuitems[i], DBUSMENU_MENUITEM_PROP_ICON, status_icons[i]); + dbusmenu_menuitem_property_set(status_menuitems[i], DBUSMENU_MENUITEM_PROP_SENSITIVE, "false"); + g_signal_connect(G_OBJECT(status_menuitems[i]), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(status_menu_click), GINT_TO_POINTER(i)); - dbusmenu_menuitem_child_append(status_menuitem, mi); + dbusmenu_menuitem_child_append(status_menuitem, status_menuitems[i]); g_debug("Built %s", status_strings[i]); } |