Index: gui/simple-greeter/gdm-user-chooser-widget.c
===================================================================
--- gui/simple-greeter/gdm-user-chooser-widget.c	(révision 6670)
+++ gui/simple-greeter/gdm-user-chooser-widget.c	(copie de travail)
@@ -67,6 +67,8 @@ struct GdmUserChooserWidgetPrivate
         guint           show_user_auto : 1;
         guint           show_normal_users : 1;
 
+        guint           real_show_user_other : 1;
+
         guint           load_idle_id;
 };
 
@@ -83,6 +85,9 @@ static void     gdm_user_chooser_widget_
 
 G_DEFINE_TYPE (GdmUserChooserWidget, gdm_user_chooser_widget, GDM_TYPE_CHOOSER_WIDGET)
 
+static void     add_user_other    (GdmUserChooserWidget *widget);
+static void     remove_user_other (GdmUserChooserWidget *widget);
+
 static int
 get_font_height_for_widget (GtkWidget *widget)
 {
@@ -123,8 +128,31 @@ get_icon_height_for_widget (GtkWidget *w
 }
 
 static void
+update_other_user_visibility (GdmUserChooserWidget *widget)
+{
+        if (!widget->priv->show_user_other) {
+                if (widget->priv->real_show_user_other) {
+                        remove_user_other (widget);
+                }
+
+                return;
+        }
+
+        if (gdm_chooser_widget_get_number_of_items (GDM_CHOOSER_WIDGET (widget)) == 1) {
+                /* we hide the Other user if it's the last one, and we show it
+                 * if there's another user */
+                if (widget->priv->real_show_user_other) {
+                        remove_user_other (widget);
+                } else {
+                        add_user_other (widget);
+                }
+        }
+}
+
+static void
 add_user_other (GdmUserChooserWidget *widget)
 {
+        widget->priv->real_show_user_other = TRUE;
         gdm_chooser_widget_add_item (GDM_CHOOSER_WIDGET (widget),
                                      GDM_USER_CHOOSER_USER_OTHER,
                                      NULL,
@@ -146,6 +174,7 @@ add_user_guest (GdmUserChooserWidget *wi
                                      0,
                                      FALSE,
                                      TRUE);
+        update_other_user_visibility (widget);
 }
 
 static void
@@ -159,11 +188,13 @@ add_user_auto (GdmUserChooserWidget *wid
                                      0,
                                      FALSE,
                                      TRUE);
+        update_other_user_visibility (widget);
 }
 
 static void
 remove_user_other (GdmUserChooserWidget *widget)
 {
+        widget->priv->real_show_user_other = FALSE;
         gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget),
                                         GDM_USER_CHOOSER_USER_OTHER);
 }
@@ -173,6 +204,7 @@ remove_user_guest (GdmUserChooserWidget
 {
         gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget),
                                         GDM_USER_CHOOSER_USER_GUEST);
+        update_other_user_visibility (widget);
 }
 
 static void
@@ -180,6 +212,7 @@ remove_user_auto (GdmUserChooserWidget *
 {
         gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget),
                                         GDM_USER_CHOOSER_USER_AUTO);
+        update_other_user_visibility (widget);
 }
 
 void
@@ -190,11 +223,7 @@ gdm_user_chooser_widget_set_show_user_ot
 
         if (widget->priv->show_user_other != show_user) {
                 widget->priv->show_user_other = show_user;
-                if (show_user) {
-                        add_user_other (widget);
-                } else {
-                        remove_user_other (widget);
-                }
+                update_other_user_visibility (widget);
         }
 }
 
@@ -369,6 +398,8 @@ add_user (GdmUserChooserWidget *widget,
         if (pixbuf != NULL) {
                 g_object_unref (pixbuf);
         }
+
+        update_other_user_visibility (widget);
 }
 
 static void
@@ -400,6 +431,8 @@ on_user_removed (GdmUserManager       *m
 
         gdm_chooser_widget_remove_item (GDM_CHOOSER_WIDGET (widget),
                                         user_name);
+
+        update_other_user_visibility (widget);
 }
 
 static void
@@ -444,8 +477,6 @@ on_users_loaded (GdmUserManager       *m
 {
         GSList *users;
 
-        widget->priv->loaded = TRUE;
-
         g_debug ("GdmUserChooserWidget: Users loaded");
 
         users = gdm_user_manager_list_users (manager);
@@ -454,7 +485,7 @@ on_users_loaded (GdmUserManager       *m
                 users = g_slist_delete_link (users, users);
         }
 
-        gtk_widget_grab_focus (GTK_WIDGET (widget));
+        widget->priv->loaded = TRUE;
 
         gdm_chooser_widget_loaded (GDM_CHOOSER_WIDGET (widget));
 }
@@ -505,6 +536,7 @@ gdm_user_chooser_widget_constructor (GTy
                                                                                                               n_construct_properties,
                                                                                                               construct_properties));
 
