aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dbus-shared-names.h1
-rw-r--r--src/indicator-session.c156
-rw-r--r--src/session-dbus.c29
-rw-r--r--src/session-dbus.xml4
-rw-r--r--src/session-service.c10
5 files changed, 45 insertions, 155 deletions
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index 2e8e959..c4ccd05 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -36,7 +36,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define INDICATOR_SESSION_SERVICE_DBUS_OBJECT "/com/canonical/indicator/session/service"
#define INDICATOR_SESSION_SERVICE_DBUS_IFACE "com.canonical.indicator.session.service"
-// TODO change the logged in prop to 'has-sessions' in keeping with the spec.
#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/indicator-session.c b/src/indicator-session.c
index 58708fd..1de33d9 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -140,11 +140,10 @@ indicator_session_init (IndicatorSession *self)
GTK_ICON_LOOKUP_FORCE_SIZE,
&error);
-
-
GtkWidget* avatar_icon = NULL;
- if (pixbuf == NULL || error != NULL) {
+ // I think the avatar image is available always but just in case have a fallback
+ if (error != NULL) {
g_warning ("Could not load the default avatar image for some reason");
self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT);
}
@@ -153,14 +152,12 @@ indicator_session_init (IndicatorSession *self)
gtk_image_set_from_pixbuf (GTK_IMAGE (avatar_icon), pixbuf);
self->users.image = GTK_IMAGE (avatar_icon);
g_object_unref (pixbuf);
+ g_error_free (error);
}
-
-
- //self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT);
self->users.label = GTK_LABEL (gtk_label_new (NULL));
// Only show once we have a valid username
- gtk_widget_hide (GTK_WIDGET(self->users.label));
+ // gtk_widget_hide (GTK_WIDGET(self->users.label));
// devices
self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME,
@@ -326,117 +323,30 @@ new_user_item (DbusmenuMenuitem * newitem,
user_widget,
parent);
- g_debug ("%s (\"%s\")", __func__,
+ g_debug ("%s (\"%s\")", __func__,
dbusmenu_menuitem_property_get (newitem,
USER_ITEM_PROP_NAME));
gtk_widget_show_all (user_item);
return TRUE;
-
- /*g_debug ("new user item called ");
- GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new());
- 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);
- 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)) {
- gint width, height;
- gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
-
- GError * error = NULL;
- GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file_at_size(icon_name, width, height, &error);
-
- if (error == NULL) {
- usericon = gtk_image_new_from_pixbuf(pixbuf);
- g_object_unref(pixbuf);
- } else {
- g_warning("Unable to load user icon '%s': %s", icon_name, error->message);
- g_error_free(error);
- }
- }
-
- if (usericon == NULL) {
- 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);
- }
- }
- 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);
- gtk_widget_show(label);
-
- GtkWidget * icon = gtk_image_new_from_icon_name ("account-logged-in",
- GTK_ICON_SIZE_MENU);
- gtk_misc_set_alignment(GTK_MISC(icon), 1.0, 0.5);
- gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0);
- if (dbusmenu_menuitem_property_get_bool(newitem, USER_ITEM_PROP_LOGGED_IN)) {
- gtk_widget_show(icon);
- } else {
- gtk_widget_hide(icon);
- }
-
- gtk_container_add(GTK_CONTAINER(gmi), hbox);
- gtk_widget_show(hbox);
-
- 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;
- */
}
-/*static void
-user_property_change (DbusmenuMenuitem * item,
- const gchar * property,
- GVariant * variant,
- gpointer user_data)
-{
- if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) {
- if (g_variant_get_boolean(variant)) {
- gtk_widget_show(GTK_WIDGET(user_data));
- } else {
- gtk_widget_hide(GTK_WIDGET(user_data));
- }
- }
- return;
-}*/
static void
-icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
+user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
{
IndicatorSession * self = INDICATOR_SESSION(user_data);
GError * error = NULL;
- gchar * name;
GVariant * result;
result = g_dbus_proxy_call_finish(self->service_proxy, res, &error);
if (error != NULL) {
+ g_warning ("unable to complete real name dbus query");
+ g_error_free (error);
return;
}
-
- g_variant_get(result, "(&s)", &name);
-
- if (name == NULL || name[0] == '\0') {
- return;
- }
-
- //indicator_image_helper_update(self->users.image, name);
+ indicator_session_update_users_label (self, result);
return;
}
@@ -446,23 +356,13 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe
IndicatorSession * self = INDICATOR_SESSION (user_data);
if (connected) {
- g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL,
+ g_dbus_proxy_call(self->service_proxy, "GetUserRealName", NULL,
G_DBUS_CALL_FLAGS_NONE, -1, NULL,
- icon_name_get_cb, user_data);
- }
- else {
- indicator_image_helper_update (self->users.image,
- USER_ITEM_ICON_DEFAULT);
+ user_real_name_get_cb, user_data);
}
return;
}
-static void
-icon_changed (IndicatorSession * session, const gchar * icon_name)
-{
- indicator_image_helper_update(session->users.image, icon_name);
- return;
-}
/* Receives all signals from the service, routed to the appropriate functions */
static void
@@ -474,14 +374,14 @@ receive_signal (GDBusProxy * proxy,
{
IndicatorSession * self = INDICATOR_SESSION(user_data);
- if (g_strcmp0(signal_name, "IconUpdated") == 0) {
- const gchar *name;
- g_variant_get (parameters, "(&s)", &name);
- icon_changed(self, name);
- }
+ if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) {
+ indicator_session_update_users_label (self, parameters);
+ }
return;
}
+
+
static void
switch_property_change (DbusmenuMenuitem * item,
const gchar * property,
@@ -506,12 +406,6 @@ switch_property_change (DbusmenuMenuitem * item,
g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) {
finalstring = _("Switch User...");
set_ellipsize = FALSE;
- indicator_session_update_users_label (INDICATOR_SESSION (user_data),
- NULL);
- }
- else{
- indicator_session_update_users_label (INDICATOR_SESSION (user_data),
- variant);
}
if (finalstring == NULL) {
@@ -642,9 +536,7 @@ build_menu_switch (DbusmenuMenuitem * newitem,
if (gmi == NULL) {
return FALSE;
}
-
- IndicatorSession* self = INDICATOR_SESSION (user_data);
-
+
g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem);
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent);
@@ -661,10 +553,7 @@ build_menu_switch (DbusmenuMenuitem * newitem,
switch_property_change (newitem,
MENU_SWITCH_USER,
dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER), client);
-
- indicator_session_update_users_label (self,
- dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER));
-
+
return TRUE;
}
@@ -675,16 +564,15 @@ indicator_session_update_users_label (IndicatorSession* self,
const gchar* username = NULL;
if (variant == NULL || g_variant_get_string(variant, NULL) == NULL ||
g_variant_get_string(variant, NULL)[0] == '\0'){
- // either way set the user label to blank
- gtk_label_set_text (self->users.label, "");
- return;
+ gtk_widget_hide(GTK_WIDGET(self->users.label));
+ return;
}
- username = g_variant_get_string(variant, NULL);
+ username = g_strdup (g_variant_get_string(variant, NULL));
// Just in case protect again.
if (username != NULL) {
- g_debug ("Updating username label ");
+ g_debug ("!!!!!!!!!!!!update users label: %s", username);
gtk_label_set_text (self->users.label, username);
gtk_widget_show(GTK_WIDGET(self->users.label));
}
diff --git a/src/session-dbus.c b/src/session-dbus.c
index fa9ea54..07cebf7 100644
--- a/src/session-dbus.c
+++ b/src/session-dbus.c
@@ -5,6 +5,7 @@ Copyright 2010 Canonical Ltd.
Authors:
Ted Gould <ted@canonical.com>
+ Conor Curran <conor.curran@canonical.com>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License version 3, as published
@@ -28,7 +29,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "session-dbus.h"
#include "dbus-shared-names.h"
-static GVariant * get_icon (SessionDbus * service);
+static GVariant * get_users_real_name (SessionDbus * service);
static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data);
@@ -98,7 +99,7 @@ session_dbus_init (SessionDbus *self)
{
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self);
- priv->name = g_strdup(ICON_DEFAULT);
+ priv->name = NULL;
priv->bus = NULL;
priv->bus_cancel = NULL;
priv->dbus_registration = 0;
@@ -163,8 +164,8 @@ bus_method_call (GDBusConnection * connection, const gchar * sender,
SessionDbus * service = SESSION_DBUS(user_data);
GVariant * retval = NULL;
- if (g_strcmp0(method, "GetIcon") == 0) {
- retval = get_icon(service);
+ if (g_strcmp0(method, "GetUserRealName") == 0) {
+ retval = get_users_real_name (service);
} else {
g_warning("Calling method '%s' on the indicator service and it's unknown", method);
}
@@ -214,10 +215,11 @@ session_dbus_finalize (GObject *object)
}
static GVariant *
-get_icon (SessionDbus * service)
+get_users_real_name (SessionDbus * service)
{
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service);
- return g_variant_new("(s)", priv->name);
+ g_debug ("Get users real name: %s", priv->name);
+ return g_variant_new ("(s)", priv->name);
}
SessionDbus *
@@ -239,19 +241,18 @@ session_dbus_set_name (SessionDbus * session, const gchar * name)
if (priv->bus != NULL) {
g_dbus_connection_emit_signal (priv->bus,
- NULL,
- INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
- INDICATOR_SESSION_SERVICE_DBUS_IFACE,
- "IconUpdated",
- g_variant_new ("(s)", priv->name, NULL),
- &error);
+ NULL,
+ INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
+ INDICATOR_SESSION_SERVICE_DBUS_IFACE,
+ "UserRealNameUpdated",
+ g_variant_new ("(s)", priv->name, NULL),
+ &error);
if (error != NULL) {
- g_warning("Unable to send IconUpdated signal: %s", error->message);
+ g_warning("Unable to send UserRealNameUpdated signal: %s", error->message);
g_error_free(error);
return;
}
}
-
return;
}
diff --git a/src/session-dbus.xml b/src/session-dbus.xml
index ee724f5..82c8dc8 100644
--- a/src/session-dbus.xml
+++ b/src/session-dbus.xml
@@ -3,11 +3,11 @@
<interface name="com.canonical.indicator.session.service">
<!-- Icon -->
- <method name="GetIcon">
+ <method name="GetUserRealName">
<arg name="name" direction="out" type="s"/>
</method>
- <signal name="IconUpdated">
+ <signal name="UserRealNameUpdated">
<arg name="name" type="s"/>
</signal>
diff --git a/src/session-service.c b/src/session-service.c
index c1fad59..d213b6d 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -143,7 +143,6 @@ keybinding_changed (GConfClient *client,
dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, gconf_value_get_string(value));
}
}
-
return;
}
@@ -161,7 +160,7 @@ ensure_gconf_client (void)
gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL);
}
- return;
+ return;
}
/* Check to see if the lockdown key is protecting from
@@ -541,6 +540,9 @@ rebuild_user_items (DbusmenuMenuitem *root,
dbusmenu_menuitem_property_set_bool (mi,
USER_ITEM_PROP_IS_CURRENT_USER,
logged_in);
+ if (logged_in == TRUE){
+ session_dbus_set_name (session_dbus, user->real_name);
+ }
dbusmenu_menuitem_child_append (root, mi);
g_signal_connect (G_OBJECT (mi),
@@ -800,8 +802,8 @@ main (int argc, char ** argv)
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
textdomain (GETTEXT_PACKAGE);
- IndicatorService * service = indicator_service_new_version(INDICATOR_SESSION_DBUS_NAME,
- INDICATOR_SESSION_DBUS_VERSION);
+ IndicatorService * service = indicator_service_new_version (INDICATOR_SESSION_DBUS_NAME,
+ INDICATOR_SESSION_DBUS_VERSION);
g_signal_connect(G_OBJECT(service),
INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
G_CALLBACK(service_shutdown), NULL);