diff options
author | mathieui <mathieui@mathieui.net> | 2016-08-19 01:00:06 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2016-08-19 01:00:06 +0200 |
commit | 82d00d495b816c237cbefac3ff2387907a7f8843 (patch) | |
tree | a9eb2b831373b765165959b003be3fc43aa8a1db /poezio/windows/confirm.py | |
parent | c94df86b2cb0230cda2281f1d955b8796b2b29bb (diff) | |
download | poezio-82d00d495b816c237cbefac3ff2387907a7f8843.tar.gz poezio-82d00d495b816c237cbefac3ff2387907a7f8843.tar.bz2 poezio-82d00d495b816c237cbefac3ff2387907a7f8843.tar.xz poezio-82d00d495b816c237cbefac3ff2387907a7f8843.zip |
Add a "confirm" tab type
This tab will be used when an external events prompts a boolean choice
to a user, like a new ssl cert, or a XEP (e.g. 0070) that needs an
answer, and for which a command-line interface with an info message
would be a pain.
Diffstat (limited to 'poezio/windows/confirm.py')
-rw-r--r-- | poezio/windows/confirm.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/poezio/windows/confirm.py b/poezio/windows/confirm.py new file mode 100644 index 00000000..591ff89a --- /dev/null +++ b/poezio/windows/confirm.py @@ -0,0 +1,38 @@ +from poezio.windows.base_wins import Win + +from poezio.theming import get_theme, to_curses_attr + +class Dialog(Win): + str_accept = " Accept " + str_refuse = " Reject " + def __init__(self, helper_text, critical=False): + self.text = helper_text + self.accept = False + self.critical = critical + + def refresh(self): + self._win.erase() + self.addstr(self.text + "\n ") + + if self.critical: + col = to_curses_attr(get_theme().COLOR_WARNING_PROMPT) + else: + col = to_curses_attr(get_theme().COLOR_TAB_NORMAL) + + if self.accept: + self.addstr(self.str_accept, col) + else: + self.addstr(self.str_accept) + + self.addstr(" ") + + if self.accept: + self.addstr(self.str_refuse) + else: + self.addstr(self.str_refuse, col) + + self._refresh() + + def toggle_choice(self): + self.accept = not self.accept + |