+        widget->priv->real_show_user_other = FALSE;
         widget->priv->show_normal_users = !is_user_list_disabled (widget);
 
         widget->priv->load_idle_id = g_idle_add ((GSourceFunc)load_users, widget);
Index: gui/simple-greeter/gdm-greeter-login-window.c
===================================================================
--- gui/simple-greeter/gdm-greeter-login-window.c	(révision 6670)
+++ gui/simple-greeter/gdm-greeter-login-window.c	(copie de travail)
@@ -114,6 +114,7 @@ struct GdmGreeterLoginWindowPrivate
         GtkWidget       *auth_banner_label;
         guint            display_is_local : 1;
         guint            is_interactive : 1;
+        guint            user_chooser_loaded : 1;
         GConfClient     *client;
 
         gboolean         banner_message_enabled;
@@ -528,9 +529,13 @@ switch_mode (GdmGreeterLoginWindow *logi
         GtkWidget  *box;
         gboolean    show_restart_buttons;
         gboolean    show_suspend_button;
+        gboolean    only_other_user;
+        gboolean    show_buttons;
 
-        show_restart_buttons = get_show_restart_buttons (login_window);
-        show_suspend_button = can_suspend (login_window);
+        only_other_user = (gdm_chooser_widget_get_number_of_items (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser)) == 0);
+        show_buttons = (number == MODE_SELECTION) || only_other_user;
+        show_restart_buttons = show_buttons && get_show_restart_buttons (login_window);
+        show_suspend_button = show_buttons && can_suspend (login_window);
 
         /* we want to run this even if we're supposed to
            be in the mode already so that we reset everything
@@ -539,7 +544,14 @@ switch_mode (GdmGreeterLoginWindow *logi
 
         default_name = NULL;
 
-        remove_sensitize_power_buttons_timeout (login_window);
+        show_widget (login_window, "shutdown-button",
+                     login_window->priv->display_is_local && show_restart_buttons);
+        show_widget (login_window, "restart-button",
+                     login_window->priv->display_is_local && show_restart_buttons);
+        show_widget (login_window, "suspend-button",
+                     login_window->priv->display_is_local && show_restart_buttons && show_suspend_button);
+        show_widget (login_window, "disconnect-button",
+                     !login_window->priv->display_is_local && show_buttons);
 
         switch (number) {
         case MODE_SELECTION:
@@ -547,15 +559,6 @@ switch_mode (GdmGreeterLoginWindow *logi
 
                 show_widget (login_window, "cancel-button", FALSE);
 
-                show_widget (login_window, "shutdown-button",
-                             login_window->priv->display_is_local && show_restart_buttons);
-                show_widget (login_window, "restart-button",
-                             login_window->priv->display_is_local && show_restart_buttons);
-                show_widget (login_window, "suspend-button",
-                             login_window->priv->display_is_local && show_restart_buttons && show_suspend_button);
-                show_widget (login_window, "disconnect-button",
-                             ! login_window->priv->display_is_local);
-
                 show_widget (login_window, "auth-input-box", FALSE);
 
                 add_sensitize_power_buttons_timeout (login_window);
@@ -568,10 +571,12 @@ switch_mode (GdmGreeterLoginWindow *logi
                 break;
         case MODE_AUTHENTICATION:
                 show_widget (login_window, "cancel-button", TRUE);
-                show_widget (login_window, "shutdown-button", FALSE);
-                show_widget (login_window, "restart-button", FALSE);
-                show_widget (login_window, "suspend-button", FALSE);
-                show_widget (login_window, "disconnect-button", FALSE);
+
+                sensitize_widget (login_window, "shutdown-button", TRUE);
+                sensitize_widget (login_window, "restart-button", TRUE);
+                sensitize_widget (login_window, "suspend-button", TRUE);
+                sensitize_widget (login_window, "disconnect-button", TRUE);
+
                 default_name = "log-in-button";
                 break;
         default:
@@ -665,10 +670,40 @@ delete_entry_text (GtkWidget *entry)
 }
 
 static void
+select_user (GdmGreeterLoginWindow *login_window,
+             const char            *user_name)
+{
+        g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
+                       0, user_name);
+
+        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) {
+                /* FIXME: handle guest account stuff */
+        } else if (strcmp (user_name, GDM_USER_CHOOSER_USER_AUTO) == 0) {
+                g_signal_emit (login_window, signals[BEGIN_AUTO_LOGIN], 0,
+                               login_window->priv->timed_login_username);
+
+                login_window->priv->timed_login_enabled = TRUE;
+                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);
+                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);
+}
+
+
+static void
 reset_dialog (GdmGreeterLoginWindow *login_window)
 {
         GtkWidget  *entry;
         GtkWidget  *label;
+        gboolean    use_selection;
 
         g_debug ("GdmGreeterLoginWindow: Resetting dialog");
         set_busy (login_window);
@@ -703,12 +738,21 @@ reset_dialog (GdmGreeterLoginWindow *log
         label = glade_xml_get_widget (GDM_GREETER_LOGIN_WINDOW (login_window)->priv->xml, "auth-prompt-label");
         gtk_label_set_text (GTK_LABEL (label), "");
 
-        switch_mode (login_window, MODE_SELECTION);
+        use_selection = !login_window->priv->user_chooser_loaded || (gdm_chooser_widget_get_number_of_items (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser)) >= 1);
+
+        if (use_selection) {
+                switch_mode (login_window, MODE_SELECTION);
+        } else {
+                select_user (login_window, GDM_USER_CHOOSER_USER_OTHER);
+        }
 
         set_sensitive (login_window, TRUE);
         set_ready (login_window);
         set_focus (GDM_GREETER_LOGIN_WINDOW (login_window));
-        gdm_chooser_widget_propagate_pending_key_events (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser));
+
+        if (use_selection) {
+                gdm_chooser_widget_propagate_pending_key_events (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser));
+        }
 }
 
 static void
