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

Fixed more signal display issues

Added a "Connecting..." dialog to tray icon in experimental branch
Possibly fixed issue where GUI statusbar would still show up as connected when ethernet cable was unplugged.
This commit is contained in:
imdano
2007-09-20 13:11:43 +00:00
parent 6f0faa1ac2
commit 2aa36c7329
5 changed files with 70 additions and 17 deletions

View File

@@ -314,10 +314,10 @@ class ConnectionWizard(dbus.service.Object):
def FormatSignalForPrinting(self, signal):
''' Returns the suffix to display after the signal strength number '''
if self.GetSignalDisplayType() == 1:
return ("-" + signal + " dBm")
return (signal + " dBm")
else:
return (signal + "%")
# End function GetSignalSuffix
# End function FormatSignalForPrinting
@dbus.service.method('org.wicd.daemon')
@@ -587,6 +587,13 @@ class ConnectionWizard(dbus.service.Object):
return strength
#end function GetCurrentSignalStrength
@dbus.service.method('org.wicd.daemon.wireless')
def GetCurrentDBMStrength(self):
''' returns the current dbm signal strength '''
dbm_strength = int(self.wifi.GetDBMStrength())
return dbm_strength
@dbus.service.method('org.wicd.daemon.wireless')
def GetCurrentNetwork(self):
'''returns the current network'''

20
edgy.py
View File

@@ -75,6 +75,7 @@ language = {}
language['connected_to_wireless'] = _('Connected to $A at $B (IP: $C)')
language['connected_to_wired'] = _('Connected to wired network (IP: $A)')
language['not_connected'] = _('Not connected')
language['connecting'] = _('Connecting...')
class TrayIconInfo():
''' class for updating the tray icon status '''
@@ -111,7 +112,10 @@ class TrayIconInfo():
Checks for and updates the tray icon for an active wireless connection
'''
if daemon.GetSignalDisplayType() == 0:
wireless_signal = int(wireless.GetCurrentSignalStrength())
else:
wireless_signal = int(wireless.GetCurrentDBMStrength())
# Only update if the signal strength has changed because doing I/O
# calls is expensive, and the icon flickers
@@ -136,8 +140,7 @@ class TrayIconInfo():
self.network = str(wireless.GetCurrentNetwork())
tr.set_tooltip(language['connected_to_wireless'].replace
('$A', self.network).replace
('$B', daemon.FormatSignalForPrinting
(str(wireless_signal))).replace
('$B', daemon.FormatSignalForPrinting(str(wireless_signal))).replace
('$C', str(wireless_ip)))
self.set_signal_image(wireless_signal, lock)
@@ -161,6 +164,9 @@ class TrayIconInfo():
self.check_for_wireless_connection(wireless_ip)
else: # No connection at all
tr.set_from_file("images/no-signal.png")
if daemon.CheckIfConnecting():
tr.set_tooltip(language['connecting'])
else:
tr.set_tooltip(language['not_connected'])
self.auto_reconnect()
@@ -171,6 +177,7 @@ class TrayIconInfo():
def set_signal_image(self, wireless_signal, lock):
''' Sets the tray icon picture for an active wireless connection '''
if daemon.GetSignalDisplayType() == 0:
if wireless_signal > 75:
tr.set_from_file("images/high-signal" + lock + ".png")
elif wireless_signal > 50:
@@ -183,6 +190,15 @@ class TrayIconInfo():
tr.set_from_file("images/no-signal.png")
# If we have no signal, we should try to reconnect.
self.auto_reconnect()
else:
if wireless_signal >= -60:
tr.set_from_file(wpath.images + "high-signal" + lock + ".png")
elif wireless_signal >= -70:
tr.set_from_file(wpath.images + "good-signal" + lock + ".png")
elif wireless_signal >= -80:
tr.set_from_file(wpath.images + "low-signal" + lock + ".png")
else:
tr.set_from_file(wpath.images + "bad-signal" + lock + ".png")
def auto_reconnect(self):
''' Automatically reconnects to a network if needed

29
gui.py
View File

