fix #1465, fix ssl_insecure

This commit is contained in:
Maximilian Hils 2016-08-02 20:08:04 -07:00
parent 49ce50d5d0
commit 4ff9dba7d2
3 changed files with 16 additions and 8 deletions

View File

@ -94,7 +94,7 @@ class Options(urwid.WidgetWrap):
select.Option(
"Don't Verify SSL/TLS Certificates",
"V",
lambda: master.server.config.ssl_insecure,
lambda: master.options.ssl_insecure,
master.options.toggler("ssl_insecure")
),
@ -140,15 +140,17 @@ class Options(urwid.WidgetWrap):
title = urwid.Text("Options")
title = urwid.Padding(title, align="left", width=("relative", 100))
title = urwid.AttrWrap(title, "heading")
self._w = urwid.Frame(
w = urwid.Frame(
self.lb,
header = title
)
super(Options, self).__init__(w)
self.master.loop.widget.footer.update("")
signals.update_settings.connect(self.sig_update_settings)
master.options.changed.connect(lambda sender, updated: self.sig_update_settings(sender))
master.options.changed.connect(self.sig_update_settings)
def sig_update_settings(self, sender):
def sig_update_settings(self, sender, updated=None):
self.lb.walker._modified()
def keypress(self, size, key):

View File

@ -124,10 +124,10 @@ class StatusBar(urwid.WidgetWrap):
super(StatusBar, self).__init__(urwid.Pile([self.ib, self.master.ab]))
signals.update_settings.connect(self.sig_update_settings)
signals.flowlist_change.connect(self.sig_update_settings)
master.options.changed.connect(lambda sender, updated: self.sig_update_settings(sender))
master.options.changed.connect(self.sig_update_settings)
self.redraw()
def sig_update_settings(self, sender):
def sig_update_settings(self, sender, updated=None):
self.redraw()
def keypress(self, *args, **kwargs):

View File

@ -86,7 +86,10 @@ class OptManager(object):
"""
if attr not in self._opts:
raise KeyError("No such option: %s" % attr)
return lambda x: self.__setattr__(attr, x)
def setter(x):
setattr(self, attr, x)
return setter
def toggler(self, attr):
"""
@ -95,7 +98,10 @@ class OptManager(object):
"""
if attr not in self._opts:
raise KeyError("No such option: %s" % attr)
return lambda: self.__setattr__(attr, not getattr(self, attr))
def toggle():
setattr(self, attr, not getattr(self, attr))
return toggle
def __repr__(self):
options = pprint.pformat(self._opts, indent=4).strip(" {}")