mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
Merged with the 1.6 sources (r227), and
curses/wicd-curses.py: modified the program so that it can run off of the experimental API. Cleaned up some of the code.
This commit is contained in:
@@ -33,9 +33,8 @@ at least get a network connection. Or those who don't like using X. :-)
|
||||
Comments, criticisms, patches, bug reports all welcome!
|
||||
"""
|
||||
|
||||
##### NOTICE: THIS DOES NOT WORK WITH THE EXPERIMENTAL BRANCH, DESPITE THE FACT
|
||||
##### THAT THIS FILE COMES WITH A FULL COPY OF THE EXPERIMENTAL BRANCH!
|
||||
##### I WILL PROBABLY BE REMEDYING THIS SOMETIME IN JANUARY.
|
||||
##### NOTICE: THIS ONLY WORKS WITH THE SOURCE IN WICD 1.6 AS FOUND IN THE BZR
|
||||
##### REPOSITORIES!
|
||||
|
||||
# UI stuff
|
||||
#import urwid.raw_display
|
||||
@@ -50,6 +49,7 @@ import gobject
|
||||
|
||||
# Other important wicd-related stuff
|
||||
import wicd.misc as misc
|
||||
from wicd import dbusmanager
|
||||
|
||||
# Internal Python stuff
|
||||
import sys
|
||||
@@ -197,7 +197,7 @@ class wrap_exceptions:
|
||||
gobject.source_remove(redraw_tag)
|
||||
loop.quit()
|
||||
ui.stop()
|
||||
print "Terminated by user."
|
||||
print "\nTerminated by user."
|
||||
raise
|
||||
except :
|
||||
# If the UI isn't inactive (redraw_tag wouldn't normally be
|
||||
@@ -210,7 +210,7 @@ class wrap_exceptions:
|
||||
# Zap the screen
|
||||
ui.stop()
|
||||
# Print out standard notification:
|
||||
print "EXCEPTION!"
|
||||
print "\nEXCEPTION!"
|
||||
print "Please report this to the maintainer and/or file a bug report with the backtrace below:"
|
||||
print redraw_tag
|
||||
# Flush the buffer so that the notification is always above the
|
||||
@@ -291,9 +291,6 @@ def gen_list_header():
|
||||
# DBUS interfaces do. ^_^
|
||||
# Whatever calls this must be exception-wrapped if it is run if the UI is up
|
||||
def gen_network_list():
|
||||
#theList = [urwid.Text(gen_list_header())]
|
||||
#theList = []
|
||||
|
||||
# Pick which strength measure to use based on what the daemon says
|
||||
if daemon.GetSignalDisplayType() == 0:
|
||||
strenstr = 'quality'
|
||||
@@ -304,15 +301,12 @@ def gen_network_list():
|
||||
|
||||
id = 0
|
||||
wiredL = []
|
||||
for profile in config.GetWiredProfileList():
|
||||
#if id == 0:
|
||||
#theList.append(urwid.Text("Wired Network(s):"))
|
||||
#wired.append(urwid.Text(('body',"Wired Network(s):") ) )
|
||||
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
|
||||
is_active = wireless.GetWirelessIP() == None and wired.GetWiredIP() != None
|
||||
is_active = wireless.GetWirelessIP('') == None and wired.GetWiredIP('') != None
|
||||
if is_active:
|
||||
theString = '>'+theString[1:]
|
||||
wiredL.append(urwid.AttrWrap(SelText(theString),'connected',
|
||||
@@ -323,9 +317,6 @@ def gen_network_list():
|
||||
|
||||
wlessL = []
|
||||
for network_id in range(0, wireless.GetNumberOfNetworks()):
|
||||
#if network_id == 0:
|
||||
#wireless.append(urwid.Text(('body', "Wireless Network(s):")) )
|
||||
|
||||
# ?: in python
|
||||
encryption = wireless.GetWirelessProperty(network_id, 'encryption_method') if wireless.GetWirelessProperty(network_id, 'encryption') else 'Unsecured'
|
||||
theString = ' %*s %25s %9s %17s %6s: %s' % ( gap,
|
||||
@@ -338,13 +329,12 @@ def gen_network_list():
|
||||
wireless.GetWirelessProperty(network_id, 'mode'), # Master, Ad-Hoc
|
||||
wireless.GetWirelessProperty(network_id, 'channel')
|
||||
)
|
||||
is_active = wireless.GetPrintableSignalStrength("") != 0 and wireless.GetCurrentNetworkID(wireless.GetIwconfig())==network_id
|
||||
is_active = wireless.GetCurrentSignalStrength("") != 0 and wireless.GetCurrentNetworkID(wireless.GetIwconfig())==network_id
|
||||
if is_active:
|
||||
theString = '>'+theString[1:]
|
||||
wlessL.append(urwid.AttrWrap(SelText(theString),'connected','connected focus'))
|
||||
else:
|
||||
wlessL.append(urwid.AttrWrap(SelText(theString),'body','focus'))
|
||||
#theList.append(SelText(theString))
|
||||
return (wiredL,wlessL)
|
||||
|
||||
|
||||
@@ -384,19 +374,16 @@ class appGUI():
|
||||
('fixed',1,self.wiredLB),
|
||||
('fixed',1,self.wlessH),
|
||||
self.wlessLB] )
|
||||
#self.netList = urwid.ListBox(wlessL)
|
||||
#walker = urwid.SimpleListWalker(gen_network_list())
|
||||
self.footer1 = urwid.AttrWrap(urwid.Text("Something important will eventually go here."),'body')
|
||||
self.footer2 = urwid.AttrWrap(urwid.Text("If you are seeing this, then something has gone wrong!"),'important')
|
||||
self.footerList = urwid.ListBox([self.footer1,self.footer2])
|
||||
# Pop takes a number!
|
||||
#walker.pop(1)
|
||||
#self.listbox = urwid.AttrWrap(urwid.ListBox(netList),'body','focus')
|
||||
self.frame = urwid.Frame(self.thePile,
|
||||
header=header,
|
||||
footer=urwid.BoxAdapter(self.footerList,2))
|
||||
#self.frame = urwid.Frame(self.screen_locker, header=header,footer=footer)
|
||||
self.frame.set_focus('body')
|
||||
|
||||
# Booleans gallore!
|
||||
self.prev_state = False
|
||||
self.connecting = False
|
||||
@@ -441,17 +428,16 @@ class appGUI():
|
||||
wireless_connecting = wireless.CheckIfWirelessConnecting()
|
||||
self.connecting = wired_connecting or wireless_connecting
|
||||
|
||||
# IN EXPERIMENTAL
|
||||
#fast = not daemon.NeedsExternalCalls()
|
||||
fast = not daemon.NeedsExternalCalls()
|
||||
if self.connecting:
|
||||
#self.lock_screen()
|
||||
#if self.statusID:
|
||||
# gobject.idle_add(self.status_bar.remove, 1, self.statusID)
|
||||
if wireless_connecting:
|
||||
#if not fast:
|
||||
iwconfig = wireless.GetIwconfig()
|
||||
#else:
|
||||
# iwconfig = ''
|
||||
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.
|
||||
gobject.idle_add(self.set_status, wireless.GetCurrentNetwork(iwconfig) +
|
||||
@@ -465,10 +451,14 @@ class appGUI():
|
||||
True)
|
||||
return True
|
||||
else:
|
||||
if check_for_wired(wired.GetWiredIP(),self.set_status):
|
||||
if check_for_wired(wired.GetWiredIP(''),self.set_status):
|
||||
return True
|
||||
elif check_for_wireless(wireless.GetIwconfig(),
|
||||
wireless.GetWirelessIP(), self.set_status):
|
||||
if not fast:
|
||||
iwconfig = wireless.GetIwconfig()
|
||||
else:
|
||||
iwconfig = ''
|
||||
if check_for_wireless(iwconfig, wireless.GetWirelessIP(""),
|
||||
self.set_status):
|
||||
return True
|
||||
else:
|
||||
self.set_status(language['not_connected'])
|
||||
@@ -479,7 +469,7 @@ class appGUI():
|
||||
# mainloop
|
||||
def set_status(self,text,from_idle=False):
|
||||
# If we are being called as the result of trying to connect to
|
||||
# something return False immediately.
|
||||
# something, return False immediately.
|
||||
if from_idle and not self.connecting:
|
||||
return False
|
||||
self.footer2 = urwid.AttrWrap(urwid.Text(text),'important')
|
||||
@@ -489,7 +479,7 @@ class appGUI():
|
||||
|
||||
# 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
|
||||
# the long run.
|
||||
# the long run, so I might as well put something there.
|
||||
incr = 0
|
||||
def idle_incr(self):
|
||||
theText = ""
|
||||
@@ -517,13 +507,6 @@ class appGUI():
|
||||
self.lock_screen()
|
||||
|
||||
# Redraw the screen
|
||||
# There exists a problem with this where any exceptions that occur (especially of
|
||||
# the DBus variety) will get spread out on the top of the screen, or not displayed
|
||||
# at all. Urwid and the glib main loop don't mix all too well. I may need to
|
||||
# consult the Urwid maintainer about this.
|
||||
#
|
||||
# The implementation of this solution is active in this program, and it appears to
|
||||
# be functioning well.
|
||||
@wrap_exceptions()
|
||||
def update_ui(self):
|
||||
#self.update_status()
|
||||
@@ -551,7 +534,6 @@ class appGUI():
|
||||
daemon.CancelConnect()
|
||||
# Prevents automatic reconnecting if that option is enabled
|
||||
daemon.SetForcedDisconnect(True)
|
||||
pass
|
||||
for k in keys:
|
||||
if k == "window resize":
|
||||
self.size = ui.get_cols_rows()
|
||||
@@ -612,7 +594,11 @@ def main():
|
||||
('header','light blue','black'),
|
||||
('important','light red','black'),
|
||||
('connected','dark green','black'),
|
||||
('connected focus','black','dark green')])
|
||||
('connected focus','black','dark green'),
|
||||
# I'll be needing these soon, so I'll leave them here for now.
|
||||
('editcp', 'light gray', 'black', 'standout'),
|
||||
('editbx', 'light gray', 'dark blue'),
|
||||
('editfc', 'white','dark blue', 'bold') ])
|
||||
# This is a wrapper around a function that calls another a function that is a
|
||||
# wrapper around a infinite loop. Fun.
|
||||
ui.run_wrapper(run)
|
||||
@@ -625,9 +611,9 @@ def run():
|
||||
|
||||
# Connect signals and whatnot to UI screen control functions
|
||||
bus.add_signal_receiver(app.dbus_scan_finished, 'SendEndScanSignal',
|
||||
'org.wicd.daemon')
|
||||
'org.wicd.daemon.wireless')
|
||||
bus.add_signal_receiver(app.dbus_scan_started, 'SendStartScanSignal',
|
||||
'org.wicd.daemon')
|
||||
'org.wicd.daemon.wireless')
|
||||
# I've left this commented out many times.
|
||||
bus.add_signal_receiver(app.update_netlist, 'StatusChanged',
|
||||
'org.wicd.daemon')
|
||||
@@ -641,22 +627,26 @@ def run():
|
||||
#gobject.idle_add(app.stop_loop)
|
||||
loop.run()
|
||||
|
||||
|
||||
# Mostly borrowed from gui.py, but also with the "need daemon first" check
|
||||
def setup_dbus():
|
||||
global proxy_obj, daemon, wireless, wired, config, dbus_ifaces
|
||||
# Mostly borrowed from gui.py
|
||||
def setup_dbus(force=True):
|
||||
global bus, daemon, wireless, wired, DBUS_AVAIL
|
||||
try:
|
||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||
except dbus.DBusException:
|
||||
print 'Error: Could not connect to the daemon. Please make sure it is running.'
|
||||
sys.exit(3)
|
||||
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
|
||||
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
||||
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
||||
config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config')
|
||||
|
||||
dbus_ifaces = {"daemon" : daemon, "wireless" : wireless, "wired" : wired,
|
||||
"config" : config}
|
||||
dbusmanager.connect_to_dbus()
|
||||
except DBusException:
|
||||
# I may need to be a little more verbose here.
|
||||
# Suggestions as to what should go here
|
||||
print "Can't connect to the daemon. Are you sure it is running?"
|
||||
print "Please check the wicd log for error messages."
|
||||
raise
|
||||
# return False # <- Will need soon.
|
||||
bus = dbusmanager.get_bus()
|
||||
dbus_ifaces = dbusmanager.get_dbus_ifaces()
|
||||
daemon = dbus_ifaces['daemon']
|
||||
wireless = dbus_ifaces['wireless']
|
||||
wired = dbus_ifaces['wired']
|
||||
DBUS_AVAIL = True
|
||||
|
||||
return True
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
setup_dbus()
|
||||
@@ -665,4 +655,7 @@ setup_dbus()
|
||||
##### MAIN ENTRY POINT
|
||||
########################################
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
# Make sure that the terminal does not try to overwrite the last line of
|
||||
# the program, so that everything looks pretty.
|
||||
print ""
|
||||
|
||||
1502
data/wicd.glade
1502
data/wicd.glade
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
wpa
|
||||
wpa-psk
|
||||
wep-hex
|
||||
wep-passphrase
|
||||
wep-shared
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name = WPA 1/2
|
||||
name = WPA 1/2 (Passphrase)
|
||||
author = Adam Blackburn
|
||||
version = 1
|
||||
require key *Key
|
||||
|
||||
15
encryption/templates/wpa-psk
Normal file
15
encryption/templates/wpa-psk
Normal file
@@ -0,0 +1,15 @@
|
||||
name = WPA 1/2 (Preshared Key)
|
||||
author = Adam Blackburn
|
||||
version = 1
|
||||
require apsk *Preshared_Key
|
||||
-----
|
||||
ctrl_interface=/var/run/wpa_supplicant
|
||||
network={
|
||||
ssid="$_ESSID"
|
||||
scan_ssid=$_SCAN
|
||||
proto=WPA RSN
|
||||
key_mgmt=WPA-PSK
|
||||
pairwise=CCMP TKIP
|
||||
group=CCMP TKIP
|
||||
psk="$_APSK"
|
||||
}
|
||||
21
setup.py
21
setup.py
@@ -219,7 +219,24 @@ class configure(Command):
|
||||
item_out.close()
|
||||
item_in.close()
|
||||
shutil.copymode(original_name, final_name)
|
||||
|
||||
class test(Command):
|
||||
description = "run Wicd's unit tests"
|
||||
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
print "importing tests"
|
||||
import tests
|
||||
print 'running tests'
|
||||
tests.run_tests()
|
||||
|
||||
class get_translations(Command):
|
||||
description = "download the translations from the online translator"
|
||||
|
||||
@@ -330,7 +347,7 @@ try:
|
||||
data.append(( wpath.suspend, ['other/50-wicd-suspend.sh' ]))
|
||||
if not wpath.no_install_pmutils:
|
||||
data.append(( wpath.pmutils, ['other/55wicd' ]))
|
||||
print 'Creating pid path', os.path.basename(wpath.pidfile)
|
||||
print 'Using pid path', os.path.basename(wpath.pidfile)
|
||||
print 'Language support for',
|
||||
for language in os.listdir('translations/'):
|
||||
if not language.startswith('.'):
|
||||
@@ -354,7 +371,7 @@ iwscan_ext = Extension(name = 'iwscan',
|
||||
libraries = ['iw'],
|
||||
sources = ['depends/python-iwscan/pyiwscan.c'])
|
||||
|
||||
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall},
|
||||
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall, 'test' : test},
|
||||
name="Wicd",
|
||||
version=VERSION_NUM,
|
||||
description="A wireless and wired network manager",
|
||||
|
||||
9
tests/__init__.py
Normal file
9
tests/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
def run_tests():
|
||||
import unittest
|
||||
test_suite = unittest.TestSuite()
|
||||
|
||||
import testwnettools
|
||||
test_suite.addTest(testwnettools.suite())
|
||||
|
||||
unittest.TextTestRunner(verbosity=5).run(test_suite)
|
||||
66
tests/testwnettools.py
Normal file
66
tests/testwnettools.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import unittest
|
||||
from wicd import wnettools
|
||||
|
||||
class TestWnettools(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.interface = wnettools.BaseInterface('eth0')
|
||||
|
||||
def test_find_wireless_interface(self):
|
||||
interfaces = wnettools.GetWirelessInterfaces()
|
||||
# wlan0 may change depending on your system
|
||||
self.assertTrue('wlan0' in interfaces)
|
||||
|
||||
def test_find_wired_interface(self):
|
||||
interfaces = wnettools.GetWiredInterfaces()
|
||||
# eth0 may change depending on your system
|
||||
self.assertTrue('eth0' in interfaces)
|
||||
|
||||
def test_wext_is_valid_wpasupplicant_driver(self):
|
||||
self.assertTrue(wnettools.IsValidWpaSuppDriver('wext'))
|
||||
|
||||
def test_needs_external_calls_not_implemented(self):
|
||||
self.assertRaises(NotImplementedError, wnettools.NeedsExternalCalls)
|
||||
|
||||
def test_get_ip_not_implemented(self):
|
||||
self.assertRaises(NotImplementedError, self.interface.GetIP)
|
||||
|
||||
def test_is_up_not_implemented(self):
|
||||
self.assertRaises(NotImplementedError, self.interface.IsUp)
|
||||
|
||||
def test_enable_debug_mode(self):
|
||||
self.interface.SetDebugMode(True)
|
||||
self.assertTrue(self.interface.verbose)
|
||||
|
||||
def test_disable_debug_mode(self):
|
||||
self.interface.SetDebugMode(False)
|
||||
self.assertFalse(self.interface.verbose)
|
||||
|
||||
def test_interface_name_sanitation(self):
|
||||
interface = wnettools.BaseInterface('blahblah; uptime > /tmp/blah | cat')
|
||||
self.assertEquals(interface.iface, 'blahblahuptimetmpblahcat')
|
||||
|
||||
def test_freq_translation_low(self):
|
||||
freq = '2.412 GHz'
|
||||
interface = wnettools.BaseWirelessInterface('wlan0')
|
||||
self.assertEquals(interface._FreqToChannel(freq), 1)
|
||||
|
||||
def test_freq_translation_high(self):
|
||||
freq = '2.484 GHz'
|
||||
interface = wnettools.BaseWirelessInterface('wlan0')
|
||||
self.assertEquals(interface._FreqToChannel(freq), 14)
|
||||
|
||||
def test_generate_psk(self):
|
||||
interface = wnettools.BaseWirelessInterface('wlan0')
|
||||
psk = interface.GeneratePSK({'essid' : 'Network 1', 'key' : 'arandompassphrase'})
|
||||
self.assertEquals(psk, 'd70463014514f4b4ebb8e3aebbdec13f4437ac3a9af084b3433f3710e658a7be')
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
tests = []
|
||||
[ tests.append(test) for test in dir(TestWnettools) if test.startswith('test') ]
|
||||
for test in tests:
|
||||
suite.addTest(TestWnettools(test))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
21
wicd/misc.py
21
wicd/misc.py
@@ -302,13 +302,22 @@ def get_gettext():
|
||||
def to_unicode(x):
|
||||
""" Attempts to convert a string to utf-8. """
|
||||
# If this is a unicode string, encode it and return
|
||||
if type(x) == unicode:
|
||||
if type(x) not in [unicode, str]:
|
||||
return x
|
||||
if isinstance(x, unicode):
|
||||
return x.encode('utf-8')
|
||||
encoding = locale.getpreferredencoding()
|
||||
try:
|
||||
ret = x.decode(encoding, 'replace').encode('utf-8')
|
||||
except:
|
||||
ret = x.decode('utf-8', 'replace').encode('utf-8')
|
||||
ret = x.decode(encoding).encode('utf-8')
|
||||
except UnicodeError:
|
||||
try:
|
||||
ret = x.decode('utf-8').encode('utf-8')
|
||||
except UnicodeError:
|
||||
try:
|
||||
ret = x.decode('latin-1').encode('utf-8')
|
||||
except UnicodeError:
|
||||
ret = x.decode('utf-8', 'replace').encode('utf-8')
|
||||
|
||||
return ret
|
||||
|
||||
def RenameProcess(new_name):
|
||||
@@ -509,8 +518,8 @@ def get_language_list_gui():
|
||||
language['bad_pass'] = _('Connection Failed: Could not authenticate (bad password?)')
|
||||
language['done'] = _('Done connecting...')
|
||||
language['scanning'] = _('Scanning')
|
||||
language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface." + \
|
||||
"This typically means there was a problem starting the daemon." + \
|
||||
language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface. " + \
|
||||
"This typically means there was a problem starting the daemon. " + \
|
||||
"Check the wicd log for more info")
|
||||
language['lost_dbus'] = _("The wicd daemon has shut down, the UI will not function properly until it is restarted.")
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ class PreferencesDialog(object):
|
||||
dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio,
|
||||
self.pumpradio]
|
||||
dhcp_method = daemon.GetDHCPClient()
|
||||
print 'DHCP method is %s' % daemon.GetDHCPClient()
|
||||
dhcp_list[dhcp_method].set_active(True)
|
||||
|
||||
wired_link_list = [self.linkautoradio, self.ethtoolradio,
|
||||
@@ -94,21 +95,10 @@ class PreferencesDialog(object):
|
||||
self.entryWirelessInterface.set_text(daemon.GetWirelessInterface())
|
||||
self.entryWiredInterface.set_text(daemon.GetWiredInterface())
|
||||
|
||||
found = False
|
||||
def_driver = daemon.GetWPADriver()
|
||||
for i, x in enumerate(self.wpadrivers):
|
||||
if x == def_driver: #and not found:
|
||||
found = True
|
||||
user_driver_index = i
|
||||
self.wpadrivercombo.remove_text(i)
|
||||
self.wpadrivercombo.append_text(x)
|
||||
|
||||
# Set the active choice here. Doing it before all the items are
|
||||
# added the combobox causes the choice to be reset.
|
||||
if found:
|
||||
self.wpadrivercombo.set_active(user_driver_index)
|
||||
else:
|
||||
# Use wext as default, since normally it is the correct driver.
|
||||
try:
|
||||
self.wpadrivercombo.set_active(self.wpadrivers.index(def_driver))
|
||||
except ValueError:
|
||||
self.wpadrivercombo.set_active(0)
|
||||
|
||||
self.useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle,
|
||||
@@ -128,22 +118,12 @@ class PreferencesDialog(object):
|
||||
self.dns2Entry.set_sensitive(False)
|
||||
self.dns3Entry.set_sensitive(False)
|
||||
|
||||
# Load backend combobox
|
||||
self.backends = daemon.GetBackendList()
|
||||
# "" is included as a hack for DBus limitations, so we remove it.
|
||||
self.backends.remove("")
|
||||
found = False
|
||||
cur_backend = daemon.GetSavedBackend()
|
||||
for i, x in enumerate(self.backends):
|
||||
if x == cur_backend:
|
||||
found = True
|
||||
backend_index = i
|
||||
self.backendcombo.remove_text(i)
|
||||
self.backendcombo.append_text(x)
|
||||
|
||||
if found:
|
||||
self.backendcombo.set_active(backend_index)
|
||||
else:
|
||||
self.backendcombo.set_active(0)
|
||||
|
||||
try:
|
||||
self.backendcombo.set_active(self.backends.index(cur_backend))
|
||||
except ValueError:
|
||||
self.backendcombo.set_active(0)
|
||||
|
||||
self.wTree.get_widget("notebook2").set_current_page(0)
|
||||
@@ -234,32 +214,34 @@ class PreferencesDialog(object):
|
||||
def setup_label(name, lbl=""):
|
||||
""" Sets up a label for the given widget name. """
|
||||
widget = self.wTree.get_widget(name)
|
||||
if lbl:
|
||||
widget.set_label(language[lbl])
|
||||
# if lbl:
|
||||
# widget.set_label(language[lbl])
|
||||
if widget is None:
|
||||
raise ValueError('widget %s does not exist' % name)
|
||||
return widget
|
||||
|
||||
# External Programs tab
|
||||
self.wTree.get_widget("gen_settings_label").set_label(language["gen_settings"])
|
||||
self.wTree.get_widget("ext_prog_label").set_label(language["ext_programs"])
|
||||
self.wTree.get_widget("dhcp_client_label").set_label(language["dhcp_client"])
|
||||
self.wTree.get_widget("wired_detect_label").set_label(language["wired_detect"])
|
||||
self.wTree.get_widget("route_flush_label").set_label(language["route_flush"])
|
||||
self.wTree.get_widget("pref_backend_label").set_label(language["backend"] + ":")
|
||||
# self.wTree.get_widget("gen_settings_label").set_label(language["gen_settings"])
|
||||
# self.wTree.get_widget("ext_prog_label").set_label(language["ext_programs"])
|
||||
# self.wTree.get_widget("dhcp_client_label").set_label(language["dhcp_client"])
|
||||
# self.wTree.get_widget("wired_detect_label").set_label(language["wired_detect"])
|
||||
# self.wTree.get_widget("route_flush_label").set_label(language["route_flush"])
|
||||
# self.wTree.get_widget("pref_backend_label").set_label(language["backend"] + ":")
|
||||
|
||||
entryWiredAutoMethod = self.wTree.get_widget("pref_wired_auto_label")
|
||||
entryWiredAutoMethod.set_label('Wired Autoconnect Setting:')
|
||||
entryWiredAutoMethod.set_alignment(0, 0)
|
||||
atrlist = pango.AttrList()
|
||||
atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50))
|
||||
entryWiredAutoMethod.set_attributes(atrlist)
|
||||
# entryWiredAutoMethod = self.wTree.get_widget("pref_wired_auto_label")
|
||||
# entryWiredAutoMethod.set_label('Wired Autoconnect Setting:')
|
||||
# entryWiredAutoMethod.set_alignment(0, 0)
|
||||
# atrlist = pango.AttrList()
|
||||
# atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50))
|
||||
# entryWiredAutoMethod.set_attributes(atrlist)
|
||||
|
||||
self.set_label("pref_dns1_label", "%s %s" % (language['dns'], language['1']))
|
||||
self.set_label("pref_dns2_label", "%s %s" % (language['dns'], language['2']))
|
||||
self.set_label("pref_dns3_label", "%s %s" % (language['dns'], language['3']))
|
||||
self.set_label("pref_search_dom_label", "%s:" % language['search_domain'])
|
||||
self.set_label("pref_wifi_label", "%s:" % language['wireless_interface'])
|
||||
self.set_label("pref_wired_label", "%s:" % language['wired_interface'])
|
||||
self.set_label("pref_driver_label", "%s:" % language['wpa_supplicant_driver'])
|
||||
# self.set_label("pref_dns1_label", "%s %s" % (language['dns'], language['1']))
|
||||
# self.set_label("pref_dns2_label", "%s %s" % (language['dns'], language['2']))
|
||||
# self.set_label("pref_dns3_label", "%s %s" % (language['dns'], language['3']))
|
||||
# self.set_label("pref_search_dom_label", "%s:" % language['search_domain'])
|
||||
# self.set_label("pref_wifi_label", "%s:" % language['wireless_interface'])
|
||||
# self.set_label("pref_wired_label", "%s:" % language['wired_interface'])
|
||||
# self.set_label("pref_driver_label", "%s:" % language['wpa_supplicant_driver'])
|
||||
|
||||
self.dialog = self.wTree.get_widget("pref_dialog")
|
||||
self.dialog.set_title(language['preferences'])
|
||||
@@ -315,6 +297,9 @@ class PreferencesDialog(object):
|
||||
"ndiswrapper", "ipw"]
|
||||
self.wpadrivers = wireless.GetWpaSupplicantDrivers(self.wpadrivers)
|
||||
self.wpadrivers.append("ralink_legacy")
|
||||
|
||||
for x in self.wpadrivers:
|
||||
self.wpadrivercombo.append_text(x)
|
||||
|
||||
self.entryWirelessInterface = self.wTree.get_widget("pref_wifi_entry")
|
||||
self.entryWiredInterface = self.wTree.get_widget("pref_wired_entry")
|
||||
@@ -327,4 +312,13 @@ class PreferencesDialog(object):
|
||||
self.dns2Entry = self.wTree.get_widget("pref_dns2_entry")
|
||||
self.dns3Entry = self.wTree.get_widget("pref_dns3_entry")
|
||||
|
||||
self.backendcombo = build_combobox("pref_backend_combobox")
|
||||
self.backendcombo = build_combobox("pref_backend_combobox")
|
||||
# Load backend combobox
|
||||
self.backends = daemon.GetBackendList()
|
||||
# "" is included as a hack for DBus limitations, so we remove it.
|
||||
self.backends.remove("")
|
||||
|
||||
cur_backend = daemon.GetSavedBackend()
|
||||
for x in self.backends:
|
||||
self.backendcombo.append_text(x)
|
||||
|
||||
|
||||
@@ -364,7 +364,8 @@ class TrayIcon(object):
|
||||
if DBUS_AVAIL:
|
||||
self.toggle_wicd_gui()
|
||||
else:
|
||||
gui.error(None, language["daemon_unavailable"])
|
||||
# gui.error(None, language["daemon_unavailable"])
|
||||
pass
|
||||
|
||||
def on_quit(self, widget=None):
|
||||
""" Closes the tray icon. """
|
||||
|
||||
@@ -41,7 +41,7 @@ import misc
|
||||
RALINK_DRIVER = 'ralink legacy'
|
||||
|
||||
|
||||
blacklist_strict = punctuation.replace("-", "") + " "
|
||||
blacklist_strict = '!"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ '
|
||||
blacklist_norm = ";`$!*|><&\\"
|
||||
blank_trans = maketrans("", "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user