1
0
mirror of https://github.com/gryf/wicd.git synced 2026-02-20 17:05:46 +01:00

Merged in curses-uimod changes from experimental-nacl.

This commit is contained in:
Andrew Psaltis
2009-03-24 12:30:25 -04:00
7 changed files with 451 additions and 348 deletions

View File

@@ -14,15 +14,15 @@ All features that I plan on implementing (that are not mentioned above) are
listed the TODO file in this same directory. If you want any other features, listed the TODO file in this same directory. If you want any other features,
ask me. I try to be on the #wicd Freenode IRC channel most of the time. ask me. I try to be on the #wicd Freenode IRC channel most of the time.
Controls: Controls (most of these should be viewable in wicd-curses itself):
F5 : refresh wireless networks F5 : refresh wireless networks
F8 or Q or q: quit F8 Q q : quit
D : disconnect from all active networks D : disconnect from all active networks
ESC : if connecting to a network, stop doing so ESC : if connecting to a network, stop doing so
ENTER : Attempt connection to selected network ENTER C : Attempt connection to selected network
P : Display preferences dialog P : Display preferences dialog
C : Display network configuration for selected network right arrow : Display network configuration for selected network
A : Display "About" dialog A : Display "About" dialog
I : Raise the "Scan for hidden networks" dialog I : Raise the "Scan for hidden networks" dialog
H or h or ? : Raise help dialog H or h or ? : Raise help dialog
@@ -33,7 +33,7 @@ O : Raise ad-hoc network dialog
IN DIALOGS (Meta usually is "Alt"): IN DIALOGS (Meta usually is "Alt"):
ESC or Q: Quit dialog without saving information (if present) ESC or Q: Quit dialog without saving information (if present)
Meta+Left/Right: Change tabs Left/Right (if tabs present) Meta+[/]: Change tabs Left/Right (if tabs present)
Meta+Enter : Quit dialog and save information Meta+Enter : Quit dialog and save information
FAQ (WIP): FAQ (WIP):

View File

