aboutsummaryrefslogtreecommitdiff
path: root/src/status-service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/status-service.c')
-rw-r--r--src/status-service.c98
1 files changed, 54 insertions, 44 deletions
diff --git a/src/status-service.c b/src/status-service.c
index 542317a..247726b 100644
--- a/src/status-service.c
+++ b/src/status-service.c
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <sys/types.h>
#include <pwd.h>
@@ -55,29 +56,34 @@ 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] = {
- /* STATUS_PROVIDER_STATUS_ONLINE, */ "user-online",
+ /* STATUS_PROVIDER_STATUS_ONLINE, */ "user-available",
/* 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,39 +92,33 @@ status_update (void) {
}
}
+ /* If changed */
if (global_status != oldglobal) {
g_debug("Global status changed to: %s", _(status_strings[global_status]));
- 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]);
- }
-
- return;
-}
-
-/* A fun little function to actually lock the screen. If,
- that's what you want, let's do it! */
-static void
-lock_screen (DbusmenuMenuitem * mi, gpointer data)
-{
- g_debug("Lock Screen");
-
- DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- g_return_if_fail(session_bus != NULL);
-
- DBusGProxy * proxy = dbus_g_proxy_new_for_name_owner(session_bus,
- "org.gnome.ScreenSaver",
- "/",
- "org.gnome.ScreenSaver",
- NULL);
- g_return_if_fail(proxy != NULL);
- dbus_g_proxy_call_no_reply(proxy,
- "Lock",
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ /* 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");
+ }
+ }
- g_object_unref(proxy);
+ /* 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;
}
@@ -190,28 +190,32 @@ build_menu (gpointer data)
build_user_item(root);
status_menuitem = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(status_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(status_strings[global_status]));
+ dbusmenu_menuitem_property_set(status_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Set Status"));
dbusmenu_menuitem_child_append(root, status_menuitem);
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;
+ }
- 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));
+ status_menuitems[i] = dbusmenu_menuitem_new();
- dbusmenu_menuitem_child_append(status_menuitem, mi);
+ 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]);
+ if (global_status == STATUS_PROVIDER_STATUS_DISCONNECTED) {
+ 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, status_menuitems[i]);
g_debug("Built %s", status_strings[i]);
}
- DbusmenuMenuitem * mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen"));
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), GINT_TO_POINTER(i));
- dbusmenu_menuitem_child_append(root, mi);
-
return FALSE;
}
@@ -220,6 +224,12 @@ main (int argc, char ** argv)
{
g_type_init();
+ /* Setting up i18n and gettext. Apparently, we need
+ all of these. */
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+
DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
GError * error = NULL;