[gdm] Add automatic cancellation of the selection to the test program



commit 80261619a6e711cf06fff53e4f77d8f9e768781f
Author: William Jon McCann <jmccann redhat com>
Date:   Thu Jun 10 15:18:51 2010 -0400

    Add automatic cancellation of the selection to the test program

 gui/simple-greeter/test-greeter-login-window.c |   42 ++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/gui/simple-greeter/test-greeter-login-window.c b/gui/simple-greeter/test-greeter-login-window.c
index e72cef9..d3dfafb 100644
--- a/gui/simple-greeter/test-greeter-login-window.c
+++ b/gui/simple-greeter/test-greeter-login-window.c
@@ -34,6 +34,39 @@
 
 #include "gdm-greeter-login-window.h"
 
+static guint cancel_idle_id = 0;
+
+static gboolean
+do_cancel (GdmGreeterLoginWindow *login_window)
+{
+        gdm_greeter_login_window_reset (GDM_GREETER_LOGIN_WINDOW (login_window));
+        cancel_idle_id = 0;
+        return FALSE;
+}
+
+static void
+on_select_user (GdmGreeterLoginWindow *login_window,
+                const char            *text,
+                gpointer               data)
+{
+        g_debug ("user selected: %s", text);
+        if (cancel_idle_id != 0) {
+                return;
+        }
+        cancel_idle_id = g_timeout_add_seconds (5, (GSourceFunc) do_cancel, login_window);
+}
+
+static void
+on_cancelled (GdmGreeterLoginWindow *login_window,
+              gpointer               data)
+{
+        g_debug ("login cancelled");
+        if (cancel_idle_id != 0) {
+                g_source_remove (cancel_idle_id);
+                cancel_idle_id = 0;
+        }
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -53,6 +86,15 @@ main (int argc, char *argv[])
         }
 
         login_window = gdm_greeter_login_window_new (TRUE);
+        g_signal_connect (login_window,
+                          "user-selected",
+                          G_CALLBACK (on_select_user),
+                          NULL);
+        g_signal_connect (login_window,
+                          "cancelled",
+                          G_CALLBACK (on_cancelled),
+                          NULL);
+
         gtk_widget_show (login_window);
 
         gtk_main ();



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