From a4eb496c3b8f5455357ef2760e003e04d781f885 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Mar 2010 20:56:35 -0600 Subject: A bunch of properties to make our new menu item type. --- src/dbus-shared-names.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 253cba8..9d39ab3 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -42,4 +42,8 @@ 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 RESTART_ITEM_TYPE "x-canonical-restart-item" +#define RESTART_ITEM_LABEL "restart-label" +#define RESTART_ITEM_ICON "restart-icon" + #endif /* __DBUS_SHARED_NAMES_H__ */ -- cgit v1.2.3 From fb8754f048176039d268157a22da3745773bd15b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 12:25:58 -0600 Subject: Adding in a handler and renderer for the restart required item --- src/indicator-session.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index a815e40..fab3463 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -69,6 +69,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 gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -108,6 +109,7 @@ indicator_session_init (IndicatorSession *self) DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); + dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); return; } @@ -253,6 +255,60 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G static const gchar * dbusmenu_item_data = "dbusmenu-item"; +/* IF the label or icon changes we need to grab that and update + the menu item */ +static void +restart_property_change (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) +{ + DbusmenuGtkClient * client = DBUSMENU_GTKCLIENT(user_data); + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(client, item); + + if (g_strcmp0(property, RESTART_ITEM_LABEL) == 0) { + gtk_menu_item_set_label(gmi, g_value_get_string(value)); + } else if (g_strcmp0(property, RESTART_ITEM_ICON) == 0) { + GtkWidget * image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(gmi)); + + if (image == NULL) { + image = gtk_image_new_from_icon_name(g_value_get_string(value), GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), image); + } else { + gtk_image_set_from_icon_name(GTK_IMAGE(image), g_value_get_string(value), GTK_ICON_SIZE_MENU); + } + } + + return; +} + +/* Builds the restart item which is a more traditional GTK image + menu item that puts the graphic into the gutter. */ +static gboolean +build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + if (gmi == NULL) { + return FALSE; + } + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(restart_property_change), client); + + /* Grab the inital values and put them into the item */ + const GValue * value; + value = dbusmenu_menuitem_property_get_value(newitem, RESTART_ITEM_LABEL); + if (value != NULL) { + restart_property_change(newitem, RESTART_ITEM_LABEL, value, client); + } + + value = dbusmenu_menuitem_property_get_value(newitem, RESTART_ITEM_ICON); + if (value != NULL) { + restart_property_change(newitem, RESTART_ITEM_ICON, value, client); + } + + return TRUE; +} + + /* Callback for when the style changes so we can reevaluate the size of the user name with the potentially new font. */ static void @@ -265,7 +321,6 @@ switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) return; } - /* This function checks to see if the user name is short enough to not need ellipsing itself, or if, it will get ellipsed by the standard label processor. */ -- cgit v1.2.3 From 9bfcbd2b420b19a43d1704c6562d4709ebb570f6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 12:39:47 -0600 Subject: Changing the service to use the new menu item --- src/gconf-helper.c | 5 +++-- src/session-service.c | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 9262b19..5efc439 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -30,6 +30,7 @@ with this program. If not, see . #include #include +#include "dbus-shared-names.h" #include "gconf-helper.h" static GConfClient * gconf_client = NULL; @@ -50,11 +51,11 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC if(g_strcmp0 (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->restart_mi, RESTART_ITEM_LABEL, _("Restart")); dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off")); } 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->restart_mi, RESTART_ITEM_LABEL, _("Restart...")); dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off...")); } } diff --git a/src/session-service.c b/src/session-service.c index febf007..51a930a 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -555,10 +555,11 @@ rebuild_items (DbusmenuMenuitem *root, g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate"); restart_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_TYPE, RESTART_ITEM_TYPE); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); } else { - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart...")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("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"); @@ -615,18 +616,18 @@ restart_dir_changed (void) if (restart_required) { if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart Required")); } else { - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required...")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart Required...")); } - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, "emblem-important"); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_ICON, "emblem-important"); } else { if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); } else { - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart...")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart...")); } - dbusmenu_menuitem_property_remove(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME); + dbusmenu_menuitem_property_remove(restart_mi, RESTART_ITEM_ICON); } return; -- cgit v1.2.3 From 535a2e63fd4e605ef63c933797abedcc28a55861 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 13:04:22 -0600 Subject: Setting up the indicator to use library translations so they'll be grabbed from the right domain. --- src/indicator-session.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index a815e40..54431ee 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -20,9 +20,13 @@ 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 + #include #include -#include +#include #include #include -- cgit v1.2.3 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 From b419d049e7fe398e52739183f26cd486b7d9c421 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 16:33:33 -0600 Subject: Using the libindicator helpers so we get things like fallbacks! \o/ --- src/indicator-session.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index de18bb3..0282616 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -32,6 +32,7 @@ with this program. If not, see . #include #include #include +#include #include "dbus-shared-names.h" #include "dbusmenu-shared.h" @@ -107,7 +108,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(ICON_DEFAULT, GTK_ICON_SIZE_MENU)); + self->status_image = indicator_image_helper(ICON_DEFAULT); self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); @@ -162,7 +163,7 @@ 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); + indicator_image_helper_update(self->status_image, OUT_name); return; } @@ -174,7 +175,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, ICON_DEFAULT, GTK_ICON_SIZE_MENU); + indicator_image_helper_update(self->status_image, ICON_DEFAULT); } return; @@ -190,7 +191,7 @@ 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); + indicator_image_helper_update(session->status_image, icon_name); return; } -- cgit v1.2.3 From 7f489865a78b866ce22627c3ac5fb224a8bec4d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 17:23:04 -0600 Subject: Changing the emblem to system-restart-panel --- src/session-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 51a930a..7d21c38 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -620,7 +620,7 @@ restart_dir_changed (void) } else { dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart Required...")); } - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_ICON, "emblem-important"); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_ICON, "system-restart-panel"); } else { if (supress_confirmations()) { dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); -- cgit v1.2.3 From 3f28a83d87eeaea304b906c42e2b3f46822833f3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 17:38:33 -0600 Subject: Restart icon name. --- 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 41ac219..a6364b1 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -50,6 +50,6 @@ with this program. If not, see . #define RESTART_ITEM_ICON "restart-icon" #define ICON_DEFAULT "system-shutdown-panel" -#define ICON_RESTART "system-shutdown-panel" +#define ICON_RESTART "system-shutdown-panel-restart" #endif /* __DBUS_SHARED_NAMES_H__ */ -- cgit v1.2.3 From 4045ff049580248fdffa58a3b8c40bf4bef07682 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 21:08:15 -0600 Subject: Switching to building with GIcon so that we don't have to add an icon, we can use fallbacks. --- src/indicator-session.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 3349886..184a335 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -326,12 +326,14 @@ restart_property_change (DbusmenuMenuitem * item, const gchar * property, const } else if (g_strcmp0(property, RESTART_ITEM_ICON) == 0) { GtkWidget * image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(gmi)); + GIcon * gicon = g_themed_icon_new_with_default_fallbacks(g_value_get_string(value)); if (image == NULL) { - image = gtk_image_new_from_icon_name(g_value_get_string(value), GTK_ICON_SIZE_MENU); + image = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), image); } else { - gtk_image_set_from_icon_name(GTK_IMAGE(image), g_value_get_string(value), GTK_ICON_SIZE_MENU); + gtk_image_set_from_gicon(GTK_IMAGE(image), gicon, GTK_ICON_SIZE_MENU); } + g_object_unref(G_OBJECT(gicon)); } return; -- cgit v1.2.3 From 70a0dc7cf431dd2c7d4faa7081cbd7ea637a825f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 21:23:35 -0600 Subject: Making sure that if we can't get the icon, we leave it alone. --- src/indicator-session.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 184a335..55579b9 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -167,6 +167,14 @@ indicator_session_finalize (GObject *object) static void icon_name_get_cb (DBusGProxy *proxy, char * OUT_name, GError *error, gpointer userdata) { + if (error != NULL) { + return; + } + + if (OUT_name == NULL || OUT_name[0] == '\0') { + return; + } + IndicatorSession * self = INDICATOR_SESSION(userdata); gtk_image_set_from_icon_name(self->status_image, OUT_name, GTK_ICON_SIZE_MENU); return; -- cgit v1.2.3 From 501c8a7e9add926f34b6dbbcce9d9e6f81706445 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 21:54:12 -0600 Subject: Looking for a desktop file, and if it exists, putting it as a final menu item. --- src/session-service.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 51a930a..c98ecff 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include +#include #include #include @@ -50,6 +51,8 @@ with this program. If not, see . #define UP_OBJECT "/org/freedesktop/UPower" #define UP_INTERFACE "org.freedesktop.UPower" +#define DESKTOP_FILE "/usr/share/applications/indicator-session-extra.desktop" + #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" #define LOCKDOWN_DIR "/desktop/gnome/lockdown" @@ -415,6 +418,16 @@ compare_users_by_username (const gchar *a, return retval; } +/* Take a desktop file and execute it */ +static void +desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data) +{ + GAppInfo * appinfo = G_APP_INFO(data); + g_return_if_fail(appinfo != NULL); + g_app_info_launch(appinfo, NULL, NULL, NULL); + return; +} + /* Builds up the menu for us */ static void rebuild_items (DbusmenuMenuitem *root, @@ -580,6 +593,21 @@ rebuild_items (DbusmenuMenuitem *root, update_menu_entries(restart_shutdown_logout_mi); + if (g_file_test(DESKTOP_FILE, G_FILE_TEST_EXISTS)) { + GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(DESKTOP_FILE)); + + if (appinfo != NULL) { + DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator); + + DbusmenuMenuitem * desktop_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(desktop_mi, DBUSMENU_MENUITEM_PROP_LABEL, g_app_info_get_name(appinfo)); + g_signal_connect(G_OBJECT(desktop_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(desktop_activate_cb), appinfo); + dbusmenu_menuitem_child_append(root, desktop_mi); + } + } + return; } -- cgit v1.2.3 From 8ea0fde8939236cca0d11aa726fe5d98f6de6526 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 13:10:43 -0500 Subject: Changing the define name to have room for more locdown keys --- src/session-service.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index f6b666f..a64f701 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -56,8 +56,8 @@ with this program. If not, see . #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" -#define LOCKDOWN_DIR "/desktop/gnome/lockdown" -#define LOCKDOWN_KEY LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_DIR "/desktop/gnome/lockdown" +#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" typedef struct _ActivateData ActivateData; struct _ActivateData @@ -103,7 +103,7 @@ lockdown_changed (GConfClient *client, if (!value || !key) return; - if (g_strcmp0 (key, LOCKDOWN_KEY) == 0) + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) { if (switch_menuitem) { @@ -127,7 +127,7 @@ ensure_gconf_client (void) gconf_client = gconf_client_get_default (); notify_lockdown_id = gconf_client_notify_add (gconf_client, - LOCKDOWN_KEY, + LOCKDOWN_KEY_USER, lockdown_changed, NULL, NULL, @@ -484,7 +484,7 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_child_append (root, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); - if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) + if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL)) { dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } -- cgit v1.2.3 From df71f47685081f5125fb12c7bb170d88538e9523 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 13:28:19 -0500 Subject: Reacting to changes in the screensaver lockdown key. --- src/session-service.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index a64f701..7ebc00a 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -58,6 +58,7 @@ with this program. If not, see . #define LOCKDOWN_DIR "/desktop/gnome/lockdown" #define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" typedef struct _ActivateData ActivateData; struct _ActivateData @@ -97,26 +98,32 @@ lockdown_changed (GConfClient *client, GConfEntry *entry, gpointer user_data) { - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); + GConfValue *value = gconf_entry_get_value (entry); + const gchar *key = gconf_entry_get_key (entry); - if (!value || !key) - return; + if (value == NULL || key == NULL) { + return; + } - if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) - { - if (switch_menuitem) - { - if (gconf_value_get_bool (value)) - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } - else - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } - } + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) { + if (switch_menuitem != NULL) { + if (gconf_value_get_bool (value)) { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } else { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } + } + } if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + if (lock_menuitem != NULL) { + if (gconf_value_get_bool (value)) { + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } else { + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } + } + } + + return; } static void -- cgit v1.2.3 From aa52289c19291ffa9bc4ed70f67d1f683cbf6381 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 13:29:01 -0500 Subject: Embarassing 4 letter word to forget. Guess the compiler would add it back anyway though. --- src/session-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 7ebc00a..24623aa 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -113,7 +113,7 @@ lockdown_changed (GConfClient *client, dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); } } - } if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + } else if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { if (lock_menuitem != NULL) { if (gconf_value_get_bool (value)) { dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); -- cgit v1.2.3 From da365cbe9598860cc4e74938ded3ad735a6db396 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 14:11:55 -0500 Subject: Tracking the separator next to the lock item as well. --- src/session-service.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 24623aa..b976236 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -73,6 +73,7 @@ static UsersServiceDbus *dbus_interface = NULL; static SessionDbus *session_dbus = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; +static DbusmenuMenuitem *lock_separator = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; static DbusmenuMenuitem * root_menuitem = NULL; @@ -116,9 +117,11 @@ lockdown_changed (GConfClient *client, } else if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { if (lock_menuitem != NULL) { if (gconf_value_get_bool (value)) { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } else { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); } } } @@ -464,12 +467,14 @@ rebuild_items (DbusmenuMenuitem *root, } else { dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); } + lock_separator = NULL; if (can_activate == TRUE) { DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator1); + lock_separator = separator1; if (check_guest_session ()) { @@ -554,6 +559,9 @@ rebuild_items (DbusmenuMenuitem *root, DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); + if (lock_separator == NULL) { + lock_separator = separator; + } logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { -- cgit v1.2.3 From 065984db24fa4e8723d9dd5add9eec0e71d43ace Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 14:45:48 -0500 Subject: Switching around the GConf notification setup to do an entire directory. --- src/session-service.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index b976236..72a93eb 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -91,7 +91,6 @@ static DbusmenuMenuitem * restart_mi = NULL; static DbusmenuMenuitem * shutdown_mi = NULL; static GConfClient * gconf_client = NULL; -static guint notify_lockdown_id = 0; static void lockdown_changed (GConfClient *client, @@ -129,20 +128,17 @@ lockdown_changed (GConfClient *client, return; } +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ static void ensure_gconf_client (void) { - if (!gconf_client) - { - gconf_client = gconf_client_get_default (); - - notify_lockdown_id = gconf_client_notify_add (gconf_client, - LOCKDOWN_KEY_USER, - lockdown_changed, - NULL, - NULL, - NULL); - } + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); + } + return; } /* A return from the command to sleep the system. Make sure -- cgit v1.2.3 From 523c02493e72d1e99e23082e9b14af51fd54ae18 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:21:26 -0500 Subject: Switching from hiding entries to just rebuilding the menus. --- src/session-service.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 72a93eb..c0703bb 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -92,6 +92,8 @@ static DbusmenuMenuitem * shutdown_mi = NULL; static GConfClient * gconf_client = NULL; +static void rebuild_items (DbusmenuMenuitem *root, UsersServiceDbus *service); + static void lockdown_changed (GConfClient *client, guint cnxd_id, @@ -105,24 +107,8 @@ lockdown_changed (GConfClient *client, return; } - if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0) { - if (switch_menuitem != NULL) { - if (gconf_value_get_bool (value)) { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } else { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } - } else if (g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { - if (lock_menuitem != NULL) { - if (gconf_value_get_bool (value)) { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } else { - dbusmenu_menuitem_property_set_bool (lock_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - dbusmenu_menuitem_property_set_bool (lock_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + rebuild_items(root_menuitem, dbus_interface); } return; -- cgit v1.2.3 From 29bd57b57fe4cf4e964fdecf034cb2ecb8cd04b1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:33:36 -0500 Subject: Changing the lockdown key to do all the switching instead of just the switch user item. --- src/session-service.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index c0703bb..66d468f 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -434,7 +434,10 @@ rebuild_items (DbusmenuMenuitem *root, gboolean can_activate; GList *children; - can_activate = users_service_dbus_can_activate_session (service); + ensure_gconf_client (); + + can_activate = users_service_dbus_can_activate_session (service) && + !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); children = dbusmenu_menuitem_take_children (root); g_list_foreach (children, (GFunc)g_object_unref, NULL); @@ -470,22 +473,12 @@ rebuild_items (DbusmenuMenuitem *root, if (check_new_session ()) { - ensure_gconf_client (); switch_menuitem = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); dbusmenu_menuitem_child_append (root, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); - - if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL)) - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } - else - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } } GList * users = NULL; -- cgit v1.2.3 From c334ecccf05654c102b112cf7d76d2f38768924f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:36:48 -0500 Subject: Removing the lock separator as we don't need it anymore. --- src/session-service.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 66d468f..cadce43 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -73,7 +73,6 @@ static UsersServiceDbus *dbus_interface = NULL; static SessionDbus *session_dbus = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; -static DbusmenuMenuitem *lock_separator = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; static DbusmenuMenuitem * root_menuitem = NULL; @@ -452,14 +451,12 @@ rebuild_items (DbusmenuMenuitem *root, } else { dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); } - lock_separator = NULL; if (can_activate == TRUE) { DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator1); - lock_separator = separator1; if (check_guest_session ()) { @@ -534,9 +531,6 @@ rebuild_items (DbusmenuMenuitem *root, DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); - if (lock_separator == NULL) { - lock_separator = separator; - } logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { -- cgit v1.2.3 From bdba7e5c6a5081c599ade54e4798f9f1af0b536e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 15:52:17 -0500 Subject: Handling the locking of the screen in the rebuild function. --- src/session-service.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index cadce43..53c305c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -431,32 +431,38 @@ rebuild_items (DbusmenuMenuitem *root, GList *u; UserData *user; gboolean can_activate; + gboolean can_lockscreen; GList *children; ensure_gconf_client (); can_activate = users_service_dbus_can_activate_session (service) && !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); + can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); children = dbusmenu_menuitem_take_children (root); g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(root, lock_menuitem); - if (!will_lock_screen()) { - dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); - } else { - dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); + g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(root, lock_menuitem); + if (!will_lock_screen()) { + dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); + } else { + dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + } } if (can_activate == TRUE) { - DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator1); + if (can_lockscreen) { + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator1); + } if (check_guest_session ()) { @@ -528,9 +534,11 @@ rebuild_items (DbusmenuMenuitem *root, g_list_free(users); } - DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); + if (can_lockscreen || can_activate) { + DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator); + } logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { -- cgit v1.2.3 From acc3a9675f035777b3b32335edb7854860bfb9ba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:00:43 -0500 Subject: Adding some comments to describe a long function. --- src/session-service.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 53c305c..3ee1f6c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -434,16 +434,21 @@ rebuild_items (DbusmenuMenuitem *root, gboolean can_lockscreen; GList *children; + /* Make sure we have a valid GConf client, and build one + if needed */ ensure_gconf_client (); + /* Check to see which menu items we're allowed to have */ can_activate = users_service_dbus_can_activate_session (service) && !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); + /* Remove the old menu items if that makes sense */ children = dbusmenu_menuitem_take_children (root); g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); + /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); @@ -456,6 +461,7 @@ rebuild_items (DbusmenuMenuitem *root, } } + /* Build all of the user switching items */ if (can_activate == TRUE) { if (can_lockscreen) { @@ -534,12 +540,16 @@ rebuild_items (DbusmenuMenuitem *root, g_list_free(users); } + /* If there were a bunch of items before us, we need a + separator. */ if (can_lockscreen || can_activate) { DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root, separator); } + /* Start going through the session based items. */ + logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); -- cgit v1.2.3 From eb8756b0a8b55f904dd74103fa33d67b1da11575 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:02:06 -0500 Subject: Only setup signals if we're building the proxy for the first time. --- src/session-service.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 3ee1f6c..9cde4b0 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -266,19 +266,19 @@ setup_up (void) { UP_ADDRESS, UP_OBJECT, DBUS_INTERFACE_PROPERTIES); + /* Connect to changed signal */ + dbus_g_proxy_add_signal(up_main_proxy, + "Changed", + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal(up_main_proxy, + "Changed", + G_CALLBACK(up_changed_cb), + NULL, + NULL); } g_return_if_fail(up_prop_proxy != NULL); - /* Connect to changed signal */ - dbus_g_proxy_add_signal(up_main_proxy, - "Changed", - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(up_main_proxy, - "Changed", - G_CALLBACK(up_changed_cb), - NULL, - NULL); /* Force an original "changed" event */ up_changed_cb(up_main_proxy, NULL); -- cgit v1.2.3 From cef6711749d305967d0341920f08aef46d6390d7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:16:53 -0500 Subject: Switching the suspend/hibernate handling to a cached value. And that way we can regen the menus without looking up the values. --- src/session-service.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 9cde4b0..9eb6d88 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -89,6 +89,9 @@ static DbusmenuMenuitem * logout_mi = NULL; static DbusmenuMenuitem * restart_mi = NULL; static DbusmenuMenuitem * shutdown_mi = NULL; +static gboolean can_hibernate = TRUE; +static gboolean can_suspend = TRUE; + static GConfClient * gconf_client = NULL; static void rebuild_items (DbusmenuMenuitem *root, UsersServiceDbus *service); @@ -175,8 +178,10 @@ suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) } g_debug("Got Suspend: %s", g_value_get_boolean(&candoit) ? "true" : "false"); - if (suspend_mi != NULL) { - dbusmenu_menuitem_property_set_value(suspend_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, &candoit); + gboolean local_can_suspend = g_value_get_boolean(&candoit); + if (local_can_suspend != can_suspend) { + can_suspend = local_can_suspend; + rebuild_items(root_menuitem, dbus_interface); } return; @@ -198,8 +203,10 @@ hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) } g_debug("Got Hibernate: %s", g_value_get_boolean(&candoit) ? "true" : "false"); - if (suspend_mi != NULL) { - dbusmenu_menuitem_property_set_value(hibernate_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, &candoit); + gboolean local_can_hibernate = g_value_get_boolean(&candoit); + if (local_can_hibernate != can_hibernate) { + can_hibernate = local_can_hibernate; + rebuild_items(root_menuitem, dbus_interface); } return; @@ -559,17 +566,19 @@ rebuild_items (DbusmenuMenuitem *root, 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_bool(suspend_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sleep")); - dbusmenu_menuitem_child_append(root, suspend_mi); - g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); - - hibernate_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set_bool(hibernate_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); - dbusmenu_menuitem_child_append(root, hibernate_mi); - g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate"); + if (can_suspend) { + suspend_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sleep")); + dbusmenu_menuitem_child_append(root, suspend_mi); + g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); + } + + if (can_hibernate) { + hibernate_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); + dbusmenu_menuitem_child_append(root, hibernate_mi); + g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate"); + } restart_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_TYPE, RESTART_ITEM_TYPE); -- cgit v1.2.3 From 03a2de405664a797b723dd8bd542b26817dd44e6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 16:55:39 -0500 Subject: Adding properties for allowing the suspend and hibernate --- src/session-service.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 4820f59..a915884 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -91,6 +91,8 @@ static DbusmenuMenuitem * shutdown_mi = NULL; static gboolean can_hibernate = TRUE; static gboolean can_suspend = TRUE; +static gboolean allow_hibernate = TRUE; +static gboolean allow_suspend = TRUE; static GConfClient * gconf_client = NULL; @@ -566,14 +568,14 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_child_append(root, logout_mi); g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); - if (can_suspend) { + if (can_suspend && allow_suspend) { suspend_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Sleep")); dbusmenu_menuitem_child_append(root, suspend_mi); g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); } - if (can_hibernate) { + if (can_hibernate && allow_hibernate) { hibernate_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); dbusmenu_menuitem_child_append(root, hibernate_mi); -- cgit v1.2.3 From 05cd0a2405c81a1147ae519b9fa89e0579284abe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 17:02:31 -0500 Subject: Grabbing the upower definition file so that we can build a client for it. --- src/Makefile.am | 9 ++ src/upower.xml | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 318 insertions(+) create mode 100644 src/upower.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3037a3b..db41db6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,13 @@ users-service-client.h: $(srcdir)/users-service.xml --output=users-service-client.h \ $(srcdir)/users-service.xml +upower-client.h: $(srcdir)/upower.xml + dbus-binding-tool \ + --prefix=_upower_client \ + --mode=glib-client \ + --output=upower-client.h \ + $(srcdir)/upower.xml + session-dbus-client.h: $(srcdir)/session-dbus.xml dbus-binding-tool \ --prefix=_session_dbus_client \ @@ -108,6 +115,7 @@ BUILT_SOURCES = \ consolekit-manager-client.h \ session-dbus-client.h \ session-dbus-server.h \ + upower-client.h \ users-service-client.h \ users-service-marshal.h \ users-service-marshal.c @@ -115,6 +123,7 @@ BUILT_SOURCES = \ EXTRA_DIST = \ consolekit-manager.xml \ session-dbus.xml \ + upower.xml \ users-service.xml \ users-service.list diff --git a/src/upower.xml b/src/upower.xml new file mode 100644 index 0000000..a4066ff --- /dev/null +++ b/src/upower.xml @@ -0,0 +1,309 @@ + + + + + + + + The DeviceKit-power service is available via the system message + bus. To access the service, use + the org.freedesktop.UPower interface on + the /org/freedesktop/UPower object on + the D-Bus system bus service with the well-known + name org.freedesktop.UPower. + + + + +$ dbus-send --print-reply \ + --system \ + --dest=org.freedesktop.UPower \ + /org/freedesktop/UPower \ + org.freedesktop.UPower.EnumerateDevices + +method return sender=:1.386 -> dest=:1.451 reply_serial=2 + array [ + object path "/org/freedesktop/UPower/devices/line_power_AC" + object path "/org/freedesktop/UPower/devices/battery_BAT0" + ] + + + + + + + + + + + + An array of object paths for devices. + + + + + + Enumerate all power objects on the system. + + + + + + + + + + Object path of device that was added. + + + + + + Emitted when a device is added. + + + + + + + + + + Object path of device that was removed. + + + + + + Emitted when a device is removed. + + + + + + + + + + Object path of device that was changed. + + + + + + Emitted when a device changed. + + + + + + + + + + + + Emitted when one or more properties on the object changes. + + + + + + + + + + + + This signal is sent when the session is about to be suspended or + hibernated. + Session and system programs have one second to do anything required + before the sleep action is taken (such as sending out Avahi or + Jabber messages). + + + + + + + + + + + + This signal is sent when the session has just returned from + Suspend() or Hibernate(). + Session and system programs can then do anything required (such as + sending out Avahi or Jabber messages). + + + + + + + + + + + + + This method tells UPower that the Suspend() or Hibernate() method + is about to be called. + This allows UPower to emit the Suspending signal whilst + session activities are happening that have to be done before the + suspend process is started. + + + This method would typically be called by the session power + management daemon, before it locks the screen and waits for the + screen to fade to black. + The session power management component would then call Suspend() or + Hibernate() when these syncronous tasks have completed. + + + If this method is not called than nothing bad will happen and + Suspend() or Hibernate() will block for the required second. + + + + + + + + + + + + + Suspends the computer into a low power state. + System state is not preserved if the power is lost. + + + If AboutToRequestSleep() has not been called then UPower will send + the Sleeping() signal and block for one second. + + + If AboutToRequestSleep() has been called less than one second + before this method is called then UPower will block for the + remaining time to complete one second of delay. + + + + + + + + + + + TRUE if allowed, otherwise FALSE + + + + + Check if the caller has (or can get) the PolicyKit privilege to call + Suspend. + + + + + + + + + + + + + Hibernates the computer into a low power state. + System state is preserved if the power is lost. + + + If AboutToRequestSleep() has not been called then UPower will send + the Sleeping() signal and block for one second. + + + If AboutToRequestSleep() has been called less than one second + before this method is called then UPower will block for the + remaining time to complete one second of delay. + + + + + + + + + + + TRUE if allowed, otherwise FALSE + + + + + Check if the caller has (or can get) the PolicyKit privilege to call + Hibernate. + + + + + + + + + + Version of the running daemon, e.g. 002. + + + + + + Whether the system is able to suspend. + + + + + + Whether the system is able to hibernate. + + + + + + Indicates whether the system is running on battery power. + This property is provided for convenience. + + + + + + Indicates whether the system is running on battery power and if the battery is critically low. + This property is provided for convenience. + + + + + + + + Indicates if the laptop lid is closed where the display cannot be seen. + + + + + + + + + + If the system has a lid device. + + + + + + + + -- cgit v1.2.3 From 28ef20a9ad4b4b5e931b6eb4833accf44c65951f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 17:15:16 -0500 Subject: Use the upower allowed interface to check to see if PK is blocking suspend and hibernate --- src/session-service.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index a915884..9dd50bf 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -47,6 +47,7 @@ with this program. If not, see . #include "session-dbus.h" #include "users-service-dbus.h" #include "lock-helper.h" +#include "upower-client.h" #define UP_ADDRESS "org.freedesktop.UPower" #define UP_OBJECT "/org/freedesktop/UPower" @@ -254,6 +255,20 @@ up_changed_cb (DBusGProxy * proxy, gpointer user_data) return; } +/* Handle the callback from the allow functions to check and + see if we're changing the value, and if so, rebuilding the + menus based on that info. */ +static void +allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer userdata) +{ + gboolean * can_do = (gboolean *)userdata; + + if (OUT_allowed != *can_do) { + *can_do = OUT_allowed; + rebuild_items (root_menuitem, dbus_interface); + } +} + /* This function goes through and sets up what we need for DKp checking. We're even setting up the calls for the props we need */ @@ -292,6 +307,14 @@ setup_up (void) { /* Force an original "changed" event */ up_changed_cb(up_main_proxy, NULL); + /* Check to see if these are getting blocked by PolicyKit */ + org_freedesktop_UPower_suspend_allowed_async(up_main_proxy, + allowed_cb, + &allow_suspend); + org_freedesktop_UPower_hibernate_allowed_async(up_main_proxy, + allowed_cb, + &allow_hibernate); + return; } -- cgit v1.2.3 From 2d17c4577bdf36b417ede0eb12c771f89be74a99 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 17:17:39 -0500 Subject: Checking the error to make sure we're getting back reasonable data or reporting the error. --- src/session-service.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 9dd50bf..7c7e513 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -261,6 +261,11 @@ up_changed_cb (DBusGProxy * proxy, gpointer user_data) static void allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer userdata) { + if (error != NULL) { + g_warning("Unable to get information on what is allowed from UPower: %s", error->message); + return; + } + gboolean * can_do = (gboolean *)userdata; if (OUT_allowed != *can_do) { -- cgit v1.2.3 From c90b0b458471bf826dbe0402d13bfc9f95793ed7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 20:19:27 -0500 Subject: Lock the screen in the various activate functions. --- src/session-service.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fa90da2..aff963d 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -342,6 +342,9 @@ static void activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) { GError * error = NULL; + + lock_screen(mi, timestamp, user_data); + if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER, &error)) { g_warning("Unable to start guest session: %s", error->message); g_error_free(error); @@ -382,6 +385,9 @@ static void activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) { GError * error = NULL; + + lock_screen(mi, timestamp, user_data); + if (!g_spawn_command_line_async("gdmflexiserver --startnew", &error)) { g_warning("Unable to start new session: %s", error->message); g_error_free(error); @@ -397,6 +403,8 @@ activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data UserData *user = (UserData *)user_data; UsersServiceDbus *service = user->service; + lock_screen(mi, timestamp, user_data); + users_service_dbus_activate_user_session (service, user); } -- cgit v1.2.3 From 40e7ac045c4c4cb93b71bf532187891f67825ce3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 20:46:01 -0500 Subject: Making a small little wrapper to check the lockdown key. --- src/session-service.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 3832e89..020aad3 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -129,6 +129,20 @@ ensure_gconf_client (void) return; } +/* Check to see if the lockdown key is protecting from + locking the screen. If not, lock it. */ +static void +lock_if_possible (void) { + ensure_gconf_client (); + + if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + lock_screen(NULL, 0, NULL); + } + + return; +} + + /* A return from the command to sleep the system. Make sure that we unthrottle the screensaver. */ static void @@ -150,7 +164,7 @@ machine_sleep (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) } screensaver_throttle(type); - lock_screen(NULL, 0, NULL); + lock_if_possible(); dbus_g_proxy_begin_call(up_main_proxy, type, @@ -341,7 +355,7 @@ activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_da { GError * error = NULL; - lock_screen(mi, timestamp, user_data); + lock_if_possible(); if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER, &error)) { g_warning("Unable to start guest session: %s", error->message); @@ -384,7 +398,7 @@ activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data { GError * error = NULL; - lock_screen(mi, timestamp, user_data); + lock_if_possible(); if (!g_spawn_command_line_async("gdmflexiserver --startnew", &error)) { g_warning("Unable to start new session: %s", error->message); @@ -401,7 +415,7 @@ activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data UserData *user = (UserData *)user_data; UsersServiceDbus *service = user->service; - lock_screen(mi, timestamp, user_data); + lock_if_possible(); users_service_dbus_activate_user_session (service, user); } -- cgit v1.2.3 From 9efeb48b00b52c8c2886c1c3a69d96d80b92d84d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 20:47:28 -0500 Subject: Switching the debug message to be more correct. --- src/lock-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index b38be65..47dcb71 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -182,7 +182,7 @@ lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data) { g_debug("Lock Screen"); if (!will_lock_screen()) { - g_debug("\tGDM set to autologin, blocking lock"); + g_debug("\tUser is guest, blocking lock"); return; } -- cgit v1.2.3 From 868fd5ed54d3d3e5ce8c054c9381602a2671e34d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 21:50:48 -0500 Subject: Update to handle the new key for showing the logout menu item. --- src/gconf-helper.c | 23 ++++++++++++++++++++++- src/gconf-helper.h | 8 +++++--- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 5efc439..588b11c 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -43,6 +43,14 @@ supress_confirmations (void) { return gconf_client_get_bool (gconf_client, SUPPRESS_KEY, NULL) ; } +gboolean +show_logout (void) { + if(!gconf_client) { + gconf_client = gconf_client_get_default (); + } + return !gconf_client_get_bool (gconf_client, LOGOUT_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); @@ -61,8 +69,19 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC } } +static void +update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { + DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data; + GConfValue * value = gconf_entry_get_value (entry); + const gchar * key = gconf_entry_get_key (entry); + + if(g_strcmp0 (key, LOGOUT_KEY) == 0) { + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE, !gconf_value_get_bool(value)); + } +} + void -update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) { +update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi, DbusmenuMenuitem * logoutitem) { if(!gconf_client) { gconf_client = gconf_client_get_default (); } @@ -70,5 +89,7 @@ update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi) GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_notify_add (gconf_client, SUPPRESS_KEY, update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); + gconf_client_notify_add (gconf_client, LOGOUT_KEY, + update_logout_callback, logoutitem, NULL, NULL); } diff --git a/src/gconf-helper.h b/src/gconf-helper.h index 951bb0f..6f9bcb7 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -33,8 +33,9 @@ with this program. If not, see . #include #include -#define SUPPRESS_KEY "/apps/indicator-session/suppress_logout_restart_shutdown" -#define GLOBAL_DIR "/apps/indicator-session" +#define GLOBAL_DIR "/apps/indicator-session" +#define SUPPRESS_KEY GLOBAL_DIR "/suppress_logout_restart_shutdown" +#define LOGOUT_KEY GLOBAL_DIR "/suppress_logout_menuitem" typedef struct _RestartShutdownLogoutMenuItems { @@ -44,7 +45,8 @@ typedef struct _RestartShutdownLogoutMenuItems } RestartShutdownLogoutMenuItems; -void update_menu_entries(RestartShutdownLogoutMenuItems*); +void update_menu_entries(RestartShutdownLogoutMenuItems*, DbusmenuMenuitem * logoutitem); gboolean supress_confirmations (void); +gboolean show_logout (void); #endif /* __GCONF_HELPER__ */ -- cgit v1.2.3 From ae2c94b40826bfa0274a3eae8ae515d99b07adb5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 15 Mar 2010 21:51:14 -0500 Subject: Add in checking whether the logout button is shown, and get it changing with the others. --- src/session-service.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fa90da2..6f27d2c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -554,6 +554,7 @@ rebuild_items (DbusmenuMenuitem *root, } else { dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out...")); } + dbusmenu_menuitem_property_set_bool(logout_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_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"); @@ -593,7 +594,7 @@ rebuild_items (DbusmenuMenuitem *root, restart_shutdown_logout_mi->restart_mi = restart_mi; restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; - update_menu_entries(restart_shutdown_logout_mi); + update_menu_entries(restart_shutdown_logout_mi, logout_mi); if (g_file_test(DESKTOP_FILE, G_FILE_TEST_EXISTS)) { GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(DESKTOP_FILE)); -- cgit v1.2.3 From 29e2c7e6daf9362367af0d801da0aa54174bb480 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 14:44:39 -0500 Subject: Add in the key for locking the screen and making that part of will_lock --- src/lock-helper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index b38be65..b0340ea 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -19,9 +19,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include #include #include "lock-helper.h" +#define GCONF_DIR "/apps/gnome-screensaver" +#define GCONF_KEY GCONF_DIR "/lock_enabled" + static DBusGProxy * gss_proxy = NULL; static GMainLoop * gss_mainloop = NULL; static guint cookie = 0; @@ -29,6 +33,8 @@ static DBusGProxyCall * cookie_call = NULL; static gboolean is_guest = FALSE; +static GConfClient * gconf_client = NULL; + void build_gss_proxy (void); /* Checks to see if there is an error and reports @@ -124,7 +130,11 @@ will_lock_screen (void) return FALSE; } - return TRUE; + if (gconf_client == NULL) { + gconf_client = gconf_client_get_default(); + } + + return !gconf_client_get_bool (gconf_client, GCONF_KEY, NULL); } /* When the screensave go active, if we've got a mainloop -- cgit v1.2.3 From 0cfa0d154f3e3fcea6c4d0c946fa665c0b12aa9a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 14:47:41 -0500 Subject: Bad boolean --- src/lock-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index b0340ea..894801e 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -134,7 +134,7 @@ will_lock_screen (void) gconf_client = gconf_client_get_default(); } - return !gconf_client_get_bool (gconf_client, GCONF_KEY, NULL); + return gconf_client_get_bool (gconf_client, GCONF_KEY, NULL); } /* When the screensave go active, if we've got a mainloop -- cgit v1.2.3 From 5bb98fd170f62423ed936fd19bab72f0ee118d81 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 15:44:41 -0500 Subject: Tracking the notifications, so that we can unregister them with new menus. --- src/gconf-helper.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 588b11c..77fde1d 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -34,6 +34,8 @@ with this program. If not, see . #include "gconf-helper.h" static GConfClient * gconf_client = NULL; +static guint confirmation_notify = 0; +static guint logout_notify = 0; gboolean supress_confirmations (void) { @@ -82,14 +84,31 @@ update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, void update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi, DbusmenuMenuitem * logoutitem) { + /* If we don't have a client, build one. */ 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, + + /* If we've not gotten any notifications, then we need + to add the directory for notifications to come from. */ + if (confirmation_notify == 0 || logout_notify == 0) { + gconf_client_add_dir (gconf_client, GLOBAL_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + } + + if (confirmation_notify != 0) { + gconf_client_notify_remove (gconf_client, confirmation_notify); + confirmation_notify = 0; + } + + if (logout_notify != 0) { + gconf_client_notify_remove (gconf_client, logout_notify); + logout_notify = 0; + } + + confirmation_notify = gconf_client_notify_add (gconf_client, SUPPRESS_KEY, update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); - gconf_client_notify_add (gconf_client, LOGOUT_KEY, + logout_notify = gconf_client_notify_add (gconf_client, LOGOUT_KEY, update_logout_callback, logoutitem, NULL, NULL); } -- cgit v1.2.3 From 9bf67d563e8b819364327c1635095ea885faf543 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 16:02:04 -0500 Subject: Instead of making the item disabled, change the text when we won't lock the screen. --- src/session-service.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fb20f3b..5614ab4 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -509,14 +509,13 @@ rebuild_items (DbusmenuMenuitem *root, /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(root, lock_menuitem); - if (!will_lock_screen()) { - dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); + if (will_lock_screen()) { + dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); } else { - dbusmenu_menuitem_property_set_bool(lock_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Start Screensaver")); } + g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(root, lock_menuitem); } /* Build all of the user switching items */ -- cgit v1.2.3 From 0b1551709e115304dadfecc6c4224be8545dfcce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 16:16:00 -0500 Subject: Adding a function for updating the logout menuitem. --- src/lock-helper.c | 11 +++++++++++ src/lock-helper.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index 20149ab..4b57f19 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -231,3 +231,14 @@ lock_screen_setup (gpointer data) return FALSE; } +void +lock_screen_update_item (DbusmenuMenuitem * mi) +{ + if (gconf_client == NULL) { + gconf_client = gconf_client_get_default(); + } + + + + +} diff --git a/src/lock-helper.h b/src/lock-helper.h index 37f1448..1d707d8 100644 --- a/src/lock-helper.h +++ b/src/lock-helper.h @@ -31,4 +31,6 @@ gboolean will_lock_screen (void); void lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data); gboolean lock_screen_setup (gpointer data); +void lock_screen_update_item (DbusmenuMenuitem * mi); + #endif /* LOCK_HELPER_H__ */ -- cgit v1.2.3 From c5050f03e27166026a55b21353d3ee058e077523 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 16:16:50 -0500 Subject: Connecting in the update item. --- src/session-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 5614ab4..b5fb42e 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -516,6 +516,7 @@ rebuild_items (DbusmenuMenuitem *root, } g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); dbusmenu_menuitem_child_append(root, lock_menuitem); + lock_screen_update_item(lock_menuitem); } /* Build all of the user switching items */ -- cgit v1.2.3 From c8438f91c8b1d588bc0d353b93852e27c3434a34 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 16:26:29 -0500 Subject: Adding in the mechanism to actually do the callback and change the label. --- src/lock-helper.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index 4b57f19..3c2a7d5 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include #include #include #include "lock-helper.h" @@ -231,6 +232,28 @@ lock_screen_setup (gpointer data) return FALSE; } +/* When the GConf key changes we need to adjust the text on + what we're going to do with the menu item */ +static void +lockscreen_update (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { + DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data; + const gchar * key = gconf_entry_get_key (entry); + + if(g_strcmp0 (key, GCONF_KEY) == 0) { + if (will_lock_screen()) { + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); + } else { + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Start Screensaver")); + } + } +} + +/* Notification handler for lock menuitems. */ +guint lock_notify = 0; + +/* Sets the menu item to be updating. There can + only be one. So we clear and reset if we get + another. */ void lock_screen_update_item (DbusmenuMenuitem * mi) { @@ -238,7 +261,19 @@ lock_screen_update_item (DbusmenuMenuitem * mi) gconf_client = gconf_client_get_default(); } + if (lock_notify == 0) { + gconf_client_add_dir (gconf_client, + GCONF_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, + NULL); + } + if (lock_notify != 0) { + gconf_client_notify_remove(gconf_client, lock_notify); + lock_notify = 0; + } + lock_notify = gconf_client_notify_add(gconf_client, GCONF_KEY, lockscreen_update, mi, NULL, NULL); + return; } -- cgit v1.2.3 From 02de3c1bb351ef18c404c4cd7fc2cf1e1a89a4eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 16:35:01 -0500 Subject: Forgot to make this static. --- src/lock-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index 3c2a7d5..e150cbc 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -249,7 +249,7 @@ lockscreen_update (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpoin } /* Notification handler for lock menuitems. */ -guint lock_notify = 0; +static guint lock_notify = 0; /* Sets the menu item to be updating. There can only be one. So we clear and reset if we get -- cgit v1.2.3 From c0b109efe19528618028937b092a7f86d51add41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 16:36:28 -0500 Subject: Splitting out the params here. --- src/lock-helper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index e150cbc..86669f6 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -273,7 +273,12 @@ lock_screen_update_item (DbusmenuMenuitem * mi) lock_notify = 0; } - lock_notify = gconf_client_notify_add(gconf_client, GCONF_KEY, lockscreen_update, mi, NULL, NULL); + lock_notify = gconf_client_notify_add(gconf_client, + GCONF_KEY, + lockscreen_update, + mi, + NULL, + NULL); return; } -- cgit v1.2.3 From 6eea2650dc1b6b0ecc16b9de2b1c2471f90454e7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 16:52:17 -0500 Subject: Make sure to call to activate teh screensaver if we can't lock it. Oh, and that takes a reply. --- src/lock-helper.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lock-helper.c b/src/lock-helper.c index 86669f6..ba6b182 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -186,24 +186,45 @@ activate_timeout (gpointer data) return FALSE; } +/* Handle errors from activating the screensaver */ +static void +active_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer user_data) +{ + GError * error = NULL; + + dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID); + + if (error != NULL) { + g_warning("Unable to activate screensaver: %s", error->message); + g_error_free(error); + } + + return; +} + /* A fun little function to actually lock the screen. If, that's what you want, let's do it! */ void lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data) { g_debug("Lock Screen"); - if (!will_lock_screen()) { - g_debug("\tUser is guest, blocking lock"); - return; - } build_gss_proxy(); g_return_if_fail(gss_proxy != NULL); - dbus_g_proxy_call_no_reply(gss_proxy, - "Lock", - G_TYPE_INVALID, - G_TYPE_INVALID); + if (will_lock_screen()) { + dbus_g_proxy_call_no_reply(gss_proxy, + "Lock", + G_TYPE_INVALID, + G_TYPE_INVALID); + } else { + dbus_g_proxy_begin_call(gss_proxy, + "SetActive", + active_cb, NULL, + NULL, + G_TYPE_BOOLEAN, TRUE, + G_TYPE_INVALID); + } if (gss_mainloop == NULL) { gss_mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From 94cd451d64dec28a5649038b3de1c5971f8f6137 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 19:58:54 -0500 Subject: Adding a way to activate the guest session through GDM --- src/session-service.c | 7 +++++++ src/users-service-dbus.c | 8 ++++++++ src/users-service-dbus.h | 1 + 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fb20f3b..cb36e9c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -386,6 +386,13 @@ activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_da lock_if_possible(); + if (dbusmenu_menuitem_property_get_bool(mi, USER_ITEM_PROP_LOGGED_IN)) { + if (users_service_dbus_activate_guest_session(USERS_SERVICE_DBUS(user_data))) { + return; + } + g_warning("Unable to activate guest session, falling back to command line activation."); + } + if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER, &error)) { g_warning("Unable to start guest session: %s", error->message); g_error_free(error); diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 4aefdff..556af98 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -1005,6 +1005,14 @@ users_service_dbus_get_user_list (UsersServiceDbus *self) return g_hash_table_get_values (priv->users); } +/* Activates the guest account if it can. */ +gboolean +users_service_dbus_activate_guest_session (UsersServiceDbus *self) +{ + + return FALSE; +} + gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user) diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index bba88a7..29f6690 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -80,6 +80,7 @@ GList *users_service_dbus_get_user_list (UsersServiceDbus *self); gboolean users_service_dbus_can_activate_session (UsersServiceDbus *self); gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user); +gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self); G_END_DECLS -- cgit v1.2.3 From 9d36c2090992551a961005bf359cdab739c8beed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 20:32:20 -0500 Subject: Adding in the GDM local display DBus interface spec. --- src/Makefile.am | 9 +++++++++ src/gdm-local-display-factory.xml | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/gdm-local-display-factory.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index db41db6..01a88a3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,13 @@ consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml --output=consolekit-manager-client.h \ $(srcdir)/consolekit-manager.xml +gdm-local-display-factory-client.h: $(srcdir)/gdm-local-display-factory.xml + dbus-binding-tool \ + --prefix=_gdm_local_display_factory_client \ + --mode=glib-client \ + --output=gdm-local-display-factory-client.h \ + $(srcdir)/gdm-local-display-factory.xml + users-service-client.h: $(srcdir)/users-service.xml dbus-binding-tool \ --prefix=_users_service_client \ @@ -113,6 +120,7 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + gdm-local-display-factory-client.h \ session-dbus-client.h \ session-dbus-server.h \ upower-client.h \ @@ -122,6 +130,7 @@ BUILT_SOURCES = \ EXTRA_DIST = \ consolekit-manager.xml \ + gdm-local-display-factory.xml \ session-dbus.xml \ upower.xml \ users-service.xml \ diff --git a/src/gdm-local-display-factory.xml b/src/gdm-local-display-factory.xml new file mode 100644 index 0000000..66fb77c --- /dev/null +++ b/src/gdm-local-display-factory.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 1a451a7dbf5eed2b4ea8fd1e221bac036c3b9d4b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 20:42:58 -0500 Subject: Building a proxy to the local display factory --- src/users-service-dbus.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 556af98..80ab5be 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -31,6 +31,7 @@ #include #include "dbus-shared-names.h" +#include "gdm-local-display-factory-client.h" #include "users-service-dbus.h" #include "users-service-client.h" #include "users-service-marshal.h" @@ -80,6 +81,7 @@ struct _UsersServiceDbusPrivate DBusGConnection *system_bus; DBusGProxy *gdm_proxy; + DBusGProxy *gdm_local_proxy; DBusGProxy *ck_proxy; DBusGProxy *seat_proxy; DBusGProxy *session_proxy; @@ -266,6 +268,11 @@ create_gdm_proxy (UsersServiceDbus *self) G_CALLBACK (user_updated), self, NULL); + + priv->gdm_local_proxy = dbus_g_proxy_new_for_name (priv->system_bus, + "org.gnome.DisplayManager", + "/org/gnome/DisplayManager/LocalDisplayFactory", + "org.gnome.DisplayManager.LocalDisplayFactory"); } static void -- cgit v1.2.3 From 5a06c7033c279c5421894ed99d01adb449568521 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 20:51:22 -0500 Subject: Switching both of these function to using the generated header file. --- src/users-service-dbus.c | 58 +++++------------------------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 80ab5be..9e7af5d 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -1016,65 +1016,17 @@ users_service_dbus_get_user_list (UsersServiceDbus *self) gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self) { - - return FALSE; + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + return org_gnome_DisplayManager_LocalDisplayFactory_switch_to_user(priv->gdm_local_proxy, "guest", NULL, NULL); } +/* Activates a specific user */ gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user) { - UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - DBusMessage *message = NULL; - DBusMessage *reply = NULL; - DBusError error; - - dbus_error_init (&error); - - if (!(message = dbus_message_new_method_call ("org.gnome.DisplayManager", - "/org/gnome/DisplayManager/LocalDisplayFactory", - "org.gnome.DisplayManager.LocalDisplayFactory", - "SwitchToUser"))) - { - g_warning ("failed to create new message"); - return FALSE; - } - - if (!dbus_message_append_args (message, - DBUS_TYPE_STRING, &user->user_name, - DBUS_TYPE_INVALID)) - { - g_warning ("failed to append args"); - return FALSE; - } - - if (!(reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (priv->system_bus), - message, - -1, - &error))) - { - if (dbus_error_is_set (&error)) - { - g_warning ("Failed to send message: %s", error.message); - dbus_error_free (&error); - - return FALSE; - } - } - - if (message) - { - dbus_message_unref (message); - } - - if (reply) - { - dbus_message_unref (reply); - } - - dbus_error_free (&error); - - return TRUE; + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + return org_gnome_DisplayManager_LocalDisplayFactory_switch_to_user(priv->gdm_local_proxy, user->user_name, NULL, NULL); } gboolean -- cgit v1.2.3 From 41fb4503ec3443835be5176733158cf5bcf372d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:46:42 -0500 Subject: Adding a menuitem property to the user data structure. --- src/users-service-dbus.c | 1 + src/users-service-dbus.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 9e7af5d..d0b52a9 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -664,6 +664,7 @@ sync_users (UsersServiceDbus *self) user->login_count = g_value_get_int (g_value_array_get_nth (values, 4)); user->icon_url = g_strdup (g_value_get_string (g_value_array_get_nth (values, 5))); user->real_name_conflict = FALSE; + user->menuitem = NULL; g_hash_table_insert (priv->users, g_strdup (user->user_name), diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index 29f6690..15dd71b 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -22,6 +22,7 @@ #include #include +#include G_BEGIN_DECLS @@ -47,7 +48,10 @@ struct _UserData GList *sessions; + /* Whether the real name here conflicts with another in the system */ gboolean real_name_conflict; + /* The menuitem representing this user if there is one. */ + DbusmenuMenuitem * menuitem; UsersServiceDbus *service; }; -- cgit v1.2.3 From 6b1354f942d4482e85c1f15b3d3649cb7c20ea63 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:47:45 -0500 Subject: Setting the menuitem for the user. --- src/session-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index cb36e9c..bc88473 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -599,6 +599,7 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); + user->menuitem = mi; } } -- cgit v1.2.3 From 8dddf3fd91765a2811732e1c5dc4a533e55bc5cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:52:29 -0500 Subject: When a session is added or removed we need to change the state of that user item. --- src/users-service-dbus.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index d0b52a9..f3952ed 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -498,6 +498,10 @@ do_add_session (UsersServiceDbus *service, g_debug ("Adding session %s", ssid); user->sessions = g_list_prepend (user->sessions, g_strdup (ssid)); + + if (user->menuitem != NULL) { + dbusmenu_menuitem_property_set_bool(user->menuitem, USER_ITEM_PROP_LOGGED_IN, TRUE); + } } else { @@ -599,6 +603,9 @@ seat_proxy_session_removed (DBusGProxy *seat_proxy, g_free (l->data); user->sessions = g_list_delete_link (user->sessions, l); + if (user->menuitem != NULL && user->sessions == NULL) { + dbusmenu_menuitem_property_set_bool(user->menuitem, USER_ITEM_PROP_LOGGED_IN, FALSE); + } } else { -- cgit v1.2.3 From 7e38445544d5d0b000336d99b3f91462e63523f5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:56:38 -0500 Subject: Adding a guest_item for the guest menu item and a function to set it. --- src/users-service-dbus.c | 12 ++++++++++++ src/users-service-dbus.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index f3952ed..c8974b9 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -88,6 +88,8 @@ struct _UsersServiceDbusPrivate GHashTable *exclusions; GHashTable *sessions; + + DbusmenuMenuitem * guest_item; }; #define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate)) @@ -157,6 +159,7 @@ users_service_dbus_init (UsersServiceDbus *self) priv->users = NULL; priv->count = 0; + priv->guest_item = NULL; /* Get the system bus */ priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); @@ -1069,3 +1072,12 @@ users_service_dbus_can_activate_session (UsersServiceDbus *self) return can_activate; } + +/* Sets the menu item that represents the guest account */ +void +users_service_dbus_set_guest_item (UsersServiceDbus * self, DbusmenuMenuitem * mi) +{ + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + priv->guest_item = mi; + return; +} diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index 15dd71b..4798d64 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -85,6 +85,8 @@ gboolean users_service_dbus_can_activate_session (UsersServiceDbus *self); gboolean users_service_dbus_activate_user_session (UsersServiceDbus *self, UserData *user); gboolean users_service_dbus_activate_guest_session (UsersServiceDbus *self); +void users_service_dbus_set_guest_item (UsersServiceDbus * self, + DbusmenuMenuitem * mi); G_END_DECLS -- cgit v1.2.3 From 2e0cbb1a5a969eb5b983e9b899a3638d5b8136d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 21:58:59 -0500 Subject: Setting the guest item once it gets built. --- src/session-service.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index bc88473..379a0a2 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -526,6 +526,9 @@ rebuild_items (DbusmenuMenuitem *root, } } + /* Set to NULL just incase we don't end up building one */ + users_service_dbus_set_guest_item(service, NULL); + /* Build all of the user switching items */ if (can_activate == TRUE) { @@ -543,6 +546,7 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); dbusmenu_menuitem_child_append (root, guest_mi); g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL); + users_service_dbus_set_guest_item(service, guest_mi); } if (check_new_session ()) -- cgit v1.2.3 From 6193ab20bfa8d93f5c3fcf70284fbe7beef69fff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 22:23:37 -0500 Subject: Setting the logged in parameter on the guest item and tracking the session ID of the guest session. --- src/users-service-dbus.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index c8974b9..3156802 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -90,6 +90,7 @@ struct _UsersServiceDbusPrivate GHashTable *sessions; DbusmenuMenuitem * guest_item; + gchar * guest_session_id; }; #define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate)) @@ -160,6 +161,7 @@ users_service_dbus_init (UsersServiceDbus *self) priv->users = NULL; priv->count = 0; priv->guest_item = NULL; + priv->guest_session_id = NULL; /* Get the system bus */ priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); @@ -203,6 +205,13 @@ users_service_dbus_dispose (GObject *object) static void users_service_dbus_finalize (GObject *object) { + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (object); + + if (priv->guest_session_id != NULL) { + g_free(priv->guest_session_id); + priv->guest_session_id = NULL; + } + G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object); } @@ -570,6 +579,16 @@ seat_proxy_session_added (DBusGProxy *seat_proxy, return; } + /* We need to special case guest here because it doesn't + show up in the GDM user tables. */ + if (g_strcmp0("guest", pwent->pw_name) == 0) { + if (priv->guest_item != NULL) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, TRUE); + } + priv->guest_session_id = g_strdup(session_id); + return; + } + user = g_hash_table_lookup (priv->users, pwent->pw_name); if (!user) { @@ -590,8 +609,14 @@ seat_proxy_session_removed (DBusGProxy *seat_proxy, GList *l; username = g_hash_table_lookup (priv->sessions, session_id); - if (!username) + if (!username) { + if (g_strcmp0(session_id, priv->guest_session_id) == 0) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, FALSE); + g_free(priv->guest_session_id); + priv->guest_session_id = NULL; + } return; + } user = g_hash_table_lookup (priv->users, username); if (!user) @@ -1079,5 +1104,10 @@ users_service_dbus_set_guest_item (UsersServiceDbus * self, DbusmenuMenuitem * m { UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); priv->guest_item = mi; + + if (priv->guest_session_id != NULL) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, TRUE); + } + return; } -- cgit v1.2.3 From da26ce14f49d21e1cb72167f9e1bf43069b4f0d0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Mar 2010 22:58:30 -0500 Subject: Switching to using sesson proxies for the session we want to look at instead of our session --- src/users-service-dbus.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 3156802..3589a6a 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -66,7 +66,7 @@ static void seat_proxy_session_removed (DBusGProxy *seat_ static gboolean do_add_session (UsersServiceDbus *service, UserData *user, const gchar *ssid); -static gchar * get_seat_internal (UsersServiceDbus *self); +static gchar * get_seat_internal (DBusGProxy *proxy); /* Private */ typedef struct _UsersServiceDbusPrivate UsersServiceDbusPrivate; @@ -402,19 +402,18 @@ get_seat (UsersServiceDbus *service) priv->ssid = ssid; create_cksession_proxy (service); - seat = get_seat_internal (service); + seat = get_seat_internal (priv->session_proxy); return seat; } static gchar * -get_seat_internal (UsersServiceDbus *self) +get_seat_internal (DBusGProxy *proxy) { - UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); GError *error = NULL; gchar *seat = NULL; - if (!dbus_g_proxy_call (priv->session_proxy, + if (!dbus_g_proxy_call (proxy, "GetSeatId", &error, G_TYPE_INVALID, @@ -440,8 +439,14 @@ get_unix_user (UsersServiceDbus *service, UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service); GError *error = NULL; guint uid; + DBusGProxy *session_proxy; + + session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, + "org.freedesktop.ConsoleKit", + session_id, + "org.freedesktop.ConsoleKit.Session"); - if (dbus_g_proxy_call (priv->session_proxy, + if (dbus_g_proxy_call (session_proxy, "GetUnixUser", &error, G_TYPE_INVALID, @@ -454,6 +459,7 @@ get_unix_user (UsersServiceDbus *service, g_error_free (error); } + g_object_unref(session_proxy); return FALSE; } @@ -462,6 +468,7 @@ get_unix_user (UsersServiceDbus *service, *uidp = (uid_t)uid; } + g_object_unref(session_proxy); return TRUE; } @@ -474,14 +481,22 @@ do_add_session (UsersServiceDbus *service, GError *error = NULL; gchar *seat = NULL; gchar *xdisplay = NULL; + DBusGProxy * session_proxy; GList *l; - seat = get_seat_internal (service); + session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, + "org.freedesktop.ConsoleKit", + ssid, + "org.freedesktop.ConsoleKit.Session"); - if (!seat || !priv->seat || strcmp (seat, priv->seat) != 0) + seat = get_seat_internal (session_proxy); + + if (!seat || !priv->seat || strcmp (seat, priv->seat) != 0) { + g_object_unref(session_proxy); return FALSE; + } - if (!dbus_g_proxy_call (priv->session_proxy, + if (!dbus_g_proxy_call (session_proxy, "GetX11Display", &error, G_TYPE_INVALID, @@ -494,9 +509,12 @@ do_add_session (UsersServiceDbus *service, g_error_free (error); } + g_object_unref(session_proxy); return FALSE; } + g_object_unref(session_proxy); + if (!xdisplay || xdisplay[0] == '\0') return FALSE; -- cgit v1.2.3 From 8b77c4fe175b42d06e3e37be5645edafde53ae58 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 08:09:07 -0500 Subject: Grabbing the session interface from consolekit --- src/Makefile.am | 9 + src/consolekit-session.xml | 435 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 444 insertions(+) create mode 100644 src/consolekit-session.xml (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 01a88a3..24e00e4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,13 @@ consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml --output=consolekit-manager-client.h \ $(srcdir)/consolekit-manager.xml +consolekit-session-client.h: $(srcdir)/consolekit-session.xml + dbus-binding-tool \ + --prefix=_consolekit_session_client \ + --mode=glib-client \ + --output=consolekit-session-client.h \ + $(srcdir)/consolekit-session.xml + gdm-local-display-factory-client.h: $(srcdir)/gdm-local-display-factory.xml dbus-binding-tool \ --prefix=_gdm_local_display_factory_client \ @@ -120,6 +127,7 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + consolekit-session-client.h \ gdm-local-display-factory-client.h \ session-dbus-client.h \ session-dbus-server.h \ @@ -130,6 +138,7 @@ BUILT_SOURCES = \ EXTRA_DIST = \ consolekit-manager.xml \ + consolekit-session.xml \ gdm-local-display-factory.xml \ session-dbus.xml \ upower.xml \ diff --git a/src/consolekit-session.xml b/src/consolekit-session.xml new file mode 100644 index 0000000..b6e1cdb --- /dev/null +++ b/src/consolekit-session.xml @@ -0,0 +1,435 @@ + + + + + + + Session objects represent and store information + related to a user session. + + The properties associated with the Session + specifically refer to the properties of the "session leader". + + + + + + + Session ID + + + + Returns the ID for Session. + + + + + + + Seat ID + + + + Returns the ID for the Seat the Session is + attached to. + + org.freedesktop.ConsoleKit.Seat + + + + + + Session type + + + + + Returns the type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + session-type + + + + + + User ID + + + + Returns the user that the session belongs to. + + + user + + + + + + POSIX User ID + + + + Returns the POSIX user ID that the session belongs to. + + unix-user + + + + + + The value of the X11 display + + + + Returns the value of the X11 DISPLAY for this session + if one is present. + + x11-display + + + + + + The value of the X11 display device + + + + Returns the value of the display device (aka TTY) that the + X11 display for the session is connected to. If there is no x11-display set then this value + is undefined. + + x11-display-device + + + + + + The value of the display device + + + + Returns the value of the display device (aka TTY) that the + session is connected to. + + display-device + + + + + + The remote host name + + + + Returns the value of the remote host name for the session. + + + remote-host-name + + + + + + The value of the native system login session ID + + + + Returns the value of the login session ID that the + underlying system uses to enforce session boundaries. If there is no login session ID + set then this value is an empty string. + + + + + + + TRUE if the session is active, otherwise FALSE + + + + Returns whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + active + + + + + + TRUE if the session is local, otherwise FALSE + + + + Returns whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + is-local + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time that the session was opened. + + + + + + + + + + Attempt to activate the this session. In most + cases, if successful, this will cause the session to + become visible and become active on the seat that it + is attached to. + + Seat.ActivateSession() + + + + + + + This will cause a Lock + signal to be emitted for this session. + + + This method is restricted to privileged users by D-Bus policy. + Lock signal + + + + + + + This will cause an Unlock + signal to be emitted for this session. + + This can be used by login managers to unlock a session before it is + re-activated during fast-user-switching. + + + This method is restricted to privileged users by D-Bus policy. + Unlock signal + + + + + + + The value of the idle-hint + + + + + Gets the value of the idle-hint + property. + + + idle-hint + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time of the last change of the idle-hint. + + + + + + + + + boolean value to set the idle-hint to + + + + + This may be used by the session to indicate that + it is idle. + + Use of this method is restricted to the user + that owns the session. + + + + + + + + TRUE if the session is active, otherwise FALSE + + + + + Emitted when the active property has changed. + + + + + + + the new value of idle-hint + + + + + Emitted when the idle-hint property has changed. + + + + + + + Emitted in response to a call to the Lock() method. + It is intended that the screensaver for the session should lock the screen in response to this signal. + + + + + + + Emitted in response to a call to the Unlock() method. + It is intended that the screensaver for the session should unlock the screen in response to this signal. + + + + + + + + The user assigned to the session. + + + + + + + The user assigned to the session. + + + + + + + + The type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + + + + + + The remote host name for the session. + + This will be set in situations where the session is + opened and controlled from a remote system. + + For example, this value will be set when the + session is created from an SSH or XDMCP connection. + + + + + + + + The display device (aka TTY) that the + session is connected to. + + + + + + + + Value of the X11 DISPLAY for this session + if one is present. + + + + + + + + + The display device (aka TTY) that the X11 display for the + session is connected to. If there is no x11-display set then + this value is undefined. + + + + + + + + + Whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + + + + + + + Whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + + + + + + + This is a hint used to indicate that the session may be idle. + + + For sessions with a x11-display set (ie. graphical + sessions), it is up to each session to delegate the + responsibility for updating this value. Typically, the + screensaver will set this. + + However, for non-graphical sessions with a display-device set + the Session object itself will periodically update this value based + on the activity detected on the display-device itself. + + + This should not be considered authoritative. + + + + + + + -- cgit v1.2.3 From 494bb4fa4748456f16e5a852fd939b9500deb61e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 08:15:09 -0500 Subject: Switching to the generated dbus interface --- src/users-service-dbus.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 3589a6a..5d157ee 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -36,6 +36,7 @@ #include "users-service-client.h" #include "users-service-marshal.h" #include "consolekit-manager-client.h" +#include "consolekit-session-client.h" static void users_service_dbus_class_init (UsersServiceDbusClass *klass); static void users_service_dbus_init (UsersServiceDbus *self); @@ -413,12 +414,7 @@ get_seat_internal (DBusGProxy *proxy) GError *error = NULL; gchar *seat = NULL; - if (!dbus_g_proxy_call (proxy, - "GetSeatId", - &error, - G_TYPE_INVALID, - DBUS_TYPE_G_OBJECT_PATH, &seat, - G_TYPE_INVALID)) + if (!org_freedesktop_ConsoleKit_Session_get_seat_id (proxy, &seat, &error)) { if (error) { @@ -446,12 +442,7 @@ get_unix_user (UsersServiceDbus *service, session_id, "org.freedesktop.ConsoleKit.Session"); - if (dbus_g_proxy_call (session_proxy, - "GetUnixUser", - &error, - G_TYPE_INVALID, - G_TYPE_UINT, &uid, - G_TYPE_INVALID)) + if (org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) { if (error) { @@ -496,12 +487,7 @@ do_add_session (UsersServiceDbus *service, return FALSE; } - if (!dbus_g_proxy_call (session_proxy, - "GetX11Display", - &error, - G_TYPE_INVALID, - G_TYPE_STRING, &xdisplay, - G_TYPE_INVALID)) + if (!org_freedesktop_ConsoleKit_Session_get_x11_display (session_proxy, &xdisplay, &error)) { if (error) { @@ -776,12 +762,7 @@ session_is_login_window (UsersServiceDbus *self, return FALSE; } - if (!dbus_g_proxy_call (proxy, - "GetSessionType", - &error, - G_TYPE_INVALID, - G_TYPE_STRING, &type, - G_TYPE_INVALID)) + if (!org_freedesktop_ConsoleKit_Session_get_session_type (proxy, &type, &error)) { g_warning ("Can't call GetSessionType: %s", error->message); g_error_free (error); -- cgit v1.2.3 From 6233fb618821692cf103a52ae1a068c1e5c5a108 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 10:47:09 -0500 Subject: Fix capitalization of 'Switch From' --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..eb7d53f 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -298,7 +298,7 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G /* TODO: We need some way to remove the elipsis from appearing twice in the label. Not sure how to do that yet. */ - finalstring = g_strdup_printf(_("Switch from %s..."), username); + finalstring = g_strdup_printf(_("Switch From %s..."), username); if (ems >= 20.0f) { set_ellipsize = TRUE; } else { -- cgit v1.2.3 From 05b52fcee1c26b0f8dd703a61226ffdb60ff301e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 10:56:28 -0500 Subject: Switching to getting locked proxies. Just to have more error handling. --- src/users-service-dbus.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 5d157ee..5b1bcd7 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -437,10 +437,17 @@ get_unix_user (UsersServiceDbus *service, guint uid; DBusGProxy *session_proxy; - session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, - "org.freedesktop.ConsoleKit", - session_id, - "org.freedesktop.ConsoleKit.Session"); + session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, + "org.freedesktop.ConsoleKit", + session_id, + "org.freedesktop.ConsoleKit.Session", + &error); + + if (error != NULL) { + g_warning("Unable to get CK Session proxy: %s", error->message); + g_error_free(error); + return FALSE; + } if (org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) { @@ -475,10 +482,17 @@ do_add_session (UsersServiceDbus *service, DBusGProxy * session_proxy; GList *l; - session_proxy = dbus_g_proxy_new_for_name(priv->system_bus, - "org.freedesktop.ConsoleKit", - ssid, - "org.freedesktop.ConsoleKit.Session"); + session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, + "org.freedesktop.ConsoleKit", + ssid, + "org.freedesktop.ConsoleKit.Session", + &error); + + if (error != NULL) { + g_warning("Unable to get CK Session proxy: %s", error->message); + g_error_free(error); + return FALSE; + } seat = get_seat_internal (session_proxy); -- cgit v1.2.3 From 89fe9da54e180a055eb155b94002ff1393d44a9f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 14:00:06 -0500 Subject: Using defines to make sure the strings are right. --- src/users-service-dbus.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 5b1bcd7..504eeee 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -38,6 +38,10 @@ #include "consolekit-manager-client.h" #include "consolekit-session-client.h" +#define CK_ADDR "org.freedesktop.ConsoleKit" +#define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session" + + static void users_service_dbus_class_init (UsersServiceDbusClass *klass); static void users_service_dbus_init (UsersServiceDbus *self); static void users_service_dbus_dispose (GObject *object); @@ -361,9 +365,9 @@ create_cksession_proxy (UsersServiceDbus *service) UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service); priv->session_proxy = dbus_g_proxy_new_for_name (priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, priv->ssid, - "org.freedesktop.ConsoleKit.Session"); + CK_SESSION_IFACE); if (!priv->session_proxy) { @@ -437,10 +441,11 @@ get_unix_user (UsersServiceDbus *service, guint uid; DBusGProxy *session_proxy; + g_debug("Building session proxy for: %s", session_id); session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, session_id, - "org.freedesktop.ConsoleKit.Session", + CK_SESSION_IFACE, &error); if (error != NULL) { @@ -483,9 +488,9 @@ do_add_session (UsersServiceDbus *service, GList *l; session_proxy = dbus_g_proxy_new_for_name_owner(priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, ssid, - "org.freedesktop.ConsoleKit.Session", + CK_SESSION_IFACE, &error); if (error != NULL) { @@ -767,9 +772,9 @@ session_is_login_window (UsersServiceDbus *self, char *type = NULL; if (!(proxy = dbus_g_proxy_new_for_name (priv->system_bus, - "org.freedesktop.ConsoleKit", + CK_ADDR, ssid, - "org.freedesktop.ConsoleKit.Session"))) + CK_SESSION_IFACE))) { g_warning ("Failed to get ConsoleKit proxy"); -- cgit v1.2.3 From 8ab1eb8c5cb2e0c64681e473131b957818a74d82 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 15:05:46 -0500 Subject: Uhg, false sucks. --- src/users-service-dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 504eeee..d581887 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -454,7 +454,7 @@ get_unix_user (UsersServiceDbus *service, return FALSE; } - if (org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) + if (!org_freedesktop_ConsoleKit_Session_get_unix_user(session_proxy, &uid, &error)) { if (error) { -- cgit v1.2.3 From 1d79b928f9df7e3185ba5846b06f3c7675ba4fea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 15:20:21 -0500 Subject: Some debugging an checking to ensure the menu item is not NULL --- src/users-service-dbus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index d581887..86007c3 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -609,6 +609,7 @@ seat_proxy_session_added (DBusGProxy *seat_proxy, dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, TRUE); } priv->guest_session_id = g_strdup(session_id); + g_debug("Found guest session: %s", priv->guest_session_id); return; } @@ -634,7 +635,10 @@ seat_proxy_session_removed (DBusGProxy *seat_proxy, username = g_hash_table_lookup (priv->sessions, session_id); if (!username) { if (g_strcmp0(session_id, priv->guest_session_id) == 0) { - dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, FALSE); + g_debug("Removing guest session: %s", priv->guest_session_id); + if (priv->guest_item != NULL) { + dbusmenu_menuitem_property_set_bool(priv->guest_item, USER_ITEM_PROP_LOGGED_IN, FALSE); + } g_free(priv->guest_session_id); priv->guest_session_id = NULL; } -- cgit v1.2.3 From 6a3728388fdf6454d2029c3d6ae0b1c71ad6222e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 15:28:46 -0500 Subject: Watch for the logged in property changing and hide or show the logged in widget depending on it. --- src/indicator-session.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..9cf58a5 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -216,6 +216,19 @@ get_icon (IndicatorObject * io) return INDICATOR_SESSION(io)->status_image; } +static void +user_property_change (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) +{ + if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { + if (g_value_get_boolean(value)) { + gtk_widget_show(GTK_WIDGET(user_data)); + } else { + gtk_widget_hide(GTK_WIDGET(user_data)); + } + } + return; +} + /* Builds an item with a hip little logged in icon. */ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) @@ -242,6 +255,8 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(user_property_change), icon); + return TRUE; } -- cgit v1.2.3 From 7ddf670002a548fd7eb980b88e9f1b2fbf1c9eeb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:23:49 -0500 Subject: Some properties for putting icons on the user items. --- src/dbus-shared-names.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index a6364b1..3ac14b3 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -44,6 +44,8 @@ with this program. If not, see . #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" +#define USER_ITEM_PROP_ICON "user-item-icon-path" +#define USER_ITEM_ICON_DEFAULT "default-icon" #define RESTART_ITEM_TYPE "x-canonical-restart-item" #define RESTART_ITEM_LABEL "restart-label" -- cgit v1.2.3 From 23b8dc273347c6782667869e3de8f1dff059937d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:24:00 -0500 Subject: Building an icon based on teh icon props --- src/indicator-session.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..e3444c0 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include #include +#include #include #include @@ -223,6 +224,23 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + GtkWidget * usericon = NULL; + const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); + if (icon_name != NULL && icon_name[0] != '\0') { + if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0) { + GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock-user-panel"); + usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); + g_object_unref(gicon); + } else { + usericon = gtk_image_new_from_file(icon_name); + } + } + if (usericon != NULL) { + gtk_misc_set_alignment(GTK_MISC(usericon), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), usericon, FALSE, FALSE, 0); + gtk_widget_show(usericon); + } + GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME)); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); -- cgit v1.2.3 From 3564afb27f1ace2d516507a1b3132bc7eb815b32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:26:16 -0500 Subject: Setting the user icon --- src/session-service.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index fb20f3b..97ed013 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -590,6 +590,11 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); } dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); + if (user->icon_url != NULL && user->icon_url[0] != '\0') { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); } -- cgit v1.2.3 From 2f000c8501f73eed31b2441e83a434f6f4564c18 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:33:05 -0500 Subject: Using proper icon. --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index e3444c0..11231cd 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -228,7 +228,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); if (icon_name != NULL && icon_name[0] != '\0') { if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0) { - GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock-user-panel"); + GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); g_object_unref(gicon); } else { -- cgit v1.2.3 From 4e4246d795baea9a286914e870eca7690e3aa5de Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:36:53 -0500 Subject: Nice debugging message. --- src/indicator-session.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 11231cd..2ffc2e3 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -232,6 +232,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); g_object_unref(gicon); } else { + g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); usericon = gtk_image_new_from_file(icon_name); } } -- cgit v1.2.3 From e94cf5b18ec45024d70a71096fd5e8aeaee6d988 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:38:31 -0500 Subject: Check to ensure the file exists. --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 2ffc2e3..2be1e12 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -227,7 +227,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl GtkWidget * usericon = NULL; const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); if (icon_name != NULL && icon_name[0] != '\0') { - if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0) { + if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0 || !g_file_test(icon_name, G_FILE_TEST_EXISTS)) { GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); g_object_unref(gicon); -- cgit v1.2.3 From d2e52c5334e119b40e12c9f3c03593737ef7bac8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:50:13 -0500 Subject: Moving debug message --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 2be1e12..4e42567 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -226,13 +226,13 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl GtkWidget * usericon = NULL; const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); + g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); if (icon_name != NULL && icon_name[0] != '\0') { if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0 || !g_file_test(icon_name, G_FILE_TEST_EXISTS)) { GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); g_object_unref(gicon); } else { - g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); usericon = gtk_image_new_from_file(icon_name); } } -- cgit v1.2.3 From e879ad7063226f453d362dbc03f2a654570ea7ce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:50:28 -0500 Subject: Handling the file URIs --- 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 97ed013..d2c2c74 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -590,8 +590,8 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); } dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); - if (user->icon_url != NULL && user->icon_url[0] != '\0') { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url); + if (user->icon_url != NULL && user->icon_url[0] != '\0' && g_str_has_prefix(user->icon_url, "file://")) { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url + strlen("file://")); } else { dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); } -- cgit v1.2.3 From c3d3a6b0a90dc9b34ea34951174a4171c1b4fd09 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:55:44 -0500 Subject: Getting the horizontal padding for a nice spacing between widgets. --- src/indicator-session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 4e42567..3c141c4 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -222,7 +222,9 @@ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + gint padding = 0; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + GtkWidget * hbox = gtk_hbox_new(FALSE, padding); GtkWidget * usericon = NULL; const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); -- cgit v1.2.3 From 1c7fe734fb887d7a998fef539d90eb612b2baf02 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Mar 2010 14:01:25 -0500 Subject: Reverting from 'Switch Off' to 'Shut Down' --- src/gconf-helper.c | 4 ++-- src/session-service.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 77fde1d..29d8526 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -62,11 +62,11 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC 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, RESTART_ITEM_LABEL, _("Restart")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); } 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, RESTART_ITEM_LABEL, _("Restart...")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off...")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down...")); } } } diff --git a/src/session-service.c b/src/session-service.c index 514a86f..c1c2e57 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -661,9 +661,9 @@ rebuild_items (DbusmenuMenuitem *root, shutdown_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off")); + dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); } else { - dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch Off...")); + dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down...")); } dbusmenu_menuitem_child_append(root, shutdown_mi); g_signal_connect(G_OBJECT(shutdown_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown"); -- cgit v1.2.3