mirror of
https://github.com/gryf/wicd.git
synced 2025-12-21 05:18:02 +01:00
Added mouse support to OptCols. Everything works :-).
This branch will be merged into experimental-nacl once I'm sure that everything works, and I update the documentation.
This commit is contained in:
@@ -530,14 +530,15 @@ class ClickCols(urwid.WidgetWrap):
|
|||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.args = args
|
self.args = args
|
||||||
def mouse_event(self,size,event,button,x,y,focus):
|
def mouse_event(self,size,event,button,x,y,focus):
|
||||||
|
if event == "mouse press":
|
||||||
self.callback(self.args)
|
self.callback(self.args)
|
||||||
|
|
||||||
# htop-style menu menu-bar on the bottom of the screen
|
# htop-style menu menu-bar on the bottom of the screen
|
||||||
class OptCols(urwid.WidgetWrap):
|
class OptCols(urwid.WidgetWrap):
|
||||||
# tuples = [(key,desc,on_event)], on_event currently ignored
|
# tuples = [(key,desc)], on_event gets passed a key
|
||||||
# attrs = (attr_key,attr_desc)
|
# attrs = (attr_key,attr_desc)
|
||||||
# mentions of 'left' and right will be converted to <- and -> respectively
|
# mentions of 'left' and right will be converted to <- and -> respectively
|
||||||
def __init__(self,tuples,attrs=('body','infobar'),debug=False):
|
def __init__(self,tuples,handler,attrs=('body','infobar'),debug=False):
|
||||||
# Find the longest string. Keys for this bar should be no greater than
|
# Find the longest string. Keys for this bar should be no greater than
|
||||||
# 2 characters long (e.g., -> for left)
|
# 2 characters long (e.g., -> for left)
|
||||||
#maxlen = 6
|
#maxlen = 6
|
||||||
@@ -564,6 +565,8 @@ class OptCols(urwid.WidgetWrap):
|
|||||||
key += '<-'
|
key += '<-'
|
||||||
elif part == 'right':
|
elif part == 'right':
|
||||||
key += '->'
|
key += '->'
|
||||||
|
elif part == 'esc':
|
||||||
|
key += 'ESC'
|
||||||
else:
|
else:
|
||||||
key += part
|
key += part
|
||||||
|
|
||||||
@@ -571,6 +574,9 @@ class OptCols(urwid.WidgetWrap):
|
|||||||
if debug:
|
if debug:
|
||||||
callback = self.debugClick
|
callback = self.debugClick
|
||||||
args = cmd[1]
|
args = cmd[1]
|
||||||
|
else:
|
||||||
|
callback = handler
|
||||||
|
args = cmd[0]
|
||||||
#self.callbacks.append(cmd[2])
|
#self.callbacks.append(cmd[2])
|
||||||
col = ClickCols([
|
col = ClickCols([
|
||||||
('fixed',len(key)+1,urwid.Text((attrs[0],key+':')) ),
|
('fixed',len(key)+1,urwid.Text((attrs[0],key+':')) ),
|
||||||
|
|||||||
@@ -163,24 +163,6 @@ def check_for_wireless(iwconfig, wireless_ip, set_status):
|
|||||||
# DBUS interfaces do. ^_^
|
# DBUS interfaces do. ^_^
|
||||||
# Whatever calls this must be exception-wrapped if it is run if the UI is up
|
# Whatever calls this must be exception-wrapped if it is run if the UI is up
|
||||||
def gen_network_list():
|
def gen_network_list():
|
||||||
#id=0
|
|
||||||
#wiredL = []
|
|
||||||
#is_active = wireless.GetWirelessIP('') == None and wired.GetWiredIP('') != None
|
|
||||||
# This one makes a list of strings to put in a combo box.
|
|
||||||
#for profile in wired.GetWiredProfileList():
|
|
||||||
#theString = '%4s %25s' % (id, profile)
|
|
||||||
#### THIS IS wired.blah() in experimental
|
|
||||||
#print config.GetLastUsedWiredNetwork()
|
|
||||||
# Tag if no wireless IP present, and wired one is
|
|
||||||
#if is_active:
|
|
||||||
# theString = '>'+theString[1:]
|
|
||||||
|
|
||||||
#wiredL.append(urwid.AttrWrap(SelText(theString),'connected',
|
|
||||||
# 'connected focus'))
|
|
||||||
#else:
|
|
||||||
#wiredL.append(urwid.AttrWrap(SelText(theString),'body','focus'))
|
|
||||||
#wiredL.append(theString)
|
|
||||||
#id+=1
|
|
||||||
wiredL = wired.GetWiredProfileList()
|
wiredL = wired.GetWiredProfileList()
|
||||||
wlessL = []
|
wlessL = []
|
||||||
# This one makes a list of NetLabels
|
# This one makes a list of NetLabels
|
||||||
@@ -239,6 +221,9 @@ def help_dialog(body):
|
|||||||
('bold',' Q'),": Quit wicd-curses\n",
|
('bold',' Q'),": Quit wicd-curses\n",
|
||||||
])
|
])
|
||||||
textF = urwid.Text('Press any key to return.')
|
textF = urwid.Text('Press any key to return.')
|
||||||
|
|
||||||
|
# textJ = urwid.Text('Nobody expects the Spanish Inquisition!')
|
||||||
|
|
||||||
blank = urwid.Text('')
|
blank = urwid.Text('')
|
||||||
# Pile containing a text and columns?
|
# Pile containing a text and columns?
|
||||||
cols = urwid.Columns([text1,text2])
|
cols = urwid.Columns([text1,text2])
|
||||||
@@ -250,6 +235,14 @@ def help_dialog(body):
|
|||||||
ui.draw_screen(dim, frame.render(dim, True))
|
ui.draw_screen(dim, frame.render(dim, True))
|
||||||
|
|
||||||
keys = ui.get_input()
|
keys = ui.get_input()
|
||||||
|
# Don't stop because someone let go of the mouse on the frame
|
||||||
|
mouse_release = False
|
||||||
|
for k in keys:
|
||||||
|
if urwid.is_mouse_event(k) and k[0] == "mouse release":
|
||||||
|
mouse_release = True
|
||||||
|
break
|
||||||
|
if mouse_release :
|
||||||
|
continue
|
||||||
if 'window resize' in keys:
|
if 'window resize' in keys:
|
||||||
dim = ui.get_cols_rows()
|
dim = ui.get_cols_rows()
|
||||||
elif keys:
|
elif keys:
|
||||||
@@ -306,10 +299,6 @@ Once there, you can adjust (or add) the "beforescript", "afterscript", and "disc
|
|||||||
main()
|
main()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
########################################
|
|
||||||
##### URWID SUPPORT CLASSES
|
|
||||||
########################################
|
|
||||||
|
|
||||||
def gen_list_header():
|
def gen_list_header():
|
||||||
if daemon.GetSignalDisplayType() == 0:
|
if daemon.GetSignalDisplayType() == 0:
|
||||||
# Allocate 25 cols for the ESSID name
|
# Allocate 25 cols for the ESSID name
|
||||||
@@ -319,6 +308,10 @@ def gen_list_header():
|
|||||||
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')
|
||||||
|
|
||||||
|
########################################
|
||||||
|
##### URWID SUPPORT CLASSES
|
||||||
|
########################################
|
||||||
|
|
||||||
# Wireless network label
|
# Wireless network label
|
||||||
class NetLabel(urwid.WidgetWrap):
|
class NetLabel(urwid.WidgetWrap):
|
||||||
def __init__(self, id, is_active):
|
def __init__(self, id, is_active):
|
||||||
@@ -566,7 +559,7 @@ class appGUI():
|
|||||||
('Q' ,'Quit',loop.quit)
|
('Q' ,'Quit',loop.quit)
|
||||||
]
|
]
|
||||||
|
|
||||||
self.primaryCols = OptCols(keys,debug=True)
|
self.primaryCols = OptCols(keys,self.handle_keys)
|
||||||
#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')
|
||||||
@@ -598,13 +591,14 @@ class appGUI():
|
|||||||
def init_other_optcols(self):
|
def init_other_optcols(self):
|
||||||
# The "tabbed" preferences dialog
|
# The "tabbed" preferences dialog
|
||||||
self.prefCols = OptCols( [('meta enter','OK'),
|
self.prefCols = OptCols( [('meta enter','OK'),
|
||||||
('ESC','Cancel'),
|
('esc','Cancel'),
|
||||||
('meta [','Tab Left',),
|
('meta [','Tab Left',),
|
||||||
('meta ]','Tab Right')],debug=True )
|
('meta ]','Tab Right')],self.handle_keys
|
||||||
|
)
|
||||||
self.confCols = OptCols( [
|
self.confCols = OptCols( [
|
||||||
('<-','OK'),
|
('left','OK'),
|
||||||
('ESC','Cancel')
|
('esc','Cancel')
|
||||||
],debug=True )
|
],self.handle_keys)
|
||||||
|
|
||||||
# Does what it says it does
|
# Does what it says it does
|
||||||
def lock_screen(self):
|
def lock_screen(self):
|
||||||
@@ -808,20 +802,8 @@ class appGUI():
|
|||||||
self.diag = None
|
self.diag = None
|
||||||
self.frame.set_footer(urwid.Pile([self.primaryCols,self.footer2]))
|
self.frame.set_footer(urwid.Pile([self.primaryCols,self.footer2]))
|
||||||
self.update_ui()
|
self.update_ui()
|
||||||
# Redraw the screen
|
|
||||||
@wrap_exceptions()
|
|
||||||
def update_ui(self):
|
|
||||||
#self.update_status()
|
|
||||||
canvas = self.frame.render( (self.size),True )
|
|
||||||
### GRRRRRRRRRRRRRRRRRRRRR ->^^^^
|
|
||||||
# It looks like if I want to get the statusbar to update itself
|
|
||||||
# continuously, I would have to use overlay the canvasses and redirect
|
|
||||||
# the input. I'll try to get that working at a later time, if people
|
|
||||||
# want that "feature".
|
|
||||||
#canvaso = urwid.CanvasOverlay(self.dialog.render( (80,20),True),canvas,0,1)
|
|
||||||
ui.draw_screen((self.size),canvas)
|
|
||||||
keys = ui.get_input()
|
|
||||||
|
|
||||||
|
def handle_keys(self,keys):
|
||||||
if not self.diag:
|
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:
|
||||||
@@ -890,6 +872,9 @@ class appGUI():
|
|||||||
if "I" in keys:
|
if "I" in keys:
|
||||||
self.raise_hidden_network_dialog()
|
self.raise_hidden_network_dialog()
|
||||||
if "H" in keys or 'h' in keys or '?' in keys:
|
if "H" in keys or 'h' in keys or '?' in keys:
|
||||||
|
# FIXME I shouldn't need this, OptCols messes up this one
|
||||||
|
# particular button
|
||||||
|
if not self.diag:
|
||||||
help_dialog(self.frame)
|
help_dialog(self.frame)
|
||||||
if "S" in keys:
|
if "S" in keys:
|
||||||
focus = self.thePile.get_focus()
|
focus = self.thePile.get_focus()
|
||||||
@@ -910,22 +895,38 @@ class appGUI():
|
|||||||
data[5],
|
data[5],
|
||||||
data[4], False)
|
data[4], False)
|
||||||
|
|
||||||
|
if self.diag:
|
||||||
|
if 'esc' in keys:
|
||||||
|
self.restore_primary()
|
||||||
|
if ('left' in keys and issubclass(self.diag.__class__,AdvancedSettingsDialog)) or 'meta enter' in keys:
|
||||||
|
self.diag.save_settings()
|
||||||
|
self.restore_primary()
|
||||||
for k in keys:
|
for k in keys:
|
||||||
if urwid.is_mouse_event(k):
|
if urwid.is_mouse_event(k):
|
||||||
event, button, col, row = k
|
event, button, col, row = k
|
||||||
self.frame.mouse_event( self.size,
|
self.frame.mouse_event( self.size,
|
||||||
event, button, col, row,
|
event, button, col, row,
|
||||||
focus=True)
|
focus=True)
|
||||||
|
continue
|
||||||
if k == "window resize":
|
if k == "window resize":
|
||||||
self.size = ui.get_cols_rows()
|
self.size = ui.get_cols_rows()
|
||||||
continue
|
continue
|
||||||
k = self.frame.keypress( self.size, k )
|
|
||||||
if self.diag:
|
# Redraw the screen
|
||||||
if k == 'esc':
|
@wrap_exceptions()
|
||||||
self.restore_primary()
|
def update_ui(self):
|
||||||
if (k == 'left' and issubclass(self.diag.__class__,AdvancedSettingsDialog)) or k == 'meta enter':
|
#self.update_status()
|
||||||
self.diag.save_settings()
|
canvas = self.frame.render( (self.size),True )
|
||||||
self.restore_primary()
|
### GRRRRRRRRRRRRRRRRRRRRR ->^^^^
|
||||||
|
# It looks like if I want to get the statusbar to update itself
|
||||||
|
# continuously, I would have to use overlay the canvasses and redirect
|
||||||
|
# the input. I'll try to get that working at a later time, if people
|
||||||
|
# want that "feature".
|
||||||
|
#canvaso = urwid.CanvasOverlay(self.dialog.render( (80,20),True),canvas,0,1)
|
||||||
|
ui.draw_screen((self.size),canvas)
|
||||||
|
keys = ui.get_input()
|
||||||
|
self.handle_keys(keys)
|
||||||
|
|
||||||
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-r288'
|
CURSES_REVNO = 'uimod-r289'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists('vcsinfo.py'):
|
if not os.path.exists('vcsinfo.py'):
|
||||||
|
|||||||
Reference in New Issue
Block a user