diff options
-rw-r--r-- | src/udev-mgr.c | 6 | ||||
-rw-r--r-- | src/user-menu-mgr.c | 62 | ||||
-rw-r--r-- | src/user-widget.c | 26 | ||||
-rw-r--r-- | src/users-service-dbus.c | 6 |
4 files changed, 83 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..f2757ad 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -29,6 +29,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. static GConfClient * gconf_client = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; + struct _UserMenuMgr { GObject parent_instance; @@ -56,6 +57,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 +127,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 +141,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); @@ -354,6 +386,34 @@ 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; + } + + return TRUE; +} + +/* Called when someone clicks on the guest session item. */ +static void +activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + g_return_if_fail (USER_IS_MENU_MGR (user_data)); + UserMenuMgr* user_mgr = USER_MENU_MGR(user_data); + UsersServiceDbus *service = user_mgr->users_dbus_interface; + + lock_if_possible(); + + if (users_service_dbus_activate_guest_session(service)) { + 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); diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index ec52771..e7507a4 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -583,7 +583,11 @@ static void add_sessions_for_user (UsersServiceDbus *self, UserData *user) { - g_return_if_fail(IS_USERS_SERVICE_DBUS(self)); + g_return_if_fail (IS_USERS_SERVICE_DBUS(self)); + + g_debug ("!!!!!!!!!! - add_sessions_for_user %i %s", + (int)user->uid, user->user_name); + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); GError *error; GPtrArray *sessions; |