1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-20 04:48:00 +01:00

Merged r340 of experimental-nacl.

This commit is contained in:
Andrew Psaltis
2009-05-23 00:38:54 -04:00
5 changed files with 39 additions and 83 deletions

View File

@@ -10,7 +10,9 @@ are a few dependencies:
6. a graphical sudo application (gksu, kdesu, and ktsuss are supported), 6. a graphical sudo application (gksu, kdesu, and ktsuss are supported),
while optional, is strongly recommended while optional, is strongly recommended
7. urwid (if you want to use the curses client - needs version >=0.9.8.3) 7. urwid (if you want to use the curses client - needs version >=0.9.8.3)
8. pm-utils (optional for suspend/resume integration - needs version >=1.2.4) 8. pm-utils (optional for suspend/resume integration)
Wicd supports using versions >=1.2.4 -- earlier versions may work just
fine, but they are completely unsupported here.
If you are installing from a bzr pull and you want If you are installing from a bzr pull and you want
the native language translations, first run this: the native language translations, first run this:

View File

@@ -558,6 +558,7 @@ class ClickCols(urwid.WidgetWrap):
class OptCols(urwid.WidgetWrap): class OptCols(urwid.WidgetWrap):
# tuples = [(key,desc)], on_event gets passed a key # tuples = [(key,desc)], on_event gets passed a key
# attrs = (attr_key,attr_desc) # attrs = (attr_key,attr_desc)
# handler = function passed the key of the "button" pressed
# 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,handler,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
@@ -578,9 +579,11 @@ class OptCols(urwid.WidgetWrap):
key = '' key = ''
for part in splitcmd: for part in splitcmd:
if part == 'ctrl': if part == 'ctrl':
key+='C^' key+='Ctrl+'
elif part == 'meta': elif part == 'meta':
key+='M^' # If anyone has a problem with this, they can bother me
# about it.
key+='Alt+'
else: else:
if part == 'left': if part == 'left':
key += '<-' key += '<-'
@@ -588,6 +591,8 @@ class OptCols(urwid.WidgetWrap):
key += '->' key += '->'
elif part == 'esc': elif part == 'esc':
key += 'ESC' key += 'ESC'
elif part == 'enter':
key += 'Enter'
else: else:
key += part key += part

View File

