commit 9b07598db55816c36a58071ef788c5dcb641e0ef Author: Alex V. Myltsev Date: Mon Aug 4 10:51:19 2008 +0400 Maintain a dialog queue to show the passphrase dialogs sequentially. Gajim 0.12 has mostly asynchronous dialogues, which is good, but showing many dialogues on the screen can be confusing and inconvenient. This patch adds a queue so that password dialogues are only displayed sequentially. diff --git a/src/dialogs.py b/src/dialogs.py index 7ffad29..7a71074 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -199,7 +199,7 @@ class EditGroupsDialog: renderer.connect('toggled', self.group_toggled_cb) column.set_attributes(renderer, active = 1, inconsistent = 2) -class PassphraseDialog: +class PassphraseDialogImplementation: '''Class for Passphrase dialog''' def __init__(self, titletext, labeltext, checkbuttontext=None, ok_handler=None, cancel_handler=None): @@ -257,6 +257,43 @@ class PassphraseDialog: if self.cancel_handler and not self.ok: self.cancel_handler() +""" The dialog queue. +The head of the queue is the active dialog (on screen), +the rest are waiting to be shown.""" +dialog_queue = [] + +class PassphraseDialog: + def __init__(self, *args, **kwargs): + self.params = args, kwargs + if not dialog_queue: + self.show() + dialog_queue.append(self) + + def show(self): + args, kwargs = self.params + for handler_name in 'ok_handler', 'cancel_handler': + if handler_name in kwargs: + handler = kwargs[handler_name] + if isinstance(handler, tuple): + handler = (self.wrap_handler(handler[0]),) + handler[1:] + else: + handler = self.wrap_handler(handler) + kwargs[handler_name] = handler + + PassphraseDialogImplementation(*args, **kwargs) + + def close(self): + head = dialog_queue.pop(0) + assert head is self + if dialog_queue: + dialog_queue[0].show() + + def wrap_handler(self, handler): + def wrapper(*args, **kwargs): + self.close() + handler(*args, **kwargs) + return wrapper + class ChooseGPGKeyDialog: '''Class for GPG key dialog''' def __init__(self, title_text, prompt_text, secret_keys, on_response,