diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-08-17 13:48:51 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-08-17 13:48:51 +0100 |
commit | 25abede4d0251f965b5f8b879d26c86129a11453 (patch) | |
tree | 348ff4bb5a71dd1899593c73f67f329f373bb47e | |
parent | fb32494de9b55663cec088ade6967da349c0cac7 (diff) | |
download | ayatana-indicator-session-25abede4d0251f965b5f8b879d26c86129a11453.tar.gz ayatana-indicator-session-25abede4d0251f965b5f8b879d26c86129a11453.tar.bz2 ayatana-indicator-session-25abede4d0251f965b5f8b879d26c86129a11453.zip |
put guest item in place and fixed ticked icon on user menu
-rw-r--r-- | src/udev-mgr.c | 6 | ||||
-rw-r--r-- | src/user-menu-mgr.c | 81 | ||||
-rw-r--r-- | src/user-widget.c | 26 |
3 files changed, 96 insertions, 17 deletions
diff --git a/src/udev-mgr.c b/src/udev-mgr.c index e3328ec..f66d862 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -254,7 +254,7 @@ debug_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action) { - const gchar* vendor; + /*const gchar* vendor; const gchar* product; const gchar* number; const gchar* name; @@ -269,7 +269,7 @@ debug_device (UdevMgr* self, g_strdup(product), g_strdup(number), g_strdup(name)); - + const gchar *const *list; const gchar *const *iter; char propstr[500]; @@ -290,7 +290,7 @@ debug_device (UdevMgr* self, strcat(propstr, " "); strcat(propstr, g_udev_device_get_property(device, *iter)); g_debug("%s", propstr); - } + }*/ } static void udev_mgr_handle_scsi_device (UdevMgr* self, diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index bf3b77f..6f9f53a 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -26,9 +26,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "lock-helper.h" #include "users-service-dbus.h" +#define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" + static GConfClient * gconf_client = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; + struct _UserMenuMgr { GObject parent_instance; @@ -56,6 +59,11 @@ static void user_change (UsersServiceDbus *service, gpointer user_data); static void ensure_gconf_client (); +static gboolean check_guest_session (void); +static void activate_guest_session (DbusmenuMenuitem * mi, + guint timestamp, + gpointer user_data); + G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); @@ -121,6 +129,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) /* Build all of the user switching items */ if (can_activate == TRUE) { + if (check_new_session ()){ switch_menuitem = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (switch_menuitem, @@ -134,8 +143,33 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), self->users_dbus_interface); + } + + if (check_guest_session ()) + { + g_debug ("ADDING GUEST SESSION"); + guest_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (guest_mi, + DBUSMENU_MENUITEM_PROP_TYPE, + USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (guest_mi, + USER_ITEM_PROP_NAME, + _("Guest Session")); + dbusmenu_menuitem_property_set_bool (guest_mi, + USER_ITEM_PROP_LOGGED_IN, + FALSE); + dbusmenu_menuitem_child_append (self->root_item, guest_mi); + g_signal_connect (G_OBJECT (guest_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_guest_session), + self); + users_service_dbus_set_guest_item (self->users_dbus_interface, + guest_mi); } - + else{ + g_debug ("NOT ADDING GUEST SESSION"); + } + GList * users = NULL; users = users_service_dbus_get_user_list (self->users_dbus_interface); self->user_count = g_list_length(users); @@ -193,7 +227,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) } dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, - user->sessions != NULL); + /*user->sessions != NULL*/FALSE); if (user->icon_file != NULL && user->icon_file[0] != '\0') { dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); } else { @@ -354,6 +388,49 @@ user_mgr_get_root_item (UserMenuMgr* self) return self->root_item; } +/* Checks to see if we should show the guest suession item */ +static gboolean +check_guest_session (void) +{ + if (geteuid() < 500) { + /* System users shouldn't have guest account shown. Mosly + this would be the case of the guest user itself. */ + return FALSE; + } + if (!g_file_test(GUEST_SESSION_LAUNCHER, G_FILE_TEST_IS_EXECUTABLE)) { + /* It doesn't appear that the Guest session stuff is + installed. So let's not use it then! */ + return FALSE; + } + + return TRUE; +} + +/* Called when someone clicks on the guest session item. */ +static void +activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + GError * error = NULL; + UserData *user = (UserData *)user_data; + UsersServiceDbus *service = user->service; + + lock_if_possible(); + + if (dbusmenu_menuitem_property_get_bool(mi, USER_ITEM_PROP_LOGGED_IN)) { + if (users_service_dbus_activate_guest_session(service)) { + return; + } + g_warning("Unable to activate guest session, falling back to command line activation."); + } + + if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER " --no-lock", &error)) { + g_warning("Unable to start guest session: %s", error->message); + g_error_free(error); + } + + return; +} + /* * Clean Entry Point diff --git a/src/user-widget.c b/src/user-widget.c index 9b046c5..6495e80 100644 --- a/src/user-widget.c +++ b/src/user-widget.c @@ -126,8 +126,6 @@ user_widget_init (UserWidget *self) priv->user_name = gtk_label_new (""); priv->container = gtk_hbox_new (FALSE, 0); - // TODO: - // Delete tick icon and draw primitively. priv->tick_icon = gtk_image_new_from_icon_name ("account-logged-in", GTK_ICON_SIZE_MENU); gtk_misc_set_alignment(GTK_MISC(priv->tick_icon), 1.0, 0.5); @@ -151,6 +149,10 @@ user_widget_init (UserWidget *self) gtk_widget_show_all (priv->container); gtk_container_add (GTK_CONTAINER (self), priv->container); + gtk_widget_show_all (priv->tick_icon); + gtk_widget_set_no_show_all (priv->tick_icon, TRUE); + gtk_widget_hide (priv->tick_icon); + // Fetch the drawing context. #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect_after (GTK_WIDGET(self), "draw", @@ -178,11 +180,6 @@ user_widget_finalize (GObject *object) G_OBJECT_CLASS (user_widget_parent_class)->finalize (object); } -/** - * We override the expose method to enable primitive drawing of the - * empty album art image and rounded rectangles on the album art. - */ - #if GTK_CHECK_VERSION(3, 0, 0) // Draw the radio dot and/or green check mark @@ -317,11 +314,16 @@ user_widget_set_twin_item (UserWidget* self, gtk_label_set_label (GTK_LABEL (priv->user_name), dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); - //if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { - // gtk_widget_show(priv->tick_icon); - //} else { - gtk_widget_show(priv->tick_icon); - //} + if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { + g_debug ("%s USER HAS ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_show(priv->tick_icon); + } + else { + g_debug ("%s USER DOESN'T HAVE ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_hide(priv->tick_icon); + } g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(twin_item, USER_ITEM_PROP_NAME), icon_name); |