mirror of
https://github.com/gryf/wicd.git
synced 2025-12-22 22:27:59 +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:
@@ -171,9 +171,10 @@ class TabColumns(urwid.WidgetWrap):
|
|||||||
attr = normal attributes
|
attr = normal attributes
|
||||||
attrsel = attribute when active
|
attrsel = attribute when active
|
||||||
"""
|
"""
|
||||||
def __init__(self,tab_str,tab_wid,title,bottom_part,attr=('body','focus'),
|
# FIXME Make the bottom_part optional
|
||||||
|
def __init__(self,tab_str,tab_wid,title,bottom_part=None,attr=('body','focus'),
|
||||||
attrsel='tab active', attrtitle='header'):
|
attrsel='tab active', attrtitle='header'):
|
||||||
self.bottom_part = bottom_part
|
#self.bottom_part = bottom_part
|
||||||
#title_wid = urwid.Text((attrtitle,title),align='right')
|
#title_wid = urwid.Text((attrtitle,title),align='right')
|
||||||
column_list = []
|
column_list = []
|
||||||
for w in tab_str:
|
for w in tab_str:
|
||||||
@@ -195,7 +196,7 @@ class TabColumns(urwid.WidgetWrap):
|
|||||||
self.pile = urwid.Pile([
|
self.pile = urwid.Pile([
|
||||||
('fixed',1,urwid.Filler(self.columns,'top')),
|
('fixed',1,urwid.Filler(self.columns,'top')),
|
||||||
urwid.Filler(lbox,'top',height=('relative',99)),
|
urwid.Filler(lbox,'top',height=('relative',99)),
|
||||||
('fixed',1,urwid.Filler(self.bottom_part,'bottom'))
|
#('fixed',1,urwid.Filler(self.bottom_part,'bottom'))
|
||||||
])
|
])
|
||||||
if not firstrun:
|
if not firstrun:
|
||||||
self.frame.set_body(self.pile)
|
self.frame.set_body(self.pile)
|
||||||
@@ -205,7 +206,7 @@ class TabColumns(urwid.WidgetWrap):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def keypress(self,size,key):
|
def keypress(self,size,key):
|
||||||
self._w.keypress(size,key)
|
key = self._w.keypress(size,key)
|
||||||
if key == "meta [" or key == "meta ]":
|
if key == "meta [" or key == "meta ]":
|
||||||
self._w.get_body().set_focus(0)
|
self._w.get_body().set_focus(0)
|
||||||
newK = 'left' if key[-1] == '[' else 'right'
|
newK = 'left' if key[-1] == '[' else 'right'
|
||||||
@@ -220,7 +221,8 @@ class TabColumns(urwid.WidgetWrap):
|
|||||||
self.columns.get_focus().set_attr('tab active')
|
self.columns.get_focus().set_attr('tab active')
|
||||||
self.active_tab = self.columns.get_focus()
|
self.active_tab = self.columns.get_focus()
|
||||||
self.gen_pile(self.tab_map[self.active_tab])
|
self.gen_pile(self.tab_map[self.active_tab])
|
||||||
return key
|
|
||||||
|
return key
|
||||||
# self.listbox.body = lw
|
# self.listbox.body = lw
|
||||||
|
|
||||||
|
|
||||||
@@ -347,7 +349,6 @@ class ComboBox(urwid.WidgetWrap):
|
|||||||
def build_combobox(self,parent,ui,row):
|
def build_combobox(self,parent,ui,row):
|
||||||
str,trash = self.label.get_text()
|
str,trash = self.label.get_text()
|
||||||
|
|
||||||
|
|
||||||
self.cbox = DynWrap(SelText([self.list[self.focus]+' vvv']),
|
self.cbox = DynWrap(SelText([self.list[self.focus]+' vvv']),
|
||||||
attrs=self.attrs,focus_attr=self.focus_attr)
|
attrs=self.attrs,focus_attr=self.focus_attr)
|
||||||
if str != '':
|
if str != '':
|
||||||
|
|||||||
@@ -237,27 +237,10 @@ class PrefsDialog(urwid.WidgetWrap):
|
|||||||
self.header2 : advancedLB}
|
self.header2 : advancedLB}
|
||||||
#self.load_settings()
|
#self.load_settings()
|
||||||
|
|
||||||
# Now for the buttons:
|
self.tabs = TabColumns(headerList,lbList,language['preferences'])
|
||||||
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.__super.__init__(self.tabs)
|
self.__super.__init__(self.tabs)
|
||||||
|
|
||||||
def load_settings(self):
|
def load_settings(self):
|
||||||
# Reset the buttons
|
|
||||||
self.CANCEL_PRESSED = False
|
|
||||||
self.OK_PRESSED = False
|
|
||||||
|
|
||||||
### General Settings
|
### General Settings
|
||||||
# ComboBox does not like dbus.Strings as text markups. My fault. :/
|
# 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:
|
for w in self.dns1,self.dns2,self.dns3,self.dns_dom,self.search_dom:
|
||||||
w.set_sensitive(new_state)
|
w.set_sensitive(new_state)
|
||||||
|
|
||||||
# Button callbacks
|
def ready_widgets(self,ui,body):
|
||||||
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):
|
|
||||||
self.wpa_cbox.build_combobox(body,ui,4)
|
self.wpa_cbox.build_combobox(body,ui,4)
|
||||||
self.backend_cbox.build_combobox(body,ui,8)
|
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
|
|
||||||
|
|||||||
@@ -564,9 +564,6 @@ class appGUI():
|
|||||||
('I' ,'Hidden',None),
|
('I' ,'Hidden',None),
|
||||||
('Q' ,'Quit',loop.quit)
|
('Q' ,'Quit',loop.quit)
|
||||||
]
|
]
|
||||||
#(' ' ,' ',None),
|
|
||||||
#(' ' ,' ',None),
|
|
||||||
#(' ' ,' ',None),
|
|
||||||
|
|
||||||
self.primaryCols = OptCols(keys,debug=True)
|
self.primaryCols = OptCols(keys,debug=True)
|
||||||
#self.time_label = urwid.Text(strftime('%H:%M:%S'))
|
#self.time_label = urwid.Text(strftime('%H:%M:%S'))
|
||||||
@@ -608,7 +605,6 @@ class appGUI():
|
|||||||
('ESC','Cancel')
|
('ESC','Cancel')
|
||||||
],debug=True )
|
],debug=True )
|
||||||
|
|
||||||
|
|
||||||
# Does what it says it does
|
# Does what it says it does
|
||||||
def lock_screen(self):
|
def lock_screen(self):
|
||||||
self.frame.set_body(self.screen_locker)
|
self.frame.set_body(self.screen_locker)
|
||||||
@@ -650,7 +646,6 @@ class appGUI():
|
|||||||
|
|
||||||
# Be clunky until I get to a later stage of development.
|
# Be clunky until I get to a later stage of development.
|
||||||
# Update the list of networks. Usually called by DBus.
|
# Update the list of networks. Usually called by DBus.
|
||||||
# TODO: Preserve current focus when updating the list.
|
|
||||||
@wrap_exceptions()
|
@wrap_exceptions()
|
||||||
def update_netlist(self,state=None, x=None, force_check=False,firstrun=False):
|
def update_netlist(self,state=None, x=None, force_check=False,firstrun=False):
|
||||||
# Don't even try to do this if we are running a dialog
|
# Don't even try to do this if we are running a dialog
|
||||||
@@ -755,7 +750,6 @@ class appGUI():
|
|||||||
self.update_ui()
|
self.update_ui()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
# Cheap little indicator stating that we are actually connecting
|
# Cheap little indicator stating that we are actually connecting
|
||||||
twirl = ['|','/','-','\\']
|
twirl = ['|','/','-','\\']
|
||||||
tcount = 0 # Counter for said indicator
|
tcount = 0 # Counter for said indicator
|
||||||
@@ -873,11 +867,14 @@ class appGUI():
|
|||||||
if not self.pref:
|
if not self.pref:
|
||||||
self.pref = PrefsDialog(self.frame,(0,1),ui,
|
self.pref = PrefsDialog(self.frame,(0,1),ui,
|
||||||
dbusmanager.get_dbus_ifaces())
|
dbusmanager.get_dbus_ifaces())
|
||||||
if self.pref.run(ui,self.size,self.frame):
|
self.pref.load_settings()
|
||||||
self.pref.save_settings()
|
self.pref.ready_widgets(ui,self.frame)
|
||||||
self.update_ui()
|
self.frame.set_footer(urwid.Pile([self.prefCols,self.footer2]))
|
||||||
|
self.diag = self.pref
|
||||||
|
self.frame.set_body(self.diag)
|
||||||
|
# Halt here, keypress gets passed to the dialog otherwise
|
||||||
|
return True
|
||||||
if "A" in keys:
|
if "A" in keys:
|
||||||
self.footer1 = self.confCols
|
|
||||||
about_dialog(self.frame)
|
about_dialog(self.frame)
|
||||||
if "C" in keys:
|
if "C" in keys:
|
||||||
# Same as "enter" for now
|
# Same as "enter" for now
|
||||||
@@ -925,7 +922,8 @@ class appGUI():
|
|||||||
if self.diag:
|
if self.diag:
|
||||||
if k == 'esc':
|
if k == 'esc':
|
||||||
self.restore_primary()
|
self.restore_primary()
|
||||||
if k == 'left' or k == 'meta enter':
|
if (k == 'left' and self.diag.__class__.__mro__[0] == \
|
||||||
|
type(urwid.WidgetWrap)) or k == 'meta enter':
|
||||||
self.diag.save_settings()
|
self.diag.save_settings()
|
||||||
self.restore_primary()
|
self.restore_primary()
|
||||||
return True
|
return True
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -28,7 +28,7 @@ import subprocess
|
|||||||
VERSION_NUM = '1.6.0a1'
|
VERSION_NUM = '1.6.0a1'
|
||||||
# REVISION_NUM is automatically updated
|
# REVISION_NUM is automatically updated
|
||||||
REVISION_NUM = 'unknown'
|
REVISION_NUM = 'unknown'
|
||||||
CURSES_REVNO = 'uimod-r287'
|
CURSES_REVNO = 'uimod-r288'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists('vcsinfo.py'):
|
if not os.path.exists('vcsinfo.py'):
|
||||||
|
|||||||
Reference in New Issue
Block a user