@@ -49,7 +49,12 @@ class SelText(urwid.Text):
"""Don't handle any keys.""" """Don't handle any keys."""
return key return key
# This class is annoying. ^_^ # ListBox that can't be selected.
class NSelListBox(urwid.ListBox):
def selectable(self):
return False
# This class is annoying. :/
class DynWrap(urwid.AttrWrap): class DynWrap(urwid.AttrWrap):
""" """
Makes an object have mutable selectivity. Attributes will change like Makes an object have mutable selectivity. Attributes will change like
@@ -136,7 +141,8 @@ class MaskingEdit(urwid.Edit):
Render edit widget and return canvas. Include cursor when in Render edit widget and return canvas. Include cursor when in
focus. focus.
""" """
# If we aren't masking anything ATM, then act like an Edit. No problems. # If we aren't masking anything ATM, then act like an Edit.
# No problems.
if self.mask_mode == "off" or (self.mask_mode == 'no_focus' and focus == True): if self.mask_mode == "off" or (self.mask_mode == 'no_focus' and focus == True):
canv = self.__super.render((maxcol,),focus) canv = self.__super.render((maxcol,),focus)
# The cache messes this thing up, because I am totally changing what # The cache messes this thing up, because I am totally changing what
@@ -165,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:
@@ -189,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)
@@ -199,12 +206,13 @@ class TabColumns(urwid.WidgetWrap):
return True return True
def keypress(self,size,key): def keypress(self,size,key):
self._w.keypress(size,key) if key == "meta [" or key == "meta ]":
if key == "meta left" or key == "meta right":
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:
key = self._w.keypress(size,key)
wid = self.pile.get_focus().get_body() wid = self.pile.get_focus().get_body()
if wid == self.columns: if wid == self.columns:
# lw = self.listbox.body # lw = self.listbox.body
@@ -213,8 +221,20 @@ 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
def mouse_event(self,size,event,button,x,y,focus):
wid = self.pile.get_focus().get_body()
if wid == self.columns:
self.active_tab.set_attr('body')
self._w.mouse_event(size,event,button,x,y,focus)
if wid == self.columns:
self.active_tab.set_attr('body')
self.columns.get_focus().set_attr('tab active')
self.active_tab = self.columns.get_focus()
self.gen_pile(self.tab_map[self.active_tab])
### Combo box code begins here ### Combo box code begins here
@@ -340,7 +360,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 != '':
@@ -438,7 +457,8 @@ class Dialog2(urwid.WidgetWrap):
def run(self,ui,parent): def run(self,ui,parent):
ui.set_mouse_tracking() ui.set_mouse_tracking()
size = ui.get_cols_rows() size = ui.get_cols_rows()
overlay = urwid.Overlay(urwid.LineBox(self.view), parent, 'center', self.width, overlay = urwid.Overlay(urwid.LineBox(self.view),
parent, 'center', self.width,
'middle', self.height) 'middle', self.height)
try: try:
while True: while True:
@@ -512,3 +532,98 @@ class InputDialog(Dialog2):
def on_exit(self, exitcode): def on_exit(self, exitcode):
return exitcode, self.edit.get_edit_text() return exitcode, self.edit.get_edit_text()
class ClickCols(urwid.WidgetWrap):
def __init__(self,items,callback=None,args=None):
cols = urwid.Columns(items)
self.__super.__init__(cols)
self.callback = callback
self.args = args
def mouse_event(self,size,event,button,x,y,focus):
if event == "mouse press":
# The keypress dealie in wicd-curses.py expects a list of keystrokes
self.callback([self.args])
# htop-style menu menu-bar on the bottom of the screen
class OptCols(urwid.WidgetWrap):
# tuples = [(key,desc)], on_event gets passed a key
# attrs = (attr_key,attr_desc)
# mentions of 'left' and right will be converted to <- and -> respectively
def __init__(self,tuples,handler,attrs=('body','infobar'),debug=False):
# Find the longest string. Keys for this bar should be no greater than
# 2 characters long (e.g., -> for left)
#maxlen = 6
#for i in tuples:
# newmax = len(i[0])+len(i[1])
# if newmax > maxlen:
# maxlen = newmax
# Construct the texts
textList = []
i = 0
# callbacks map the text contents to its assigned callback.
self.callbacks = []
for cmd in tuples:
splitcmd = cmd[0].split()
key = ''
for part in splitcmd:
if part == 'ctrl':
key+='C^'
elif part == 'meta':
key+='M^'
else:
if part == 'left':
key += '<-'
elif part == 'right':
key += '->'
elif part == 'esc':
key += 'ESC'
else:
key += part
#theText = urwid.Text([(attrs[0],cmd[0]),(attrs[1],cmd[1])])
if debug:
callback = self.debugClick
args = cmd[1]
else:
callback = handler
args = cmd[0]
#self.callbacks.append(cmd[2])
col = ClickCols([
('fixed',len(key)+1,urwid.Text((attrs[0],key+':')) ),
urwid.AttrWrap(urwid.Text(cmd[1]),attrs[1])],
callback,args)
#if i != len(tuples)-1:
# textList.append(('fixed',maxlen,col))
#else: # The last one
textList.append(col)
i+=1
if debug:
self.debug = urwid.Text("DEBUG_MODE")
textList.append(('fixed',10,self.debug))
cols = urwid.Columns(textList)
self.__super.__init__(cols)
def debugClick(self,args):
self.debug.set_text(args)
def mouse_event(self,size,event,button,x,y,focus):
# Widgets are evenly long (as of current), so...
return self._w.mouse_event(size,event,button,x,y,focus)
"""
if self.debug:
if x > size[0]-10:
return
widsize = (size[0]-10)/len(self.callbacks)
else:
widsize = size[0]/len(self.callbacks)
widnum = x/widsize
if self.debug:
text = str(widnum)
if self.callbacks[widnum] == None:
text += " None"
self.debug.set_text(text)
elif self.callbacks[widnum] != None:
self.callbacks[widnum]()
"""

View File

@@ -82,13 +82,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,
@@ -103,16 +96,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)
@@ -164,54 +150,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):
@@ -438,6 +379,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()

View File