@@ -131,6 +131,7 @@ language['after_script'] = _('Run script after connect')
language['disconnect_script'] = _('Run disconnect script')
language['script_settings'] = _('Scripts')
language['use_ics'] = _('Activate Internet Connection Sharing')
language['madwifi_for_adhoc'] = _('Check if using madwifi/atheros drivers')
language['default_wired'] = _('Use as default profile (overwrites any previous default)')
language['use_debug_mode'] = _('Enable debug mode')
language['use_global_dns'] = _('Use global DNS servers')
@@ -224,7 +225,7 @@ class LabelEntry(gtk.HBox):
self.auto_hide_text = value
def show_characters(self,widget=None,event=None):
#when the box has focus, show the characters
# When the box has focus, show the characters
if self.auto_hide_text and widget:
self.entry.set_visibility(True)
@@ -342,7 +343,7 @@ class PrettyWirelessNetworkEntry(PrettyNetworkEntry):
if strength is not None:
strength = int(strength)
else:
dbm_strength = -1
strength = -1
if dbm_strength is not None:
dbm_strength = int(dbm_strength)
else:
@@ -794,11 +795,11 @@ class WirelessNetworkEntry(NetworkEntry):
display_type = daemon.GetSignalDisplayType()
if daemon.GetWPADriver() == 'ralink legacy' or display_type == 1:
ending = "dBm"
start = "-"
disp_strength = str(dbm_strength)
else:
ending = "%"
start = ""
self.lblStrength.set_label(start + str(strength) + ending)
disp_strength = str(strength)
self.lblStrength.set_label(disp_strength + ending)
def setMACAddress(self,address):
self.lblMAC.set_label(str(address))
@@ -810,7 +811,8 @@ class WirelessNetworkEntry(NetworkEntry):
self.set_label(self.essid + ' <span color="#666666">' + str(type) + '</span>')
if on and not type:
self.lblEncryption.set_label(language['secured'])
self.set_label(self.essid + ' <span color="#666666">Secured</span>')
self.set_use_markup(True)
self.set_label(self.essid + ' <span color="#666666">' + 'Secured' + '</span>')
if not on:
self.lblEncryption.set_label(language['unsecured'])
@@ -912,7 +914,9 @@ class appGui:
'''shows a dialog that creates a new adhoc network'''
#create a new adhoc network here.
print 'create adhoc network'
dialog = gtk.Dialog(title=language['create_adhoc_network'], flags = gtk.DIALOG_MODAL, buttons=(gtk.STOCK_OK,1,gtk.STOCK_CANCEL,2))
dialog = gtk.Dialog(title = language['create_adhoc_network'],
flags = gtk.DIALOG_MODAL,
buttons=(gtk.STOCK_OK, 1, gtk.STOCK_CANCEL, 2))
dialog.set_has_separator(False)
dialog.set_size_request(400,-1)
self.useEncryptionCheckbox = gtk.CheckButton(language['use_wep_encryption'])
@@ -1144,19 +1148,24 @@ class appGui:
network = wireless.GetCurrentNetwork()
if network:
strength = wireless.GetCurrentSignalStrength()
if strength != None: #do this because if strength is 0, if strength: doesn't work
dbm_strength = wireless.GetCurrentDBMStrength()
if strength is not None and dbm_strength is not None:
network = str(network)
if daemon.GetSignalDisplayType() == 0:
strength = str(strength)
else:
strength = str(dbm_strength)
ip = str(wireless_ip)
self.statusID=self.status_bar.push(1, language['connected_to_wireless'].replace
('$A',network).replace('$B',daemon.FormatSignalForPrinting(strength)).replace
('$A',network).replace
('$B',daemon.FormatSignalForPrinting(strength)).replace
('$C',wireless_ip))
if not daemon.GetDebugMode():
config.EnableLogging()
return True
wired_ip = wired.GetWiredIP()
if wired_ip:
if wired.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
if wired.CheckPluggedIn():
self.statusID = self.status_bar.push(1,language['connected_to_wired'].replace('$A',wired_ip))
if not daemon.GetDebugMode():
config.EnableLogging()

View File

@@ -208,6 +208,17 @@ class Wireless(Controller):
self.wpa_driver)
return wiface.GetSignalStrength()
def GetDBMStrength(self):
""" Get the dBm signal strength of the current network.
Returns:
The current dBm signal strength.
"""
wiface = wnettools.WirelessInterface(self.wireless_interface,
self.wpa_driver)
return wiface.GetDBMStrength()
def GetCurrentNetwork(self):
""" Get current network name.

View File

@@ -526,9 +526,7 @@ class WirelessInterface(Interface):
"""
if network.get('key') != None:
iwpriv = misc.Run('iwpriv ' + self.iface + ' get_site_survey')
lines = iwpriv.splitlines()
lines = lines[2:]
lines = self._GetRalinkInfo()
for x in lines:
info = x.split()
if len(info) < 5:
@@ -589,6 +587,18 @@ class WirelessInterface(Interface):
return strength
def GetDBMStrength(self):
""" Get the dBm signal strength of the current network.
Returns:
The dBm signal strength.
"""
cmd = 'iwconfig ' + self.iface
if self.verbose: print cmd
output = misc.Run(cmd)
dbm_strength = misc.RunRegex(signaldbm_pattern,output)
return dbm_strength
def GetCurrentNetwork(self):
""" Get the essid of the current network.