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
This commit is contained in:
parent
7464add904
commit
855a31ff25
@ -25,7 +25,7 @@ const KeyringDialog = new Lang.Class({
|
|||||||
this.prompt = new Shell.KeyringPrompt();
|
this.prompt = new Shell.KeyringPrompt();
|
||||||
this.prompt.connect('show-password', Lang.bind(this, this._onShowPassword));
|
this.prompt.connect('show-password', Lang.bind(this, this._onShowPassword));
|
||||||
this.prompt.connect('show-confirm', Lang.bind(this, this._onShowConfirm));
|
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',
|
let mainContentBox = new St.BoxLayout({ style_class: 'prompt-dialog-main-layout',
|
||||||
vertical: false });
|
vertical: false });
|
||||||
|
@ -100,7 +100,6 @@ G_DEFINE_TYPE_WITH_CODE (ShellKeyringPrompt, shell_keyring_prompt, G_TYPE_OBJECT
|
|||||||
enum {
|
enum {
|
||||||
SIGNAL_SHOW_PASSWORD,
|
SIGNAL_SHOW_PASSWORD,
|
||||||
SIGNAL_SHOW_CONFIRM,
|
SIGNAL_SHOW_CONFIRM,
|
||||||
SIGNAL_HIDE_PROMPT,
|
|
||||||
SIGNAL_LAST
|
SIGNAL_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -258,10 +257,8 @@ shell_keyring_prompt_dispose (GObject *obj)
|
|||||||
{
|
{
|
||||||
ShellKeyringPrompt *self = SHELL_KEYRING_PROMPT (obj);
|
ShellKeyringPrompt *self = SHELL_KEYRING_PROMPT (obj);
|
||||||
|
|
||||||
if (self->shown) {
|
if (self->shown)
|
||||||
self->shown = FALSE;
|
gcr_prompt_close (GCR_PROMPT (self));
|
||||||
g_signal_emit (self, signals[SIGNAL_HIDE_PROMPT], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->async_result)
|
if (self->async_result)
|
||||||
shell_keyring_prompt_cancel (self);
|
shell_keyring_prompt_cancel (self);
|
||||||
@ -384,11 +381,6 @@ shell_keyring_prompt_class_init (ShellKeyringPromptClass *klass)
|
|||||||
0, 0, NULL, NULL,
|
0, 0, NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__VOID,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
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
|
static void
|
||||||
@ -482,6 +474,19 @@ shell_keyring_prompt_confirm_finish (GcrPrompt *prompt,
|
|||||||
return self->last_reply;
|
return self->last_reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
shell_keyring_prompt_iface (GcrPromptIface *iface)
|
shell_keyring_prompt_iface (GcrPromptIface *iface)
|
||||||
{
|
{
|
||||||
@ -489,6 +494,7 @@ shell_keyring_prompt_iface (GcrPromptIface *iface)
|
|||||||
iface->prompt_password_finish = shell_keyring_prompt_password_finish;
|
iface->prompt_password_finish = shell_keyring_prompt_password_finish;
|
||||||
iface->prompt_confirm_async = shell_keyring_prompt_confirm_async;
|
iface->prompt_confirm_async = shell_keyring_prompt_confirm_async;
|
||||||
iface->prompt_confirm_finish = shell_keyring_prompt_confirm_finish;
|
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;
|
GSimpleAsyncResult *res;
|
||||||
|
|
||||||
g_return_if_fail (SHELL_IS_KEYRING_PROMPT (self));
|
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;
|
self->last_reply = GCR_PROMPT_REPLY_CANCEL;
|
||||||
|
|
||||||
res = self->async_result;
|
res = self->async_result;
|
||||||
|
Loading…
Reference in New Issue
Block a user