From 7c1f28e80e07e3a352947fd089f9b1d127ff77b8 Mon Sep 17 00:00:00 2001 From: Christoph Korn Date: Tue, 8 Sep 2009 21:26:38 +0200 Subject: The menu now immediately is updated when the gconf-key about the logout/shutdown/restart confirmations is changed. --- src/gtk-dialog/Makefile.am | 4 ++-- src/gtk-dialog/gconf-helper.c | 49 +++++++++++++++++++++++++++++++++++++++---- src/gtk-dialog/gconf-helper.h | 21 +++++++++++++++++-- src/session-service.c | 43 ++++++++++++++++++++++--------------- 4 files changed, 92 insertions(+), 25 deletions(-) diff --git a/src/gtk-dialog/Makefile.am b/src/gtk-dialog/Makefile.am index 90a6209..9cdc18e 100644 --- a/src/gtk-dialog/Makefile.am +++ b/src/gtk-dialog/Makefile.am @@ -10,6 +10,6 @@ gtk_logout_helper_SOURCES = \ logout-dialog.c \ logout-dialog.h -gtk_logout_helper_CFLAGS = $(GTKLOGOUTHELPER_CFLAGS) $(GCONF_CFLAGS) -Wall -Werror -gtk_logout_helper_LDADD = $(GTKLOGOUTHELPER_LIBS) $(GCONF_LIBS) +gtk_logout_helper_CFLAGS = $(SESSIONSERVICE_CFLAGS) $(GTKLOGOUTHELPER_CFLAGS) $(GCONF_CFLAGS) -Wall -Werror +gtk_logout_helper_LDADD = $(SESSIONSERVICE_LIBS) $(GTKLOGOUTHELPER_LIBS) $(GCONF_LIBS) diff --git a/src/gtk-dialog/gconf-helper.c b/src/gtk-dialog/gconf-helper.c index 0bd21ad..7fc40d6 100644 --- a/src/gtk-dialog/gconf-helper.c +++ b/src/gtk-dialog/gconf-helper.c @@ -1,6 +1,5 @@ /* -A small wrapper utility to load indicators and put them as menu items -into the gnome-panel using it's applet interface. +A small wrapper utility for connecting to gconf. Copyright 2009 Canonical Ltd. @@ -23,10 +22,52 @@ with this program. If not, see . #include +#include + +#include +#include + +#include +#include + #include "gconf-helper.h" +static GConfClient * gconf_client = NULL; + gboolean supress_confirmations (void) { - GConfClient *client = gconf_client_get_default (); - return gconf_client_get_bool (client, SUPPRESS_KEY, NULL) ; + if(!gconf_client) { + gconf_client = gconf_client_get_default (); + } + return gconf_client_get_bool (gconf_client, SUPPRESS_KEY, NULL) ; +} + +static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { + RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = (RestartShutdownLogoutMenuItems*) data; + GConfValue * value = gconf_entry_get_value (entry); + const gchar * key = gconf_entry_get_key (entry); + + if(strcmp (key, SUPPRESS_KEY) == 0) { + if (gconf_value_get_bool (value)) { + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown")); + } else { + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out ...")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart ...")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown ...")); + } + } } + +void +update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { + if(!gconf_client) { + gconf_client = gconf_client_get_default (); + } + gconf_client_add_dir (gconf_client, GLOBAL_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add (gconf_client, SUPPRESS_KEY, + update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); +} + diff --git a/src/gtk-dialog/gconf-helper.h b/src/gtk-dialog/gconf-helper.h index 1d78fd8..951bb0f 100644 --- a/src/gtk-dialog/gconf-helper.h +++ b/src/gtk-dialog/gconf-helper.h @@ -1,6 +1,5 @@ /* -A small wrapper utility to load indicators and put them as menu items -into the gnome-panel using it's applet interface. +A small wrapper utility for connecting to gconf. Copyright 2009 Canonical Ltd. @@ -26,8 +25,26 @@ with this program. If not, see . #include +#include + +#include +#include + +#include +#include + #define SUPPRESS_KEY "/apps/indicator-session/suppress_logout_restart_shutdown" +#define GLOBAL_DIR "/apps/indicator-session" + +typedef struct _RestartShutdownLogoutMenuItems +{ + DbusmenuMenuitem * logout_mi; + DbusmenuMenuitem * restart_mi; + DbusmenuMenuitem * shutdown_mi; +} +RestartShutdownLogoutMenuItems; +void update_menu_entries(RestartShutdownLogoutMenuItems*); gboolean supress_confirmations (void); #endif /* __GCONF_HELPER__ */ diff --git a/src/session-service.c b/src/session-service.c index 9e5cbb2..33b58a3 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -6,6 +6,7 @@ Copyright 2009 Canonical Ltd. Authors: Ted Gould + Christoph Korn This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -47,6 +48,9 @@ static DBusGProxyCall * hibernate_call = NULL; static DbusmenuMenuitem * hibernate_mi = NULL; static DbusmenuMenuitem * suspend_mi = NULL; +static DbusmenuMenuitem * logout_mi = NULL; +static DbusmenuMenuitem * restart_mi = NULL; +static DbusmenuMenuitem * shutdown_mi = NULL; /* Let's put this machine to sleep, with some info on how it should sleep. */ @@ -222,16 +226,14 @@ show_dialog (DbusmenuMenuitem * mi, gchar * type) provides in the UI. It also connects them to the callbacks. */ static void create_items (DbusmenuMenuitem * root) { - DbusmenuMenuitem * mi = NULL; - - mi = dbusmenu_menuitem_new(); + logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); + dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out ...")); + dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out ...")); } - dbusmenu_menuitem_child_append(root, mi); - g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); + dbusmenu_menuitem_child_append(root, logout_mi); + g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); suspend_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); @@ -245,23 +247,30 @@ create_items (DbusmenuMenuitem * root) { dbusmenu_menuitem_child_append(root, hibernate_mi); g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(sleep), "Hibernate"); - mi = dbusmenu_menuitem_new(); + restart_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); + dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart ...")); + dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart ...")); } - dbusmenu_menuitem_child_append(root, mi); - g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "restart"); + dbusmenu_menuitem_child_append(root, restart_mi); + g_signal_connect(G_OBJECT(restart_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "restart"); - mi = dbusmenu_menuitem_new(); + shutdown_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown")); + dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown")); } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown ...")); + dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown ...")); } - dbusmenu_menuitem_child_append(root, mi); - g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown"); + dbusmenu_menuitem_child_append(root, shutdown_mi); + g_signal_connect(G_OBJECT(shutdown_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown"); + + RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); + restart_shutdown_logout_mi->logout_mi = logout_mi; + restart_shutdown_logout_mi->restart_mi = restart_mi; + restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; + + update_menu_entries(restart_shutdown_logout_mi); return; } -- cgit v1.2.3 From 935d113e94596808eb0db0cf1719905b68c237d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 12:10:07 -0500 Subject: 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. --- src/status-provider.h | 1 + src/status-service.c | 55 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/status-provider.h b/src/status-provider.h index 522e61b..a0e1c55 100644 --- a/src/status-provider.h +++ b/src/status-provider.h @@ -42,6 +42,7 @@ typedef enum STATUS_PROVIDER_STATUS_DND, STATUS_PROVIDER_STATUS_INVISIBLE, STATUS_PROVIDER_STATUS_OFFLINE, + STATUS_PROVIDER_STATUS_DISCONNECTED, /* Leave as last */ STATUS_PROVIDER_STATUS_LAST } 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]); } -- cgit v1.2.3 From 6fa2a0c95d455ba4eb0a310b0314fb493a6148da Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 12:24:05 -0500 Subject: Adding disconnected to the pidgin handler. --- src/status-provider-pidgin.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/status-provider-pidgin.c b/src/status-provider-pidgin.c index 052ce12..e65dc54 100644 --- a/src/status-provider-pidgin.c +++ b/src/status-provider-pidgin.c @@ -59,7 +59,8 @@ static const pg_status_t sp_to_pg_map[STATUS_PROVIDER_STATUS_LAST] = { /* STATUS_PROVIDER_STATUS_AWAY, */ PG_STATUS_AWAY, /* STATUS_PROVIDER_STATUS_DND */ PG_STATUS_UNAVAILABLE, /* STATUS_PROVIDER_STATUS_INVISIBLE*/ PG_STATUS_INVISIBLE, - /* STATUS_PROVIDER_STATUS_OFFLINE */ PG_STATUS_OFFLINE + /* STATUS_PROVIDER_STATUS_OFFLINE */ PG_STATUS_OFFLINE, + /* STATUS_PROVIDER_STATUS_DISCONNECTED*/ PG_STATUS_OFFLINE }; typedef struct _StatusProviderPidginPrivate StatusProviderPidginPrivate; @@ -346,11 +347,17 @@ set_status (StatusProvider * sp, StatusProviderStatus status) } /* Takes the cached Pidgin status and makes it into the generic - Status provider status */ + Status provider status. If there is no Pidgin proxy then it + returns the disconnected state. */ static StatusProviderStatus get_status (StatusProvider * sp) { - g_return_val_if_fail(IS_STATUS_PROVIDER_PIDGIN(sp), STATUS_PROVIDER_STATUS_OFFLINE); + g_return_val_if_fail(IS_STATUS_PROVIDER_PIDGIN(sp), STATUS_PROVIDER_STATUS_DISCONNECTED); StatusProviderPidginPrivate * priv = STATUS_PROVIDER_PIDGIN_GET_PRIVATE(sp); + + if (priv->proxy == NULL) { + return STATUS_PROVIDER_STATUS_DISCONNECTED; + } + return pg_to_sp_map[priv->pg_status]; } -- cgit v1.2.3 From 2ad97fd722286b1e9780c10efc3a87e42a0796c4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 12:24:16 -0500 Subject: Adding disconnected to the telepathy handler. --- src/status-provider-telepathy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c index e22c27d..31da224 100644 --- a/src/status-provider-telepathy.c +++ b/src/status-provider-telepathy.c @@ -55,7 +55,8 @@ static mc_status_t sp_to_mc_map[] = { /* STATUS_PROVIDER_STATUS_AWAY, */ MC_STATUS_AWAY, /* STATUS_PROVIDER_STATUS_DND */ MC_STATUS_DND, /* STATUS_PROVIDER_STATUS_INVISIBLE*/ MC_STATUS_HIDDEN, - /* STATUS_PROVIDER_STATUS_OFFLINE */ MC_STATUS_OFFLINE + /* STATUS_PROVIDER_STATUS_OFFLINE */ MC_STATUS_OFFLINE, + /* STATUS_PROVIDER_STATUS_DISCONNECTED*/MC_STATUS_OFFLINE }; typedef struct _StatusProviderTelepathyPrivate StatusProviderTelepathyPrivate; @@ -258,10 +259,11 @@ set_status (StatusProvider * sp, StatusProviderStatus status) static StatusProviderStatus get_status (StatusProvider * sp) { + g_return_val_if_fail(IS_STATUS_PROVIDER_TELEPATHY(sp), STATUS_PROVIDER_STATUS_DISCONNECTED); StatusProviderTelepathyPrivate * priv = STATUS_PROVIDER_TELEPATHY_GET_PRIVATE(sp); if (priv->proxy == NULL) { - return mc_to_sp_map[MC_STATUS_OFFLINE]; + return STATUS_PROVIDER_STATUS_DISCONNECTED; } return mc_to_sp_map[priv->mc_status]; -- cgit v1.2.3 From ec17d0a7bae74ab2f276b73e03b7d60877d3bcfa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 13:08:56 -0500 Subject: Splitting out the building of the Pidgin proxy into it's own function. --- src/status-provider-pidgin.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/status-provider-pidgin.c b/src/status-provider-pidgin.c index e65dc54..f4704db 100644 --- a/src/status-provider-pidgin.c +++ b/src/status-provider-pidgin.c @@ -66,6 +66,7 @@ static const pg_status_t sp_to_pg_map[STATUS_PROVIDER_STATUS_LAST] = { typedef struct _StatusProviderPidginPrivate StatusProviderPidginPrivate; struct _StatusProviderPidginPrivate { DBusGProxy * proxy; + DBusGProxy * dbus_proxy; pg_status_t pg_status; }; @@ -81,6 +82,7 @@ static void status_provider_pidgin_finalize (GObject *object); /* Internal Funcs */ static void set_status (StatusProvider * sp, StatusProviderStatus status); static StatusProviderStatus get_status (StatusProvider * sp); +static void setup_pidgin_proxy (StatusProviderPidgin * self); G_DEFINE_TYPE (StatusProviderPidgin, status_provider_pidgin, STATUS_PROVIDER_TYPE); @@ -179,27 +181,55 @@ status_provider_pidgin_init (StatusProviderPidgin *self) priv->proxy = NULL; priv->pg_status = PG_STATUS_OFFLINE; + DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + g_return_if_fail(bus != NULL); /* Can't do anymore DBus stuff without this, + all non-DBus stuff should be done */ + + /* GError * error = NULL; */ + + setup_pidgin_proxy(self); + + return; +} + +static void +setup_pidgin_proxy (StatusProviderPidgin * self) +{ + StatusProviderPidginPrivate * priv = STATUS_PROVIDER_PIDGIN_GET_PRIVATE(self); + + if (priv->proxy != NULL) { + g_debug("Odd, we were asked to set up a Pidgin proxy when we already had one."); + return; + } + DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); g_return_if_fail(bus != NULL); /* Can't do anymore DBus stuff without this, all non-DBus stuff should be done */ GError * error = NULL; + + /* Set up the Pidgin Proxy */ priv->proxy = dbus_g_proxy_new_for_name_owner (bus, "im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject", "im.pidgin.purple.PurpleInterface", &error); + /* Report any errors */ if (error != NULL) { g_debug("Unable to get Pidgin proxy: %s", error->message); g_error_free(error); - return; } + /* If we have a proxy, let's start using it */ if (priv->proxy != NULL) { + /* Set the proxy to NULL if it's destroyed */ g_object_add_weak_pointer (G_OBJECT(priv->proxy), (gpointer *)&priv->proxy); + /* If it's destroyed, let's clean up as well */ g_signal_connect(G_OBJECT(priv->proxy), "destroy", G_CALLBACK(proxy_destroy), self); + /* Watching for the status change coming from the + Pidgin side of things. */ g_debug("Adding Pidgin Signals"); dbus_g_object_register_marshaller(_status_provider_pidgin_marshal_VOID__INT_INT, G_TYPE_NONE, @@ -217,6 +247,8 @@ status_provider_pidgin_init (StatusProviderPidgin *self) (void *)self, NULL); + /* Get the current status to update our cached + value of the status. */ dbus_g_proxy_begin_call(priv->proxy, "PurpleSavedstatusGetCurrent", savedstatus_cb, -- cgit v1.2.3 From 0952465001fe38e0872e1472739ae7786aa1761a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 13:28:43 -0500 Subject: Watch dbus namechanges and see if Pidgin comes on the bus. --- src/status-provider-pidgin.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/status-provider-pidgin.c b/src/status-provider-pidgin.c index f4704db..3c0ca15 100644 --- a/src/status-provider-pidgin.c +++ b/src/status-provider-pidgin.c @@ -83,6 +83,7 @@ static void status_provider_pidgin_finalize (GObject *object); static void set_status (StatusProvider * sp, StatusProviderStatus status); static StatusProviderStatus get_status (StatusProvider * sp); static void setup_pidgin_proxy (StatusProviderPidgin * self); +static void dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderPidgin * self); G_DEFINE_TYPE (StatusProviderPidgin, status_provider_pidgin, STATUS_PROVIDER_TYPE); @@ -185,13 +186,48 @@ status_provider_pidgin_init (StatusProviderPidgin *self) g_return_if_fail(bus != NULL); /* Can't do anymore DBus stuff without this, all non-DBus stuff should be done */ - /* GError * error = NULL; */ + GError * error = NULL; + + /* Set up the dbus Proxy */ + priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (bus, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + &error); + if (error != NULL) { + g_warning("Unable to connect to DBus events: %s", error->message); + g_error_free(error); + return; + } + + /* Configure the name owner changing */ + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(dbus_namechange), + self, NULL); setup_pidgin_proxy(self); return; } +/* Watch to see if the Pidgin comes up on Dbus */ +static void +dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderPidgin * self) +{ + g_return_if_fail(name != NULL); + g_return_if_fail(new != NULL); + + if (g_strcmp0(name, "im.pidgin.purple.PurpleService") == 0) { + setup_pidgin_proxy(self); + } + return; +} + +/* Setup the Pidgin proxy so that we can talk to it + and get signals from it. */ static void setup_pidgin_proxy (StatusProviderPidgin * self) { -- cgit v1.2.3 From acdeaff5212ea63681d0f2b6d623d0780b6350ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 13:40:49 -0500 Subject: Checking the global status on whether the menu items should be sensitive or not. --- src/status-service.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/status-service.c b/src/status-service.c index 195529b..d8f60d4 100644 --- a/src/status-service.c +++ b/src/status-service.c @@ -234,7 +234,9 @@ build_menu (gpointer data) 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"); + 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]); -- cgit v1.2.3 From d97e28df45374c687c60529b5e868e2910187571 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 13:52:12 -0500 Subject: Function to build the telepathy proxy. --- src/status-provider-telepathy.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c index 31da224..4430a8e 100644 --- a/src/status-provider-telepathy.c +++ b/src/status-provider-telepathy.c @@ -75,6 +75,7 @@ static void status_provider_telepathy_init (StatusProviderTelepathy *self) static void status_provider_telepathy_dispose (GObject *object); static void status_provider_telepathy_finalize (GObject *object); /* Internal Funcs */ +static void build_telepathy_proxy (StatusProviderTelepathy * self); static void set_status (StatusProvider * sp, StatusProviderStatus status); static StatusProviderStatus get_status (StatusProvider * sp); static void changed_status (DBusGProxy * proxy, guint status, gchar * message, StatusProvider * sp); @@ -110,6 +111,16 @@ status_provider_telepathy_init (StatusProviderTelepathy *self) priv->proxy = NULL; priv->mc_status = MC_STATUS_OFFLINE; + build_telepathy_proxy(self); + + return; +} + +static void +build_telepathy_proxy (StatusProviderTelepathy * self) +{ + StatusProviderTelepathyPrivate * priv = STATUS_PROVIDER_TELEPATHY_GET_PRIVATE(self); + GError * error = NULL; DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); -- cgit v1.2.3 From ff14ae64765101fc90581d5b927d68ce2b15297c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 13:58:24 -0500 Subject: Checking to see if we have the proxy already. --- src/status-provider-telepathy.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c index 4430a8e..58bc6ca 100644 --- a/src/status-provider-telepathy.c +++ b/src/status-provider-telepathy.c @@ -121,8 +121,14 @@ build_telepathy_proxy (StatusProviderTelepathy * self) { StatusProviderTelepathyPrivate * priv = STATUS_PROVIDER_TELEPATHY_GET_PRIVATE(self); + if (priv->proxy != NULL) { + g_debug("Hmm, being asked to build a proxy we alredy have."); + return; + } + GError * error = NULL; + /* Grabbing the session bus */ DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (session_bus == NULL) { g_warning("Unable to connect to Session Bus: %s", error == NULL ? "No message" : error->message); @@ -130,7 +136,7 @@ build_telepathy_proxy (StatusProviderTelepathy * self) return; } - priv->proxy = NULL; + /* Get the proxy to Mission Control */ priv->proxy = dbus_g_proxy_new_for_name_owner(session_bus, "org.freedesktop.Telepathy.MissionControl", "/org/freedesktop/Telepathy/MissionControl", @@ -138,10 +144,13 @@ build_telepathy_proxy (StatusProviderTelepathy * self) &error); if (priv->proxy != NULL) { + /* If it goes, we set the proxy to NULL */ g_object_add_weak_pointer (G_OBJECT(priv->proxy), (gpointer *)&priv->proxy); + /* And we clean up other variables associated */ g_signal_connect(G_OBJECT(priv->proxy), "destroy", G_CALLBACK(proxy_destroy), self); + /* Set up the signal handler for watching when status changes. */ dbus_g_object_register_marshaller(_status_provider_telepathy_marshal_VOID__UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, -- cgit v1.2.3 From b93e75aaa4634ac8f995ac3ea7596e3946a59e18 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 14:04:51 -0500 Subject: Watching for Mission Control comming on the bus. --- src/status-provider-telepathy.c | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c index 58bc6ca..f33e26f 100644 --- a/src/status-provider-telepathy.c +++ b/src/status-provider-telepathy.c @@ -62,6 +62,7 @@ static mc_status_t sp_to_mc_map[] = { typedef struct _StatusProviderTelepathyPrivate StatusProviderTelepathyPrivate; struct _StatusProviderTelepathyPrivate { DBusGProxy * proxy; + DBusGProxy * dbus_proxy; mc_status_t mc_status; }; @@ -76,6 +77,7 @@ static void status_provider_telepathy_dispose (GObject *object); static void status_provider_telepathy_finalize (GObject *object); /* Internal Funcs */ static void build_telepathy_proxy (StatusProviderTelepathy * self); +static void dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderTelepathy * self); static void set_status (StatusProvider * sp, StatusProviderStatus status); static StatusProviderStatus get_status (StatusProvider * sp); static void changed_status (DBusGProxy * proxy, guint status, gchar * message, StatusProvider * sp); @@ -109,8 +111,39 @@ status_provider_telepathy_init (StatusProviderTelepathy *self) StatusProviderTelepathyPrivate * priv = STATUS_PROVIDER_TELEPATHY_GET_PRIVATE(self); priv->proxy = NULL; + priv->dbus_proxy = NULL; priv->mc_status = MC_STATUS_OFFLINE; + GError * error = NULL; + + /* Grabbing the session bus */ + DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (bus == NULL) { + g_warning("Unable to connect to Session Bus: %s", error == NULL ? "No message" : error->message); + g_error_free(error); + return; + } + + /* Set up the dbus Proxy */ + priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (bus, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + &error); + if (error != NULL) { + g_warning("Unable to connect to DBus events: %s", error->message); + g_error_free(error); + return; + } + + /* Configure the name owner changing */ + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(dbus_namechange), + self, NULL); + build_telepathy_proxy(self); return; @@ -184,6 +217,19 @@ build_telepathy_proxy (StatusProviderTelepathy * self) return; } +/* Watch to see if the Mission Control comes up on Dbus */ +static void +dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderTelepathy * self) +{ + g_return_if_fail(name != NULL); + g_return_if_fail(new != NULL); + + if (g_strcmp0(name, "org.freedesktop.Telepathy.MissionControl") == 0) { + build_telepathy_proxy(self); + } + return; +} + static void status_provider_telepathy_dispose (GObject *object) { -- cgit v1.2.3 From a275332bb21be6dab623738366aaeeff6afc7687 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 14:09:43 -0500 Subject: Adding in a debug message for Telepathy proxy. --- src/status-provider-telepathy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/status-provider-telepathy.c b/src/status-provider-telepathy.c index f33e26f..f2815fb 100644 --- a/src/status-provider-telepathy.c +++ b/src/status-provider-telepathy.c @@ -149,9 +149,13 @@ status_provider_telepathy_init (StatusProviderTelepathy *self) return; } +/* Builds up the proxy to Mission Control and configures all of the + signals for getting info from the proxy. Also does a call to get + the inital value of the status. */ static void build_telepathy_proxy (StatusProviderTelepathy * self) { + g_debug("Building Telepathy Proxy"); StatusProviderTelepathyPrivate * priv = STATUS_PROVIDER_TELEPATHY_GET_PRIVATE(self); if (priv->proxy != NULL) { -- cgit v1.2.3 From c2ed34abf815609d4b0044dc46d6be63a9e5c570 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 15:53:15 -0500 Subject: Removing the space on the elipsis --- src/session-service.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index 9e5cbb2..15c85cb 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -228,7 +228,7 @@ create_items (DbusmenuMenuitem * root) { if (supress_confirmations()) { dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out ...")); + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out...")); } dbusmenu_menuitem_child_append(root, mi); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); @@ -249,7 +249,7 @@ create_items (DbusmenuMenuitem * root) { if (supress_confirmations()) { dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart ...")); + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart...")); } dbusmenu_menuitem_child_append(root, mi); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "restart"); @@ -258,7 +258,7 @@ create_items (DbusmenuMenuitem * root) { if (supress_confirmations()) { dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown")); } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown ...")); + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shutdown...")); } dbusmenu_menuitem_child_append(root, mi); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown"); -- cgit v1.2.3 From edba4f977f7ba9692e48cf40dea2466b07e967e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 15:59:38 -0500 Subject: Grabbing the icons from the indicator dir where we install them. --- src/gtk-dialog/Makefile.am | 2 +- src/gtk-dialog/gtk-logout-helper.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gtk-dialog/Makefile.am b/src/gtk-dialog/Makefile.am index 90a6209..5f2df2f 100644 --- a/src/gtk-dialog/Makefile.am +++ b/src/gtk-dialog/Makefile.am @@ -10,6 +10,6 @@ gtk_logout_helper_SOURCES = \ logout-dialog.c \ logout-dialog.h -gtk_logout_helper_CFLAGS = $(GTKLOGOUTHELPER_CFLAGS) $(GCONF_CFLAGS) -Wall -Werror +gtk_logout_helper_CFLAGS = $(GTKLOGOUTHELPER_CFLAGS) $(GCONF_CFLAGS) -Wall -Werror -DINDICATOR_ICONS_DIR="\"$(INDICATORICONSDIR)\"" gtk_logout_helper_LDADD = $(GTKLOGOUTHELPER_LIBS) $(GCONF_LIBS) diff --git a/src/gtk-dialog/gtk-logout-helper.c b/src/gtk-dialog/gtk-logout-helper.c index 13991ca..e6a9ef8 100644 --- a/src/gtk-dialog/gtk-logout-helper.c +++ b/src/gtk-dialog/gtk-logout-helper.c @@ -133,6 +133,10 @@ main (int argc, char * argv[]) return 1; } + /* Init some theme/icon stuff */ + gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), + INDICATOR_ICONS_DIR); + GtkWidget * dialog = NULL; if (!pk_require_auth(type) && !supress_confirmations()) { dialog = logout_dialog_new(type); -- cgit v1.2.3 From 0cb4e60ef1a5034dec49ea28f0545055c0460597 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 16:03:59 -0500 Subject: Setting the window icon now that we have the right path --- src/gtk-dialog/logout-dialog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gtk-dialog/logout-dialog.c b/src/gtk-dialog/logout-dialog.c index a80dbef..a94c649 100644 --- a/src/gtk-dialog/logout-dialog.c +++ b/src/gtk-dialog/logout-dialog.c @@ -298,8 +298,9 @@ logout_dialog_init (LogoutDialog *logout_dialog) GTK_RESPONSE_OK); gtk_widget_grab_default (logout_dialog->ok_button); - /* Title */ + /* Window Title and Icon */ gtk_window_set_title (GTK_WINDOW(logout_dialog), _(title_strings[logout_dialog->action])); + gtk_window_set_icon_name (GTK_WINDOW(logout_dialog), icon_strings[logout_dialog->action]); /* hbox */ logout_dialog->hbox = gtk_hbox_new (FALSE, 12); -- cgit v1.2.3 -- cgit v1.2.3 From 82395ac94e6daaf020d0310602756007a6b89451 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 17:10:37 -0500 Subject: Making a 0.1.3 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 957a471..fa7a941 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-session.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-session, 0.1.2) +AM_INIT_AUTOMAKE(indicator-session, 0.1.3) AM_MAINTAINER_MODE -- cgit v1.2.3 From 0ae60895fc38666a407b2e76c5cdebd706d40834 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Sep 2009 20:39:48 -0500 Subject: releasing version 0.1.3-0ubuntu1~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3ebae48..0e8925d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -indicator-session (0.1.3-0ubuntu1~ppa1) UNRELEASED; urgency=low +indicator-session (0.1.3-0ubuntu1~ppa1) karmic; urgency=low * Upstream release 0.1.3 * GConf Key change listening @@ -6,7 +6,7 @@ indicator-session (0.1.3-0ubuntu1~ppa1) UNRELEASED; urgency=low * Label fixes * Icon fixes for logout windows (LP: #426355) - -- Ted Gould Thu, 10 Sep 2009 20:33:43 -0500 + -- Ted Gould Thu, 10 Sep 2009 20:38:44 -0500 indicator-session (0.1.2-0ubuntu1) karmic; urgency=low -- cgit v1.2.3