[gdm/multi-stack: 33/35] manage tasks outside of task list



commit 912075a067a8428ea7d68d34d488717d12a51cc7
Author: Ray Strode <rstrode redhat com>
Date:   Fri Aug 6 11:14:23 2010 -0400

    manage tasks outside of task list
    
    The task list isn't very good for tracking tasks as
    they come and go, since it replies on the groaty details
    of toggle buttons and widget activation and such.
    
    We now use it soley for display purposes when necessary
    and otherwise, keep track of the tasks in a separate list.
    
    Also, differentiate single authentication modes from
    multiple authentication modes, so we don't show the task list
    when we don't need to.

 gui/simple-greeter/gdm-greeter-login-window.c |  396 +++++++++++++------------
 1 files changed, 206 insertions(+), 190 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index cb03d06..627a6f9 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -100,6 +100,7 @@ enum {
         MODE_TIMED_LOGIN,
         MODE_SELECTION,
         MODE_AUTHENTICATION,
+        MODE_MULTIPLE_AUTHENTICATION,
 };
 
 enum {
@@ -121,6 +122,8 @@ struct GdmGreeterLoginWindowPrivate
         guint            is_interactive : 1;
         guint            user_chooser_loaded : 1;
         GConfClient     *client;
+        GList           *tasks;
+        GdmTask         *active_task;
         GList           *tasks_to_enable;
 
         gboolean         banner_message_enabled;
@@ -182,6 +185,9 @@ static void     gdm_greeter_login_window_start_session_when_ready (GdmGreeterLog
 static void handle_stopped_conversation (GdmGreeterLoginWindow *login_window,
                                          const char            *service_name);
 
+static void begin_single_service_verification (GdmGreeterLoginWindow *login_window,
+                                               const char            *service_name);
+
 G_DEFINE_TYPE (GdmGreeterLoginWindow, gdm_greeter_login_window, GTK_TYPE_WINDOW)
 
 static void
@@ -215,26 +221,22 @@ set_sensitive (GdmGreeterLoginWindow *login_window,
 static void
 set_focus (GdmGreeterLoginWindow *login_window)
 {
-        GdmTask *task;
-
         gdk_window_focus (gtk_widget_get_window (GTK_WIDGET (login_window)), GDK_CURRENT_TIME);
 
-        task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
-
-        if (task != NULL && gdm_conversation_focus (GDM_CONVERSATION (task))) {
+        if (login_window->priv->active_task != NULL &&
+            gdm_conversation_focus (GDM_CONVERSATION (login_window->priv->active_task))) {
                 char *name;
-                name = gdm_task_get_name (task);
+                name = gdm_task_get_name (login_window->priv->active_task);
                 g_debug ("GdmGreeterLoginWindow: focusing task %s", name);
                 g_free (name);
         } else if (gtk_widget_get_realized (login_window->priv->user_chooser) && ! gtk_widget_has_focus (login_window->priv->user_chooser)) {
                 gtk_widget_grab_focus (login_window->priv->user_chooser);
         }
-        g_object_unref (task);
+
 }
 
 static gboolean
-set_task_conversation_message (GdmTaskList *task_list,
-                               GdmTask     *task,
+set_task_conversation_message (GdmTask     *task,
                                const char  *message)
 {
 
@@ -249,10 +251,9 @@ set_message (GdmGreeterLoginWindow *login_window,
 {
         g_return_if_fail (GDM_IS_GREETER_LOGIN_WINDOW (login_window));
 
-        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                    (GdmTaskListForeachFunc)
-                                    set_task_conversation_message,
-                                    (gpointer) text);
+        g_list_foreach (login_window->priv->tasks,
+                        (GFunc) set_task_conversation_message,
+                        (gpointer) text);
 }
 
 static void
@@ -455,7 +456,6 @@ set_log_in_button_mode (GdmGreeterLoginWindow *login_window,
         GtkWidget *unlock_button;
         char      *item;
         gboolean   in_use;
-        GdmTask   *task;
 
         in_use = FALSE;
         item = gdm_chooser_widget_get_active_item (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser));
@@ -497,20 +497,16 @@ set_log_in_button_mode (GdmGreeterLoginWindow *login_window,
 
         switch (mode) {
         case LOGIN_BUTTON_HIDDEN:
-                task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
-                if (task != NULL) {
-                        hide_task_actions (task);
-                        g_object_unref (task);
+                if (login_window->priv->active_task != NULL) {
+                        hide_task_actions (login_window->priv->active_task);
                 }
 
                 gtk_widget_hide (button);
                 break;
         case LOGIN_BUTTON_ANSWER_QUERY:
-                task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
-                if (task != NULL) {
-                        show_task_actions (task);
-                        grab_default_button_for_task (task);
-                        g_object_unref (task);
+                if (login_window->priv->active_task != NULL) {
+                        show_task_actions (login_window->priv->active_task);
+                        grab_default_button_for_task (login_window->priv->active_task);
                 }
 
                 gtk_widget_hide (button);
@@ -557,6 +553,7 @@ maybe_show_cancel_button (GdmGreeterLoginWindow *login_window)
                 show = TRUE;
                 break;
         case MODE_AUTHENTICATION:
+        case MODE_MULTIPLE_AUTHENTICATION:
                 if (login_window->priv->num_queries > 1) {
                         /* if we are inside a pam conversation past
                            the first step */
@@ -581,7 +578,7 @@ update_conversation_list_visibility (GdmGreeterLoginWindow *login_window)
 {
         int number_of_tasks;
 
-        if (login_window->priv->dialog_mode != MODE_AUTHENTICATION) {
+        if (login_window->priv->dialog_mode != MODE_MULTIPLE_AUTHENTICATION) {
                 gtk_widget_hide (login_window->priv->conversation_list);
                 return;
         }
@@ -624,6 +621,7 @@ switch_mode (GdmGreeterLoginWindow *login_window,
                 gtk_widget_show (login_window->priv->session_option_widget);
                 break;
         case MODE_AUTHENTICATION:
+        case MODE_MULTIPLE_AUTHENTICATION:
                 set_log_in_button_mode (login_window, LOGIN_BUTTON_ANSWER_QUERY);
                 gtk_widget_show (login_window->priv->session_option_widget);
                 break;
@@ -663,39 +661,36 @@ switch_mode (GdmGreeterLoginWindow *login_window,
         }
 }
 
-static gboolean
-task_has_service_name (GdmTaskList *task_list,
-                       GdmTask     *task,
-                       const char  *service_name)
+static GdmTask *
+find_task_with_service_name (GdmGreeterLoginWindow *login_window,
+                             const char            *service_name)
 {
-        char *task_service_name;
-        gboolean has_service_name;
+        GList *node;
 
-        task_service_name = gdm_conversation_get_service_name (GDM_CONVERSATION (task));
+        node = login_window->priv->tasks;
+        while (node != NULL) {
+                GdmTask *task;
+                char *task_service_name;
+                gboolean has_service_name;
 
-        has_service_name = strcmp (service_name, task_service_name) == 0;
-        g_free (task_service_name);
+                task = GDM_TASK (node->data);
 
-        return has_service_name;
-}
+                task_service_name = gdm_conversation_get_service_name (GDM_CONVERSATION (task));
+                has_service_name = strcmp (service_name, task_service_name) == 0;
+                g_free (task_service_name);
 
-static GdmTask *
-find_task_with_service_name (GdmGreeterLoginWindow *login_window,
-                             const char            *service_name)
-{
-        GdmTask *task;
+                if (has_service_name) {
+                        return task;
+                }
 
-        task = gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                           (GdmTaskListForeachFunc)
-                                           task_has_service_name,
-                                           (gpointer) service_name);
+                node = node->next;
+        }
 
-        return task;
+        return NULL;
 }
 
 static gboolean
-reset_task (GdmTaskList           *task_list,
-            GdmTask               *task,
+reset_task (GdmTask               *task,
             GdmGreeterLoginWindow *login_window)
 {
         char *name;
@@ -706,28 +701,31 @@ reset_task (GdmTaskList           *task_list,
 
         login_window->priv->tasks_to_enable = g_list_remove (login_window->priv->tasks_to_enable, task);
 
+        gdm_task_list_remove_task (GDM_TASK_LIST (login_window->priv->conversation_list), task);
         gdm_conversation_reset (GDM_CONVERSATION (task));
         return FALSE;
 }
 
 static gboolean
-task_is_disabled (GdmTaskList *task_list,
-                  GdmTask     *task)
-{
-        return !gdm_task_is_enabled (task);
-}
-
-static gboolean
 tasks_are_enabled (GdmGreeterLoginWindow *login_window)
 {
-        GdmTask *task;
 
-        task = gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                           (GdmTaskListForeachFunc)
-                                           task_is_disabled,
-                                           NULL);
+        GList *node;
+
+        node = login_window->priv->tasks;
+        while (node != NULL) {
+                GdmTask *task;
+
+                task = GDM_TASK (node->data);
+
+                if (!gdm_task_is_enabled (task)) {
+                        return FALSE;
+                }
+
+                node = node->next;
+        }
 
-        return task == NULL;
+        return TRUE;
 }
 
 static gboolean
@@ -741,6 +739,8 @@ can_jump_to_authenticate (GdmGreeterLoginWindow *login_window)
                 res = FALSE;
         } else if (login_window->priv->dialog_mode == MODE_AUTHENTICATION) {
                 res = FALSE;
+        } else if (login_window->priv->dialog_mode == MODE_MULTIPLE_AUTHENTICATION) {
+                res = FALSE;
         } else if (login_window->priv->user_list_disabled) {
                 res = (login_window->priv->timed_login_username == NULL);
         } else {
@@ -750,39 +750,81 @@ can_jump_to_authenticate (GdmGreeterLoginWindow *login_window)
         return res;
 }
 
-static gboolean
-begin_task_verification (GdmTaskList           *task_list,
-                         GdmTask               *task,
-                         GdmGreeterLoginWindow *login_window)
+static void
+begin_other_verification (GdmGreeterLoginWindow *login_window)
 {
-        char *service_name;
+        /* FIXME: we should drop this code and do all OTHER handling
+         * entirely from within the password plugin
+         * (ala how smart card manages its "Smartcard Authentication" item)
+         */
+        begin_single_service_verification (login_window, "gdm-password");
+}
 
-        if (!gdm_task_is_visible (task)) {
-                return FALSE;
-        }
+static void
+set_task_active (GdmGreeterLoginWindow *login_window,
+                 GdmTask               *task)
+{
+        GtkWidget *container;
+        char *name;
 
-        service_name = gdm_conversation_get_service_name (GDM_CONVERSATION (task));
-        if (service_name != NULL) {
-                g_signal_emit (login_window, signals[BEGIN_VERIFICATION], 0, service_name);
-                g_free (service_name);
+        name = gdm_task_get_name (task);
+        g_debug ("GdmGreeterLoginWindow: task '%s' activated", name);
+        g_free (name);
+
+        container = g_object_get_data (G_OBJECT (task),
+                                       "gdm-greeter-login-window-page-container");
+
+        if (container == NULL) {
+                GtkWidget *page;
+
+                container = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+                gtk_container_add (GTK_CONTAINER (login_window->priv->auth_page_box),
+                                   container);
+
+                page = gdm_conversation_get_page (GDM_CONVERSATION (task));
+                if (page != NULL) {
+                        gtk_container_add (GTK_CONTAINER (container), page);
+                        gtk_widget_show (page);
+                }
+                g_object_set_data (G_OBJECT (task),
+                                   "gdm-greeter-login-window-page-container",
+                                   container);
         }
 
-        return FALSE;
+        gtk_widget_show (container);
+
+        login_window->priv->active_task = task;
+        switch_mode (login_window, login_window->priv->dialog_mode);
 }
 
 static void
-begin_verification (GdmGreeterLoginWindow *login_window)
+clear_active_task (GdmGreeterLoginWindow *login_window)
 {
-        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                    (GdmTaskListForeachFunc)
-                                    begin_task_verification,
-                                    login_window);
 
-        switch_mode (login_window, MODE_AUTHENTICATION);
+        GtkWidget *container;
+        GtkActionGroup *actions;
 
-        update_conversation_list_visibility (login_window);
-}
+        if (login_window->priv->active_task == NULL) {
+                return;
+        }
+
+        container = g_object_get_data (G_OBJECT (login_window->priv->active_task),
+                                       "gdm-greeter-login-window-page-container");
+
+        if (container != NULL) {
+                gtk_widget_hide (container);
+        }
+
+        actions = gdm_conversation_get_actions (GDM_CONVERSATION (login_window->priv->active_task));
+
+        if (actions != NULL) {
+                gtk_action_group_set_sensitive (actions, FALSE);
+                gtk_action_group_set_visible (actions, FALSE);
+                g_object_unref (actions);
+        }
 
+        login_window->priv->active_task = NULL;
+}
 
 static void
 reset_dialog (GdmGreeterLoginWindow *login_window,
@@ -817,18 +859,16 @@ reset_dialog (GdmGreeterLoginWindow *login_window,
                 set_message (login_window, "");
         }
 
-        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                    (GdmTaskListForeachFunc)
-                                    reset_task,
-                                    login_window);
+        g_list_foreach (login_window->priv->tasks, (GFunc) reset_task, login_window);
 
         if (can_jump_to_authenticate (login_window)) {
                 /* If we don't have a user list jump straight to authenticate */
                 g_debug ("GdmGreeterLoginWindow: jumping straight to authenticate");
                 g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
                                0, GDM_USER_CHOOSER_USER_OTHER);
-                begin_verification (login_window);
+                begin_other_verification (login_window);
         } else {
+                clear_active_task (login_window);
                 switch_mode (login_window, dialog_mode);
         }
 
@@ -873,9 +913,9 @@ gdm_greeter_login_window_ready (GdmGreeterLoginWindow *login_window,
                 if (gdm_chooser_widget_is_loaded (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser))) {
                         gdm_conversation_set_ready (GDM_CONVERSATION (task));
                 } else {
-                        login_window->priv->tasks_to_enable = g_list_prepend (login_window->priv->tasks_to_enable, task);
+                        login_window->priv->tasks_to_enable = g_list_prepend (login_window->priv->tasks_to_enable,
+                                                                              g_object_ref (task));
                 }
-                g_object_unref (task);
         }
 
         set_sensitive (GDM_GREETER_LOGIN_WINDOW (login_window), TRUE);
@@ -888,7 +928,7 @@ gdm_greeter_login_window_ready (GdmGreeterLoginWindow *login_window,
                 g_debug ("Starting PAM conversation since user list disabled or no local users");
                 g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
                                0, GDM_USER_CHOOSER_USER_OTHER);
-                begin_verification (login_window);
+                begin_other_verification (login_window);
         }
 
         return TRUE;
@@ -910,24 +950,37 @@ handle_stopped_conversation (GdmGreeterLoginWindow *login_window,
                 return;
         }
 
+        if (login_window->priv->dialog_mode == MODE_AUTHENTICATION) {
+                g_debug ("GdmGreeterLoginWindow: conversation failed, starting over");
+                restart_conversations (login_window);
+                return;
+        } else if (login_window->priv->dialog_mode != MODE_MULTIPLE_AUTHENTICATION) {
+                g_warning ("conversation %s stopped when it shouldn't have been running (mode %d)",
+                           service_name, login_window->priv->dialog_mode);
+                restart_conversations (login_window);
+                return;
+        }
+
         task = find_task_with_service_name (login_window, service_name);
 
         if (task != NULL) {
                 gdm_conversation_reset (GDM_CONVERSATION (task));
 
                 g_object_set_data (G_OBJECT (task), "needs-to-be-stopped", GINT_TO_POINTER (FALSE));
-                g_object_unref (task);
         }
 
         /* If every conversation has failed, then just start over.
          */
         task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
 
-        if (!gdm_task_is_enabled (task)) {
+        if (task == NULL || !gdm_task_is_enabled (task)) {
                 g_debug ("GdmGreeterLoginWindow: No conversations left, starting over");
                 restart_conversations (login_window);
         }
-        g_object_unref (task);
+
+        if (task != NULL) {
+                g_object_unref (task);
+        }
 
         update_conversation_list_visibility (login_window);
 }
@@ -943,8 +996,8 @@ gdm_greeter_login_window_conversation_stopped (GdmGreeterLoginWindow *login_wind
 
         g_debug ("GdmGreeterLoginWindow: conversation '%s' has stopped", service_name);
 
-        task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
-        if (task != NULL && task_has_service_name (GDM_TASK_LIST (login_window->priv->conversation_list), task, service_name)) {
+        task = find_task_with_service_name (login_window, service_name);
+        if (task != NULL && gdm_task_is_enabled (task)) {
 
                 messages_pending = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (task), "message-pending"));
         } else {
@@ -963,8 +1016,7 @@ gdm_greeter_login_window_conversation_stopped (GdmGreeterLoginWindow *login_wind
 }
 
 static gboolean
-restart_task_conversation (GdmTaskList           *task_list,
-                           GdmTask               *task,
+restart_task_conversation (GdmTask               *task,
                            GdmGreeterLoginWindow *login_window)
 {
         char *service_name;
@@ -993,10 +1045,7 @@ gdm_greeter_login_window_reset (GdmGreeterLoginWindow *login_window)
         g_return_val_if_fail (GDM_IS_GREETER_LOGIN_WINDOW (login_window), FALSE);
         reset_dialog (GDM_GREETER_LOGIN_WINDOW (login_window), MODE_SELECTION);
 
-        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                    (GdmTaskListForeachFunc)
-                                    restart_task_conversation,
-                                    login_window);
+        g_list_foreach (login_window->priv->tasks, (GFunc) restart_task_conversation, login_window);
 
         g_free (login_window->priv->service_name_of_session_ready_to_start);
         login_window->priv->service_name_of_session_ready_to_start = NULL;
@@ -1022,7 +1071,6 @@ gdm_greeter_login_window_info (GdmGreeterLoginWindow *login_window,
                 gdm_conversation_set_message (GDM_CONVERSATION (task),
                                               text);
                 show_task_actions (task);
-                g_object_unref (task);
         }
 
         return TRUE;
@@ -1046,7 +1094,6 @@ gdm_greeter_login_window_problem (GdmGreeterLoginWindow *login_window,
                 gdm_conversation_set_message (GDM_CONVERSATION (task),
                                               text);
                 show_task_actions (task);
-                g_object_unref (task);
         }
 
         gdk_window_beep (gtk_widget_get_window (GTK_WIDGET (login_window)));
@@ -1085,9 +1132,19 @@ gdm_greeter_login_window_service_unavailable (GdmGreeterLoginWindow *login_windo
         task = find_task_with_service_name (login_window, service_name);
 
         if (task != NULL) {
-                gdm_task_list_remove_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                           task);
-                g_object_unref (task);
+                GdmTask *active_task;
+
+                gdm_task_set_enabled (task, FALSE);
+
+                active_task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
+
+                if (active_task == task) {
+                        restart_conversations (login_window);
+                }
+
+                if (active_task != NULL) {
+                        g_object_unref (active_task);
+                }
         }
 
         return TRUE;
@@ -1222,7 +1279,6 @@ gdm_greeter_login_window_info_query (GdmGreeterLoginWindow *login_window,
         if (task != NULL) {
                 gdm_conversation_ask_question (GDM_CONVERSATION (task),
                                                text);
-                g_object_unref (task);
         }
 
         set_log_in_button_mode (login_window, LOGIN_BUTTON_ANSWER_QUERY);
@@ -1253,7 +1309,6 @@ gdm_greeter_login_window_secret_info_query (GdmGreeterLoginWindow *login_window,
         if (task != NULL) {
                 gdm_conversation_ask_secret (GDM_CONVERSATION (task),
                                              text);
-                g_object_unref (task);
         }
 
         set_log_in_button_mode (login_window, LOGIN_BUTTON_ANSWER_QUERY);
@@ -1348,8 +1403,7 @@ on_user_chooser_visibility_changed (GdmGreeterLoginWindow *login_window)
 }
 
 static gboolean
-begin_task_verification_for_selected_user (GdmTaskList           *task_list,
-                                           GdmTask               *task,
+begin_task_verification_for_selected_user (GdmTask               *task,
                                            GdmGreeterLoginWindow *login_window)
 {
         char *user_name;
@@ -1367,6 +1421,9 @@ begin_task_verification_for_selected_user (GdmTaskList           *task_list,
                 g_free (service_name);
         }
 
+        gdm_task_list_add_task (GDM_TASK_LIST (login_window->priv->conversation_list),
+                                task);
+
         g_free (user_name);
         return FALSE;
 }
@@ -1414,7 +1471,7 @@ on_users_loaded (GdmUserChooserWidget  *user_chooser,
                 g_debug ("GdmGreeterLoginWindow: jumping straight to authenticate");
                 g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
                                0, GDM_USER_CHOOSER_USER_OTHER);
-                begin_verification (login_window);
+                begin_other_verification (login_window);
         }
 }
 
@@ -1422,19 +1479,23 @@ static void
 choose_user (GdmGreeterLoginWindow *login_window,
              const char            *user_name)
 {
+        GdmTask *task;
+
         g_assert (user_name != NULL);
         g_debug ("GdmGreeterLoginWindow: user chosen '%s'", user_name);
 
         g_signal_emit (G_OBJECT (login_window), signals[USER_SELECTED],
                        0, user_name);
 
+        g_list_foreach (login_window->priv->tasks,
+                        (GFunc) begin_task_verification_for_selected_user,
+                        login_window);
 
-        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                    (GdmTaskListForeachFunc)
-                                    begin_task_verification_for_selected_user,
-                                    login_window);
+        task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
+        set_task_active (login_window, task);
+        g_object_unref (task);
 
-        switch_mode (login_window, MODE_AUTHENTICATION);
+        switch_mode (login_window, MODE_MULTIPLE_AUTHENTICATION);
         update_conversation_list_visibility (login_window);
 }
 
@@ -1450,35 +1511,34 @@ begin_auto_login (GdmGreeterLoginWindow *login_window)
         /* just wait for the user to select language and stuff */
         set_message (login_window, _("Select language and click Log In"));
 
+        clear_active_task (login_window);
         switch_mode (login_window, MODE_TIMED_LOGIN);
 
         show_widget (login_window, "conversation-list", FALSE);
-        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                    (GdmTaskListForeachFunc) reset_task,
-                                    login_window);
+        g_list_foreach (login_window->priv->tasks,
+                        (GFunc) reset_task,
+                        login_window);
 }
 
-static gboolean
-reset_task_if_not_given (GdmTaskList *task_list,
-                         GdmTask     *task,
+static void
+reset_task_if_not_given (GdmTask     *task,
                          GdmTask     *given_task)
 {
         if (task == given_task) {
-                return FALSE;
+                return;
         }
 
         gdm_conversation_reset (GDM_CONVERSATION (task));
-        return FALSE;
 }
 
 static void
 reset_every_task_but_given_task (GdmGreeterLoginWindow *login_window,
                                  GdmTask               *task)
 {
-        gdm_task_list_foreach_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                    (GdmTaskListForeachFunc)
-                                    reset_task_if_not_given,
-                                    task);
+        g_list_foreach (login_window->priv->tasks,
+                        (GFunc) reset_task_if_not_given,
+                        task);
+
 }
 
 static void
@@ -1501,11 +1561,10 @@ begin_single_service_verification (GdmGreeterLoginWindow *login_window,
          */
         g_signal_emit (login_window, signals[BEGIN_VERIFICATION], 0, service_name);
 
-        switch_mode (login_window, MODE_AUTHENTICATION);
-        gdm_task_list_set_active_task (GDM_TASK_LIST (login_window->priv->conversation_list), task);
-
         reset_every_task_but_given_task (login_window, task);
-        g_object_unref (task);
+
+        set_task_active (login_window, task);
+        switch_mode (login_window, MODE_AUTHENTICATION);
 
         show_widget (login_window, "conversation-list", FALSE);
 }
@@ -1536,7 +1595,7 @@ on_user_chooser_activated (GdmUserChooserWidget  *user_chooser,
                 g_debug ("GdmGreeterLoginWindow: Starting all auth conversations");
                 g_free (item_id);
 
-                begin_verification (login_window);
+                begin_other_verification (login_window);
         } else if (strcmp (item_id, GDM_USER_CHOOSER_USER_GUEST) == 0) {
                 /* FIXME: handle guest account stuff */
                 g_free (item_id);
@@ -1774,63 +1833,28 @@ static void
 on_task_activated (GdmGreeterLoginWindow *login_window,
                    GdmTask               *task)
 {
-        GtkWidget *container;
-        char *name;
-
-        name = gdm_task_get_name (task);
-        g_debug ("GdmGreeterLoginWindow: task '%s' activated", name);
-        g_free (name);
-
-        container = g_object_get_data (G_OBJECT (task),
-                                       "gdm-greeter-login-window-page-container");
-
-        if (container == NULL) {
-                GtkWidget *page;
-
-                container = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-                gtk_container_add (GTK_CONTAINER (login_window->priv->auth_page_box),
-                                   container);
-
-                page = gdm_conversation_get_page (GDM_CONVERSATION (task));
-                if (page != NULL) {
-                        gtk_container_add (GTK_CONTAINER (container), page);
-                        gtk_widget_show (page);
-                }
-                g_object_set_data (G_OBJECT (task),
-                                   "gdm-greeter-login-window-page-container",
-                                   container);
-        }
-
-        gtk_widget_show (container);
-        switch_mode (login_window, login_window->priv->dialog_mode);
+        set_task_active (login_window, task);
 }
 
 static void
 on_task_deactivated (GdmGreeterLoginWindow *login_window,
                      GdmTask               *task)
 {
-        GtkWidget *container;
         char *name;
-        GtkActionGroup *actions;
+
+        if (login_window->priv->active_task != task) {
+                g_warning ("inactive task has been deactivated");
+                return;
+        }
 
         name = gdm_task_get_name (task);
         g_debug ("GdmGreeterLoginWindow: task '%s' now in background", name);
         g_free (name);
 
-        container = g_object_get_data (G_OBJECT (task),
-                                       "gdm-greeter-login-window-page-container");
+        clear_active_task (login_window);
 
-        if (container != NULL) {
-                gtk_widget_hide (container);
-        }
-
-        actions = gdm_conversation_get_actions (GDM_CONVERSATION (task));
-
-        if (actions != NULL) {
-                gtk_action_group_set_sensitive (actions, FALSE);
-                gtk_action_group_set_visible (actions, FALSE);
-                g_object_unref (actions);
-        }
+        login_window->priv->active_task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
+        g_object_unref (login_window->priv->active_task);
 }
 
 static void
@@ -1953,6 +1977,7 @@ load_theme (GdmGreeterLoginWindow *login_window)
         box = GTK_WIDGET (gtk_builder_get_object (login_window->priv->builder, "computer-info-event-box"));
         g_signal_connect (box, "button-press-event", G_CALLBACK (on_computer_info_label_button_press), login_window);
 
+        clear_active_task (login_window);
         switch_mode (login_window, MODE_SELECTION);
 
         gdm_profile_end (NULL);
@@ -2332,15 +2357,12 @@ on_conversation_chose_user (GdmGreeterLoginWindow *login_window,
 
         /* If we're already authenticating then we can't pick a user
          */
-        if (login_window->priv->dialog_mode == MODE_AUTHENTICATION) {
+        if (login_window->priv->dialog_mode == MODE_AUTHENTICATION || login_window->priv->dialog_mode == MODE_MULTIPLE_AUTHENTICATION) {
                 return FALSE;
         }
 
-        if (gdm_task_list_set_active_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                           GDM_TASK (conversation))) {
-                gdm_user_chooser_widget_set_chosen_user_name (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser),
-                                                              username);
-        }
+        gdm_user_chooser_widget_set_chosen_user_name (GDM_USER_CHOOSER_WIDGET (login_window->priv->user_chooser),
+                                                      username);
 
         return TRUE;
 }
@@ -2364,11 +2386,7 @@ on_conversation_message_set (GdmGreeterLoginWindow *login_window,
         }
 
         if (login_window->priv->service_name_of_session_ready_to_start != NULL ) {
-                GdmTask *task;
-
-                task = gdm_task_list_get_active_task (GDM_TASK_LIST (login_window->priv->conversation_list));
-
-                if (task == GDM_TASK (conversation)) {
+                if (login_window->priv->active_task == GDM_TASK (conversation)) {
                         gdm_greeter_login_window_start_session (login_window);
                 }
         }
@@ -2544,9 +2562,7 @@ gdm_greeter_login_window_add_extension (GdmGreeterLoginWindow *login_window,
         g_debug ("GdmGreeterLoginWindow: new extension '%s - %s' added",
                 name, description);
 
-        gdm_task_list_add_task (GDM_TASK_LIST (login_window->priv->conversation_list),
-                                GDM_TASK (extension));
-
+        login_window->priv->tasks = g_list_append (login_window->priv->tasks, extension);
         service_name = gdm_conversation_get_service_name (GDM_CONVERSATION (extension));
 
         if (gdm_task_is_choosable (GDM_TASK (extension))) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]