@@ -68,8 +68,8 @@ class PrefsDialog(urwid.WidgetWrap):
global_dns_cat_t = ('header',language['global_dns_servers']) global_dns_cat_t = ('header',language['global_dns_servers'])
global_dns_t = ('editcp',language['use_global_dns']) global_dns_t = ('editcp',language['use_global_dns'])
dns_dom_t = ('editcp',' DNS Domain: ') dns_dom_t = ('editcp',' '+language['dns_domain']+': ')
search_dom_t = ('editcp',' Search domain:') search_dom_t = ('editcp',' '+language['search_domain']+':')
dns1_t = ('editcp',' DNS server 1: ') dns1_t = ('editcp',' DNS server 1: ')
dns2_t = ('editcp',' DNS server 2: ') dns2_t = ('editcp',' DNS server 2: ')
dns3_t = ('editcp',' DNS server 3: ') dns3_t = ('editcp',' DNS server 3: ')
@@ -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. :/
@@ -322,7 +305,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())
@@ -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

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -* coding: utf-8 -*-
""" wicd-curses. (curses/urwid-based) console interface to wicd """ wicd-curses. (curses/urwid-based) console interface to wicd
@@ -50,14 +51,14 @@ from wicd import dbusmanager
# Internal Python stuff # Internal Python stuff
import sys import sys
from time import sleep from time import sleep, strftime, ctime
# Curses UIs for other stuff # Curses UIs for other stuff
from curses_misc import SelText,DynEdit,DynIntEdit,ComboBox,Dialog2,TextDialog,InputDialog,error from curses_misc import *
from prefs_curses import PrefsDialog from prefs_curses import PrefsDialog
import netentry_curses import netentry_curses
from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog,AdvancedSettingsDialog
from optparse import OptionParser from optparse import OptionParser
@@ -90,22 +91,22 @@ class wrap_exceptions:
#gobject.source_remove(redraw_tag) #gobject.source_remove(redraw_tag)
loop.quit() loop.quit()
ui.stop() ui.stop()
print "\n"+language['terminated'] print >> sys.stderr, "\n"+language['terminated']
#raise #raise
except DBusException: except DBusException:
#gobject.source_remove(redraw_tag) #gobject.source_remove(redraw_tag)
loop.quit() loop.quit()
ui.stop() ui.stop()
print "\n"+language['dbus_fail'] print >> sys.stderr,"\n"+language['dbus_fail']
raise raise
except : except :
# Quit the loop # Quit the loop
if 'loop' in locals(): #if 'loop' in locals():
loop.quit() loop.quit()
# Zap the screen # Zap the screen
ui.stop() ui.stop()
# Print out standard notification: # Print out standard notification:
print "\n" + language['exception'] print >> sys.stderr, "\n" + language['exception']
# Flush the buffer so that the notification is always above the # Flush the buffer so that the notification is always above the
# backtrace # backtrace
sys.stdout.flush() sys.stdout.flush()
@@ -157,44 +158,11 @@ def check_for_wireless(iwconfig, wireless_ip, set_status):
return True return True
# Self explanitory, and not used until I can get some list sort function
# working...
# Also defunct.
# Current list header is STR,ESSID,ENCRYPT,BSSID,TYPE,CHANNEL
#def gen_list_header():
# return '%3s %4s %s %19s %s ' % ('NUM','STR','BSSID','CHANNEL','ESSID')
# Generate the list of networks. # Generate the list of networks.
# Mostly borrowed/stolen from wpa_cli, since I had no clue what all of those # Mostly borrowed/stolen from wpa_cli, since I had no clue what all of those
# 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():
# Pick which strength measure to use based on what the daemon says
if daemon.GetSignalDisplayType() == 0:
strenstr = 'quality'
gap = 3
else:
strenstr = 'strength'
gap = 5
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
@@ -227,24 +195,62 @@ def about_dialog(body):
about = TextDialog(theText,16,55,header=('header','About Wicd')) about = TextDialog(theText,16,55,header=('header','About Wicd'))
about.run(ui,body) about.run(ui,body)
# Modeled after htop's help
def help_dialog(body): def help_dialog(body):
theText = [ textT = urwid.Text(('header','Wicd-curses help'),'right')
textSH = urwid.Text(['This is ',('blue','wicd-curses-'+CURSES_REVNO),' using wicd ',unicode(daemon.Hello()),'\n'])
textH = urwid.Text([
"For more detailed help, consult the wicd-curses(8) man page.\n", "For more detailed help, consult the wicd-curses(8) man page.\n",
"\n", "All controls are case sensitive\n", ('bold','->'),' and ',('bold','<-')," are the right and left arrows respectively.\n"])
('bold','H')," or ",('bold','h'),' or ',('bold','?')," Display this help dialog\n",
('bold','enter')," Connect to selected network\n", text1 = urwid.Text([
('bold','D')," Disconnect from all networks\n", ('bold',' H h ?'),": Display this help dialog\n",
('bold','ESC')," Stop a network connection in progress\n", ('bold','enter C'),": Connect to selected network\n",
('bold','F5')," or ", ('bold','R')," Refresh network list\n", ('bold',' D'),": Disconnect from all networks\n",
('bold','P')," Prefrences dialog\n", ('bold',' ESC'),": Stop a connection in progress\n",
('bold','I')," Scan for hidden networks\n", ('bold',' F5 R'),": Refresh network list\n",
('bold','S')," Select scripts\n", ('bold',' P'),": Prefrences dialog\n",
('bold','O')," Set up Ad-hoc network\n", ])
('bold','C')," Configure Selected Network\n", text2 = urwid.Text([
('bold','A')," Display 'about' dialog\n" ('bold',' I'),": Scan for hidden networks\n",
] ('bold',' S'),": Select scripts\n",
help = TextDialog(theText,18,62,header=('header',"Wicd-Curses Help")) ('bold',' O'),": Set up Ad-hoc network\n",
help.run(ui,body) ('bold',' ->'),": Configure selected network\n",
('bold',' A'),": Display 'about' dialog\n",
('bold',' F8 q Q'),": Quit wicd-curses\n",
])
textF = urwid.Text('Press any key to return.')
# textJ = urwid.Text(('important','Nobody expects the Spanish Inquisition!'))
blank = urwid.Text('')
# Pile containing a text and columns?
cols = urwid.Columns([text1,text2])
pile = urwid.Pile([textH,cols])
fill = urwid.Filler(pile)
frame = urwid.Frame(fill,header=urwid.Pile([textT,textSH]),footer=textF)
dim = ui.get_cols_rows()
while True:
ui.draw_screen(dim, frame.render(dim, True))
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:
dim = ui.get_cols_rows()
elif keys:
break
#elif keys != '':
# break
#help = TextDialog(theText,18,62,header=('header',"Wicd-Curses Help"))
#help.run(ui,body)
def run_configscript(parent,netname,nettype): def run_configscript(parent,netname,nettype):
configfile = wpath.etc+netname+'-settings.conf' configfile = wpath.etc+netname+'-settings.conf'
@@ -293,6 +299,15 @@ Once there, you can adjust (or add) the "beforescript", "afterscript", and "disc
main() main()
""" """
def gen_list_header():
if daemon.GetSignalDisplayType() == 0:
# Allocate 25 cols for the ESSID name
essidgap = 25
else:
# Need 3 more to accomodate dBm strings
essidgap = 28
return 'C %s %*s %9s %17s %6s %s' % ('STR ',essidgap,'ESSID','ENCRYPT','BSSID','MODE','CHNL')
######################################## ########################################
##### URWID SUPPORT CLASSES ##### URWID SUPPORT CLASSES
######################################## ########################################
@@ -300,13 +315,14 @@ Once there, you can adjust (or add) the "beforescript", "afterscript", and "disc
# 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):
# Pick which strength measure to use based on what the daemon says # Pick which strength measure to use based on what the daemon says
# gap allocates more space to the first module
if daemon.GetSignalDisplayType() == 0: if daemon.GetSignalDisplayType() == 0:
strenstr = 'quality' strenstr = 'quality'
gap = 3 gap = 4 # Allow for 100%
else: else:
strenstr = 'strength' strenstr = 'strength'
gap = 5 gap = 7 # -XX dbm = 7
self.id = id self.id = id
# All of that network property stuff # All of that network property stuff
self.stren = daemon.FormatSignalForPrinting( self.stren = daemon.FormatSignalForPrinting(
@@ -316,7 +332,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: %s' % (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:]
@@ -481,6 +497,7 @@ class AdHocDialog(Dialog2):
self.key_edit.get_edit_text()) self.key_edit.get_edit_text())
return exitcode, data return exitcode, data
######################################## ########################################
##### APPLICATION INTERFACE CLASS ##### APPLICATION INTERFACE CLASS
######################################## ########################################
@@ -488,6 +505,7 @@ class AdHocDialog(Dialog2):
class appGUI(): class appGUI():
"""The UI itself, all glory belongs to it!""" """The UI itself, all glory belongs to it!"""
def __init__(self): def __init__(self):
global loop
self.size = ui.get_cols_rows() self.size = ui.get_cols_rows()
# Happy screen saying that you can't do anything because we're scanning # Happy screen saying that you can't do anything because we're scanning
# for networks. :-) # for networks. :-)
@@ -503,7 +521,8 @@ class appGUI():
header = urwid.AttrWrap(urwid.Text(self.TITLE,align='right'), 'header') header = urwid.AttrWrap(urwid.Text(self.TITLE,align='right'), 'header')
self.wiredH=urwid.Filler(urwid.Text("Wired Network(s)")) self.wiredH=urwid.Filler(urwid.Text("Wired Network(s)"))
self.wlessH=urwid.Filler(urwid.Text("Wireless Network(s)")) self.list_header=urwid.AttrWrap(urwid.Text(gen_list_header()),'listbar')
self.wlessH=NSelListBox([urwid.Text("Wireless Network(s)"),self.list_header])
#if wireless.GetNumberOfNetworks() == 0: #if wireless.GetNumberOfNetworks() == 0:
# wireless.Scan() # wireless.Scan()
@@ -511,7 +530,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)
@@ -525,17 +546,36 @@ class appGUI():
# spam,spam,spam,spam,spam,spam,spam,spam,spam,spam,spam,spam, # spam,spam,spam,spam,spam,spam,spam,spam,spam,spam,spam,spam,
# spam,spam,spam,spam] ] # spam,spam,spam,spam] ]
#self.spamLB = urwid.ListBox(spamL) #self.spamLB = urwid.ListBox(spamL)
# Keymappings proposed by nanotube in #wicd
keys = [
('H' ,'Help' ,None),
('right','Config',None),
#(' ',' ',None),
('C' ,'Connect',None),
('D' ,'Disconn',None),
('R' ,'Refresh',None),
('P' ,'Prefs',None),
('I' ,'Hidden',None),
('Q' ,'Quit',loop.quit)
]
self.footer1 = urwid.AttrWrap(urwid.Text("Something important will eventually go here."),'body') self.primaryCols = OptCols(keys,self.handle_keys)
self.footer2 = urwid.AttrWrap(urwid.Text("If you are seeing this, then something has gone wrong!"),'important') #self.time_label = urwid.Text(strftime('%H:%M:%S'))
self.footerList = urwid.ListBox([self.footer1,self.footer2]) self.time_label = \
urwid.AttrWrap(urwid.Text(strftime('%H:%M:%S')), 'timebar')
self.status_label = urwid.AttrWrap(urwid.Text('blah'),'important')
self.footer2 = urwid.Columns([self.status_label,('fixed', 8, self.time_label)])
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
@@ -548,6 +588,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')],self.handle_keys
)
self.confCols = OptCols( [
('meta enter','OK'),
('esc','Cancel')
],self.handle_keys)
# 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)
@@ -586,14 +638,19 @@ class appGUI():
where = self.thePile.get_focus().get_focus()[1] where = self.thePile.get_focus().get_focus()[1]
#where = self.wlessLB.get_focus()[1] #where = self.wlessLB.get_focus()[1]
self.focusloc = (wlessorwired,where) self.focusloc = (wlessorwired,where)
# 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):
# 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())
""" Updates the overall network list.""" """ Updates the overall network list."""
if not state: if not state:
state, x = daemon.GetConnectionStatus() state, x = daemon.GetConnectionStatus()
@@ -615,7 +672,7 @@ class appGUI():
#if firstrun: #if firstrun:
self.thePile = urwid.Pile([('fixed',1,self.wiredH), self.thePile = urwid.Pile([('fixed',1,self.wiredH),
('fixed',1,self.wiredCB), ('fixed',1,self.wiredCB),
('fixed',1,self.wlessH), ('fixed',2,self.wlessH),
self.wlessLB] ) self.wlessLB] )
if not firstrun: if not firstrun:
self.frame.body = self.thePile self.frame.body = self.thePile
@@ -630,7 +687,7 @@ class appGUI():
else: else:
self.thePile.set_focus(self.wiredCB) self.thePile.set_focus(self.wiredCB)
else: else:
self.thePile = urwid.Pile([('fixed',1,self.wlessH),self.wlessLB] ) self.thePile = urwid.Pile([('fixed',2,self.wlessH),self.wlessLB] )
if not firstrun: if not firstrun:
self.frame.body = self.thePile self.frame.body = self.thePile
#if self.focusloc[0] == self.wlessLB: #if self.focusloc[0] == self.wlessLB:
@@ -645,6 +702,7 @@ class appGUI():
self.wiredCB.get_body().set_focus(wired.GetWiredProfileList().index(wired.GetDefaultWiredNetwork())) self.wiredCB.get_body().set_focus(wired.GetWiredProfileList().index(wired.GetDefaultWiredNetwork()))
# Update the footer/status bar # Update the footer/status bar
conn_status = False
@wrap_exceptions() @wrap_exceptions()
def update_status(self): def update_status(self):
wired_connecting = wired.CheckIfWiredConnecting() wired_connecting = wired.CheckIfWiredConnecting()
@@ -652,26 +710,13 @@ class appGUI():
self.connecting = wired_connecting or wireless_connecting self.connecting = wired_connecting or wireless_connecting
fast = not daemon.NeedsExternalCalls() fast = not daemon.NeedsExternalCalls()
if self.connecting: if self.connecting:
#self.lock_screen() if not self.conn_status:
#if self.statusID: #self.lock_screen()
# gobject.idle_add(self.status_bar.remove, 1, self.statusID) #if self.statusID:
if wireless_connecting: # gobject.idle_add(self.status_bar.remove, 1, self.statusID)
if not fast: self.conn_status = True
iwconfig = wireless.GetIwconfig() gobject.idle_add(self.set_connecting_status,fast)
else:
iwconfig = ''
# set_status is rigged to return false when it is not
# connecting to anything, so this should work.
gobject.idle_add(self.set_status, wireless.GetCurrentNetwork(iwconfig) +
': ' +
language[str(wireless.CheckWirelessConnectingMessage())],
True )
if wired_connecting:
gobject.idle_add(self.set_status, language['wired_network'] +
': ' +
language[str(wired.CheckWiredConnectingMessage())],
True)
return True return True
else: else:
if check_for_wired(wired.GetWiredIP(''),self.set_status): if check_for_wired(wired.GetWiredIP(''),self.set_status):
@@ -688,9 +733,32 @@ class appGUI():
self.update_ui() self.update_ui()
return True return True
def set_connecting_status(self,fast):
wired_connecting = wired.CheckIfWiredConnecting()
wireless_connecting = wireless.CheckIfWirelessConnecting()
if wireless_connecting:
if not fast:
iwconfig = wireless.GetIwconfig()
else:
iwconfig = ''
# set_status is rigged to return false when it is not
# connecting to anything, so this should work.
return self.set_status(wireless.GetCurrentNetwork(iwconfig) +
': ' +
language[str(wireless.CheckWirelessConnectingMessage())],
True)
if wired_connecting:
return self.set_status( language['wired_network'] +
': ' +
language[str(wired.CheckWiredConnectingMessage())],
True)
else:
self.conn_status=False
return False
# 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
def set_status(self,text,from_idle=False): def set_status(self,text,from_idle=False):
# Set the status text, usually called by the update_status method # Set the status text, usually called by the update_status method
# from_idle : a check to see if we are being called directly from the # from_idle : a check to see if we are being called directly from the
@@ -701,6 +769,8 @@ class appGUI():
if from_idle and not self.connecting: if from_idle and not self.connecting:
#self.update_netlist() #self.update_netlist()
self.update_status() self.update_status()
self.conn_status=False
#self.tcount = 0
#self.update_ui() #self.update_ui()
return False return False
toAppend = '' toAppend = ''
@@ -708,26 +778,22 @@ class appGUI():
# the wheel. # the wheel.
if from_idle and self.connecting: if from_idle and self.connecting:
# This is probably the wrong way to do this, but it works for now. # This is probably the wrong way to do this, but it works for now.
toAppend=self.twirl[self.incr % 4] self.tcount+=1
self.footer2 = urwid.AttrWrap(urwid.Text(text+' '+toAppend),'important') toAppend=self.twirl[self.tcount % 4]
self.frame.set_footer(urwid.BoxAdapter( #self.footer2 = urwid.Columns([
urwid.ListBox([self.footer1,self.footer2]),2)) # urwid.AttrWrap(urwid.Text(text+' '+toAppend),'important'),
# ('fixed',8,urwid.Text(str(self.time),align='right'))])
self.status_label.set_text(text+' '+toAppend)
#self.frame.set_footer(urwid.BoxAdapter(
# urwid.ListBox([self.footer1,self.footer2]),2))
return True return True
# Make sure the screen is still working by providing a pretty counter. # Make sure the screen is still working by providing a pretty counter.
# Not necessary in the end, but I will be using footer1 for stuff in # Not necessary in the end, but I will be using footer1 for stuff in
# the long run, so I might as well put something there. # the long run, so I might as well put something there.
incr = 0 #@wrap_exceptions()
@wrap_exceptions() def update_time(self):
def idle_incr(self): self.time_label.set_text(strftime('%H:%M:%S'))
theText = " "
if self.connecting:
theText += "-- "+language['connecting']+' -- '+language["esc_to_cancel"]
else:
theText += "-- Press H or ? for Help"
quit_note = ' -- '+language["press_to_quit"]
self.footer1 = urwid.Text(str(self.incr) + theText+quit_note,wrap='clip')
self.incr+=1
return True return True
# Yeah, I'm copying code. Anything wrong with that? # Yeah, I'm copying code. Anything wrong with that?
@@ -743,96 +809,104 @@ class appGUI():
def dbus_scan_started(self): def dbus_scan_started(self):
self.lock_screen() self.lock_screen()
# Redraw the screen def restore_primary(self):
@wrap_exceptions() self.frame.set_body(self.thePile)
def update_ui(self): self.diag = None
#self.update_status() self.frame.set_footer(urwid.Pile([self.primaryCols,self.footer2]))
canvas = self.frame.render( (self.size),True ) self.update_ui()
### GRRRRRRRRRRRRRRRRRRRRR ->^^^^
# It looks like if I wanted 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()
# Handle keystrokes def handle_keys(self,keys):
if "f8" in keys or 'Q' in keys or 'q' in keys: if not self.diag:
loop.quit() # Handle keystrokes
#return False if "f8" in keys or 'Q' in keys or 'q' in keys:
if "f5" in keys or 'R' in keys: loop.quit()
self.lock_screen() #return False
wireless.Scan(True) if "f5" in keys or 'R' in keys:
if "D" in keys: self.lock_screen()
# Disconnect from all networks. wireless.Scan(True)
daemon.Disconnect() if "D" in keys:
self.update_netlist() # Disconnect from all networks.
# Guess what! I actually need to put this here, else I'll have tons of daemon.Disconnect()
# references to self.frame lying around. ^_^ self.update_netlist()
if "enter" in keys: if 'right' in keys:
focus = self.frame.body.get_focus() focus = self.thePile.get_focus()
if focus == self.wiredCB: self.frame.set_footer(urwid.Pile([self.confCols,self.footer2]))
self.special = focus
self.connect("wired",0)
else:
# wless list only other option
wid,pos = self.thePile.get_focus().get_focus()
self.connect("wireless",pos)
if "esc" in keys:
# Force disconnect here if connection in progress
if self.connecting:
daemon.CancelConnect()
# Prevents automatic reconnecting if that option is enabled
daemon.SetForcedDisconnect(True)
if "P" in keys:
if not self.pref:
self.pref = PrefsDialog(self.frame,(0,1),ui,
dbusmanager.get_dbus_ifaces())
if self.pref.run(ui,self.size,self.frame):
self.pref.save_results()
self.update_ui()
if "A" in keys:
about_dialog(self.frame)
if "C" in keys:
focus = self.thePile.get_focus()
try:
if focus == self.wiredCB: if focus == self.wiredCB:
WiredSettingsDialog(self.wiredCB.get_body(). self.diag = WiredSettingsDialog(self.wiredCB.get_body().get_selected_profile())
get_selected_profile()).run(ui,self.size,self.frame) self.frame.set_body(self.diag)
else: else:
# wireless list only other option # wireless list only other option
wid,pos = self.thePile.get_focus().get_focus() wid,pos = self.thePile.get_focus().get_focus()
WirelessSettingsDialog(pos).run(ui,self.size,self.frame) self.diag = WirelessSettingsDialog(pos)
except: self.diag.ready_widgets(ui,self.frame)
# wtf do I need this? self.frame.set_body(self.diag)
loop.quit() # Guess what! I actually need to put this here, else I'll have
raise # tons of references to self.frame lying around. ^_^
#self.netentry = NetEntryBase(dbusmanager.get_dbus_ifaces()) if "enter" in keys:
#self.netentry.run(ui,self.size,self.frame) #pass
if "I" in keys: focus = self.frame.body.get_focus()
self.raise_hidden_network_dialog() if focus == self.wiredCB:
if "H" in keys or 'h' in keys or '?' in keys: self.special = focus
help_dialog(self.frame) self.connect("wired",0)
if "S" in keys: else:
focus = self.thePile.get_focus() # wless list only other option
if focus == self.wiredCB: wid,pos = self.thePile.get_focus().get_focus()
nettype = 'wired' self.connect("wireless",pos)
netname = self.wiredCB.get_body().get_selected_profile()
else: if "esc" in keys:
nettype = 'wireless' # Force disconnect here if connection in progress
netname = str(self.wlessLB.get_focus()[1]) if self.connecting:
run_configscript(self.frame,netname,nettype) daemon.CancelConnect()
if "O" in keys: # Prevents automatic reconnecting if that option is enabled
exitcode,data = AdHocDialog().run(ui,self.frame) daemon.SetForcedDisconnect(True)
#data = (essid,ip,channel,use_ics,use_encrypt,key_edit) if "P" in keys:
if exitcode == 1: if not self.pref:
wireless.CreateAdHocNetwork(data[0], self.pref = PrefsDialog(self.frame,(0,1),ui,
data[2], dbusmanager.get_dbus_ifaces())
data[1], "WEP", self.pref.load_settings()
data[5], self.pref.ready_widgets(ui,self.frame)
data[4], False) 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:
about_dialog(self.frame)
if "C" in keys:
# Same as "enter" for now
focus = self.frame.body.get_focus()
if focus == self.wiredCB:
self.special = focus
self.connect("wired",0)
else:
# wless list only other option
wid,pos = self.thePile.get_focus().get_focus()
self.connect("wireless",pos)
if "I" in keys:
self.raise_hidden_network_dialog()
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)
if "S" in keys:
focus = self.thePile.get_focus()
if focus == self.wiredCB:
nettype = 'wired'
netname = self.wiredCB.get_body().get_selected_profile()
else:
nettype = 'wireless'
netname = str(self.wlessLB.get_focus()[1])
run_configscript(self.frame,netname,nettype)
if "O" in keys:
exitcode,data = AdHocDialog().run(ui,self.frame)
#data = (essid,ip,channel,use_ics,use_encrypt,key_edit)
if exitcode == 1:
wireless.CreateAdHocNetwork(data[0],
data[2],
data[1], "WEP",
data[5],
data[4], False)
for k in keys: for k in keys:
if urwid.is_mouse_event(k): if urwid.is_mouse_event(k):
@@ -840,10 +914,35 @@ class appGUI():
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 self.diag:
if k == 'esc':
self.restore_primary()
break
if k == 'meta enter':
self.diag.save_settings()
self.restore_primary()
break
self.frame.keypress(self.size,k)
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 )
# 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()
self.handle_keys(keys)
return True return True
def connect(self, nettype, networkid, networkentry=None): def connect(self, nettype, networkid, networkentry=None):
@@ -864,7 +963,6 @@ class appGUI():
def main(): def main():
global ui global ui
# We are _not_ python. # We are _not_ python.
misc.RenameProcess('wicd-curses') misc.RenameProcess('wicd-curses')
@@ -881,34 +979,37 @@ def main():
# Default Color scheme. # Default Color scheme.
# Other potential color schemes can be found at: # Other potential color schemes can be found at:
# http://excess.org/urwid/wiki/RecommendedPalette # http://excess.org/urwid/wiki/RecommendedPalette
# Note: the current palette below is optimized for the linux console.
# For example, this looks particularly bad on a default-colored XTerm. # Thanks to nanotube on #wicd for helping with this
# NB: To find current terminal background use variable COLORFGBG
ui.register_palette([ ui.register_palette([
('body','default','default'), ('body','default','default'),
('focus','dark magenta','light gray'), ('focus','dark magenta','light gray'),
('header','light blue','default'), ('header','light blue','default'),
('important','light red','default'), ('important','light red','default'),
('connected','dark green','default'), ('connected','dark green','default'),
('connected focus','default','dark green'), ('connected focus','black','dark green'),
('editcp', 'default', 'default', 'standout'), ('editcp', 'default', 'default', 'standout'),
('editbx', 'light gray', 'dark blue'), ('editbx', 'light gray', 'dark blue'),
('editfc', 'white','dark blue', 'bold'), ('editfc', 'white','dark blue', 'bold'),
('editnfc','dark gray','default'), ('editnfc','brown','default','bold'),
('tab active','dark green','light gray'), ('tab active','dark green','light gray'),
('infobar','light gray','dark blue'),
('timebar','dark gray','default'),
('listbar','dark gray','default'),
# Simple colors around text # Simple colors around text
('green','dark green','default'), ('green','dark green','default'),
('blue','dark blue','default'), ('blue','light blue','default'),
('red','dark red','default'), ('red','dark red','default'),
('bold','white','black','bold')]) ('bold','white','black','bold')])
# This is a wrapper around a function that calls another a function that is a # This is a wrapper around a function that calls another a function that
# wrapper around a infinite loop. Fun. # is a wrapper around a infinite loop. Fun.
urwid.set_encoding('utf8') urwid.set_encoding('utf8')
ui.run_wrapper(run) ui.run_wrapper(run)
def run(): def run():
global loop global loop
loop = gobject.MainLoop()
ui.set_mouse_tracking() ui.set_mouse_tracking()
app = appGUI() app = appGUI()
@@ -920,12 +1021,12 @@ def run():
# I've left this commented out many times. # I've left this commented out many times.
bus.add_signal_receiver(app.update_netlist, 'StatusChanged', bus.add_signal_receiver(app.update_netlist, 'StatusChanged',
'org.wicd.daemon') 'org.wicd.daemon')
loop = gobject.MainLoop()
# Update what the interface looks like as an idle function # Update what the interface looks like as an idle function
gobject.idle_add(app.update_ui) gobject.idle_add(app.update_ui)
# Update the connection status on the bottom every 1.5 s. # Update the connection status on the bottom every 1.5 s.
gobject.timeout_add(1500,app.update_status) gobject.timeout_add(1500,app.update_status)
gobject.idle_add(app.idle_incr) # This will make sure that it is updated on the second.
gobject.timeout_add(500,app.update_time)
# DEFUNCT: Terminate the loop if the UI is terminated. # DEFUNCT: Terminate the loop if the UI is terminated.
#gobject.idle_add(app.stop_loop) #gobject.idle_add(app.stop_loop)
loop.run() loop.run()
@@ -938,7 +1039,7 @@ def setup_dbus(force=True):
except DBusException: except DBusException:
# I may need to be a little more verbose here. # I may need to be a little more verbose here.
# Suggestions as to what should go here, please? # Suggestions as to what should go here, please?
print language['cannot_connect_to_daemon'] print >> sys.stderr, language['cannot_connect_to_daemon']
#raise #raise
# return False # <- Will need soon. # return False # <- Will need soon.
bus = dbusmanager.get_bus() bus = dbusmanager.get_bus()
@@ -967,4 +1068,4 @@ if __name__ == '__main__':
main() main()
# Make sure that the terminal does not try to overwrite the last line of # Make sure that the terminal does not try to overwrite the last line of
# the program, so that everything looks pretty. # the program, so that everything looks pretty.
print "" #print ""

View File

@@ -52,7 +52,7 @@ Raise the "About wicd-curses" dialog
.\".PP .\".PP
.\"The following is a work in progress and might not be fully functional as of yet. .\"The following is a work in progress and might not be fully functional as of yet.
.TP .TP
.BR C .BR "C " or "enter"
Bring up network configuration controller for the selected network Bring up network configuration controller for the selected network
.TP .TP
.BR delete .BR delete

View File

@@ -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 = 'r279' CURSES_REVNO = 'uimod'
try: try:
if not os.path.exists('vcsinfo.py'): if not os.path.exists('vcsinfo.py'):