aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-02-18 09:36:34 -0600
committerTed Gould <ted@gould.cx>2010-02-18 09:36:34 -0600
commitfc732a57ad37e295233804a37419e39cefff5683 (patch)
tree757e9e911e42c083a1a813700bc639053687aee1 /src
parent9dab152713df2694ed4f447561bfbd31a51479e9 (diff)
parent4a297fec6d7fbc75035aa7d3d1eedb90bea98d15 (diff)
downloadayatana-indicator-session-fc732a57ad37e295233804a37419e39cefff5683.tar.gz
ayatana-indicator-session-fc732a57ad37e295233804a37419e39cefff5683.tar.bz2
ayatana-indicator-session-fc732a57ad37e295233804a37419e39cefff5683.zip
Adding in user items
Diffstat (limited to 'src')
-rw-r--r--src/dbus-shared-names.h4
-rw-r--r--src/indicator-session.c30
-rw-r--r--src/session-service.c8
3 files changed, 40 insertions, 2 deletions
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index 1fd256f..253cba8 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -38,4 +38,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define INDICATOR_SESSION_DBUS_OBJECT "/org/ayatana/indicator/session/menu"
#define INDICATOR_SESSION_DBUS_VERSION 0
+#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"
+
#endif /* __DBUS_SHARED_NAMES_H__ */
diff --git a/src/indicator-session.c b/src/indicator-session.c
index 1b9629b..ee7d76c 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -106,6 +106,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);
return;
}
@@ -145,6 +146,35 @@ get_icon (IndicatorObject * io)
return INDICATOR_SESSION(io)->status_image;
}
+/* Builds an item with a hip little logged in icon. */
+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);
+
+ 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);
+
+ return TRUE;
+}
+
/* Indicator based function to get the menu for the whole
applet. This starts up asking for the parts of the menu
from the various services. */
diff --git a/src/session-service.c b/src/session-service.c
index d074cb8..9fb9ee7 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -445,7 +445,9 @@ rebuild_items (DbusmenuMenuitem *root,
if (check_guest_session ())
{
mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Guest Session"));
+ dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
+ dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, _("Guest Session"));
+ dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, FALSE);
dbusmenu_menuitem_child_append (root, mi);
g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL);
}
@@ -495,7 +497,9 @@ rebuild_items (DbusmenuMenuitem *root,
user->service = service;
mi = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, user->real_name);
+ dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE);
+ 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);
dbusmenu_menuitem_child_append (root, mi);
g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user);
}