@@ -1323,7 +1367,19 @@ static void
 on_users_loaded (GdmUserChooserWidget  *user_chooser,
                  GdmGreeterLoginWindow *login_window)
 {
-        gdm_chooser_widget_activate_if_one_item (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser));
+        int number_users;
+
+        login_window->priv->user_chooser_loaded = TRUE;
+
+        number_users = gdm_chooser_widget_get_number_of_items (GDM_CHOOSER_WIDGET (user_chooser));
+
+        if (number_users == 1) {
+                gdm_chooser_widget_activate_if_one_item (GDM_CHOOSER_WIDGET (user_chooser));
+        } else if (number_users == 0) {
+                select_user (login_window, GDM_USER_CHOOSER_USER_OTHER);
+        }
+
+        set_focus (GDM_GREETER_LOGIN_WINDOW (login_window));
 }
 
 static void
@@ -1339,28 +1395,7 @@ on_user_chosen (GdmUserChooserWidget  *u
                 return;
         }
 
-        g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
-                       0, user_name);
-
-        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) {
-                /* FIXME: handle guest account stuff */
-        } else if (strcmp (user_name, GDM_USER_CHOOSER_USER_AUTO) == 0) {
-                g_signal_emit (login_window, signals[BEGIN_AUTO_LOGIN], 0,
-                               login_window->priv->timed_login_username);
-
-                login_window->priv->timed_login_enabled = TRUE;
-                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);
-                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);
+        select_user (login_window, user_name);
 
         g_free (user_name);
 }
@@ -1914,6 +1949,7 @@ gdm_greeter_login_window_init (GdmGreete
 
         login_window->priv = GDM_GREETER_LOGIN_WINDOW_GET_PRIVATE (login_window);
 
+        login_window->priv->user_chooser_loaded = FALSE;
         login_window->priv->timed_login_enabled = FALSE;
 
         login_window->priv->dialog_mode = MODE_SELECTION;
Index: gui/simple-greeter/gdm-chooser-widget.c
===================================================================
--- gui/simple-greeter/gdm-chooser-widget.c	(révision 6670)
+++ gui/simple-greeter/gdm-chooser-widget.c	(copie de travail)
@@ -593,6 +593,16 @@ update_separator_visibility (GdmChooserW
 }
 
 static void
+update_chooser_visibility (GdmChooserWidget *widget)
+{
+	if (gdm_chooser_widget_get_number_of_items (widget) > 0) {
+		gtk_widget_show (widget->priv->scrollable_widget);
+	} else {
+		gtk_widget_hide (widget->priv->scrollable_widget);
+	}
+}
+
+static void
 set_inactive_items_visible (GdmChooserWidget *widget,
                             gboolean          should_show)
 {
@@ -1771,7 +1781,6 @@ gdm_chooser_widget_init (GdmChooserWidge
         add_frame (widget);
 
         widget->priv->scrollable_widget = gdm_scrollable_widget_new ();
-        gtk_widget_show (widget->priv->scrollable_widget);
         gtk_container_add (GTK_CONTAINER (widget->priv->frame_alignment),
                            widget->priv->scrollable_widget);
 
@@ -2055,6 +2064,8 @@ gdm_chooser_widget_add_item (GdmChooserW
                                            -1);
 
         move_cursor_to_top (widget);
+
+        update_chooser_visibility (widget);
 }
 
 void
@@ -2103,6 +2114,8 @@ gdm_chooser_widget_remove_item (GdmChoos
         gtk_list_store_remove (widget->priv->list_store, &iter);
 
         move_cursor_to_top (widget);
+
+        update_chooser_visibility (widget);
 }
 
 gboolean