@@ -229,7 +229,7 @@ def help_dialog(body):
# textJ = urwid.Text(('important','Nobody expects the Spanish Inquisition!')) # textJ = urwid.Text(('important','Nobody expects the Spanish Inquisition!'))
blank = urwid.Text('') blank = urwid.Text('')
# Pile containing a text and columns?
cols = urwid.Columns([text1,text2]) cols = urwid.Columns([text1,text2])
pile = urwid.Pile([textH,cols]) pile = urwid.Pile([textH,cols])
fill = urwid.Filler(pile) fill = urwid.Filler(pile)
@@ -251,10 +251,6 @@ def help_dialog(body):
dim = ui.get_cols_rows() dim = ui.get_cols_rows()
elif keys: elif keys:
break 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'
@@ -350,7 +346,6 @@ class NetLabel(urwid.WidgetWrap):
def keypress(self,size,key): def keypress(self,size,key):
return self._w.keypress(size,key) return self._w.keypress(size,key)
def connect(self): def connect(self):
# This should work.
wireless.ConnectWireless(self.id) wireless.ConnectWireless(self.id)
class WiredComboBox(ComboBox): class WiredComboBox(ComboBox):
@@ -361,7 +356,6 @@ class WiredComboBox(ComboBox):
self.ADD_PROFILE = '---'+language["add_new_profile"]+'---' self.ADD_PROFILE = '---'+language["add_new_profile"]+'---'
self.__super.__init__(use_enter=False) self.__super.__init__(use_enter=False)
self.set_list(list) self.set_list(list)
#self.set_focus(self.theList.index(wired.GetDefaultProfile()))
def set_list(self,list): def set_list(self,list):
self.theList = list self.theList = list
@@ -370,16 +364,10 @@ class WiredComboBox(ComboBox):
is_active = wireless.GetWirelessIP('') == None and wired.GetWiredIP('') != None is_active = wireless.GetWirelessIP('') == None and wired.GetWiredIP('') != None
for profile in list: for profile in list:
theString = '%4s %25s' % (id, profile) theString = '%4s %25s' % (id, profile)
#### THIS IS wired.blah() in experimental
#print config.GetLastUsedWiredNetwork()
# Tag if no wireless IP present, and wired one is # Tag if no wireless IP present, and wired one is
if is_active: if is_active:
theString = '>'+theString[1:] theString = '>'+theString[1:]
#wiredL.append(urwid.AttrWrap(SelText(theString),'connected',
# 'connected focus'))
#else:
# wiredL.append(urwid.AttrWrap(SelText(theString),'body','focus'))
wiredL.append(theString) wiredL.append(theString)
id+=1 id+=1
wiredL.append(self.ADD_PROFILE) wiredL.append(self.ADD_PROFILE)
@@ -393,8 +381,6 @@ class WiredComboBox(ComboBox):
if self.theList != []: if self.theList != []:
wired.ReadWiredNetworkProfile(self.get_selected_profile()) wired.ReadWiredNetworkProfile(self.get_selected_profile())
#def rebuild_combobox(self):
# pass
def keypress(self,size,key): def keypress(self,size,key):
prev_focus = self.get_focus()[1] prev_focus = self.get_focus()[1]
key = self.__super.keypress(size,key) key = self.__super.keypress(size,key)
@@ -513,24 +499,19 @@ class appGUI():
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. :-)
# Will need a translation sooner or later
self.screen_locker = urwid.Filler(urwid.Text(('important',language['scanning_stand_by']), align='center')) self.screen_locker = urwid.Filler(urwid.Text(('important',language['scanning_stand_by']), align='center'))
self.no_wlan = urwid.Filler(urwid.Text(('important',language['no_wireless_networks_found']), align='center')) self.no_wlan = urwid.Filler(urwid.Text(('important',language['no_wireless_networks_found']), align='center'))
self.TITLE = language['wicd_curses'] self.TITLE = language['wicd_curses']
self.WIRED_IDX = 1 self.WIRED_IDX = 1
self.WLESS_IDX = 3 self.WLESS_IDX = 3
#wrap1 = urwid.AttrWrap(txt, 'black')
#fill = urwid.Filler(txt)
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.list_header=urwid.AttrWrap(urwid.Text(gen_list_header()),'listbar') self.list_header=urwid.AttrWrap(urwid.Text(gen_list_header()),'listbar')
self.wlessH=NSelListBox([urwid.Text("Wireless Network(s)"),self.list_header]) self.wlessH=NSelListBox([urwid.Text("Wireless Network(s)"),self.list_header])
#if wireless.GetNumberOfNetworks() == 0: # FIXME: This should be two variables
# wireless.Scan() self.focusloc = [1,0]
self.focusloc = (1,0)
# 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()
@@ -542,14 +523,6 @@ class appGUI():
self.wlessLB = urwid.ListBox(wlessL) self.wlessLB = urwid.ListBox(wlessL)
self.update_netlist(force_check=True,firstrun=True) 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,
# 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,spam,spam,spam,spam,
# spam,spam,spam,spam] ]
#self.spamLB = urwid.ListBox(spamL)
# Keymappings proposed by nanotube in #wicd # Keymappings proposed by nanotube in #wicd
keys = [ keys = [
('H' ,'Help' ,None), ('H' ,'Help' ,None),
@@ -565,14 +538,12 @@ class appGUI():
] ]
self.primaryCols = OptCols(keys,self.handle_keys) self.primaryCols = OptCols(keys,self.handle_keys)
#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.Pile([self.primaryCols,self.footer2]) self.footerList = urwid.Pile([self.primaryCols,self.footer2])
# Pop takes a number!
#walker.pop(1)
self.frame = urwid.Frame(self.thePile, self.frame = urwid.Frame(self.thePile,
header=header, header=header,
footer=self.footerList) footer=self.footerList)
@@ -595,7 +566,6 @@ class appGUI():
self.update_tag = None self.update_tag = None
#self.max_wait = ui.max_wait #self.max_wait = ui.max_wait
#self.dialog = PrefOverlay(self.frame,self.size)
def doScan(self, sync=False): def doScan(self, sync=False):
self.scanning = True self.scanning = True
@@ -604,15 +574,12 @@ 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'),
('meta [','Tab Left',), ('meta [','Tab Left',),
('meta ]','Tab Right')],self.handle_keys ('meta ]','Tab Right'),
) ('esc','Cancel') ], self.handle_keys)
self.confCols = OptCols( [ self.confCols = OptCols( [ ('meta enter','OK'),
('meta enter','OK'), ('esc','Cancel') ],self.handle_keys)
('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):
@@ -647,7 +614,6 @@ class appGUI():
# Location of last known focus is remapped to current location. # Location of last known focus is remapped to current location.
# This might need to be cleaned up later. # This might need to be cleaned up later.
#self.set_status(str(self.frame.get_body().get_focus())+ ' '+ str(self.wiredCB))
if self.thePile.get_focus() == self.wiredCB: if self.thePile.get_focus() == self.wiredCB:
wlessorwired = self.WIRED_IDX wlessorwired = self.WIRED_IDX
where = self.thePile.get_focus().get_body().get_focus()[1] where = self.thePile.get_focus().get_body().get_focus()[1]
@@ -658,7 +624,7 @@ class appGUI():
else: else:
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.
@@ -677,8 +643,7 @@ class appGUI():
state, x = daemon.GetConnectionStatus() state, x = daemon.GetConnectionStatus()
if force_check or self.prev_state != state: if force_check or self.prev_state != state:
wiredL,wlessL = gen_network_list() 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().set_list(wiredL)
self.wiredCB.get_body().build_combobox(self.frame,ui,3) self.wiredCB.get_body().build_combobox(self.frame,ui,3)
if len(wlessL) != 0: if len(wlessL) != 0:
@@ -689,16 +654,13 @@ class appGUI():
else: else:
self.wlessLB = self.no_wlan self.wlessLB = self.no_wlan
if daemon.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn(): if daemon.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
#if daemon.GetAlwaysShowWiredInterface():
#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',2,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
#self.focusloc = (self.thePile.get_focus(),
# self.thePile.get_focus().get_focus()[1])
self.thePile.set_focus(self.focusloc[0]) self.thePile.set_focus(self.focusloc[0])
if self.focusloc[0] == self.WIRED_IDX: if self.focusloc[0] == self.WIRED_IDX:
self.thePile.get_focus().get_body().set_focus(self.focusloc[1]) self.thePile.get_focus().get_body().set_focus(self.focusloc[1])
@@ -711,10 +673,11 @@ class appGUI():
self.thePile = urwid.Pile([('fixed',2,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[1] == None:
self.focusloc[1] = 0
if self.wlessLB != self.no_wlan:
self.wlessLB.set_focus(self.focusloc[1]) self.wlessLB.set_focus(self.focusloc[1])
#self.thePile.get_focus().set_focus(self.focusloc[1])
#self.always_show_wired = not self.always_show_wired
self.prev_state = state self.prev_state = state
if not firstrun: if not firstrun:
self.update_ui() self.update_ui()
@@ -733,9 +696,6 @@ class appGUI():
fast = not daemon.NeedsExternalCalls() fast = not daemon.NeedsExternalCalls()
if self.connecting: if self.connecting:
if not self.conn_status: if not self.conn_status:
#self.lock_screen()
#if self.statusID:
# gobject.idle_add(self.status_bar.remove, 1, self.statusID)
self.conn_status = True self.conn_status = True
gobject.idle_add(self.set_connecting_status,fast) gobject.idle_add(self.set_connecting_status,fast)
return True return True
@@ -788,11 +748,8 @@ 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_status() self.update_status()
self.conn_status=False self.conn_status=False
#self.tcount = 0
#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
@@ -801,12 +758,7 @@ class appGUI():
# 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.
self.tcount+=1 self.tcount+=1
toAppend=self.twirl[self.tcount % 4] toAppend=self.twirl[self.tcount % 4]
#self.footer2 = urwid.Columns([
# urwid.AttrWrap(urwid.Text(text+' '+toAppend),'important'),
# ('fixed',8,urwid.Text(str(self.time),align='right'))])
self.status_label.set_text(text+' '+toAppend) 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.
@@ -872,7 +824,6 @@ class appGUI():
# Guess what! I actually need to put this here, else I'll have # Guess what! I actually need to put this here, else I'll have
# tons of references to self.frame lying around. ^_^ # tons of references to self.frame lying around. ^_^
if "enter" in keys: if "enter" in keys:
#pass
focus = self.frame.body.get_focus() focus = self.frame.body.get_focus()
if focus == self.wiredCB: if focus == self.wiredCB:
self.special = focus self.special = focus
@@ -1093,8 +1044,6 @@ def run():
gobject.timeout_add(1500,app.update_status) gobject.timeout_add(1500,app.update_status)
# This will make sure that it is updated on the second. # This will make sure that it is updated on the second.
gobject.timeout_add(500,app.update_time) gobject.timeout_add(500,app.update_time)
# DEFUNCT: Terminate the loop if the UI is terminated.
#gobject.idle_add(app.stop_loop)
app.update_ui() app.update_ui()
# Get input file descriptors and add callbacks to the ui-updating function # Get input file descriptors and add callbacks to the ui-updating function

View File

@@ -511,11 +511,11 @@ class appGui(object):
printLine = True # In this case we print a separator. printLine = True # In this case we print a separator.
wirednet = WiredNetworkEntry() wirednet = WiredNetworkEntry()
self.network_list.pack_start(wirednet, False, False) self.network_list.pack_start(wirednet, False, False)
wirednet.connect_button.connect("button-press-event", self.connect, wirednet.connect_button.connect("clicked", self.connect,
"wired", 0, wirednet) "wired", 0, wirednet)
wirednet.disconnect_button.connect("button-press-event", self.disconnect, wirednet.disconnect_button.connect("clicked", self.disconnect,
"wired", 0, wirednet) "wired", 0, wirednet)
wirednet.advanced_button.connect("button-press-event", wirednet.advanced_button.connect("clicked",
self.edit_advanced, "wired", 0, self.edit_advanced, "wired", 0,
wirednet) wirednet)
@@ -533,13 +533,13 @@ class appGui(object):
printLine = True printLine = True
tempnet = WirelessNetworkEntry(x) tempnet = WirelessNetworkEntry(x)
self.network_list.pack_start(tempnet, False, False) self.network_list.pack_start(tempnet, False, False)
tempnet.connect_button.connect("button-press-event", tempnet.connect_button.connect("clicked",
self.connect, "wireless", x, self.connect, "wireless", x,
tempnet) tempnet)
tempnet.disconnect_button.connect("button-press-event", tempnet.disconnect_button.connect("clicked",
self.disconnect, "wireless", self.disconnect, "wireless",
x, tempnet) x, tempnet)
tempnet.advanced_button.connect("button-press-event", tempnet.advanced_button.connect("clicked",
self.edit_advanced, "wireless", self.edit_advanced, "wireless",
x, tempnet) x, tempnet)
else: else:
@@ -598,7 +598,7 @@ class appGui(object):
return True return True
def edit_advanced(self, widget, event, ttype, networkid, networkentry): def edit_advanced(self, widget, ttype, networkid, networkentry):
""" Display the advanced settings dialog. """ Display the advanced settings dialog.
Displays the advanced settings dialog and saves any changes made. Displays the advanced settings dialog and saves any changes made.
@@ -649,7 +649,7 @@ class appGui(object):
return False return False
return True return True
def connect(self, widget, event, nettype, networkid, networkentry): def connect(self, widget, nettype, networkid, networkentry):
""" Initiates the connection process in the daemon. """ """ Initiates the connection process in the daemon. """
cancel_button = self.wTree.get_widget("cancel_button") cancel_button = self.wTree.get_widget("cancel_button")
cancel_button.set_sensitive(True) cancel_button.set_sensitive(True)
@@ -663,7 +663,7 @@ class appGui(object):
wired.ConnectWired() wired.ConnectWired()
self.update_statusbar() self.update_statusbar()
def disconnect(self, widget, event, nettype, networkid, networkentry): def disconnect(self, widget, nettype, networkid, networkentry):
""" Disconnects from the given network. """ Disconnects from the given network.
Keyword arguments: Keyword arguments:

View File

@@ -238,7 +238,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
""" Build the wired settings dialog. """ """ Build the wired settings dialog. """
AdvancedSettingsDialog.__init__(self) AdvancedSettingsDialog.__init__(self)
self.des = self.connect("destroy", self.destroy_called) self.des = self.connect("destroy", self.destroy_called)
self.script_button.connect("button-press-event", self.edit_scripts) self.script_button.connect("clicked", self.edit_scripts)
self.prof_name = name self.prof_name = name
def set_net_prop(self, option, value): def set_net_prop(self, option, value):
@@ -335,7 +335,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
# Connect signals. # Connect signals.
self.chkbox_encryption.connect("toggled", self.toggle_encryption) self.chkbox_encryption.connect("toggled", self.toggle_encryption)
self.combo_encryption.connect("changed", self.change_encrypt_method) self.combo_encryption.connect("changed", self.change_encrypt_method)
self.script_button.connect("button-press-event", self.edit_scripts) self.script_button.connect("clicked", self.edit_scripts)
self.des = self.connect("destroy", self.destroy_called) self.des = self.connect("destroy", self.destroy_called)
def destroy_called(self, *args): def destroy_called(self, *args):