mirror of
https://github.com/gryf/wicd.git
synced 2025-12-21 13:28:08 +01:00
More htoppish ui changes
curses/prefs_curses.py: changed save_results to save_settings
curses/curses_misc.py:
M^[ and M^] shift the tabs left and right respectively. The curses module
has trouble picking up M^left and M^right
curses/netentry_curses.py:
Removed the buttons and button-related code from the interface.
Removed the overlay code.
Adapted the code for direct insertion into the wicd-curses interface
curses/wicd-curses.py:
Teaked the wireless header.
Added support for sticking the network config dialog into the interface, and
changing the current OptCols when it is activated.
Added new OptCols for other large dialogs
This commit is contained in:
@@ -206,9 +206,10 @@ class TabColumns(urwid.WidgetWrap):
|
|||||||
|
|
||||||
def keypress(self,size,key):
|
def keypress(self,size,key):
|
||||||
self._w.keypress(size,key)
|
self._w.keypress(size,key)
|
||||||
if key == "meta left" or key == "meta right":
|
if key == "meta [" or key == "meta ]":
|
||||||
self._w.get_body().set_focus(0)
|
self._w.get_body().set_focus(0)
|
||||||
self.keypress(size,key[5:])
|
newK = 'left' if key[-1] == '[' else 'right'
|
||||||
|
self.keypress(size,newK)
|
||||||
self._w.get_body().set_focus(1)
|
self._w.get_body().set_focus(1)
|
||||||
else:
|
else:
|
||||||
wid = self.pile.get_focus().get_body()
|
wid = self.pile.get_focus().get_body()
|
||||||
|
|||||||
@@ -84,13 +84,6 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
|
|||||||
|
|
||||||
_blank = urwid.Text('')
|
_blank = urwid.Text('')
|
||||||
|
|
||||||
# Buttons. These need to be added to the list in superclasses.
|
|
||||||
self.OK_PRESSED= False
|
|
||||||
self.CANCEL_PRESSED = False
|
|
||||||
self.ok_button = urwid.AttrWrap(urwid.Button('OK',self.ok_callback),'body','focus')
|
|
||||||
self.cancel_button = urwid.AttrWrap(urwid.Button('Cancel',self.cancel_callback),'body','focus')
|
|
||||||
self.button_cols = urwid.Columns([self.ok_button,self.cancel_button])
|
|
||||||
|
|
||||||
walker = urwid.SimpleListWalker([self.static_ip_cb,
|
walker = urwid.SimpleListWalker([self.static_ip_cb,
|
||||||
self.ip_edit,
|
self.ip_edit,
|
||||||
self.netmask_edit,
|
self.netmask_edit,
|
||||||
@@ -105,16 +98,9 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
|
|||||||
|
|
||||||
self._listbox = urwid.ListBox(walker)
|
self._listbox = urwid.ListBox(walker)
|
||||||
#self._frame = urwid.Frame(self._listbox)
|
#self._frame = urwid.Frame(self._listbox)
|
||||||
self._frame = urwid.Frame(self._listbox,footer=self.button_cols)
|
self._frame = urwid.Frame(self._listbox)
|
||||||
self.__super.__init__(self._frame)
|
self.__super.__init__(self._frame)
|
||||||
|
|
||||||
|
|
||||||
# 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 static_ip_set_state(self,checkb,new_state,user_data=None):
|
def static_ip_set_state(self,checkb,new_state,user_data=None):
|
||||||
for w in [ self.ip_edit,self.netmask_edit,self.gateway_edit ]:
|
for w in [ self.ip_edit,self.netmask_edit,self.gateway_edit ]:
|
||||||
w.set_sensitive(new_state)
|
w.set_sensitive(new_state)
|
||||||
@@ -166,54 +152,9 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
|
|||||||
self.set_net_prop("dns1", '')
|
self.set_net_prop("dns1", '')
|
||||||
self.set_net_prop("dns2", '')
|
self.set_net_prop("dns2", '')
|
||||||
self.set_net_prop("dns3", '')
|
self.set_net_prop("dns3", '')
|
||||||
|
# Prevent comboboxes from dying.
|
||||||
def prerun(self,ui,dim,display):
|
def ready_widgets(self,ui,body):
|
||||||
pass
|
pass
|
||||||
def run(self,ui,dim,display):
|
|
||||||
self.ui = ui
|
|
||||||
self.parent = display
|
|
||||||
width,height = ui.get_cols_rows()
|
|
||||||
|
|
||||||
self.overlay = urwid.Overlay(self, display, ('fixed left', 0),width
|
|
||||||
, ('fixed top',1), height-3)
|
|
||||||
self.prerun(ui,dim,display)
|
|
||||||
#self.ready_comboboxes(ui,overlay)
|
|
||||||
|
|
||||||
keys = True
|
|
||||||
while True:
|
|
||||||
if keys:
|
|
||||||
ui.draw_screen(dim, self.overlay.render(dim, True))
|
|
||||||
keys = ui.get_input()
|
|
||||||
|
|
||||||
for k in keys:
|
|
||||||
#Send key to underlying widget:
|
|
||||||
if urwid.is_mouse_event(k):
|
|
||||||
event, button, col, row = k
|
|
||||||
self.overlay.mouse_event( dim,
|
|
||||||
event, button, col, row,
|
|
||||||
focus=True)
|
|
||||||
else:
|
|
||||||
k = self.overlay.keypress(dim, k)
|
|
||||||
if k in ('up','page up'):
|
|
||||||
self._w.set_focus('body')
|
|
||||||
# Until I figure out a better way to do this, then
|
|
||||||
# this will have to do.
|
|
||||||
self._w.body.get_focus()[0].get_focus()._invalidate()
|
|
||||||
#self._w.body.keypress(dim,'down')
|
|
||||||
elif k in ('down','page down'):
|
|
||||||
self._w.set_focus('footer')
|
|
||||||
|
|
||||||
if "window resize" in keys:
|
|
||||||
dim = ui.get_cols_rows()
|
|
||||||
if "esc" in keys or 'Q' in keys:
|
|
||||||
return False
|
|
||||||
if "meta enter" in keys or self.OK_PRESSED:
|
|
||||||
self.OK_PRESSED = False
|
|
||||||
if self.save_settings():
|
|
||||||
return True
|
|
||||||
if self.CANCEL_PRESSED:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class WiredSettingsDialog(AdvancedSettingsDialog):
|
class WiredSettingsDialog(AdvancedSettingsDialog):
|
||||||
def __init__(self,name):
|
def __init__(self,name):
|
||||||
@@ -367,13 +308,13 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
|||||||
encrypt_methods[self.encryption_combo.get_focus()[1] ][1])
|
encrypt_methods[self.encryption_combo.get_focus()[1] ][1])
|
||||||
for x in encryption_info:
|
for x in encryption_info:
|
||||||
if encryption_info[x].get_edit_text() == "":
|
if encryption_info[x].get_edit_text() == "":
|
||||||
error(self.ui, self.overlay,language['encrypt_info_missing'])
|
error(self.ui, self.body,language['encrypt_info_missing'])
|
||||||
return False
|
return False
|
||||||
self.set_net_prop(x, noneToString(encryption_info[x].
|
self.set_net_prop(x, noneToString(encryption_info[x].
|
||||||
get_edit_text()))
|
get_edit_text()))
|
||||||
elif not self.encryption_chkbox.get_state() and \
|
elif not self.encryption_chkbox.get_state() and \
|
||||||
wireless.GetWirelessProperty(self.networkID, "encryption"):
|
wireless.GetWirelessProperty(self.networkID, "encryption"):
|
||||||
error(self.ui, self.overlay, language['enable_encryption'])
|
error(self.ui, self.body, language['enable_encryption'])
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
#print 'encryption is ' + str(wireless.GetWirelessProperty(self.networkID,
|
#print 'encryption is ' + str(wireless.GetWirelessProperty(self.networkID,
|
||||||
@@ -431,6 +372,8 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
|||||||
self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)
|
self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)
|
||||||
#self._w.body.body.append(self.pile_encrypt)
|
#self._w.body.body.append(self.pile_encrypt)
|
||||||
|
|
||||||
def prerun(self,ui,dim,display):
|
def ready_widgets(self,ui,body):
|
||||||
self.encryption_combo.build_combobox(self.overlay,ui,14)
|
self.ui = ui
|
||||||
|
self.body = body
|
||||||
|
self.encryption_combo.build_combobox(body,ui,14)
|
||||||
self.change_encrypt_method()
|
self.change_encrypt_method()
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ class PrefsDialog(urwid.WidgetWrap):
|
|||||||
self.debug_mode_checkb.set_state(daemon.GetDebugMode())
|
self.debug_mode_checkb.set_state(daemon.GetDebugMode())
|
||||||
self.use_dbm_checkb.set_state(daemon.GetSignalDisplayType())
|
self.use_dbm_checkb.set_state(daemon.GetSignalDisplayType())
|
||||||
|
|
||||||
def save_results(self):
|
def save_settings(self):
|
||||||
""" Pushes the selected settings to the daemon.
|
""" Pushes the selected settings to the daemon.
|
||||||
This exact order is found in prefs.py"""
|
This exact order is found in prefs.py"""
|
||||||
daemon.SetUseGlobalDNS(self.global_dns_checkb.get_state())
|
daemon.SetUseGlobalDNS(self.global_dns_checkb.get_state())
|
||||||
|
|||||||
66
curses/wicd-curses.py
Normal file → Executable file
66
curses/wicd-curses.py
Normal file → Executable file
@@ -314,7 +314,7 @@ def gen_list_header():
|
|||||||
# Allocate 25 cols for the ESSID name
|
# Allocate 25 cols for the ESSID name
|
||||||
essidgap = 25
|
essidgap = 25
|
||||||
else:
|
else:
|
||||||
# Need 3 more to accomodate dBm strings (I think)
|
# Need 3 more to accomodate dBm strings
|
||||||
essidgap = 28
|
essidgap = 28
|
||||||
return 'C %s %*s %9s %17s %6s %s' % ('STR ',essidgap,'ESSID','ENCRYPT','BSSID','MODE','CHNL')
|
return 'C %s %*s %9s %17s %6s %s' % ('STR ',essidgap,'ESSID','ENCRYPT','BSSID','MODE','CHNL')
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ class NetLabel(urwid.WidgetWrap):
|
|||||||
self.encrypt = wireless.GetWirelessProperty(id,'encryption_method') if wireless.GetWirelessProperty(id, 'encryption') else language['unsecured']
|
self.encrypt = wireless.GetWirelessProperty(id,'encryption_method') if wireless.GetWirelessProperty(id, 'encryption') else language['unsecured']
|
||||||
self.mode = wireless.GetWirelessProperty(id, 'mode') # Master, Ad-Hoc
|
self.mode = wireless.GetWirelessProperty(id, 'mode') # Master, Ad-Hoc
|
||||||
self.channel = wireless.GetWirelessProperty(id, 'channel')
|
self.channel = wireless.GetWirelessProperty(id, 'channel')
|
||||||
theString = ' %*s %25s %9s %17s %6s %4s' % (gap,
|
theString = ' %-*s %25s %9s %17s %6s %4s' % (gap,
|
||||||
self.stren,self.essid,self.encrypt,self.bssid,self.mode,self.channel)
|
self.stren,self.essid,self.encrypt,self.bssid,self.mode,self.channel)
|
||||||
if is_active:
|
if is_active:
|
||||||
theString = '>'+theString[1:]
|
theString = '>'+theString[1:]
|
||||||
@@ -536,7 +536,9 @@ class appGUI():
|
|||||||
|
|
||||||
# These are empty to make sure that things go my way.
|
# These are empty to make sure that things go my way.
|
||||||
wiredL,wlessL = [],[]# = gen_network_list()
|
wiredL,wlessL = [],[]# = gen_network_list()
|
||||||
|
|
||||||
self.frame = None
|
self.frame = None
|
||||||
|
self.diag = None
|
||||||
|
|
||||||
self.wiredCB = urwid.Filler(WiredComboBox(wiredL))
|
self.wiredCB = urwid.Filler(WiredComboBox(wiredL))
|
||||||
self.wlessLB = urwid.ListBox(wlessL)
|
self.wlessLB = urwid.ListBox(wlessL)
|
||||||
@@ -566,20 +568,23 @@ class appGUI():
|
|||||||
#(' ' ,' ',None),
|
#(' ' ,' ',None),
|
||||||
#(' ' ,' ',None),
|
#(' ' ,' ',None),
|
||||||
|
|
||||||
self.footer1 = 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'))
|
||||||
self.time_label = \
|
self.time_label = \
|
||||||
urwid.AttrWrap(urwid.Text(strftime('%H:%M:%S')), 'timebar')
|
urwid.AttrWrap(urwid.Text(strftime('%H:%M:%S')), 'timebar')
|
||||||
self.status_label = urwid.AttrWrap(urwid.Text('blah'),'important')
|
self.status_label = urwid.AttrWrap(urwid.Text('blah'),'important')
|
||||||
self.footer2 = urwid.Columns([self.status_label,('fixed', 8, self.time_label)])
|
self.footer2 = urwid.Columns([self.status_label,('fixed', 8, self.time_label)])
|
||||||
self.footerList = urwid.ListBox([self.footer1,self.footer2])
|
self.footerList = urwid.Pile([self.primaryCols,self.footer2])
|
||||||
# Pop takes a number!
|
# Pop takes a number!
|
||||||
#walker.pop(1)
|
#walker.pop(1)
|
||||||
self.frame = urwid.Frame(self.thePile,
|
self.frame = urwid.Frame(self.thePile,
|
||||||
header=header,
|
header=header,
|
||||||
footer=urwid.BoxAdapter(self.footerList,2))
|
footer=self.footerList)
|
||||||
self.wiredCB.get_body().build_combobox(self.frame,ui,3)
|
self.wiredCB.get_body().build_combobox(self.frame,ui,3)
|
||||||
|
|
||||||
|
# Init the other columns used in the program
|
||||||
|
self.init_other_optcols()
|
||||||
|
|
||||||
self.frame.set_body(self.thePile)
|
self.frame.set_body(self.thePile)
|
||||||
# Booleans gallore!
|
# Booleans gallore!
|
||||||
self.prev_state = False
|
self.prev_state = False
|
||||||
@@ -592,6 +597,18 @@ class appGUI():
|
|||||||
|
|
||||||
#self.dialog = PrefOverlay(self.frame,self.size)
|
#self.dialog = PrefOverlay(self.frame,self.size)
|
||||||
|
|
||||||
|
def init_other_optcols(self):
|
||||||
|
# The "tabbed" preferences dialog
|
||||||
|
self.prefCols = OptCols( [('meta enter','OK'),
|
||||||
|
('ESC','Cancel'),
|
||||||
|
('meta [','Tab Left',),
|
||||||
|
('meta ]','Tab Right')],debug=True )
|
||||||
|
self.confCols = OptCols( [
|
||||||
|
('<-','OK'),
|
||||||
|
('ESC','Cancel')
|
||||||
|
],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)
|
||||||
@@ -636,7 +653,11 @@ class appGUI():
|
|||||||
# TODO: Preserve current focus when updating the list.
|
# 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):
|
||||||
# Run focus-collecting code if we are not running this for the first time
|
# Don't even try to do this if we are running a dialog
|
||||||
|
if self.diag:
|
||||||
|
return
|
||||||
|
# Run focus-collecting code if we are not running this for the first
|
||||||
|
# time
|
||||||
if not firstrun:
|
if not firstrun:
|
||||||
self.update_focusloc()
|
self.update_focusloc()
|
||||||
self.list_header.set_text(gen_list_header())
|
self.list_header.set_text(gen_list_header())
|
||||||
@@ -787,6 +808,11 @@ class appGUI():
|
|||||||
def dbus_scan_started(self):
|
def dbus_scan_started(self):
|
||||||
self.lock_screen()
|
self.lock_screen()
|
||||||
|
|
||||||
|
def restore_primary(self):
|
||||||
|
self.frame.set_body(self.thePile)
|
||||||
|
self.diag = None
|
||||||
|
self.frame.set_footer(urwid.Pile([self.primaryCols,self.footer2]))
|
||||||
|
self.update_ui()
|
||||||
# Redraw the screen
|
# Redraw the screen
|
||||||
@wrap_exceptions()
|
@wrap_exceptions()
|
||||||
def update_ui(self):
|
def update_ui(self):
|
||||||
@@ -801,6 +827,7 @@ class appGUI():
|
|||||||
ui.draw_screen((self.size),canvas)
|
ui.draw_screen((self.size),canvas)
|
||||||
keys = ui.get_input()
|
keys = ui.get_input()
|
||||||
|
|
||||||
|
if not self.diag:
|
||||||
# Handle keystrokes
|
# Handle keystrokes
|
||||||
if "f8" in keys or 'Q' in keys or 'q' in keys:
|
if "f8" in keys or 'Q' in keys or 'q' in keys:
|
||||||
loop.quit()
|
loop.quit()
|
||||||
@@ -812,8 +839,20 @@ class appGUI():
|
|||||||
# Disconnect from all networks.
|
# Disconnect from all networks.
|
||||||
daemon.Disconnect()
|
daemon.Disconnect()
|
||||||
self.update_netlist()
|
self.update_netlist()
|
||||||
# Guess what! I actually need to put this here, else I'll have tons of
|
if 'right' in keys:
|
||||||
# references to self.frame lying around. ^_^
|
focus = self.thePile.get_focus()
|
||||||
|
self.frame.set_footer(urwid.Pile([self.confCols,self.footer2]))
|
||||||
|
if focus == self.wiredCB:
|
||||||
|
self.diag = WiredSettingsDialog(self.wiredCB.get_body().get_selected_profile())
|
||||||
|
self.frame.set_body(self.diag)
|
||||||
|
else:
|
||||||
|
# wireless list only other option
|
||||||
|
wid,pos = self.thePile.get_focus().get_focus()
|
||||||
|
self.diag = WirelessSettingsDialog(pos)
|
||||||
|
self.diag.ready_widgets(ui,self.frame)
|
||||||
|
self.frame.set_body(self.diag)
|
||||||
|
# Guess what! I actually need to put this here, else I'll have
|
||||||
|
# tons of references to self.frame lying around. ^_^
|
||||||
if "enter" in keys:
|
if "enter" in keys:
|
||||||
focus = self.frame.body.get_focus()
|
focus = self.frame.body.get_focus()
|
||||||
if focus == self.wiredCB:
|
if focus == self.wiredCB:
|
||||||
@@ -835,9 +874,10 @@ class appGUI():
|
|||||||
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):
|
if self.pref.run(ui,self.size,self.frame):
|
||||||
self.pref.save_results()
|
self.pref.save_settings()
|
||||||
self.update_ui()
|
self.update_ui()
|
||||||
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:
|
||||||
focus = self.thePile.get_focus()
|
focus = self.thePile.get_focus()
|
||||||
@@ -882,7 +922,13 @@ class appGUI():
|
|||||||
if k == "window resize":
|
if k == "window resize":
|
||||||
self.size = ui.get_cols_rows()
|
self.size = ui.get_cols_rows()
|
||||||
continue
|
continue
|
||||||
self.frame.keypress( self.size, k )
|
k = self.frame.keypress( self.size, k )
|
||||||
|
if self.diag:
|
||||||
|
if k == 'esc':
|
||||||
|
self.restore_primary()
|
||||||
|
if k == 'left' or k == 'meta enter':
|
||||||
|
self.diag.save_settings()
|
||||||
|
self.restore_primary()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def connect(self, nettype, networkid, networkentry=None):
|
def connect(self, nettype, networkid, networkentry=None):
|
||||||
|
|||||||
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-r286'
|
CURSES_REVNO = 'uimod-r287'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists('vcsinfo.py'):
|
if not os.path.exists('vcsinfo.py'):
|
||||||
|
|||||||
Reference in New Issue
Block a user