[gcr] gcr: In the frob-prompt tool delay during 'password checking' state



commit 3d3822f590951e61d7d9c1aae6fa638a640f85f9
Author: Stef Walter <stefw gnome org>
Date:   Mon Oct 22 16:10:11 2012 +0200

    gcr: In the frob-prompt tool delay during 'password checking' state
    
     * This is so we can better test the cancellation.

 gcr/tests/frob-prompt.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gcr/tests/frob-prompt.c b/gcr/tests/frob-prompt.c
index 59f15a7..2e9421d 100644
--- a/gcr/tests/frob-prompt.c
+++ b/gcr/tests/frob-prompt.c
@@ -36,6 +36,14 @@ static gchar *prompt_type = NULL;
 static gint prompt_delay = 0;
 static gboolean prompt_window = FALSE;
 
+static gboolean
+on_delay_timeout (gpointer data)
+{
+	GMainLoop *loop = data;
+	g_main_loop_quit (loop);
+	return FALSE;
+}
+
 static void
 prompt_perform (GtkWidget *parent)
 {
@@ -50,11 +58,11 @@ prompt_perform (GtkWidget *parent)
 	GcrPromptReply reply;
 	gchar *caller_id = NULL;
 	gboolean cont = TRUE;
+	GMainLoop *loop;
 	gchar *type;
 	gchar *choice;
 	guint i, j;
 
-
 	file = g_key_file_new ();
 	if (!g_key_file_load_from_file (file, file_name, G_KEY_FILE_NONE, &error))
 		errx (1, "couldn't load prompt info: %s", error->message);
@@ -77,8 +85,15 @@ prompt_perform (GtkWidget *parent)
 		g_free (caller_id);
 	}
 
+	loop = g_main_loop_new (NULL, FALSE);
 	groups = g_key_file_get_groups (file, NULL);
 	for (i = 0; cont && groups[i] != NULL; i++) {
+
+		if (i != 0) {
+			g_timeout_add_seconds (prompt_delay, on_delay_timeout, loop);
+			g_main_loop_run (loop);
+		}
+
 		keys = g_key_file_get_keys (file, groups[i], NULL, NULL);
 		for (j = 0; keys[j] != NULL; j++) {
 			key = keys[j];
@@ -135,10 +150,9 @@ prompt_perform (GtkWidget *parent)
 			g_print ("choice chosen: %s", gcr_prompt_get_choice_chosen (prompt) ? "true" : "false");
 		g_free (choice);
 		g_print ("\n");
-
-
 	}
 
+	g_main_loop_unref (loop);
 	g_object_unref (prompt);
 	g_strfreev (groups);
 	g_key_file_free (file);



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