mirror of
https://github.com/gryf/wicd.git
synced 2026-02-25 11:45:50 +01:00
curses/prefs_curses.py: Adapted widgets for integration into the main UI
curses/curses_misc.py:
Removed the "bottom_part" from the TabColumns
curses/wicd-curses.py:
Added support for editing preferences directly in the main UI w/o a dialog
'left' now only quits with saving for the NetworkSettingsDialogs
(suggestions as for what to do here would be appreciated)
This commit is contained in:
@@ -237,27 +237,10 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
self.header2 : advancedLB}
|
||||
#self.load_settings()
|
||||
|
||||
# Now for the buttons:
|
||||
ok_t = 'OK'
|
||||
cancel_t = 'Cancel'
|
||||
|
||||
ok_button = urwid.AttrWrap(urwid.Button('OK',self.ok_callback),'body','focus')
|
||||
cancel_button = urwid.AttrWrap(urwid.Button('Cancel',self.cancel_callback),'body','focus')
|
||||
# Variables set by the buttons' callback functions
|
||||
self.CANCEL_PRESSED = False
|
||||
self.OK_PRESSED = False
|
||||
|
||||
|
||||
self.button_cols = urwid.Columns([ok_button,cancel_button],
|
||||
dividechars=1)
|
||||
|
||||
self.tabs = TabColumns(headerList,lbList,language['preferences'],self.button_cols)
|
||||
self.tabs = TabColumns(headerList,lbList,language['preferences'])
|
||||
self.__super.__init__(self.tabs)
|
||||
|
||||
def load_settings(self):
|
||||
# Reset the buttons
|
||||
self.CANCEL_PRESSED = False
|
||||
self.OK_PRESSED = False
|
||||
|
||||
### General Settings
|
||||
# ComboBox does not like dbus.Strings as text markups. My fault. :/
|
||||
@@ -378,45 +361,6 @@ class PrefsDialog(urwid.WidgetWrap):
|
||||
for w in self.dns1,self.dns2,self.dns3,self.dns_dom,self.search_dom:
|
||||
w.set_sensitive(new_state)
|
||||
|
||||
# Button callbacks
|
||||
def ok_callback(self,button_object,user_data=None):
|
||||
self.OK_PRESSED = True
|
||||
def cancel_callback(self,button_object,user_data=None):
|
||||
self.CANCEL_PRESSED = True
|
||||
|
||||
def ready_comboboxes(self,ui,body):
|
||||
def ready_widgets(self,ui,body):
|
||||
self.wpa_cbox.build_combobox(body,ui,4)
|
||||
self.backend_cbox.build_combobox(body,ui,8)
|
||||
|
||||
# Put the widget into an overlay, and run!
|
||||
def run(self,ui, dim, display):
|
||||
width,height = ui.get_cols_rows()
|
||||
self.load_settings()
|
||||
|
||||
overlay = urwid.Overlay(self.tabs, display, ('fixed left', 0),width
|
||||
, ('fixed top',1), height-3)
|
||||
self.ready_comboboxes(ui,overlay)
|
||||
|
||||
keys = True
|
||||
while True:
|
||||
if keys:
|
||||
ui.draw_screen(dim, overlay.render(dim, True))
|
||||
keys = ui.get_input()
|
||||
|
||||
if "window resize" in keys:
|
||||
dim = ui.get_cols_rows()
|
||||
if "esc" in keys or 'Q' in keys:
|
||||
return False
|
||||
for k in keys:
|
||||
#Send key to underlying widget:
|
||||
overlay.keypress(dim, k)
|
||||
if urwid.is_mouse_event(k):
|
||||
event, button, col, row = k
|
||||
overlay.mouse_event( dim,
|
||||
event, button, col, row,
|
||||
focus=True)
|
||||
# Check if buttons are pressed.
|
||||
if self.CANCEL_PRESSED:
|
||||
return False
|
||||
if self.OK_PRESSED or 'meta enter' in keys:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user