[gnome-shell/gnome-3-8] components: Allow cancelling of dialog between prompts
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-8] components: Allow cancelling of dialog between prompts
- Date: Thu, 9 May 2013 03:58:04 +0000 (UTC)
commit d7528b878cc0b4461142fbeb9e01cc3bc9ae26fd
Author: Stef Walter <stefw gnome org>
Date: Tue Sep 25 21:53:36 2012 +0200
components: Allow cancelling of dialog between prompts
Some callers of the keyring prompt keep the dialog up while
processing the prompt. Allow the user to cancel the prompt
while in this state.
This is propagated to the caller, who can cancel the operation
in question when this occurs.
https://bugzilla.gnome.org/show_bug.cgi?id=682830
js/ui/components/keyring.js | 2 +-
src/shell-keyring-prompt.c | 40 ++++++++++++++++++++++++++++------------
2 files changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/components/keyring.js b/js/ui/components/keyring.js
index ae67b55..40d06d1 100644
--- a/js/ui/components/keyring.js
+++ b/js/ui/components/keyring.js
@@ -25,7 +25,7 @@ const KeyringDialog = new Lang.Class({
this.prompt = new Shell.KeyringPrompt();
this.prompt.connect('show-password', Lang.bind(this, this._onShowPassword));
this.prompt.connect('show-confirm', Lang.bind(this, this._onShowConfirm));
- this.prompt.connect('hide-prompt', Lang.bind(this, this._onHidePrompt));
+ this.prompt.connect('prompt-close', Lang.bind(this, this._onHidePrompt));
let mainContentBox = new St.BoxLayout({ style_class: 'prompt-dialog-main-layout',
vertical: false });
diff --git a/src/shell-keyring-prompt.c b/src/shell-keyring-prompt.c
index 01eb409..bafcb90 100644
--- a/src/shell-keyring-prompt.c
+++ b/src/shell-keyring-prompt.c
@@ -100,7 +100,6 @@ G_DEFINE_TYPE_WITH_CODE (ShellKeyringPrompt, shell_keyring_prompt, G_TYPE_OBJECT
enum {
SIGNAL_SHOW_PASSWORD,
SIGNAL_SHOW_CONFIRM,
- SIGNAL_HIDE_PROMPT,
SIGNAL_LAST
};
@@ -258,10 +257,8 @@ shell_keyring_prompt_dispose (GObject *obj)
{
ShellKeyringPrompt *self = SHELL_KEYRING_PROMPT (obj);
- if (self->shown) {
- self->shown = FALSE;
- g_signal_emit (self, signals[SIGNAL_HIDE_PROMPT], 0);
- }
+ if (self->shown)
+ gcr_prompt_close (GCR_PROMPT (self));
if (self->async_result)
shell_keyring_prompt_cancel (self);
@@ -384,11 +381,6 @@ shell_keyring_prompt_class_init (ShellKeyringPromptClass *klass)
0, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
- signals[SIGNAL_HIDE_PROMPT] = g_signal_new ("hide-prompt", G_TYPE_FROM_CLASS (klass),
- 0, 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
}
static void
@@ -483,12 +475,26 @@ shell_keyring_prompt_confirm_finish (GcrPrompt *prompt,
}
static void
+shell_keyring_prompt_close (GcrPrompt *prompt)
+{
+ ShellKeyringPrompt *self = SHELL_KEYRING_PROMPT (prompt);
+
+ /*
+ * We expect keyring.js to connect to this signal and do the
+ * actual work of closing the prompt.
+ */
+
+ self->shown = FALSE;
+}
+
+static void
shell_keyring_prompt_iface (GcrPromptIface *iface)
{
iface->prompt_password_async = shell_keyring_prompt_password_async;
iface->prompt_password_finish = shell_keyring_prompt_password_finish;
iface->prompt_confirm_async = shell_keyring_prompt_confirm_async;
iface->prompt_confirm_finish = shell_keyring_prompt_confirm_finish;
+ iface->prompt_close = shell_keyring_prompt_close;
}
/**
@@ -746,9 +752,19 @@ shell_keyring_prompt_cancel (ShellKeyringPrompt *self)
GSimpleAsyncResult *res;
g_return_if_fail (SHELL_IS_KEYRING_PROMPT (self));
- g_return_if_fail (self->mode != PROMPTING_NONE);
- g_return_if_fail (self->async_result != NULL);
+ /*
+ * If cancelled while not prompting, we should just close the prompt,
+ * the user wants it to go away.
+ */
+ if (self->mode == PROMPTING_NONE)
+ {
+ if (self->shown)
+ gcr_prompt_close (GCR_PROMPT (self));
+ return;
+ }
+
+ g_return_if_fail (self->async_result != NULL);
self->last_reply = GCR_PROMPT_REPLY_CANCEL;
res = self->async_result;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]