diff options
author | Ted Gould <ted@gould.cx> | 2010-03-18 14:19:39 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-03-18 14:19:39 -0500 |
commit | 2b2e31f1ea346dd43cc2e4838695984e3f8ca67e (patch) | |
tree | b58ce0b44fca14ed5e35ef08799fbc0d8e128ef6 /src/session-dbus.c | |
parent | 631d34aad2f454fb334330f3b041e8e0c4495434 (diff) | |
parent | f1095e5616806c67db70f3875eea38abf6ce9e19 (diff) | |
download | ayatana-indicator-session-2b2e31f1ea346dd43cc2e4838695984e3f8ca67e.tar.gz ayatana-indicator-session-2b2e31f1ea346dd43cc2e4838695984e3f8ca67e.tar.bz2 ayatana-indicator-session-2b2e31f1ea346dd43cc2e4838695984e3f8ca67e.zip |
Upstream release 0.2.6
∘ Updating sessions to make guest account marked when being
used (LP: #436030)
∘ String "Switch From" is miscapitalized (LP: #540265)
∘ Follow user switching lockdown key (LP: #504360)
∘ Use user avatar images in session menu (LP: #436028)
∘ Don't show suspend/hibernate if disabled in Policy Kit (LP: #432598)
∘ Lock screen when switching users (LP: #536801)
∘ Fix callback prototype (LP: #536990)
∘ Revert back to "Shut Down" instead of "Switch Off" (LP: #540056)
∘ Fix leaked GConf notifications
∘ Add GConf key for showing the "Log Out" item
∘ Adding the ability to specify a desktop file to have at the end
of the menu.
∘ Setting up restart required notification by changing panel icon
and icon in menus.
∘ Use the libindicator image helpers
∘ Set proper translation domain for loadable indicator
∘ Translation update
Diffstat (limited to 'src/session-dbus.c')
-rw-r--r-- | src/session-dbus.c | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/src/session-dbus.c b/src/session-dbus.c new file mode 100644 index 0000000..20a0fa0 --- /dev/null +++ b/src/session-dbus.c @@ -0,0 +1,139 @@ +/* +The Dbus object on the bus for the indicator. + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould <ted@canonical.com> + +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 +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "session-dbus.h" +#include "dbus-shared-names.h" + +static gboolean _session_dbus_server_get_icon (SessionDbus * service, gchar ** icon, GError ** error); + +#include "session-dbus-server.h" + +typedef struct _SessionDbusPrivate SessionDbusPrivate; +struct _SessionDbusPrivate { + gchar * name; +}; + +/* Signals */ +enum { + ICON_UPDATED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + +#define SESSION_DBUS_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), SESSION_DBUS_TYPE, SessionDbusPrivate)) + +static void session_dbus_class_init (SessionDbusClass *klass); +static void session_dbus_init (SessionDbus *self); +static void session_dbus_dispose (GObject *object); +static void session_dbus_finalize (GObject *object); + +G_DEFINE_TYPE (SessionDbus, session_dbus, G_TYPE_OBJECT); + +static void +session_dbus_class_init (SessionDbusClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (SessionDbusPrivate)); + + object_class->dispose = session_dbus_dispose; + object_class->finalize = session_dbus_finalize; + + signals[ICON_UPDATED] = g_signal_new ("icon-updated", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (SessionDbusClass, icon_updated), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + + dbus_g_object_type_install_info(SESSION_DBUS_TYPE, &dbus_glib__session_dbus_server_object_info); + + return; +} + +static void +session_dbus_init (SessionDbus *self) +{ + DBusGConnection * session = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + dbus_g_connection_register_g_object(session, INDICATOR_SESSION_SERVICE_DBUS_OBJECT, G_OBJECT(self)); + + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); + + priv->name = g_strdup(ICON_DEFAULT); + + return; +} + +static void +session_dbus_dispose (GObject *object) +{ + + G_OBJECT_CLASS (session_dbus_parent_class)->dispose (object); + return; +} + +static void +session_dbus_finalize (GObject *object) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(object); + + if (priv->name != NULL) { + g_free(priv->name); + priv->name = NULL; + } + + G_OBJECT_CLASS (session_dbus_parent_class)->finalize (object); + return; +} + +static gboolean +_session_dbus_server_get_icon (SessionDbus * service, gchar ** icon, GError ** error) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service); + *icon = g_strdup(priv->name); + return TRUE; +} + +SessionDbus * +session_dbus_new (void) +{ + return SESSION_DBUS(g_object_new(SESSION_DBUS_TYPE, NULL)); +} + +void +session_dbus_set_name (SessionDbus * session, const gchar * name) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); + if (priv->name != NULL) { + g_free(priv->name); + priv->name = NULL; + } + priv->name = g_strdup(name); + g_signal_emit(G_OBJECT(session), signals[ICON_UPDATED], 0, priv->name, TRUE); + return; +} |