mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
curses/curses_misc.py:
Modified TextDialog to use a listbox as opposed to one long text box Aligned the header on the right in Dialog2 by default curses/wicd-curses.py: Removed the traceback if the user presses ctrl+c Refactored about_dialog to support the modified TextDialog Added a help dialog. Raise it with "H" Refactored some code in the appGUI constructor so that I can recycle update_netlist() curses/TODO, curses/README, in/man=wicd-curses.8.in: Help dialog now active in/man=wicd-curses.8.in: Removed redundant scipt selector command
This commit is contained in:
@@ -25,7 +25,8 @@ P : Display preferences dialog
|
||||
C : Display network configuration for selected network (only works for
|
||||
wireless at the moment)
|
||||
A : Display "About" dialog
|
||||
I : Raise up the "Scan for hidden networks" dialog
|
||||
I : Raise the "Scan for hidden networks" dialog
|
||||
H : Raise help dialog
|
||||
|
||||
IN DIALOGS (Meta usually is "Alt"):
|
||||
ESC or Q: Quit dialog without saving information (if present)
|
||||
|
||||
@@ -5,5 +5,4 @@ Things to do (in no particular order):
|
||||
* Make keystrokes customizable
|
||||
* Make color schemes customizable
|
||||
* Implement a "make an ad-hoc network" dialog
|
||||
* Implement a "help" dialog
|
||||
* Perform a mass code cleanup
|
||||
|
||||
@@ -370,7 +370,7 @@ class Dialog2(urwid.WidgetWrap):
|
||||
|
||||
self.frame = urwid.Frame( body, focus_part='footer')
|
||||
if text is not None:
|
||||
self.frame.header = urwid.Pile( [urwid.Text(text),
|
||||
self.frame.header = urwid.Pile( [urwid.Text(text,align='right'),
|
||||
urwid.Divider()] )
|
||||
w = self.frame
|
||||
self.view = w
|
||||
@@ -428,13 +428,12 @@ class Dialog2(urwid.WidgetWrap):
|
||||
def unhandled_key(self, size, key):
|
||||
pass
|
||||
|
||||
# Simple dialog with text in it and "OK"
|
||||
class TextDialog(Dialog2):
|
||||
def __init__(self, text, height, width, header=None):
|
||||
def __init__(self, text, height, width, header=None,align='left'):
|
||||
l = []
|
||||
# read the whole file (being slow, not lazy this time)
|
||||
#for line in open(file).readlines():
|
||||
# l.append( urwid.Text( line.rstrip() ))
|
||||
l = [urwid.Text(text)]
|
||||
for line in text:
|
||||
l.append( urwid.Text( line,align=align))
|
||||
body = urwid.ListBox(l)
|
||||
body = urwid.AttrWrap(body, 'body')
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class wrap_exceptions:
|
||||
loop.quit()
|
||||
ui.stop()
|
||||
print "\nTerminated by user."
|
||||
raise
|
||||
#raise
|
||||
except DBusException:
|
||||
gobject.source_remove(redraw_tag)
|
||||
# Quit the loop
|
||||
@@ -211,23 +211,39 @@ def about_dialog(body):
|
||||
# The ASCII Art "Wicd" was made from the "smslant" font on one of those
|
||||
# online ASCII big text generators.
|
||||
theText = [
|
||||
('green'," /// \\\\\\")," _ ___ __\n",
|
||||
('green'," /// \\\\\\")," | | /| / (_)______/ /\n",
|
||||
('green'," /// \\\\\\")," | |/ |/ / / __/ _ / \n",
|
||||
('green',"/|| // \\\\ ||\\")," |__/|__/_/\__/\_,_/ \n",
|
||||
('green',"||| ||"),"(|^|)",('green',"|| |||"),
|
||||
" ($VERSION) \n".replace("$VERSION",daemon.Hello()),
|
||||
[('green'," /// \\\\\\")," _ ___ __"],
|
||||
[('green'," /// \\\\\\")," | | /| / (_)______/ /"],
|
||||
[('green'," /// \\\\\\")," | |/ |/ / / __/ _ / "],
|
||||
[('green',"/|| // \\\\ ||\\")," |__/|__/_/\__/\_,_/ "],
|
||||
[('green',"||| ||"),"(|^|)",('green',"|| |||"),
|
||||
" ($VERSION) ".replace("$VERSION",daemon.Hello())],
|
||||
|
||||
('green',"\\|| \\\\")," |+| ",('green',"// ||/ \n"),
|
||||
('green'," \\\\\\")," |+| ",('green',"///")," http://wicd.net \n",
|
||||
('green'," \\\\\\")," |+| ",('green',"///")," Brought to you by:\n",
|
||||
('green'," \\\\\\")," |+| ",('green',"///")," Adam Blackburn (wicd)\n",
|
||||
" ___|+|___ Dan O'Reilly (wicd)\n",
|
||||
" |---------| Andrew Psaltis (this ui)\n",
|
||||
"---------------------------------------------------"]
|
||||
about = TextDialog(theText,55,14)
|
||||
[('green',"\\|| \\\\")," |+| ",('green',"// ||/ ")],
|
||||
[('green'," \\\\\\")," |+| ",('green',"///")," http://wicd.net"],
|
||||
[('green'," \\\\\\")," |+| ",('green',"///")," Brought to you by:"],
|
||||
[('green'," \\\\\\")," |+| ",('green',"///")," Adam Blackburn (wicd)"],
|
||||
" ___|+|___ Dan O'Reilly (wicd)",
|
||||
" |---------| Andrew Psaltis (this ui)",
|
||||
"-----------------------------------------------------"]
|
||||
about = TextDialog(theText,16,55,header=('header','About Wicd'))
|
||||
about.run(ui,body)
|
||||
|
||||
def help_dialog(body):
|
||||
theText = [
|
||||
"For more detailed help, consult the wicd-curses(8) man page.",
|
||||
"", "All controls are case sensitive",
|
||||
[('bold','H')," Display this help dialog"],
|
||||
[('bold','enter')," Connect to selected network"],
|
||||
[('bold','D')," Disconnect from all networks"],
|
||||
[('bold','ESC')," Stop a network connection in progress"],
|
||||
[('bold','F5')," or ", ('bold','R')," Refresh network list"],
|
||||
[('bold','P')," Prefrences dialog"],
|
||||
[('bold','I')," Scan for hidden networks"],
|
||||
[('bold','S')," Select scripts"]
|
||||
]
|
||||
help = TextDialog(theText,15,62,header=('header',"Wicd-Curses Help"))
|
||||
help.run(ui,body)
|
||||
|
||||
########################################
|
||||
##### URWID SUPPORT CLASSES
|
||||
########################################
|
||||
@@ -335,6 +351,8 @@ class appGUI():
|
||||
self.screen_locker = urwid.Filler(urwid.Text(('important',"Scanning networks... stand by..."), align='center'))
|
||||
self.no_wlan = urwid.Filler(urwid.Text(('important',"No wireless networks found."), align='center'))
|
||||
self.TITLE = 'Wicd Curses Interface'
|
||||
self.WIRED_IDX = 1
|
||||
self.WLESS_IDX = 3
|
||||
|
||||
#wrap1 = urwid.AttrWrap(txt, 'black')
|
||||
#fill = urwid.Filler(txt)
|
||||
@@ -345,9 +363,16 @@ class appGUI():
|
||||
|
||||
#if wireless.GetNumberOfNetworks() == 0:
|
||||
# wireless.Scan()
|
||||
wiredL,wlessL = gen_network_list()
|
||||
self.focusloc = (1,0)
|
||||
|
||||
# These are empty to make sure that things go my way.
|
||||
wiredL,wlessL = [],[]# = gen_network_list()
|
||||
self.frame = None
|
||||
|
||||
self.wiredCB = urwid.Filler(ComboBox(list=wiredL,use_enter=False))
|
||||
self.wlessLB = urwid.ListBox(wlessL)
|
||||
self.update_netlist(force_check=True,firstrun=True)
|
||||
|
||||
# Stuff I used to simulate large lists
|
||||
#spam = SelText('spam')
|
||||
#spamL = [ urwid.AttrWrap( w, None, 'focus' ) for w in [spam,spam,spam,
|
||||
@@ -357,15 +382,6 @@ class appGUI():
|
||||
# spam,spam,spam,spam] ]
|
||||
#self.spamLB = urwid.ListBox(spamL)
|
||||
|
||||
# Choose whether to show the wired part of the interface, if a cable
|
||||
# is plugged in, or the
|
||||
if daemon.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
|
||||
self.thePile = urwid.Pile([('fixed',1,self.wiredH),
|
||||
('fixed',1,self.wiredCB),
|
||||
('fixed',1,self.wlessH),
|
||||
self.wlessLB] )
|
||||
else:
|
||||
self.thePile = urwid.Pile([('fixed',1,self.wlessH),self.wlessLB] )
|
||||
self.footer1 = urwid.AttrWrap(urwid.Text("Something important will eventually go here."),'body')
|
||||
self.footer2 = urwid.AttrWrap(urwid.Text("If you are seeing this, then something has gone wrong!"),'important')
|
||||
self.footerList = urwid.ListBox([self.footer1,self.footer2])
|
||||
@@ -384,7 +400,6 @@ class appGUI():
|
||||
self.screen_locked = False
|
||||
#self.always_show_wired = daemon.GetAlwaysShowWiredInterface()
|
||||
|
||||
self.focusloc = (1,0)
|
||||
|
||||
self.pref = None
|
||||
|
||||
@@ -400,8 +415,6 @@ class appGUI():
|
||||
def unlock_screen(self):
|
||||
self.frame.set_body(self.thePile)
|
||||
self.screen_locked = False
|
||||
# I'm hoping that this will get rid of Adam's problem with the ListBox not
|
||||
# redisplaying itself immediately upon completion.
|
||||
self.update_netlist(force_check=True)
|
||||
self.update_ui()
|
||||
|
||||
@@ -420,9 +433,9 @@ class appGUI():
|
||||
# This might need to be cleaned up later.
|
||||
|
||||
if self.thePile.get_focus() is self.wiredCB:
|
||||
wlessorwired = 1
|
||||
wlessorwired = self.WIRED_IDX
|
||||
else :
|
||||
wlessorwired = 3
|
||||
wlessorwired = self.WLESS_IDX
|
||||
if self.thePile.get_focus() == self.no_wlan:
|
||||
where = 0
|
||||
elif self.thePile.get_focus() == self.wiredCB:
|
||||
@@ -436,21 +449,24 @@ class appGUI():
|
||||
# Update the list of networks. Usually called by DBus.
|
||||
# TODO: Preserve current focus when updating the list.
|
||||
@wrap_exceptions()
|
||||
def update_netlist(self,state=None, x=None, force_check=False):
|
||||
def update_netlist(self,state=None, x=None, force_check=False,firstrun=False):
|
||||
if not firstrun:
|
||||
self.update_focusloc()
|
||||
""" Updates the overall network list."""
|
||||
if not state:
|
||||
state, x = daemon.GetConnectionStatus()
|
||||
if self.prev_state != state or force_check:
|
||||
if force_check or self.prev_state != state:
|
||||
wiredL,wlessL = gen_network_list()
|
||||
#self.wiredCB = urwid.Filler(ComboBox(wiredL,self.frame,ui,3,
|
||||
# use_enter=False))
|
||||
self.wiredCB.get_body().set_list(wiredL)
|
||||
self.wiredCB.get_body().build_combobox(self.frame,ui,3)
|
||||
if len(wlessL) != 0:
|
||||
self.wlessLB.body = urwid.SimpleListWalker(wlessL)
|
||||
self.wlessLB = urwid.ListBox(wlessL)
|
||||
#self.wlessLB.body = urwid.SimpleListWalker(wlessL)
|
||||
else:
|
||||
self.wlessLB.body = urwid.SimpleListWalker([self.no_wlan])
|
||||
self.wlessLB = self.no_wlan
|
||||
#self.wlessLB.body = urwid.SimpleListWalker([self.no_wlan])
|
||||
if daemon.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
|
||||
#if daemon.GetAlwaysShowWiredInterface():
|
||||
self.thePile = urwid.Pile([('fixed',1,self.wiredH),
|
||||
@@ -460,7 +476,7 @@ class appGUI():
|
||||
#self.focusloc = (self.thePile.get_focus(),
|
||||
# self.thePile.get_focus().get_focus()[1])
|
||||
self.thePile.set_focus(self.focusloc[0])
|
||||
if self.focusloc[0] == 1:
|
||||
if self.focusloc[0] == self.WIRED_IDX:
|
||||
self.thePile.get_focus().get_body().set_focus(self.focusloc[1])
|
||||
else:
|
||||
self.thePile.get_focus().set_focus(self.focusloc[1])
|
||||
@@ -631,7 +647,8 @@ class appGUI():
|
||||
#self.netentry.run(ui,self.size,self.frame)
|
||||
if "I" in keys:
|
||||
self.raise_hidden_network_dialog()
|
||||
|
||||
if "H" in keys:
|
||||
help_dialog(self.frame)
|
||||
for k in keys:
|
||||
if urwid.is_mouse_event(k):
|
||||
event, button, col, row = k
|
||||
@@ -700,7 +717,8 @@ def main():
|
||||
# Simple colors around text
|
||||
('green','dark green','default'),
|
||||
('blue','dark blue','default'),
|
||||
('red','dark red','default')])
|
||||
('red','dark red','default'),
|
||||
('bold','default','default','bold')])
|
||||
# This is a wrapper around a function that calls another a function that is a
|
||||
# wrapper around a infinite loop. Fun.
|
||||
ui.run_wrapper(run)
|
||||
|
||||
@@ -36,6 +36,9 @@ Bring up the preferences controller
|
||||
.TP
|
||||
.BR I
|
||||
Bring up hidden network scanning dialog
|
||||
.TP
|
||||
.BR H
|
||||
Bring up a rather simplistic help dialog. Of course, it mentions this man page first. :-)
|
||||
.PP
|
||||
The following is a work in progress and might not be fully functional as of yet.
|
||||
.TP
|
||||
@@ -46,12 +49,6 @@ The following are not implemented yet:
|
||||
.TP
|
||||
.BR S
|
||||
Bring up the script selector for the selected network (requires superuser privileges)
|
||||
.TP
|
||||
.BR R
|
||||
Bring up script selector "dialog."
|
||||
.TP
|
||||
.BR H
|
||||
Bring up a rather simplistic help dialog. Of course, it mentions this man page first. :-)
|
||||
.SH "FILES"
|
||||
These are not used yet.
|
||||
.TP
|
||||
|
||||
Reference in New Issue
Block a user