[gdm/gnome-2-30] Simplify the handling of dialog state
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/gnome-2-30] Simplify the handling of dialog state
- Date: Tue, 22 Jun 2010 23:28:43 +0000 (UTC)
commit 7e0720dfc8504c81015baf0b27c9c93ce9f0a702
Author: William Jon McCann <jmccann redhat com>
Date: Tue Jun 22 19:00:21 2010 -0400
Simplify the handling of dialog state
Should fix https://bugzilla.gnome.org/show_bug.cgi?id=622431
gui/simple-greeter/gdm-greeter-login-window.c | 132 ++++++++++++-------------
1 files changed, 62 insertions(+), 70 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index a64113e..2b0215c 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -86,8 +86,9 @@
enum {
MODE_UNDEFINED = 0,
+ MODE_TIMED_LOGIN,
MODE_SELECTION,
- MODE_AUTHENTICATION
+ MODE_AUTHENTICATION,
};
enum {
@@ -109,10 +110,11 @@ struct GdmGreeterLoginWindowPrivate
gboolean banner_message_enabled;
guint gconf_cnxn;
+ guint last_mode;
guint dialog_mode;
gboolean user_list_disabled;
- gboolean show_cancel_button;
+ guint num_queries;
gboolean timed_login_already_enabled;
gboolean timed_login_enabled;
@@ -401,21 +403,42 @@ user_chooser_has_no_user (GdmGreeterLoginWindow *login_window)
}
static void
-adjust_other_login_visibility (GdmGreeterLoginWindow *login_window)
+maybe_show_cancel_button (GdmGreeterLoginWindow *login_window)
{
- if (! login_window->priv->user_chooser_loaded) {
- return;
- }
+ gboolean show;
- if (login_window->priv->dialog_mode != MODE_SELECTION) {
- return;
- }
+ show = FALSE;
- if (gdm_chooser_widget_get_number_of_items (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser)) == 0) {
- set_log_in_button_mode (login_window, LOGIN_BUTTON_ANSWER_QUERY);
- } else {
- set_log_in_button_mode (login_window, LOGIN_BUTTON_HIDDEN);
+ /* only show the cancel button if there is something to go
+ back to */
+
+ switch (login_window->priv->dialog_mode) {
+ case MODE_SELECTION:
+ /* should never have anything to return to from here */
+ show = FALSE;
+ break;
+ case MODE_TIMED_LOGIN:
+ /* should always have something to return to from here */
+ show = TRUE;
+ break;
+ case MODE_AUTHENTICATION:
+ if (login_window->priv->num_queries > 1) {
+ /* if we are inside a pam conversation past
+ the first step */
+ show = TRUE;
+ } else {
+ if (login_window->priv->user_list_disabled || user_chooser_has_no_user (login_window)) {
+ show = FALSE;
+ } else {
+ show = TRUE;
+ }
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
+
+ show_widget (login_window, "cancel-button", show);
}
static void
@@ -431,48 +454,29 @@ switch_mode (GdmGreeterLoginWindow *login_window,
/* we want to run this even if we're supposed to
be in the mode already so that we reset everything
to a known state */
- login_window->priv->dialog_mode = number;
+ if (login_window->priv->dialog_mode != number) {
+ login_window->priv->last_mode = login_window->priv->dialog_mode;
+ login_window->priv->dialog_mode = number;
+ }
default_name = NULL;
switch (number) {
case MODE_SELECTION:
set_log_in_button_mode (login_window, LOGIN_BUTTON_HIDDEN);
-
- show_widget (login_window, "cancel-button", FALSE);
-
- show_widget (login_window, "auth-input-box", FALSE);
-
- /*
- * Although the cancel button is not shown in the selection
- * dialog, the show_cancel_button flag manages when the
- * cancel button is shown on subsequent PAM queries. Set the
- * flag to true initially since the button should appear on
- * the first query, since the button takes the user back to
- * selection mode.
- */
- login_window->priv->show_cancel_button = TRUE;
+ break;
+ case MODE_TIMED_LOGIN:
+ set_log_in_button_mode (login_window, LOGIN_BUTTON_TIMED_LOGIN);
break;
case MODE_AUTHENTICATION:
- default_name = "log-in-button";
+ set_log_in_button_mode (login_window, LOGIN_BUTTON_ANSWER_QUERY);
break;
default:
g_assert_not_reached ();
}
- box = GTK_WIDGET (gtk_builder_get_object (login_window->priv->builder,
- "buttonbox"));
- gtk_button_box_set_layout (GTK_BUTTON_BOX (box),
- (number == MODE_SELECTION) ?
- GTK_BUTTONBOX_SPREAD :
- GTK_BUTTONBOX_END );
-
- if (default_name != NULL) {
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (login_window->priv->builder, default_name));
- gtk_widget_grab_default (widget);
- }
+ show_widget (login_window, "auth-input-box", FALSE);
+ maybe_show_cancel_button (login_window);
/*
* The rest of this function sets up the user list, so just return if
@@ -520,12 +524,13 @@ reset_dialog (GdmGreeterLoginWindow *login_window)
{
GtkWidget *entry;
GtkWidget *label;
+ guint mode;
g_debug ("GdmGreeterLoginWindow: Resetting dialog");
set_busy (login_window);
set_sensitive (login_window, FALSE);
- login_window->priv->show_cancel_button = FALSE;
+ login_window->priv->num_queries = 0;
if (login_window->priv->timed_login_enabled) {
gdm_chooser_widget_set_item_timer (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser),
@@ -556,17 +561,18 @@ reset_dialog (GdmGreeterLoginWindow *login_window)
label = GTK_WIDGET (gtk_builder_get_object (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->builder, "auth-prompt-label"));
gtk_label_set_text (GTK_LABEL (label), "");
+ mode = MODE_SELECTION;
if (login_window->priv->user_list_disabled || user_chooser_has_no_user (login_window)) {
- switch_mode (login_window, MODE_AUTHENTICATION);
- } else {
- switch_mode (login_window, MODE_SELECTION);
+ /* If we don't have a user list jump straight to authenticate */
+ mode = MODE_AUTHENTICATION;
}
+ switch_mode (login_window, mode);
set_sensitive (login_window, TRUE);
set_ready (login_window);
set_focus (GDM_GREETER_LOGIN_WINDOW (login_window));
update_banner_message (login_window);
- adjust_other_login_visibility (login_window);
+
if (gdm_chooser_widget_get_number_of_items (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser)) >= 1) {
gdm_chooser_widget_propagate_pending_key_events (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser));
}
@@ -730,21 +736,6 @@ gdm_greeter_login_window_start_session_when_ready (GdmGreeterLoginWindow *login_
}
}
-static void
-_show_cancel_button (GdmGreeterLoginWindow *login_window)
-{
- /*
- * If show_cancel_button is false, this is because the face browser
- * is disabled and the first query is showing. It does not make sense
- * to display the cancel button when showing the initial query and
- * the face browser is disabled. Set the flag to true so that the
- * button is shown on following queries.
- */
- show_widget (login_window, "cancel-button",
- login_window->priv->show_cancel_button);
- login_window->priv->show_cancel_button = TRUE;
-}
-
gboolean
gdm_greeter_login_window_info_query (GdmGreeterLoginWindow *login_window,
const char *text)
@@ -754,7 +745,8 @@ gdm_greeter_login_window_info_query (GdmGreeterLoginWindow *login_window,
g_return_val_if_fail (GDM_IS_GREETER_LOGIN_WINDOW (login_window), FALSE);
- _show_cancel_button (login_window);
+ login_window->priv->num_queries++;
+ maybe_show_cancel_button (login_window);
g_debug ("GdmGreeterLoginWindow: info query: %s", text);
@@ -785,7 +777,8 @@ gdm_greeter_login_window_secret_info_query (GdmGreeterLoginWindow *login_window,
g_return_val_if_fail (GDM_IS_GREETER_LOGIN_WINDOW (login_window), FALSE);
- _show_cancel_button (login_window);
+ login_window->priv->num_queries++;
+ maybe_show_cancel_button (login_window);
entry = GTK_WIDGET (gtk_builder_get_object (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->builder, "auth-prompt-entry"));
delete_entry_text (entry);
@@ -881,7 +874,6 @@ on_user_chooser_visibility_changed (GdmGreeterLoginWindow *login_window)
{
g_debug ("GdmGreeterLoginWindow: Chooser visibility changed");
update_banner_message (login_window);
- adjust_other_login_visibility (login_window);
}
static void
@@ -891,11 +883,9 @@ on_users_loaded (GdmUserChooserWidget *user_chooser,
g_debug ("GdmGreeterLoginWindow: users loaded");
login_window->priv->user_chooser_loaded = TRUE;
update_banner_message (login_window);
- adjust_other_login_visibility (login_window);
if (user_chooser_has_no_user (login_window)) {
- /* There's no face browser to show */
- login_window->priv->show_cancel_button = FALSE;
+ /* jump straight to authenticate */
switch_mode (login_window, MODE_AUTHENTICATION);
g_debug ("Starting PAM conversation since no local users");
@@ -910,6 +900,7 @@ on_user_chosen (GdmUserChooserWidget *user_chooser,
GdmGreeterLoginWindow *login_window)
{
char *user_name;
+ guint mode;
user_name = gdm_user_chooser_widget_get_chosen_user_name (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser));
g_debug ("GdmGreeterLoginWindow: user chosen '%s'", user_name);
@@ -921,6 +912,7 @@ on_user_chosen (GdmUserChooserWidget *user_chooser,
g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
0, user_name);
+ mode = MODE_AUTHENTICATION;
if (strcmp (user_name, GDM_USER_CHOOSER_USER_OTHER) == 0) {
g_signal_emit (login_window, signals[BEGIN_VERIFICATION], 0);
} else if (strcmp (user_name, GDM_USER_CHOOSER_USER_GUEST) == 0) {
@@ -933,13 +925,13 @@ on_user_chosen (GdmUserChooserWidget *user_chooser,
restart_timed_login_timeout (login_window);
/* just wait for the user to select language and stuff */
- set_log_in_button_mode (login_window, LOGIN_BUTTON_TIMED_LOGIN);
+ mode = MODE_TIMED_LOGIN;
set_message (login_window, _("Select language and click Log In"));
} else {
g_signal_emit (login_window, signals[BEGIN_VERIFICATION_FOR_USER], 0, user_name);
}
- switch_mode (login_window, MODE_AUTHENTICATION);
+ switch_mode (login_window, mode);
g_free (user_name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]