[gdm/multi-stack: 15/49] Add a way for plugins to pick users from list



commit d2e1f986ae6c5c5b6e55df7f062031160ebb4dc6
Author: Ray Strode <rstrode redhat com>
Date:   Wed Feb 18 12:32:39 2009 -0500

    Add a way for plugins to pick users from list
    
    The smartcard plugin is going to want to
    start its conversation as soon as the card
    gets plugged in.

 gui/simple-greeter/gdm-greeter-login-window.c      |   36 ++++++++++++++++++++
 .../libgdmsimplegreeter/gdm-conversation.c         |   32 +++++++++++++++++
 .../libgdmsimplegreeter/gdm-conversation.h         |    6 +++
 3 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index e27b905..912a1e6 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -1796,6 +1796,34 @@ on_conversation_answer (GdmGreeterLoginWindow *login_window,
         set_ready (login_window);
 }
 
+static void
+on_conversation_cancel (GdmGreeterLoginWindow *login_window,
+                        GdmConversation       *conversation)
+{
+        do_cancel (login_window);
+}
+
+static void
+on_conversation_chose_user (GdmGreeterLoginWindow *login_window,
+                            const char            *username,
+                            GdmConversation       *conversation)
+{
+        if (!gdm_chooser_widget_is_loaded (GDM_CHOOSER_WIDGET (login_window->priv->user_chooser))) {
+                char *name;
+
+                name = gdm_task_get_name (GDM_TASK (conversation));
+                g_warning ("Task %s is trying to choose user before list is loaded", name);
+                g_free (name);
+                return;
+        }
+
+        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);
+        }
+}
+
 void
 gdm_greeter_login_window_remove_extension (GdmGreeterLoginWindow *login_window,
  GdmGreeterExtension *extension)
@@ -1933,6 +1961,14 @@ gdm_greeter_login_window_add_extension (GdmGreeterLoginWindow *login_window,
                                   "answer",
                                   G_CALLBACK (on_conversation_answer),
                                   login_window);
+        g_signal_connect_swapped (GDM_CONVERSATION (extension),
+                                  "cancel",
+                                  G_CALLBACK (on_conversation_cancel),
+                                  login_window);
+        g_signal_connect_swapped (GDM_CONVERSATION (extension),
+                                  "user-chosen",
+                                  G_CALLBACK (on_conversation_chose_user),
+                                  login_window);
 
         name = gdm_task_get_name (GDM_TASK (extension));
         description = gdm_task_get_description (GDM_TASK (extension));
diff --git a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c
index e21c56b..cef435c 100644
--- a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c
+++ b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.c
@@ -30,6 +30,8 @@
 
 enum {
         ANSWER,
+        USER_CHOSEN,
+        CANCEL,
         LAST_SIGNAL
 };
 
@@ -71,6 +73,25 @@ gdm_conversation_class_init (gpointer g_iface)
                               g_cclosure_marshal_VOID__STRING,
                               G_TYPE_NONE,
                               1, G_TYPE_STRING);
+        signals [USER_CHOSEN] =
+                g_signal_new ("user-chosen",
+                              iface_type,
+                              G_SIGNAL_RUN_FIRST,
+                              G_STRUCT_OFFSET (GdmConversationIface, user_chosen),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+        signals [CANCEL] =
+                g_signal_new ("cancel",
+                              iface_type,
+                              G_SIGNAL_RUN_FIRST,
+                              G_STRUCT_OFFSET (GdmConversationIface, cancel),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE, 0);
 }
 
 void
@@ -145,3 +166,14 @@ gdm_conversation_answer (GdmConversation   *conversation,
         g_signal_emit (conversation, signals [ANSWER], 0, answer);
 }
 
+void
+gdm_conversation_cancel (GdmConversation   *conversation)
+{
+        g_signal_emit (conversation, signals [CANCEL], 0);
+}
+void
+gdm_conversation_choose_user (GdmConversation *conversation,
+                              const char      *username)
+{
+        g_signal_emit (conversation, signals [USER_CHOSEN], 0, username);
+}
diff --git a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h
index f1910cf..fb4bf49 100644
--- a/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h
+++ b/gui/simple-greeter/libgdmsimplegreeter/gdm-conversation.h
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
 #define GDM_CONVERSATION_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), GDM_TYPE_CONVERSATION, GdmConversationIface))
 
 #define GDM_CONVERSATION_DEFAULT_ACTION "default-action"
+#define GDM_CONVERSATION_OTHER_USER "__other"
 
 typedef struct _GdmConversation      GdmConversation;
 typedef struct _GdmConversationIface GdmConversationIface;
@@ -59,6 +60,8 @@ struct _GdmConversationIface
 
         /* signals */
         char * (* answer)       (GdmConversation *conversation);
+        void   (* cancel)       (GdmConversation *conversation);
+        void   (* user_chosen)     (GdmConversation *conversation);
 };
 
 GType  gdm_conversation_get_type     (void) G_GNUC_CONST;
@@ -81,6 +84,9 @@ gboolean   gdm_conversation_focus    (GdmConversation *conversation);
  */
 void   gdm_conversation_answer (GdmConversation   *conversation,
                                 const char        *answer);
+void   gdm_conversation_cancel (GdmConversation   *conversation);
+void   gdm_conversation_choose_user (GdmConversation   *conversation,
+                                     const char        *username);
 
 G_END_DECLS
 



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