From 931ee90269a965820091d1397e4f5ebf123720a7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 13:58:39 -0600 Subject: Adding in base objects --- src/session-dbus.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/session-dbus.h (limited to 'src/session-dbus.h') diff --git a/src/session-dbus.h b/src/session-dbus.h new file mode 100644 index 0000000..be57df7 --- /dev/null +++ b/src/session-dbus.h @@ -0,0 +1,31 @@ +#ifndef __SESSION_DBUS_H__ +#define __SESSION_DBUS_H__ + +#include +#include + +G_BEGIN_DECLS + +#define SESSION_DBUS_TYPE (session_dbus_get_type ()) +#define SESSION_DBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SESSION_DBUS_TYPE, SessionDbus)) +#define SESSION_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SESSION_DBUS_TYPE, SessionDbusClass)) +#define IS_SESSION_DBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SESSION_DBUS_TYPE)) +#define IS_SESSION_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SESSION_DBUS_TYPE)) +#define SESSION_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SESSION_DBUS_TYPE, SessionDbusClass)) + +typedef struct _SessionDbus SessionDbus; +typedef struct _SessionDbusClass SessionDbusClass; + +struct _SessionDbusClass { + GObjectClass parent_class; +}; + +struct _SessionDbus { + GObject parent; +}; + +GType session_dbus_get_type (void); + +G_END_DECLS + +#endif -- cgit v1.2.3 From a92cec4aa9f3b7a014f9ed0e3dc3b2617e4114be Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 14:26:46 -0600 Subject: providing a set_name function --- src/session-dbus.c | 12 ++++++++++++ src/session-dbus.h | 1 + 2 files changed, 13 insertions(+) (limited to 'src/session-dbus.h') diff --git a/src/session-dbus.c b/src/session-dbus.c index 96b4500..cc12311 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -80,3 +80,15 @@ _session_dbus_server_get_icon (SessionDbus * service, gchar ** icon, GError ** e *icon = g_strdup(priv->name); return TRUE; } + +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); + return; +} diff --git a/src/session-dbus.h b/src/session-dbus.h index be57df7..d606378 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -25,6 +25,7 @@ struct _SessionDbus { }; GType session_dbus_get_type (void); +void session_dbus_set_name (SessionDbus * session, const gchar * name); G_END_DECLS -- cgit v1.2.3 From 0d2c0778772b92815dd1a773f6a5e10ed3c80869 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 14:33:30 -0600 Subject: Build us a signal --- src/session-dbus.c | 17 +++++++++++++++++ src/session-dbus.h | 1 + 2 files changed, 18 insertions(+) (limited to 'src/session-dbus.h') diff --git a/src/session-dbus.c b/src/session-dbus.c index cc12311..fd506ad 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -13,6 +13,14 @@ 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)) @@ -33,6 +41,14 @@ session_dbus_class_init (SessionDbusClass *klass) 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; @@ -90,5 +106,6 @@ session_dbus_set_name (SessionDbus * session, const gchar * name) priv->name = NULL; } priv->name = g_strdup(name); + g_signal_emit(G_OBJECT(session), signals[ICON_UPDATED], 0, priv->name, TRUE); return; } diff --git a/src/session-dbus.h b/src/session-dbus.h index d606378..67c151c 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -18,6 +18,7 @@ typedef struct _SessionDbusClass SessionDbusClass; struct _SessionDbusClass { GObjectClass parent_class; + void (*icon_updated) (SessionDbus * session, gchar * icon, gpointer user_data); }; struct _SessionDbus { -- cgit v1.2.3 From e504d1d019cf0af9b210d8150a5822f5e4878f4f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 14:37:58 -0600 Subject: Creating our little dbus-object. --- src/session-dbus.c | 6 ++++++ src/session-dbus.h | 1 + src/session-service.c | 4 ++++ 3 files changed, 11 insertions(+) (limited to 'src/session-dbus.h') diff --git a/src/session-dbus.c b/src/session-dbus.c index fd506ad..60002d0 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -97,6 +97,12 @@ _session_dbus_server_get_icon (SessionDbus * service, gchar ** icon, GError ** e 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) { diff --git a/src/session-dbus.h b/src/session-dbus.h index 67c151c..2169b49 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -26,6 +26,7 @@ struct _SessionDbus { }; GType session_dbus_get_type (void); +SessionDbus * session_dbus_new (void); void session_dbus_set_name (SessionDbus * session, const gchar * name); G_END_DECLS diff --git a/src/session-service.c b/src/session-service.c index febf007..693c73a 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -43,6 +43,7 @@ with this program. If not, see . #include "gconf-helper.h" +#include "session-dbus.h" #include "users-service-dbus.h" #include "lock-helper.h" @@ -65,6 +66,7 @@ struct _ActivateData static DBusGConnection *system_bus = NULL; static DBusGProxy *gdm_proxy = NULL; static UsersServiceDbus *dbus_interface = NULL; +static SessionDbus *session_dbus = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; @@ -691,6 +693,8 @@ main (int argc, char ** argv) DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, root_menuitem); + session_dbus = session_dbus_new(); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 8d65fd684fb6672d513bb1cf29e182ee5696a375 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 16:10:57 -0600 Subject: Copyright headers --- src/session-dbus.c | 21 +++++++++++++++++++++ src/session-dbus.h | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'src/session-dbus.h') diff --git a/src/session-dbus.c b/src/session-dbus.c index 1413916..20a0fa0 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -1,3 +1,24 @@ +/* +The Dbus object on the bus for the indicator. + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/src/session-dbus.h b/src/session-dbus.h index 2169b49..792917b 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -1,3 +1,24 @@ +/* +The Dbus object on the bus for the indicator. + +Copyright 2010 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + #ifndef __SESSION_DBUS_H__ #define __SESSION_DBUS_H__ -- cgit v1.2.3