summaryrefslogtreecommitdiff
path: root/src/windows.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-03-08 22:39:30 +0100
committermathieui <mathieui@mathieui.net>2012-03-08 22:39:30 +0100
commit9d42ebdf2e5d770ca66a0b7f95adbe36bfd7083e (patch)
tree9146fcf67fa626191c36b49e4a7a94065d470f7e /src/windows.py
parent13a269d6b211d571486d223bba71bd4230c82838 (diff)
downloadpoezio-9d42ebdf2e5d770ca66a0b7f95adbe36bfd7083e.tar.gz
poezio-9d42ebdf2e5d770ca66a0b7f95adbe36bfd7083e.tar.bz2
poezio-9d42ebdf2e5d770ca66a0b7f95adbe36bfd7083e.tar.xz
poezio-9d42ebdf2e5d770ca66a0b7f95adbe36bfd7083e.zip
Validate the SSL cert using the TOFU (Trust On First Use) model
Diffstat (limited to 'src/windows.py')
-rw-r--r--src/windows.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/windows.py b/src/windows.py
index 5b48f052..50cad4c6 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -806,6 +806,48 @@ class HelpText(Win):
def do_command(self, key, raw=False):
return False
+class YesNoInput(Win):
+ """
+ A Window just displaying a Yes/No input
+ Used to ask a confirmation
+ """
+ def __init__(self, text=''):
+ Win.__init__(self)
+ self.key_func = {
+ 'y' : self.on_yes,
+ 'n' : self.on_no,
+ }
+ self.txt = text
+ self.value = None
+
+ def on_yes(self):
+ self.value = True
+
+ def on_no(self):
+ self.value = False
+
+ def refresh(self, txt=None):
+ log.debug('Refresh: %s',self.__class__.__name__)
+ if txt:
+ self.txt = txt
+ with g_lock:
+ self._win.erase()
+ self.addstr(0, 0, self.txt[:self.width-1], to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self.finish_line(get_theme().COLOR_INFORMATION_BAR)
+ self._refresh()
+
+ def do_command(self, key, raw=False):
+ if key.lower() in self.key_func:
+ self.key_func[key]()
+
+ def prompt(self):
+ """Monopolizes the input while waiting for a recognized keypress"""
+ cl = []
+ while self.value is None:
+ if len(cl) == 1 and cl[0] in self.key_func:
+ self.key_func[cl[0]]()
+ cl = self.core.read_keyboard()
+
class Input(Win):
"""
The simplest Input possible, provides just a way to edit a single line