From eed04dff5181b860c8c86281e94018f8228ddc72 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 13:43:37 -0600 Subject: Simple starter object for making the dbus interface. --- src/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index cd525bd..d8d8acd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,8 @@ indicator_session_service_SOURCES = \ lock-helper.c \ lock-helper.h \ session-service.c \ + session-dbus.c \ + session-dbus.h \ dbusmenu-shared.h \ gconf-helper.c \ users-service-dbus.h \ -- cgit v1.2.3 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.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/session-dbus.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/session-dbus.c create mode 100644 src/session-dbus.h (limited to 'src') diff --git a/src/session-dbus.c b/src/session-dbus.c new file mode 100644 index 0000000..2b7443e --- /dev/null +++ b/src/session-dbus.c @@ -0,0 +1,54 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "session-dbus.h" + +typedef struct _SessionDbusPrivate SessionDbusPrivate; +struct _SessionDbusPrivate { + gint dummy; +}; + +#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; + + return; +} + +static void +session_dbus_init (SessionDbus *self) +{ +} + +static void +session_dbus_dispose (GObject *object) +{ + + G_OBJECT_CLASS (session_dbus_parent_class)->dispose (object); + return; +} + +static void +session_dbus_finalize (GObject *object) +{ + + G_OBJECT_CLASS (session_dbus_parent_class)->finalize (object); + return; +} 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 64c34204592848587c9b965c339d75305b35eebe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 14:00:20 -0600 Subject: Setting up session dbus interface client server stuff. --- src/Makefile.am | 19 +++++++++++++++++++ src/session-dbus.xml | 15 +++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/session-dbus.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index d8d8acd..3037a3b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ sessionlibdir = $(INDICATORDIR) sessionlib_LTLIBRARIES = libsession.la libsession_la_SOURCES = \ indicator-session.c \ + session-dbus-client.h \ dbus-shared-names.h \ dbusmenu-shared.h \ users-service-client.h @@ -32,6 +33,20 @@ users-service-client.h: $(srcdir)/users-service.xml --output=users-service-client.h \ $(srcdir)/users-service.xml +session-dbus-client.h: $(srcdir)/session-dbus.xml + dbus-binding-tool \ + --prefix=_session_dbus_client \ + --mode=glib-client \ + --output=session-dbus-client.h \ + $(srcdir)/session-dbus.xml + +session-dbus-server.h: $(srcdir)/session-dbus.xml + dbus-binding-tool \ + --prefix=_session_dbus_server \ + --mode=glib-server \ + --output=session-dbus-server.h \ + $(srcdir)/session-dbus.xml + users-service-marshal.h: $(srcdir)/users-service.list glib-genmarshal --header \ --prefix=_users_service_marshal $(srcdir)/users-service.list \ @@ -52,6 +67,7 @@ indicator_session_service_SOURCES = \ session-service.c \ session-dbus.c \ session-dbus.h \ + session-dbus-server.h \ dbusmenu-shared.h \ gconf-helper.c \ users-service-dbus.h \ @@ -90,12 +106,15 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + session-dbus-client.h \ + session-dbus-server.h \ users-service-client.h \ users-service-marshal.h \ users-service-marshal.c EXTRA_DIST = \ consolekit-manager.xml \ + session-dbus.xml \ users-service.xml \ users-service.list diff --git a/src/session-dbus.xml b/src/session-dbus.xml new file mode 100644 index 0000000..3ce1693 --- /dev/null +++ b/src/session-dbus.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + -- cgit v1.2.3 From 2922e646021966770309caf17538b4b241885973 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 14:14:12 -0600 Subject: Connecting and registering the dbus object. --- src/session-dbus.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/session-dbus.c b/src/session-dbus.c index 2b7443e..3f5e6c7 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -4,6 +4,10 @@ #include "session-dbus.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 { gint dummy; @@ -29,6 +33,8 @@ session_dbus_class_init (SessionDbusClass *klass) object_class->dispose = session_dbus_dispose; object_class->finalize = session_dbus_finalize; + dbus_g_object_type_install_info(SESSION_DBUS_TYPE, &dbus_glib__session_dbus_server_object_info); + return; } @@ -52,3 +58,10 @@ session_dbus_finalize (GObject *object) G_OBJECT_CLASS (session_dbus_parent_class)->finalize (object); return; } + +static gboolean +_session_dbus_server_get_icon (SessionDbus * service, gchar ** icon, GError ** error) +{ + + return TRUE; +} -- cgit v1.2.3 From d9427c6a4ecc0a50cac8a674c465631c59ff59f2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 14:22:40 -0600 Subject: Setting up the object and giving it a name. --- src/session-dbus.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/session-dbus.c b/src/session-dbus.c index 3f5e6c7..96b4500 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -10,7 +10,7 @@ static gboolean _session_dbus_server_get_icon (SessionDbus * service, gchar ** i typedef struct _SessionDbusPrivate SessionDbusPrivate; struct _SessionDbusPrivate { - gint dummy; + gchar * name; }; #define SESSION_DBUS_GET_PRIVATE(o) \ @@ -41,6 +41,14 @@ session_dbus_class_init (SessionDbusClass *klass) static void session_dbus_init (SessionDbus *self) { + DBusGConnection * session = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + dbus_g_connection_register_g_object(session, "/bob", G_OBJECT(self)); + + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); + + priv->name = g_strdup("icon"); + + return; } static void @@ -54,6 +62,12 @@ session_dbus_dispose (GObject *object) 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; @@ -62,6 +76,7 @@ session_dbus_finalize (GObject *object) 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; } -- 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') 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') 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') 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 05dbbb9a09bfa74c23683c8110bf0853635a635e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 14:59:01 -0600 Subject: Add shared names for the dbus interfaces. --- src/dbus-shared-names.h | 3 +++ src/session-dbus.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 253cba8..2c30b36 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -38,6 +38,9 @@ with this program. If not, see . #define INDICATOR_SESSION_DBUS_OBJECT "/org/ayatana/indicator/session/menu" #define INDICATOR_SESSION_DBUS_VERSION 0 +#define INDICATOR_SESSION_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/session/service" +#define INDICATOR_SESSION_SERVICE_DBUS_IFACE "org.ayatana.indicator.session.service" + #define USER_ITEM_TYPE "x-canonical-user-item" #define USER_ITEM_PROP_NAME "user-item-name" #define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" diff --git a/src/session-dbus.c b/src/session-dbus.c index 60002d0..f656bb0 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -3,6 +3,7 @@ #endif #include "session-dbus.h" +#include "dbus-shared-names.h" static gboolean _session_dbus_server_get_icon (SessionDbus * service, gchar ** icon, GError ** error); @@ -58,7 +59,7 @@ static void session_dbus_init (SessionDbus *self) { DBusGConnection * session = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - dbus_g_connection_register_g_object(session, "/bob", G_OBJECT(self)); + dbus_g_connection_register_g_object(session, INDICATOR_SESSION_SERVICE_DBUS_OBJECT, G_OBJECT(self)); SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); -- cgit v1.2.3 From fced2aaae755846922b46fa55a6444f0e0406c8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:08:25 -0600 Subject: Building us a proxy! Now we are dangerous. --- src/indicator-session.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index a815e40..0b8d77e 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -55,6 +55,7 @@ struct _IndicatorSession { IndicatorServiceManager * service; GtkImage * status_image; DbusmenuGtkMenu * menu; + DBusGProxy * service_proxy; }; GType indicator_session_get_type (void); @@ -109,6 +110,12 @@ indicator_session_init (IndicatorSession *self) dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + self->service_proxy = dbus_g_proxy_new_for_name(session_bus, + INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE); + return; } @@ -122,6 +129,11 @@ indicator_session_dispose (GObject *object) self->service = NULL; } + if (self->service_proxy != NULL) { + g_object_unref(self->service_proxy); + self->service_proxy = NULL; + } + G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object); return; } -- cgit v1.2.3 From 10ab858ea1a244f92b57d3e8c96c76045e02e93b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:26:50 -0600 Subject: Icon name changing signal for updating the image. --- src/indicator-session.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 0b8d77e..c23cd0b 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -70,6 +70,7 @@ static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static void icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -116,6 +117,14 @@ indicator_session_init (IndicatorSession *self) INDICATOR_SESSION_SERVICE_DBUS_OBJECT, INDICATOR_SESSION_SERVICE_DBUS_IFACE); + dbus_g_proxy_add_signal(self->service_proxy, "IconUpdated", + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(self->service_proxy, + "IconUpdated", + G_CALLBACK(icon_changed), + self, + NULL); + return; } @@ -152,6 +161,14 @@ get_label (IndicatorObject * io) return NULL; } +static void +icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data) +{ + IndicatorSession * session = INDICATOR_SESSION(user_data); + gtk_image_set_from_icon_name(session->status_image, icon_name, GTK_ICON_SIZE_MENU); + return; +} + static GtkImage * get_icon (IndicatorObject * io) { -- cgit v1.2.3 From 802d6447947701b2578a29babd2357642b982645 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:35:07 -0600 Subject: Setting the icon to something sensable --- src/session-dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-dbus.c b/src/session-dbus.c index f656bb0..7159d7f 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -63,7 +63,7 @@ session_dbus_init (SessionDbus *self) SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); - priv->name = g_strdup("icon"); + priv->name = g_strdup("system-shutdown-panel"); return; } -- cgit v1.2.3 From 746636765323cb223ef84af13920a9620176eb4f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:47:33 -0600 Subject: Getting the icon, but only when we're connected. --- src/indicator-session.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index c23cd0b..6e259dc 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -35,6 +35,7 @@ with this program. If not, see . #include "dbus-shared-names.h" #include "dbusmenu-shared.h" +#include "session-dbus-client.h" #define INDICATOR_SESSION_TYPE (indicator_session_get_type ()) #define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession)) @@ -71,6 +72,7 @@ static GtkMenu * get_menu (IndicatorObject * io); static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data); +static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -103,6 +105,7 @@ indicator_session_init (IndicatorSession *self) /* Now let's fire these guys up. */ self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); + g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); @@ -155,6 +158,28 @@ indicator_session_finalize (GObject *object) return; } +static void +icon_name_get_cb (DBusGProxy *proxy, char * OUT_name, GError *error, gpointer userdata) +{ + IndicatorSession * self = INDICATOR_SESSION(userdata); + gtk_image_set_from_icon_name(self->status_image, OUT_name, GTK_ICON_SIZE_MENU); + return; +} + +static void +service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION(user_data); + + if (connected) { + org_ayatana_indicator_session_service_get_icon_async(self->service_proxy, icon_name_get_cb, user_data); + } else { + gtk_image_set_from_icon_name(self->status_image, "system-shutdown-panel", GTK_ICON_SIZE_MENU); + } + + return; +} + static GtkLabel * get_label (IndicatorObject * io) { -- cgit v1.2.3 From 2dd05e216cdc0e7ab9318a410758eade2d3e68a4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:49:52 -0600 Subject: Moving the icon names into the shared header files --- src/dbus-shared-names.h | 3 +++ src/indicator-session.c | 4 ++-- src/session-dbus.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 2c30b36..8cbb488 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -45,4 +45,7 @@ with this program. If not, see . #define USER_ITEM_PROP_NAME "user-item-name" #define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" +#define ICON_DEFAULT "system-shutdown-panel" +#define ICON_RESTART "system-shutdown-restart-panel" + #endif /* __DBUS_SHARED_NAMES_H__ */ diff --git a/src/indicator-session.c b/src/indicator-session.c index 6e259dc..de18bb3 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -107,7 +107,7 @@ indicator_session_init (IndicatorSession *self) self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); - self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); + self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name(ICON_DEFAULT, GTK_ICON_SIZE_MENU)); self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); @@ -174,7 +174,7 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe if (connected) { org_ayatana_indicator_session_service_get_icon_async(self->service_proxy, icon_name_get_cb, user_data); } else { - gtk_image_set_from_icon_name(self->status_image, "system-shutdown-panel", GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name(self->status_image, ICON_DEFAULT, GTK_ICON_SIZE_MENU); } return; diff --git a/src/session-dbus.c b/src/session-dbus.c index 7159d7f..1413916 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -63,7 +63,7 @@ session_dbus_init (SessionDbus *self) SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); - priv->name = g_strdup("system-shutdown-panel"); + priv->name = g_strdup(ICON_DEFAULT); return; } -- cgit v1.2.3 From 5d784227da6b87b8588724ac1d894c6116fc2b01 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:52:13 -0600 Subject: Setting the icon when the restart is touched. --- src/session-service.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 693c73a..6c4dd1b 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -622,6 +622,7 @@ restart_dir_changed (void) dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required...")); } dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, "emblem-important"); + session_dbus_set_name(session_dbus, ICON_RESTART); } else { if (supress_confirmations()) { dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); @@ -629,6 +630,7 @@ restart_dir_changed (void) dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart...")); } dbusmenu_menuitem_property_remove(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME); + session_dbus_set_name(session_dbus, ICON_DEFAULT); } return; -- cgit v1.2.3 From 78211dc46ae22a439653df6db0f3b6e9c67160f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 16:07:33 -0600 Subject: Protecting from a NULL object --- src/session-service.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 6c4dd1b..b88ee30 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -622,15 +622,19 @@ restart_dir_changed (void) dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required...")); } dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, "emblem-important"); - session_dbus_set_name(session_dbus, ICON_RESTART); - } else { + if (session_dbus != NULL) { + session_dbus_set_name(session_dbus, ICON_RESTART); + } + } else { if (supress_confirmations()) { dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); } else { dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart...")); } dbusmenu_menuitem_property_remove(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME); - session_dbus_set_name(session_dbus, ICON_DEFAULT); + if (session_dbus != NULL) { + session_dbus_set_name(session_dbus, ICON_DEFAULT); + } } return; -- cgit v1.2.3 From 91d75debaa1a5aa7c210da029ab123c96633225b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 16:08:28 -0600 Subject: Making our service come up a little earlier --- src/session-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index b88ee30..75c8650 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -674,6 +674,8 @@ main (int argc, char ** argv) INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_shutdown), NULL); + session_dbus = session_dbus_new(); + g_idle_add(lock_screen_setup, NULL); root_menuitem = dbusmenu_menuitem_new(); @@ -699,8 +701,6 @@ 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') 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 From 44d2e3243736990ca867eba36f4371252e2adf11 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 16:19:05 -0600 Subject: Keeping the names the same for now, until we have artwork. --- src/dbus-shared-names.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 8cbb488..11d62bb 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -46,6 +46,6 @@ with this program. If not, see . #define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" #define ICON_DEFAULT "system-shutdown-panel" -#define ICON_RESTART "system-shutdown-restart-panel" +#define ICON_RESTART "system-shutdown-panel" #endif /* __DBUS_SHARED_NAMES_H__ */ -- cgit v1.2.3