[gcr] gcr: Add prompt-close action signal to GcrPrompt



commit 457348bccd3a8c7f76157549d86bc41fc3f1175c
Author: Stef Walter <stefw gnome org>
Date:   Fri Sep 21 09:28:14 2012 +0200

    gcr: Add prompt-close action signal to GcrPrompt
    
     * This signal is fired when the prompt is closed, regardless of
       whether that closure was initiated by the user, or by the the
       application.
     * Add a gcr_prompt_close() method to fire this signal.
     * After closing a prompt the prompt should not display any further
       password or confirm prompts to the user.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678611

 docs/reference/gcr/gcr-sections.txt |    1 +
 gcr/gcr-base.symbols                |    1 +
 gcr/gcr-prompt.c                    |   41 +++++++++++++++++++++++++++++++++++
 gcr/gcr-prompt.h                    |    4 +++
 4 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gcr/gcr-sections.txt b/docs/reference/gcr/gcr-sections.txt
index be85461..2b21ca9 100644
--- a/docs/reference/gcr/gcr-sections.txt
+++ b/docs/reference/gcr/gcr-sections.txt
@@ -743,6 +743,7 @@ gcr_prompt_confirm_async
 gcr_prompt_confirm_finish
 gcr_prompt_confirm_run
 gcr_prompt_reset
+gcr_prompt_close
 gcr_prompt_get_title
 gcr_prompt_set_title
 gcr_prompt_get_message
diff --git a/gcr/gcr-base.symbols b/gcr/gcr-base.symbols
index 5bc2708..bcf7bfb 100644
--- a/gcr/gcr-base.symbols
+++ b/gcr/gcr-base.symbols
@@ -152,6 +152,7 @@ gcr_pkcs11_initialize_finish
 gcr_pkcs11_set_modules
 gcr_pkcs11_set_trust_lookup_uris
 gcr_pkcs11_set_trust_store_uri
+gcr_prompt_close
 gcr_prompt_confirm
 gcr_prompt_confirm_async
 gcr_prompt_confirm_finish
diff --git a/gcr/gcr-prompt.c b/gcr/gcr-prompt.c
index 9e54065..033d536 100644
--- a/gcr/gcr-prompt.c
+++ b/gcr/gcr-prompt.c
@@ -64,6 +64,7 @@
  * @prompt_password_finish: complete a password prompt
  * @prompt_confirm_async: begin a confirm prompt
  * @prompt_confirm_finish: complete a confirm prompt
+ * @prompt_close: close a prompt
  *
  * The interface for implementing #GcrPrompt.
  */
@@ -75,6 +76,14 @@
  *
  * Various replies returned by gcr_prompt_confirm() and friends.
  */
+
+enum {
+	PROMPT_CLOSE,
+	NUM_SIGNALS
+};
+
+static guint signals[NUM_SIGNALS];
+
 typedef struct {
 	GAsyncResult *result;
 	GMainLoop *loop;
@@ -226,6 +235,20 @@ gcr_prompt_default_init (GcrPromptIface *iface)
 		                g_param_spec_string ("cancel-label", "Cancel label", "Cancel button label",
 		                                     _("Cancel"), G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
 
+		/**
+		 * GcrPrompt::prompt-close:
+		 *
+		 * Action signal fired when the prompt is to be closed. After the default
+		 * handler has run, the prompt is closed. The various prompting methods
+		 * will return results as if the user dismissed the prompt.
+		 *
+		 * You can use the gcr_prompt_close() method to emit this signal.
+		 */
+		signals[PROMPT_CLOSE] = g_signal_new ("prompt-close", GCR_TYPE_PROMPT, G_SIGNAL_RUN_FIRST,
+		                                      G_STRUCT_OFFSET (GcrPromptIface, prompt_close),
+		                                      NULL, NULL, g_cclosure_marshal_generic,
+		                                      G_TYPE_NONE, 0);
+
 		g_once_init_leave (&initialized, 1);
 	}
 }
@@ -1027,3 +1050,21 @@ gcr_prompt_confirm_run (GcrPrompt *prompt,
 
 	return reply;
 }
+
+/**
+ * gcr_prompt_close:
+ * @prompt: a prompt
+ *
+ * Closes the prompt so that in can no longer be used to prompt. The various
+ * prompt methods will return results as if the user dismissed the prompt.
+ *
+ * The prompt may also be closed by the implementor of the #GcrPrompt object.
+ *
+ * This emits the GcrPrompt::prompt-close signal on the prompt object.
+ */
+void
+gcr_prompt_close (GcrPrompt *prompt)
+{
+	g_return_if_fail (GCR_IS_PROMPT (prompt));
+	g_signal_emit (prompt, signals[PROMPT_CLOSE], 0);
+}
diff --git a/gcr/gcr-prompt.h b/gcr/gcr-prompt.h
index 00ff8a6..67735c3 100644
--- a/gcr/gcr-prompt.h
+++ b/gcr/gcr-prompt.h
@@ -67,6 +67,8 @@ struct _GcrPromptIface {
 	GcrPromptReply     (* prompt_confirm_finish)    (GcrPrompt *prompt,
 	                                                 GAsyncResult *result,
 	                                                 GError **error);
+
+	void               (* prompt_close)             (GcrPrompt *prompt);
 };
 
 GType                gcr_prompt_get_type                  (void);
@@ -159,6 +161,8 @@ GcrPromptReply       gcr_prompt_confirm_run               (GcrPrompt *prompt,
                                                            GCancellable *cancellable,
                                                            GError **error);
 
+void                 gcr_prompt_close                     (GcrPrompt *prompt);
+
 G_END_DECLS
 
 #endif /* __GCR_PROMPT_H__ */



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