1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-08 14:54:15 +01:00

Merged mainline r297.

This commit is contained in:
Robby Workman
2009-02-13 10:07:40 -06:00
6 changed files with 46 additions and 63 deletions

View File

@@ -34,8 +34,8 @@ def error(ui,parent,message):
return dialog.run(ui,parent) return dialog.run(ui,parent)
# My savior. :-) # My savior. :-)
# Although I could have made this myself pretty easily, just want to give credit where # Although I could have made this myself pretty easily, just want to give credit
# its due. # where it's due.
# http://excess.org/urwid/browser/contrib/trunk/rbreu_filechooser.py # http://excess.org/urwid/browser/contrib/trunk/rbreu_filechooser.py
class SelText(urwid.Text): class SelText(urwid.Text):
"""A selectable text widget. See urwid.Text.""" """A selectable text widget. See urwid.Text."""
@@ -137,14 +137,14 @@ class MaskingEdit(urwid.Edit):
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 == 'on_focus' and focus == True): if self.mask_mode == "off" or (self.mask_mode == 'on_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 is # The cache messes this thing up, because I am totally changing what
# displayed. # is displayed.
self._invalidate() self._invalidate()
return canv return canv
# Else, we have a slight mess to deal with...
# Else, we have a slight mess to deal with...
self._shift_view_to_cursor = not not focus # force bool self._shift_view_to_cursor = not not focus # force bool
text, attr = self.get_text() text, attr = self.get_text()
@@ -218,14 +218,13 @@ class TabColumns(urwid.WidgetWrap):
### Combo box code begins here ### Combo box code begins here
class ComboBoxException(Exception): class ComboBoxException(Exception):
pass pass
# A "combo box" of SelTexts # A "combo box" of SelTexts
# I based this off of the code found here: # I based this off of the code found here:
# http://excess.org/urwid/browser/contrib/trunk/rbreu_menus.py # http://excess.org/urwid/browser/contrib/trunk/rbreu_menus.py
# This is a hack. It isn't without quirks, but it more or less works. # This is a hack/kludge. It isn't without quirks, but it more or less works.
# We need to wait for changes in urwid's Canvas controls before we can actually # We need to wait for changes in urwid's Canvas controls before we can actually
# make a real ComboBox. # make a real ComboBox.
class ComboBox(urwid.WidgetWrap): class ComboBox(urwid.WidgetWrap):
@@ -342,9 +341,11 @@ class ComboBox(urwid.WidgetWrap):
str,trash = self.label.get_text() str,trash = self.label.get_text()
self.cbox = DynWrap(SelText([self.list[self.focus]+' vvv']),attrs=self.attrs,focus_attr=self.focus_attr) self.cbox = DynWrap(SelText([self.list[self.focus]+' vvv']),
attrs=self.attrs,focus_attr=self.focus_attr)
if str != '': if str != '':
w = urwid.Columns([('fixed',len(str),self.label),self.cbox],dividechars=1) w = urwid.Columns([('fixed',len(str),self.label),self.cbox],
dividechars=1)
self.overlay = self.ComboSpace(self.list,parent,ui,self.focus, self.overlay = self.ComboSpace(self.list,parent,ui,self.focus,
pos=(len(str)+1,row)) pos=(len(str)+1,row))
else: else:
@@ -371,7 +372,8 @@ class ComboBox(urwid.WidgetWrap):
self.set_focus(self.list.index(retval)) self.set_focus(self.list.index(retval))
#self.cbox.set_w(SelText(retval+' vvv')) #self.cbox.set_w(SelText(retval+' vvv'))
if self.callback != None: if self.callback != None:
self.callback(self,self.overlay._listbox.get_focus()[1],self.user_args) self.callback(self,self.overlay._listbox.get_focus()[1],
self.user_args)
return self._w.keypress(size,key) return self._w.keypress(size,key)
def selectable(self): def selectable(self):
@@ -417,6 +419,7 @@ class Dialog2(urwid.WidgetWrap):
#w = urwid.Padding(w, ('fixed left',2), ('fixed right',2)) #w = urwid.Padding(w, ('fixed left',2), ('fixed right',2))
#w = urwid.Filler(w, ('fixed top',1), ('fixed bottom',1)) #w = urwid.Filler(w, ('fixed top',1), ('fixed bottom',1))
#w = urwid.AttrWrap(w, 'body') #w = urwid.AttrWrap(w, 'body')
# buttons: tuple of name,exitcode # buttons: tuple of name,exitcode
def add_buttons(self, buttons): def add_buttons(self, buttons):
l = [] l = []
@@ -509,8 +512,3 @@ 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()
# Pile that has an edit and a label saying that the file at the path specified
# does not exist
#class FileGuessEdit(urwid.WidgetWrap):
# def __init__(self,caption='',

View File

@@ -343,7 +343,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
return noneToBlankString(wireless.GetWirelessProperty(networkid, label)) return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
# Ripped from netentry.py # Ripped from netentry.py
def save_settings(self, networkid): def save_settings(self):
# Check encryption info # Check encryption info
if self.encryption_chkbox.get_state(): if self.encryption_chkbox.get_state():
#print "setting encryption info..." #print "setting encryption info..."
@@ -358,11 +358,11 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
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(networkid, "encryption"): wireless.GetWirelessProperty(self.networkID, "encryption"):
error(self.ui, self.overlay, language['enable_encryption']) error(self.ui, self.overlay, language['enable_encryption'])
return False return False
else: else:
#print 'encryption is ' + str(wireless.GetWirelessProperty(networkid, #print 'encryption is ' + str(wireless.GetWirelessProperty(self.networkID,
# "encryption")) # "encryption"))
#print "no encryption specified..." #print "no encryption specified..."
self.set_net_prop("enctype", "None") self.set_net_prop("enctype", "None")
@@ -372,9 +372,9 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.set_net_prop('use_settings_globally', True) self.set_net_prop('use_settings_globally', True)
else: else:
self.set_net_prop('use_settings_globally', False) self.set_net_prop('use_settings_globally', False)
wireless.RemoveGlobalEssidEntry(networkid) wireless.RemoveGlobalEssidEntry(self.networkID)
wireless.SaveWirelessNetworkProfile(networkid) wireless.SaveWirelessNetworkProfile(self.networkID)
return True return True
# More or less ripped from netentry.py # More or less ripped from netentry.py

View File

@@ -110,7 +110,8 @@ class PrefsDialog(urwid.WidgetWrap):
backend_cat_t = ('header',language['backend']) backend_cat_t = ('header',language['backend'])
backend_t = language['backend']+':' backend_t = language['backend']+':'
backend_list = ['spam','double spam','triple spam','quadruple spam'] backend_list = ['spam','double spam','triple spam','quadruple spam']
#backend_warn_t = ('important','Changes to the backend (probably) requires a daemon restart') #backend_warn_t = ('important',
# 'Changes to the backend (probably) requires a daemon restart')
debug_cat_t = ('header',language['debugging']) debug_cat_t = ('header',language['debugging'])
debug_mode_t = language['use_debug_mode'] debug_mode_t = language['use_debug_mode']
@@ -145,10 +146,10 @@ class PrefsDialog(urwid.WidgetWrap):
self.always_show_wired_checkb = urwid.CheckBox(always_show_wired_t) self.always_show_wired_checkb = urwid.CheckBox(always_show_wired_t)
self.wired_auto_l = [] self.wired_auto_l = []
self.wired_auto_cat = urwid.Text(wired_auto_cat_t) self.wired_auto_cat= urwid.Text(wired_auto_cat_t)
self.wired_auto_1 = urwid.RadioButton(self.wired_auto_l,wired_auto_1_t) self.wired_auto_1 = urwid.RadioButton(self.wired_auto_l,wired_auto_1_t)
self.wired_auto_2 = urwid.RadioButton(self.wired_auto_l,wired_auto_2_t) self.wired_auto_2 = urwid.RadioButton(self.wired_auto_l,wired_auto_2_t)
self.wired_auto_3 = urwid.RadioButton(self.wired_auto_l,wired_auto_3_t) self.wired_auto_3 = urwid.RadioButton(self.wired_auto_l,wired_auto_3_t)
self.auto_reconn_cat = urwid.Text(auto_reconn_cat_t) self.auto_reconn_cat = urwid.Text(auto_reconn_cat_t)
self.auto_reconn_checkb = urwid.CheckBox(auto_reconn_t) self.auto_reconn_checkb = urwid.CheckBox(auto_reconn_t)
@@ -247,23 +248,10 @@ class PrefsDialog(urwid.WidgetWrap):
self.OK_PRESSED = False self.OK_PRESSED = False
self.button_cols = urwid.Columns([ok_button,cancel_button],dividechars=1) self.button_cols = urwid.Columns([ok_button,cancel_button],
#self.active_tab = self.header0 dividechars=1)
#self.columns = urwid.Columns([('fixed',len(header0_t),self.header0),
# ('fixed',len(header1_t),self.header1),
# ('fixed',len(header2_t),self.header2),
# urwid.Text(('header',title),align='right')],
# dividechars=1)
#content = [self.columns,generalPile]
#self._label = urwid.AttrWrap(SelText(titles),attr[0],attr[1])
#self.walker = urwid.SimpleListWalker(content)
#self.listbox = urwid.ListBox(self.walker)
#self._linebox = urwid.LineBox(self._listbox)
self.tabs = TabColumns(headerList,lbList,language['preferences'],self.button_cols) self.tabs = TabColumns(headerList,lbList,language['preferences'],self.button_cols)
#overlay = urwid.Overlay(self.tabs, body, ('fixed left', pos[0]),
# width, ('fixed top', pos[1]), height)
self.__super.__init__(self.tabs) self.__super.__init__(self.tabs)
def load_settings(self): def load_settings(self):
@@ -272,7 +260,7 @@ class PrefsDialog(urwid.WidgetWrap):
self.OK_PRESSED = False self.OK_PRESSED = False
### General Settings ### General Settings
# Urwid does not like dbus.Strings as text markups # ComboBox does not like dbus.Strings as text markups. My fault. :/
wless_iface = unicode(daemon.GetWirelessInterface()) wless_iface = unicode(daemon.GetWirelessInterface())
wired_iface = unicode(daemon.GetWiredInterface()) wired_iface = unicode(daemon.GetWiredInterface())
self.wless_edit.set_edit_text(wless_iface) self.wless_edit.set_edit_text(wless_iface)
@@ -292,7 +280,6 @@ class PrefsDialog(urwid.WidgetWrap):
# Wired Automatic Connection # Wired Automatic Connection
self.wired_auto_l[daemon.GetWiredAutoConnectMethod()-1] self.wired_auto_l[daemon.GetWiredAutoConnectMethod()-1]
self.auto_reconn_checkb.set_state(daemon.GetAutoReconnect()) self.auto_reconn_checkb.set_state(daemon.GetAutoReconnect())
### External Programs ### External Programs
@@ -320,7 +307,7 @@ class PrefsDialog(urwid.WidgetWrap):
try: try:
self.wpa_cbox.set_focus(self.wpadrivers.index(def_driver)) self.wpa_cbox.set_focus(self.wpadrivers.index(def_driver))
except ValueError: except ValueError:
pass # It defaults to 0 anyway pass # It defaults to 0 anyway (I hope)
self.backends = daemon.GetBackendList() self.backends = daemon.GetBackendList()
self.thebackends= [unicode(w) for w in self.backends] self.thebackends= [unicode(w) for w in self.backends]
@@ -405,9 +392,6 @@ class PrefsDialog(urwid.WidgetWrap):
def run(self,ui, dim, display): def run(self,ui, dim, display):
width,height = ui.get_cols_rows() width,height = ui.get_cols_rows()
self.load_settings() self.load_settings()
# TODO: The below, if things go 'well'
# If we are small, "tabbify" the interface
# Else, pile it together
overlay = urwid.Overlay(self.tabs, display, ('fixed left', 0),width overlay = urwid.Overlay(self.tabs, display, ('fixed left', 0),width
, ('fixed top',1), height-3) , ('fixed top',1), height-3)
@@ -425,12 +409,12 @@ class PrefsDialog(urwid.WidgetWrap):
return False return False
for k in keys: for k in keys:
#Send key to underlying widget: #Send key to underlying widget:
overlay.keypress(dim, k)
if urwid.is_mouse_event(k): if urwid.is_mouse_event(k):
event, button, col, row = k event, button, col, row = k
overlay.mouse_event( dim, overlay.mouse_event( dim,
event, button, col, row, event, button, col, row,
focus=True) focus=True)
overlay.keypress(dim, k)
# Check if buttons are pressed. # Check if buttons are pressed.
if self.CANCEL_PRESSED: if self.CANCEL_PRESSED:
return False return False

View File

@@ -93,9 +93,7 @@ class wrap_exceptions:
#raise #raise
except DBusException: except DBusException:
gobject.source_remove(redraw_tag) gobject.source_remove(redraw_tag)
# Quit the loop
loop.quit() loop.quit()
# Zap the screen
ui.stop() ui.stop()
print "\n"+language['dbus_fail'] print "\n"+language['dbus_fail']
raise raise
@@ -166,8 +164,8 @@ def check_for_wireless(iwconfig, wireless_ip, set_status):
# working... # working...
# Also defunct. # Also defunct.
# Current list header is STR,ESSID,ENCRYPT,BSSID,TYPE,CHANNEL # Current list header is STR,ESSID,ENCRYPT,BSSID,TYPE,CHANNEL
def gen_list_header(): #def gen_list_header():
return '%3s %4s %s %19s %s ' % ('NUM','STR','BSSID','CHANNEL','ESSID') # 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
@@ -245,9 +243,10 @@ def help_dialog(body):
('bold','I')," Scan for hidden networks\n", ('bold','I')," Scan for hidden networks\n",
('bold','S')," Select scripts\n", ('bold','S')," Select scripts\n",
('bold','O')," Set up Ad-hoc network\n", ('bold','O')," Set up Ad-hoc network\n",
('bold','C')," Configure Selected Network\n" ('bold','C')," Configure Selected Network\n",
('bold','A')," Display 'about' dialog\n"
] ]
help = TextDialog(theText,17,62,header=('header',"Wicd-Curses Help")) help = TextDialog(theText,18,62,header=('header',"Wicd-Curses Help"))
help.run(ui,body) help.run(ui,body)
def run_configscript(parent,netname,nettype): def run_configscript(parent,netname,nettype):
@@ -545,7 +544,6 @@ class appGUI():
self.prev_state = False self.prev_state = False
self.connecting = False self.connecting = False
self.screen_locked = False self.screen_locked = False
#self.always_show_wired = daemon.GetAlwaysShowWiredInterface()
self.pref = None self.pref = None
@@ -704,9 +702,9 @@ class appGUI():
# something, and we aren't connecting to something, return False # something, and we aren't connecting to something, return False
# immediately. # immediately.
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.update_ui() #self.update_ui()
return False return False
toAppend = '' toAppend = ''
# If we are connecting and being called from the idle function, spin # If we are connecting and being called from the idle function, spin
@@ -726,10 +724,10 @@ class appGUI():
@wrap_exceptions() @wrap_exceptions()
def idle_incr(self): def idle_incr(self):
theText = " " theText = " "
#if self.special != None:
# theText += self.special
if self.connecting: if self.connecting:
theText += "-- "+language['connecting']+' -- '+language["esc_to_cancel"] theText += "-- "+language['connecting']+' -- '+language["esc_to_cancel"]
else:
theText += "-- Press H or ? for Help"
quit_note = ' -- '+language["press_to_quit"] quit_note = ' -- '+language["press_to_quit"]
self.footer1 = urwid.Text(str(self.incr) + theText+quit_note,wrap='clip') self.footer1 = urwid.Text(str(self.incr) + theText+quit_note,wrap='clip')
self.incr+=1 self.incr+=1
@@ -761,11 +759,11 @@ class appGUI():
#canvaso = urwid.CanvasOverlay(self.dialog.render( (80,20),True),canvas,0,1) #canvaso = urwid.CanvasOverlay(self.dialog.render( (80,20),True),canvas,0,1)
ui.draw_screen((self.size),canvas) ui.draw_screen((self.size),canvas)
keys = ui.get_input() keys = ui.get_input()
# Should make a keyhandler method, but this will do until I get around to
# that stage # 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()
return False #return False
if "f5" in keys or 'R' in keys: if "f5" in keys or 'R' in keys:
self.lock_screen() self.lock_screen()
wireless.Scan(True) wireless.Scan(True)

View File

@@ -39,6 +39,9 @@ Bring up hidden network scanning dialog
.TP .TP
.BR "H " or " h " or " ?" .BR "H " or " h " or " ?"
Bring up a rather simplistic help dialog. Of course, it mentions this man page first. :-) Bring up a rather simplistic help dialog. Of course, it mentions this man page first. :-)
.TP
.BR A
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

View File

@@ -27,7 +27,7 @@ import subprocess
# VERSIONNUMBER # VERSIONNUMBER
VERSION_NUM = '1.6.0' VERSION_NUM = '1.6.0'
REVISION_NUM = 'unknown' REVISION_NUM = 'unknown'
CURSES_REVNO = 'r270' CURSES_REVNO = 'r273'
try: try:
if not os.path.exists('vcsinfo.py'): if not os.path.exists('vcsinfo.py'):