ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #03819
[Merge] lp:~cjcurran/indicator-session/user-image-panel into lp:indicator-session
Conor Curran has proposed merging lp:~cjcurran/indicator-session/user-image-panel into lp:indicator-session.
Requested reviews:
Ted Gould (ted)
For more details, see:
https://code.launchpad.net/~cjcurran/indicator-session/user-image-panel/+merge/72615
If accepted by design this will embed the user image on the panel.
--
https://code.launchpad.net/~cjcurran/indicator-session/user-image-panel/+merge/72615
Your team ayatana-commits is subscribed to branch lp:indicator-session.
=== modified file 'src/indicator-session.c'
--- src/indicator-session.c 2011-08-22 13:05:48 +0000
+++ src/indicator-session.c 2011-08-23 18:51:24 +0000
@@ -91,11 +91,15 @@
gpointer user_data);
static void indicator_session_update_users_label (IndicatorSession* self,
const gchar* name);
+static void indicator_session_update_users_panel_icon (IndicatorSession* self,
+ const gchar* name);
+
static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data);
static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
static void user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data);
static void user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data);
+static void current_user_image_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data);
static void indicator_session_class_init (IndicatorSessionClass *klass);
static void indicator_session_init (IndicatorSession *self);
@@ -144,23 +148,16 @@
GdkPixbuf* pixbuf = NULL;
GError* error = NULL;
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- "avatar-default",
+ USER_ITEM_ICON_DEFAULT,
17,
GTK_ICON_LOOKUP_FORCE_SIZE,
&error);
- // 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);
- }
- else{
- avatar_icon = gtk_image_new ();
- 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);
- }
+ avatar_icon = gtk_image_new ();
+ 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.label = GTK_LABEL (gtk_label_new (NULL));
@@ -169,10 +166,10 @@
INDICATOR_SESSION_DBUS_OBJECT));
self->devices.image = indicator_image_helper (ICON_DEFAULT);
- gtk_widget_show (GTK_WIDGET(self->devices.menu));
- gtk_widget_show (GTK_WIDGET(self->devices.image));
- gtk_widget_show (GTK_WIDGET(self->users.image));
- gtk_widget_show (GTK_WIDGET(self->users.menu));
+ gtk_widget_show (GTK_WIDGET (self->devices.menu));
+ gtk_widget_show (GTK_WIDGET (self->devices.image));
+ gtk_widget_show (GTK_WIDGET (self->users.image));
+ gtk_widget_show (GTK_WIDGET (self->users.menu));
g_object_ref_sink (self->users.menu);
g_object_ref_sink (self->users.image);
@@ -302,6 +299,14 @@
NULL,
user_real_name_get_cb,
user_data);
+ g_dbus_proxy_call (self->service_proxy,
+ "GetCurrentUserImage",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ current_user_image_get_cb,
+ user_data);
return;
}
@@ -422,6 +427,27 @@
return;
}
+static void
+current_user_image_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data)
+{
+ IndicatorSession * self = INDICATOR_SESSION(user_data);
+ GError * error = NULL;
+ GVariant * result;
+
+ result = g_dbus_proxy_call_finish(self->service_proxy, res, &error);
+
+ if (error != NULL) {
+ g_warning ("unable to complete current user image get");
+ g_error_free (error);
+ return;
+ }
+
+ const gchar* image_path = NULL;
+ g_variant_get (result, "(s)", &image_path);
+ indicator_session_update_users_panel_icon (self, image_path);
+ return;
+}
+
static void
user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data)
{
@@ -468,11 +494,16 @@
{
IndicatorSession * self = INDICATOR_SESSION(user_data);
- if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) {
+ if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) {
const gchar* username = NULL;
g_variant_get (parameters, "(s)", &username);
indicator_session_update_users_label (self, username);
}
+ else if (g_strcmp0(signal_name, "CurrentUserImage") == 0) {
+ const gchar* path = NULL;
+ g_variant_get (parameters, "(s)", &path);
+ indicator_session_update_users_panel_icon (self, path);
+ }
else if (g_strcmp0(signal_name, "UserMenuIsVisible") == 0) {
gboolean update;
g_variant_get (parameters, "(b)", &update);
@@ -681,6 +712,31 @@
}
static void
+indicator_session_update_users_panel_icon (IndicatorSession* self,
+ const gchar* name)
+{
+ GdkPixbuf* pixbuf = NULL;
+ GError* error = NULL;
+ pixbuf = gdk_pixbuf_new_from_file_at_size (name, 17, 17, NULL);
+ g_debug ("indicator_session_update_users_panel_icon %s", name);
+ if (pixbuf == NULL || error != NULL) {
+ g_warning ("Could not load the user image (%s) for some reason",
+ name);
+ }
+ else{
+ gtk_image_set_from_pixbuf (GTK_IMAGE(self->users.image), pixbuf);
+ }
+ if (pixbuf != NULL){
+ g_object_unref (pixbuf);
+ pixbuf = NULL;
+ }
+ if (error != NULL){
+ g_error_free (error);
+ error = NULL;
+ }
+}
+
+static void
indicator_session_update_users_label (IndicatorSession* self,
const gchar* name)
{
=== modified file 'src/session-dbus.c'
--- src/session-dbus.c 2011-08-09 08:59:20 +0000
+++ src/session-dbus.c 2011-08-23 18:51:24 +0000
@@ -38,6 +38,7 @@
typedef struct _SessionDbusPrivate SessionDbusPrivate;
struct _SessionDbusPrivate {
gchar * name;
+ gchar * user_image;
gboolean user_menu_is_visible;
GDBusConnection * bus;
GCancellable * bus_cancel;
@@ -99,7 +100,7 @@
session_dbus_init (SessionDbus *self)
{
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self);
-
+ priv->user_image = NULL;
priv->name = NULL;
priv->bus = NULL;
priv->bus_cancel = NULL;
@@ -171,6 +172,9 @@
if (g_strcmp0(method, "GetUserRealName") == 0) {
retval = get_users_real_name (service);
}
+ else if (g_strcmp0(method, "GetCurrentUserImage") == 0) {
+ retval = g_variant_new ("(s)", priv->user_image);
+ }
else if (g_strcmp0 (method, "GetUserMenuVisibility") == 0){
retval = g_variant_new ("(b)", priv->user_menu_is_visible);
}
@@ -294,6 +298,30 @@
}
}
+void
+session_dbus_set_current_user_image (SessionDbus* session, gchar* image)
+{
+ SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session);
+ GError * error = NULL;
+
+ priv->user_image = image;
+
+ if (priv->bus != NULL && priv->user_image != NULL) {
+ g_dbus_connection_emit_signal (priv->bus,
+ NULL,
+ INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
+ INDICATOR_SESSION_SERVICE_DBUS_IFACE,
+ "CurrentUserImage",
+ g_variant_new ("(s)", priv->user_image),
+ &error);
+
+ if (error != NULL) {
+ g_warning("Unable to send Current User Image signal: %s", error->message);
+ g_error_free(error);
+ }
+ }
+}
+
void session_dbus_restart_required (SessionDbus* session)
{
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session);
=== modified file 'src/session-dbus.h'
--- src/session-dbus.h 2011-08-09 08:59:20 +0000
+++ src/session-dbus.h 2011-08-23 18:51:24 +0000
@@ -51,6 +51,7 @@
void session_dbus_set_name (SessionDbus * session, const gchar * name);
void session_dbus_set_users_real_name (SessionDbus * session, const gchar * name);
void session_dbus_set_user_menu_visibility (SessionDbus* session, gboolean visible);
+void session_dbus_set_current_user_image (SessionDbus* session, gchar* image);
void session_dbus_restart_required (SessionDbus* session);
G_END_DECLS
=== modified file 'src/session-dbus.xml'
--- src/session-dbus.xml 2011-08-09 08:59:20 +0000
+++ src/session-dbus.xml 2011-08-23 18:51:24 +0000
@@ -5,6 +5,9 @@
<method name="GetUserRealName">
<arg name="name" direction="out" type="s"/>
</method>
+ <method name="GetCurrentUserImage">
+ <arg name="path" direction="out" type="s"/>
+ </method>
<method name="GetUserMenuVisibility">
<arg name="update" direction="out" type="b"/>
</method>
@@ -14,6 +17,9 @@
<signal name="UserRealNameUpdated">
<arg name="name" type="s"/>
</signal>
+ <signal name="CurrentUserImage">
+ <arg name="path" type="s"/>
+ </signal>
<signal name="UserMenuIsVisible">
<arg name="update" type="b"/>
</signal>
=== modified file 'src/user-menu-mgr.c'
--- src/user-menu-mgr.c 2011-08-23 11:51:51 +0000
+++ src/user-menu-mgr.c 2011-08-23 18:51:24 +0000
@@ -49,6 +49,9 @@
static void activate_online_accounts (DbusmenuMenuitem *mi,
guint timestamp,
gpointer user_data);
+static void activate_user_accounts (DbusmenuMenuitem *mi,
+ guint timestamp,
+ gpointer user_data);
static void user_menu_mgr_rebuild_items (UserMenuMgr *self,
gboolean greeter_mode);
static gboolean check_new_session ();
@@ -239,6 +242,8 @@
g_debug ("about to set the users real name to %s for user %s",
user->real_name, user->user_name);
session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name);
+ session_dbus_set_current_user_image (self->session_dbus_interface,
+ g_strdup(dbusmenu_menuitem_property_get(mi, USER_ITEM_PROP_ICON)));
}
dbusmenu_menuitem_child_append (self->root_item, mi);
Follow ups