[gdm] Switch User item should be hidden when VT switching is disabled
- From: Ray Strode <halfline src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gdm] Switch User item should be hidden when VT switching is disabled
- Date: Wed, 27 Jan 2010 16:52:05 +0000 (UTC)
commit e5775ea560b290f00d10a1d8a8473baac1ab3457
Author: Halton Huo <halton huo sun com>
Date: Wed Jan 27 11:49:50 2010 -0500
Switch User item should be hidden when VT switching is disabled
http://bugzilla.gnome.org/show_bug.cgi?id=607051
gui/simple-greeter/gdm-user-manager.c | 77 ++++++++++++++++-----------------
gui/simple-greeter/gdm-user-manager.h | 2 +
gui/user-switch-applet/applet.c | 4 +-
3 files changed, 42 insertions(+), 41 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user-manager.c b/gui/simple-greeter/gdm-user-manager.c
index c4fb246..58def68 100644
--- a/gui/simple-greeter/gdm-user-manager.c
+++ b/gui/simple-greeter/gdm-user-manager.c
@@ -155,9 +155,7 @@ static char *
_get_primary_user_session_id (GdmUserManager *manager,
GdmUser *user)
{
- gboolean res;
gboolean can_activate_sessions;
- GError *error;
GList *sessions;
GList *l;
char *primary_ssid;
@@ -170,25 +168,7 @@ _get_primary_user_session_id (GdmUserManager *manager,
primary_ssid = NULL;
sessions = NULL;
- g_debug ("GdmUserManager: checking if seat can activate sessions");
-
- error = NULL;
- res = dbus_g_proxy_call (manager->priv->seat_proxy,
- "CanActivateSessions",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &can_activate_sessions,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("unable to determine if seat can activate sessions: %s",
- error->message);
- g_error_free (error);
- } else {
- g_warning ("unable to determine if seat can activate sessions");
- }
- goto out;
- }
+ can_activate_sessions = gdm_user_manager_can_switch (manager);
if (! can_activate_sessions) {
g_debug ("GdmUserManager: seat is unable to activate sessions");
@@ -344,25 +324,7 @@ _get_login_window_session_id (GdmUserManager *manager)
primary_ssid = NULL;
sessions = NULL;
- g_debug ("GdmSlave: checking if seat can activate sessions");
-
- error = NULL;
- res = dbus_g_proxy_call (manager->priv->seat_proxy,
- "CanActivateSessions",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &can_activate_sessions,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("unable to determine if seat can activate sessions: %s",
- error->message);
- g_error_free (error);
- } else {
- g_warning ("unable to determine if seat can activate sessions");
- }
- goto out;
- }
+ can_activate_sessions = gdm_user_manager_can_switch (manager);
if (! can_activate_sessions) {
g_debug ("GdmSlave: seat is unable to activate sessions");
@@ -438,6 +400,41 @@ gdm_user_manager_goto_login_session (GdmUserManager *manager)
}
gboolean
+gdm_user_manager_can_switch (GdmUserManager *manager)
+{
+ gboolean res;
+ gboolean can_activate_sessions;
+ GError *error;
+
+ if (manager->priv->seat_id == NULL || manager->priv->seat_id[0] == '\0') {
+ g_debug ("GdmUserManager: display seat ID is not set; can't switch sessions");
+ return FALSE;
+ }
+
+ g_debug ("GdmUserManager: checking if seat can activate sessions");
+
+ error = NULL;
+ res = dbus_g_proxy_call (manager->priv->seat_proxy,
+ "CanActivateSessions",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, &can_activate_sessions,
+ G_TYPE_INVALID);
+ if (! res) {
+ if (error != NULL) {
+ g_warning ("unable to determine if seat can activate sessions: %s",
+ error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("unable to determine if seat can activate sessions");
+ }
+ return FALSE;
+ }
+
+ return can_activate_sessions;
+}
+
+gboolean
gdm_user_manager_activate_user_session (GdmUserManager *manager,
GdmUser *user)
{
diff --git a/gui/simple-greeter/gdm-user-manager.h b/gui/simple-greeter/gdm-user-manager.h
index 6c696e5..b2d0019 100644
--- a/gui/simple-greeter/gdm-user-manager.h
+++ b/gui/simple-greeter/gdm-user-manager.h
@@ -80,6 +80,8 @@ GdmUser * gdm_user_manager_get_user_by_uid (GdmUserManager *mana
gboolean gdm_user_manager_activate_user_session (GdmUserManager *manager,
GdmUser *user);
+gboolean gdm_user_manager_can_switch (GdmUserManager *manager);
+
gboolean gdm_user_manager_goto_login_session (GdmUserManager *manager);
G_END_DECLS
diff --git a/gui/user-switch-applet/applet.c b/gui/user-switch-applet/applet.c
index 2c364f1..5d73283 100644
--- a/gui/user-switch-applet/applet.c
+++ b/gui/user-switch-applet/applet.c
@@ -703,7 +703,9 @@ static void
update_switch_user (GdmAppletData *adata)
{
GSList *users;
+ gboolean can_switch;
+ can_switch = gdm_user_manager_can_switch (adata->manager);
users = gdm_user_manager_list_users (adata->manager);
adata->has_other_users = FALSE;
if (users != NULL) {
@@ -711,7 +713,7 @@ update_switch_user (GdmAppletData *adata)
}
g_slist_free (users);
- if (adata->has_other_users) {
+ if (can_switch && adata->has_other_users) {
gtk_widget_show (adata->login_screen_item);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]