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

fixed bug where wired icon wouldn't change if cable became unplugged, fixed yet another indentation screw up

This commit is contained in:
imdano
2007-07-17 08:03:16 +00:00
parent 5bd069702d
commit e7fd625617

101
edgy.py
View File

@@ -87,61 +87,64 @@ def set_signal_image():
config.DisableLogging() config.DisableLogging()
wired_ip = wired.GetWiredIP() wired_ip = wired.GetWiredIP()
if wired.CheckPluggedIn() == True and wired_ip: if wired.CheckPluggedIn() == True and wired_ip != None:
if stillWired == False: # Only set image/tooltip if it hasn't been set already if stillWired == False: # Only set image/tooltip if it hasn't been set already
tr.set_from_file("images/wired.png") tr.set_from_file("images/wired.png")
tr.set_tooltip(language['connected_to_wired'].replace('$A',wired_ip)) tr.set_tooltip(language['connected_to_wired'].replace('$A',wired_ip))
stillWired = True stillWired = True
lock = '' lock = ''
else:
if stillWired == True:
tr.set_from_file("images/no-signal.png")
tr.set_tooltip(language['not_connected'])
stillWired = False
wireless_ip = wireless.GetWirelessIP()
#If ip returns as None, we are probably returning from hibernation and need to force signal to 0 to avoid crashing
if wireless_ip != None:
signal = int(wireless.GetCurrentSignalStrength())
else: else:
stillWired = False signal = 0
wireless_ip = wireless.GetWirelessIP()
#If ip returns as None, we are probably returning from hibernation and need to force signal to 0 to avoid crashing #only update if the signal strength has changed because doing I/O calls is expensive,
if wireless_ip != None: #and the icon flickers
signal = int(wireless.GetCurrentSignalStrength()) if (signal != LastStrength or network != wireless.GetCurrentNetwork()) and wireless_ip != None:
else: LastStrength = signal
signal = 0 lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing
curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray
#only update if the signal strength has changed because doing I/O calls is expensive, if signal > 0 and curNetID > -1 and wireless.GetWirelessProperty(curNetID,"encryption"):
#and the icon flickers lock = '-lock' #set the string to '-lock' so that it will display the lock picture
if (signal != LastStrength or network != wireless.GetCurrentNetwork()) and wireless_ip != None: network = str(wireless.GetCurrentNetwork())
LastStrength = signal tr.set_tooltip(language['connected_to_wireless'].replace('$A',network).replace('$B',str(signal)).replace('$C',str(wireless_ip)))
lock = '' #set the string to '' so that when it is put in "high-signal" + lock + ".png", there will be nothing if signal > 75:
curNetID = wireless.GetCurrentNetworkID() #the network ID needs to be checked because a negative value here will break the tray tr.set_from_file("images/high-signal" + lock + ".png")
if signal > 0 and curNetID > -1 and wireless.GetWirelessProperty(curNetID,"encryption"): elif signal > 50:
lock = '-lock' #set the string to '-lock' so that it will display the lock picture tr.set_from_file("images/good-signal" + lock + ".png")
network = str(wireless.GetCurrentNetwork()) elif signal > 25:
tr.set_tooltip(language['connected_to_wireless'].replace('$A',network).replace('$B',str(signal)).replace('$C',str(wireless_ip))) tr.set_from_file("images/low-signal" + lock + ".png")
if signal > 75: elif signal > 0:
tr.set_from_file("images/high-signal" + lock + ".png") tr.set_from_file("images/bad-signal" + lock + ".png")
elif signal > 50: elif signal == 0:
tr.set_from_file("images/good-signal" + lock + ".png") tr.set_from_file("images/no-signal.png")
elif signal > 25: #Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when
tr.set_from_file("images/low-signal" + lock + ".png") #a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works.
elif signal > 0: #First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to
tr.set_from_file("images/bad-signal" + lock + ".png") #connect to any network set to autoconnect.
elif signal == 0: if wireless.GetAutoReconnect() == True and wireless.CheckIfWirelessConnecting() == False and wireless.GetForcedDisconnect() == False:
tr.set_from_file("images/no-signal.png") curNetID = wireless.GetCurrentNetworkID()
#Auto-reconnect code - not sure how well this works. I know that without the ForcedDisconnect check it reconnects you when if curNetID > -1:
#a disconnect is forced. People who have disconnection problems need to test it to determine if it actually works. wireless.ConnectWireless(wireless.GetCurrentNetworkID())
#First it will attempt to reconnect to the last known wireless network, and if that fails it should run a scan and try to print 'Trying to autoreconnect'
#connect to any network set to autoconnect. while wireless.CheckIfWirelessConnecting() == True:
if wireless.GetAutoReconnect() == True and wireless.CheckIfWirelessConnecting() == False and wireless.GetForcedDisconnect() == False: time.sleep(1)
curNetID = wireless.GetCurrentNetworkID() if wireless.GetCurrentSignalStrength() != 0:
if curNetID > -1: print "Successfully autoreconnected."
wireless.ConnectWireless(wireless.GetCurrentNetworkID()) else:
print 'Trying to autoreconnect' print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
while wireless.CheckIfWirelessConnecting() == True: print wireless.AutoConnect(True)
time.sleep(1)
if wireless.GetCurrentSignalStrength() != 0: elif wireless_ip == None:
print "Successfully autoreconnected." tr.set_from_file("images/no-signal.png")
else: tr.set_tooltip(language['not_connected'])
print "Couldn't reconnect to last used network, scanning for an autoconnect network..."
print wireless.AutoConnect(True)
elif wireless_ip == None:
tr.set_from_file("images/no-signal.png")
tr.set_tooltip(language['not_connected'])
if not daemon.GetDebugMode(): if not daemon.GetDebugMode():
config.EnableLogging() config.EnableLogging()