mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
Merge r450 of mainline 1.6.
This commit is contained in:
@@ -33,10 +33,6 @@ def error(ui,parent,message):
|
|||||||
dialog = TextDialog(message,6,40,('important',"ERROR"))
|
dialog = TextDialog(message,6,40,('important',"ERROR"))
|
||||||
return dialog.run(ui,parent)
|
return dialog.run(ui,parent)
|
||||||
|
|
||||||
# My savior. :-)
|
|
||||||
# Although I could have made this myself pretty easily, just want to give credit
|
|
||||||
# where it's due.
|
|
||||||
# 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."""
|
||||||
|
|
||||||
@@ -253,7 +249,7 @@ class ComboBoxException(Exception):
|
|||||||
# 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/kludge. 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 API before we can actually
|
||||||
# make a real ComboBox.
|
# make a real ComboBox.
|
||||||
class ComboBox(urwid.WidgetWrap):
|
class ComboBox(urwid.WidgetWrap):
|
||||||
"""A ComboBox of text objects"""
|
"""A ComboBox of text objects"""
|
||||||
@@ -333,9 +329,8 @@ class ComboBox(urwid.WidgetWrap):
|
|||||||
str,trash = self.label.get_text()
|
str,trash = self.label.get_text()
|
||||||
|
|
||||||
self.overlay = None
|
self.overlay = None
|
||||||
#w,sensitive=True,attrs=('editbx','editnfc'),focus_attr='editfc')
|
|
||||||
self.cbox = DynWrap(SelText(self.DOWN_ARROW),attrs=attrs,focus_attr=focus_attr)
|
self.cbox = DynWrap(SelText(self.DOWN_ARROW),attrs=attrs,focus_attr=focus_attr)
|
||||||
# Unicode will kill me sooner or later. ^_^
|
# Unicode will kill me sooner or later.
|
||||||
if label != '':
|
if label != '':
|
||||||
w = urwid.Columns([('fixed',len(str),self.label),self.cbox],dividechars=1)
|
w = urwid.Columns([('fixed',len(str),self.label),self.cbox],dividechars=1)
|
||||||
else:
|
else:
|
||||||
@@ -344,10 +339,9 @@ class ComboBox(urwid.WidgetWrap):
|
|||||||
|
|
||||||
# We need this to pick our keypresses
|
# We need this to pick our keypresses
|
||||||
self.use_enter = use_enter
|
self.use_enter = use_enter
|
||||||
# The Focus
|
|
||||||
self.focus = focus
|
self.focus = focus
|
||||||
|
|
||||||
# The callback and friends
|
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.user_args = user_args
|
self.user_args = user_args
|
||||||
|
|
||||||
@@ -442,11 +436,6 @@ class Dialog2(urwid.WidgetWrap):
|
|||||||
urwid.Divider()] )
|
urwid.Divider()] )
|
||||||
w = self.frame
|
w = self.frame
|
||||||
self.view = w
|
self.view = w
|
||||||
|
|
||||||
# pad area around listbox
|
|
||||||
#w = urwid.Padding(w, ('fixed left',2), ('fixed right',2))
|
|
||||||
#w = urwid.Filler(w, ('fixed top',1), ('fixed bottom',1))
|
|
||||||
#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):
|
||||||
@@ -503,8 +492,6 @@ class Dialog2(urwid.WidgetWrap):
|
|||||||
class TextDialog(Dialog2):
|
class TextDialog(Dialog2):
|
||||||
def __init__(self, text, height, width, header=None,align='left'):
|
def __init__(self, text, height, width, header=None,align='left'):
|
||||||
l = [urwid.Text(text)]
|
l = [urwid.Text(text)]
|
||||||
#for line in text:
|
|
||||||
# l.append( urwid.Text( line,align=align))
|
|
||||||
body = urwid.ListBox(l)
|
body = urwid.ListBox(l)
|
||||||
body = urwid.AttrWrap(body, 'body')
|
body = urwid.AttrWrap(body, 'body')
|
||||||
|
|
||||||
@@ -596,7 +583,6 @@ class OptCols(urwid.WidgetWrap):
|
|||||||
else:
|
else:
|
||||||
key += part
|
key += part
|
||||||
|
|
||||||
#theText = urwid.Text([(attrs[0],cmd[0]),(attrs[1],cmd[1])])
|
|
||||||
if debug:
|
if debug:
|
||||||
callback = self.debugClick
|
callback = self.debugClick
|
||||||
args = cmd[1]
|
args = cmd[1]
|
||||||
@@ -608,9 +594,6 @@ class OptCols(urwid.WidgetWrap):
|
|||||||
('fixed',len(key)+1,urwid.Text((attrs[0],key+':')) ),
|
('fixed',len(key)+1,urwid.Text((attrs[0],key+':')) ),
|
||||||
urwid.AttrWrap(urwid.Text(cmd[1]),attrs[1])],
|
urwid.AttrWrap(urwid.Text(cmd[1]),attrs[1])],
|
||||||
callback,args)
|
callback,args)
|
||||||
#if i != len(tuples)-1:
|
|
||||||
# textList.append(('fixed',maxlen,col))
|
|
||||||
#else: # The last one
|
|
||||||
textList.append(col)
|
textList.append(col)
|
||||||
i+=1
|
i+=1
|
||||||
if debug:
|
if debug:
|
||||||
@@ -625,19 +608,3 @@ class OptCols(urwid.WidgetWrap):
|
|||||||
def mouse_event(self,size,event,button,x,y,focus):
|
def mouse_event(self,size,event,button,x,y,focus):
|
||||||
# Widgets are evenly long (as of current), so...
|
# Widgets are evenly long (as of current), so...
|
||||||
return self._w.mouse_event(size,event,button,x,y,focus)
|
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]()
|
|
||||||
"""
|
|
||||||
|
|||||||
@@ -383,18 +383,25 @@ class WiredComboBox(ComboBox):
|
|||||||
|
|
||||||
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 = ComboBox.keypress(self,size,key)
|
||||||
if self.get_focus()[1] == len(self.list)-1:
|
if key == ' ':
|
||||||
dialog = InputDialog(('header',language["add_new_wired_profile"]),7,30)
|
if self.get_focus()[1] == len(self.list)-1:
|
||||||
|
dialog = InputDialog(('header',language["add_new_wired_profile"]),7,30)
|
||||||
exitcode,name = dialog.run(ui,self.parent)
|
exitcode,name = dialog.run(ui,self.parent)
|
||||||
if exitcode == 0:
|
if exitcode == 0:
|
||||||
wired.CreateWiredNetworkProfile(name,False)
|
name = name.strip()
|
||||||
self.set_list(wired.GetWiredProfileList())
|
if not name:
|
||||||
self.rebuild_combobox()
|
error(ui,self.parent,'Invalid profile name')
|
||||||
self.set_focus(prev_focus)
|
self.set_focus(prev_focus)
|
||||||
else:
|
return key
|
||||||
wired.ReadWiredNetworkProfile(self.get_selected_profile())
|
|
||||||
|
wired.CreateWiredNetworkProfile(name,False)
|
||||||
|
self.set_list(wired.GetWiredProfileList())
|
||||||
|
self.rebuild_combobox()
|
||||||
|
self.set_focus(prev_focus)
|
||||||
|
else:
|
||||||
|
print "updating..."
|
||||||
|
wired.ReadWiredNetworkProfile(self.get_selected_profile())
|
||||||
if key == 'delete':
|
if key == 'delete':
|
||||||
if len(self.theList) == 1:
|
if len(self.theList) == 1:
|
||||||
error(self.ui,self.parent,language["no_delete_last_profile"])
|
error(self.ui,self.parent,language["no_delete_last_profile"])
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -526,7 +526,7 @@ try:
|
|||||||
data.append((wpath.resume, ['other/80-wicd-connect.sh' ]))
|
data.append((wpath.resume, ['other/80-wicd-connect.sh' ]))
|
||||||
data.append((wpath.suspend, ['other/50-wicd-suspend.sh' ]))
|
data.append((wpath.suspend, ['other/50-wicd-suspend.sh' ]))
|
||||||
if not wpath.no_install_pmutils:
|
if not wpath.no_install_pmutils:
|
||||||
data.append((wpath.pmutils, ['other/55wicd' ]))
|
data.append((wpath.pmutils, ['other/91wicd' ]))
|
||||||
print 'Using pid path', os.path.basename(wpath.pidfile)
|
print 'Using pid path', os.path.basename(wpath.pidfile)
|
||||||
print 'Language support for',
|
print 'Language support for',
|
||||||
for language in os.listdir('translations/'):
|
for language in os.listdir('translations/'):
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class WirelessInterface(Interface, BaseWirelessInterface):
|
|||||||
try:
|
try:
|
||||||
results = self.scan_iface.Scan()
|
results = self.scan_iface.Scan()
|
||||||
except iwscan.error, e:
|
except iwscan.error, e:
|
||||||
print "ERROR: %s"
|
print "ERROR: %s" % e
|
||||||
return []
|
return []
|
||||||
return filter(None, [self._parse_ap(cell) for cell in results])
|
return filter(None, [self._parse_ap(cell) for cell in results])
|
||||||
|
|
||||||
|
|||||||
@@ -655,17 +655,16 @@ class WiredNetworkEntry(NetworkEntry):
|
|||||||
|
|
||||||
def add_profile(self, widget):
|
def add_profile(self, widget):
|
||||||
""" Add a profile to the profile list. """
|
""" Add a profile to the profile list. """
|
||||||
print "adding profile"
|
|
||||||
|
|
||||||
response = string_input("Enter a profile name", "The profile name " +
|
response = string_input("Enter a profile name", "The profile name " +
|
||||||
"will not be used by the computer. It " +
|
"will not be used by the computer. It " +
|
||||||
"allows you to " +
|
"allows you to " +
|
||||||
"easily distinguish between different network " +
|
"easily distinguish between different network " +
|
||||||
"profiles.", "Profile name:")
|
"profiles.", "Profile name:").strip()
|
||||||
|
|
||||||
# if response is "" or None
|
# if response is "" or None
|
||||||
if not response:
|
if not response:
|
||||||
return
|
error(None, "Invalid profile name", block=True)
|
||||||
|
return False
|
||||||
|
|
||||||
profile_name = response
|
profile_name = response
|
||||||
profile_list = wired.GetWiredProfileList()
|
profile_list = wired.GetWiredProfileList()
|
||||||
|
|||||||
@@ -866,7 +866,8 @@ class WirelessConnectThread(ConnectThread):
|
|||||||
if self.network.get('enctype'):
|
if self.network.get('enctype'):
|
||||||
self.SetStatus('validating_authentication')
|
self.SetStatus('validating_authentication')
|
||||||
if not wiface.ValidateAuthentication(time.time()):
|
if not wiface.ValidateAuthentication(time.time()):
|
||||||
if not self.connect_result:
|
print "connect result is %s" % self.connect_result
|
||||||
|
if not self.connect_result or self.connect_result == 'Failed':
|
||||||
self.abort_connection('bad_pass')
|
self.abort_connection('bad_pass')
|
||||||
|
|
||||||
# Set up gateway, IP address, and DNS servers.
|
# Set up gateway, IP address, and DNS servers.
|
||||||
|
|||||||
@@ -44,11 +44,10 @@ def get_gettext():
|
|||||||
lc, encoding = locale.getdefaultlocale(envvars=('LC_MESSAGES',
|
lc, encoding = locale.getdefaultlocale(envvars=('LC_MESSAGES',
|
||||||
'LC_ALL', 'LANG',
|
'LC_ALL', 'LANG',
|
||||||
'LANGUAGE'))
|
'LANGUAGE'))
|
||||||
|
langs += [lc]
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
print str(e)
|
print str(e)
|
||||||
print "Default locale unavailable, falling back to en_US"
|
print "Default locale unavailable, falling back to en_US"
|
||||||
if (lc):
|
|
||||||
langs += [lc]
|
|
||||||
langs += ["en_US"]
|
langs += ["en_US"]
|
||||||
lang = gettext.translation('wicd', local_path, languages=langs,
|
lang = gettext.translation('wicd', local_path, languages=langs,
|
||||||
fallback=True)
|
fallback=True)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
self._debug_mode = bool(self.config.get("Settings", "debug_mode"))
|
self._debug_mode = bool(self.config.get("Settings", "debug_mode"))
|
||||||
self.wifi = networking.Wireless(debug=self._debug_mode)
|
self.wifi = networking.Wireless(debug=self._debug_mode)
|
||||||
self.wired = networking.Wired(debug=self._debug_mode)
|
self.wired = networking.Wired(debug=self._debug_mode)
|
||||||
self.wired_bus= WiredDaemon(bus_name, self, wired=self.wired)
|
self.wired_bus = WiredDaemon(bus_name, self, wired=self.wired)
|
||||||
self.wireless_bus = WirelessDaemon(bus_name, self, wifi=self.wifi)
|
self.wireless_bus = WirelessDaemon(bus_name, self, wifi=self.wifi)
|
||||||
self.forced_disconnect = False
|
self.forced_disconnect = False
|
||||||
self.need_profile_chooser = False
|
self.need_profile_chooser = False
|
||||||
@@ -518,7 +518,7 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
# 1 = default profile
|
# 1 = default profile
|
||||||
# 2 = show list
|
# 2 = show list
|
||||||
# 3 = last used profile
|
# 3 = last used profile
|
||||||
self.config.set("Settings","wired_connect_mode", int(method),
|
self.config.set("Settings", "wired_connect_mode", int(method),
|
||||||
write=True)
|
write=True)
|
||||||
self.wired_connect_mode = int(method)
|
self.wired_connect_mode = int(method)
|
||||||
self.wired_bus.connect_mode = int(method)
|
self.wired_bus.connect_mode = int(method)
|
||||||
@@ -856,7 +856,7 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
"""
|
"""
|
||||||
b_wired = self.wired_bus
|
b_wired = self.wired_bus
|
||||||
b_wifi = self.wireless_bus
|
b_wifi = self.wireless_bus
|
||||||
app_conf= self.config
|
app_conf = self.config
|
||||||
# Load the backend.
|
# Load the backend.
|
||||||
be_def = 'external'
|
be_def = 'external'
|
||||||
self.SetBackend(app_conf.get("Settings", "backend", default=be_def))
|
self.SetBackend(app_conf.get("Settings", "backend", default=be_def))
|
||||||
@@ -880,7 +880,7 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
dns1 = app_conf.get("Settings", "global_dns_1", default='None')
|
dns1 = app_conf.get("Settings", "global_dns_1", default='None')
|
||||||
dns2 = app_conf.get("Settings", "global_dns_2", default='None')
|
dns2 = app_conf.get("Settings", "global_dns_2", default='None')
|
||||||
dns3 = app_conf.get("Settings", "global_dns_3", default='None')
|
dns3 = app_conf.get("Settings", "global_dns_3", default='None')
|
||||||
dns_dom =app_conf.get("Settings", "global_dns_dom", default='None')
|
dns_dom = app_conf.get("Settings", "global_dns_dom", default='None')
|
||||||
search_dom = app_conf.get("Settings", "global_search_dom", default='None')
|
search_dom = app_conf.get("Settings", "global_search_dom", default='None')
|
||||||
self.SetGlobalDNS(dns1, dns2, dns3, dns_dom, search_dom)
|
self.SetGlobalDNS(dns1, dns2, dns3, dns_dom, search_dom)
|
||||||
self.SetAutoReconnect(app_conf.get("Settings", "auto_reconnect",
|
self.SetAutoReconnect(app_conf.get("Settings", "auto_reconnect",
|
||||||
@@ -1201,6 +1201,8 @@ class WirelessDaemon(dbus.service.Object):
|
|||||||
if cur_network["hidden"]:
|
if cur_network["hidden"]:
|
||||||
if cur_network.get("essid") in ["", "Hidden", "<hidden>", None]:
|
if cur_network.get("essid") in ["", "Hidden", "<hidden>", None]:
|
||||||
cur_network["essid"] = "<hidden>"
|
cur_network["essid"] = "<hidden>"
|
||||||
|
else:
|
||||||
|
cur_network['essid'] = self.config.get(section, 'essid')
|
||||||
return "100: Loaded Profile"
|
return "100: Loaded Profile"
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon.wireless')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
@@ -1448,7 +1450,7 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
if self.config.has_section(profilename):
|
if self.config.has_section(profilename):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for option in ["ip", "broadcast", "netmask","gateway", "search_domain",
|
for option in ["ip", "broadcast", "netmask", "gateway", "search_domain",
|
||||||
"dns_domain", "dns1", "dns2", "dns3", "beforescript",
|
"dns_domain", "dns1", "dns2", "dns3", "beforescript",
|
||||||
"afterscript", "predisconnectscript",
|
"afterscript", "predisconnectscript",
|
||||||
"postdisconnectscript"]:
|
"postdisconnectscript"]:
|
||||||
@@ -1506,8 +1508,10 @@ class WiredDaemon(dbus.service.Object):
|
|||||||
if not self.config.has_option(prof, script):
|
if not self.config.has_option(prof, script):
|
||||||
self.config.set(prof, script, None)
|
self.config.set(prof, script, None)
|
||||||
|
|
||||||
if profilename == "":
|
profilename = profilename.strip()
|
||||||
|
if not profilename:
|
||||||
self.config.write()
|
self.config.write()
|
||||||
|
print "Warning: Bad wired profile name given, ignoring."
|
||||||
return "500: Bad Profile name"
|
return "500: Bad Profile name"
|
||||||
if self.debug_mode:
|
if self.debug_mode:
|
||||||
print "saving wired profile %s" % profilename
|
print "saving wired profile %s" % profilename
|
||||||
|
|||||||
Reference in New Issue
Block a user