mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48: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:
11
daemon.py
11
daemon.py
@@ -314,10 +314,10 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
def FormatSignalForPrinting(self, signal):
|
def FormatSignalForPrinting(self, signal):
|
||||||
''' Returns the suffix to display after the signal strength number '''
|
''' Returns the suffix to display after the signal strength number '''
|
||||||
if self.GetSignalDisplayType() == 1:
|
if self.GetSignalDisplayType() == 1:
|
||||||
return ("-" + signal + " dBm")
|
return (signal + " dBm")
|
||||||
else:
|
else:
|
||||||
return (signal + "%")
|
return (signal + "%")
|
||||||
# End function GetSignalSuffix
|
# End function FormatSignalForPrinting
|
||||||
|
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon')
|
@dbus.service.method('org.wicd.daemon')
|
||||||
@@ -587,6 +587,13 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
return strength
|
return strength
|
||||||
#end function GetCurrentSignalStrength
|
#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')
|
@dbus.service.method('org.wicd.daemon.wireless')
|
||||||
def GetCurrentNetwork(self):
|
def GetCurrentNetwork(self):
|
||||||
'''returns the current network'''
|
'''returns the current network'''
|
||||||
|
|||||||
20
edgy.py
20
edgy.py
@@ -75,6 +75,7 @@ language = {}
|
|||||||
language['connected_to_wireless'] = _('Connected to $A at $B (IP: $C)')
|
language['connected_to_wireless'] = _('Connected to $A at $B (IP: $C)')
|
||||||
language['connected_to_wired'] = _('Connected to wired network (IP: $A)')
|
language['connected_to_wired'] = _('Connected to wired network (IP: $A)')
|
||||||
language['not_connected'] = _('Not connected')
|
language['not_connected'] = _('Not connected')
|
||||||
|
language['connecting'] = _('Connecting...')
|
||||||
|
|
||||||
class TrayIconInfo():
|
class TrayIconInfo():
|
||||||
''' class for updating the tray icon status '''
|
''' 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
|
Checks for and updates the tray icon for an active wireless connection
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
if daemon.GetSignalDisplayType() == 0:
|
||||||
wireless_signal = int(wireless.GetCurrentSignalStrength())
|
wireless_signal = int(wireless.GetCurrentSignalStrength())
|
||||||
|
else:
|
||||||
|
wireless_signal = int(wireless.GetCurrentDBMStrength())
|
||||||
|
|
||||||
# Only update if the signal strength has changed because doing I/O
|
# Only update if the signal strength has changed because doing I/O
|
||||||
# calls is expensive, and the icon flickers
|
# calls is expensive, and the icon flickers
|
||||||
@@ -136,8 +140,7 @@ class TrayIconInfo():
|
|||||||
self.network = str(wireless.GetCurrentNetwork())
|
self.network = str(wireless.GetCurrentNetwork())
|
||||||
tr.set_tooltip(language['connected_to_wireless'].replace
|
tr.set_tooltip(language['connected_to_wireless'].replace
|
||||||
('$A', self.network).replace
|
('$A', self.network).replace
|
||||||
('$B', daemon.FormatSignalForPrinting
|
('$B', daemon.FormatSignalForPrinting(str(wireless_signal))).replace
|
||||||
(str(wireless_signal))).replace
|
|
||||||
('$C', str(wireless_ip)))
|
('$C', str(wireless_ip)))
|
||||||
self.set_signal_image(wireless_signal, lock)
|
self.set_signal_image(wireless_signal, lock)
|
||||||
|
|
||||||
@@ -161,6 +164,9 @@ class TrayIconInfo():
|
|||||||
self.check_for_wireless_connection(wireless_ip)
|
self.check_for_wireless_connection(wireless_ip)
|
||||||
else: # No connection at all
|
else: # No connection at all
|
||||||
tr.set_from_file("images/no-signal.png")
|
tr.set_from_file("images/no-signal.png")
|
||||||
|
if daemon.CheckIfConnecting():
|
||||||
|
tr.set_tooltip(language['connecting'])
|
||||||
|
else:
|
||||||
tr.set_tooltip(language['not_connected'])
|
tr.set_tooltip(language['not_connected'])
|
||||||
self.auto_reconnect()
|
self.auto_reconnect()
|
||||||
|
|
||||||
@@ -171,6 +177,7 @@ class TrayIconInfo():
|
|||||||
|
|
||||||
def set_signal_image(self, wireless_signal, lock):
|
def set_signal_image(self, wireless_signal, lock):
|
||||||
''' Sets the tray icon picture for an active wireless connection '''
|
''' Sets the tray icon picture for an active wireless connection '''
|
||||||
|
if daemon.GetSignalDisplayType() == 0:
|
||||||
if wireless_signal > 75:
|
if wireless_signal > 75:
|
||||||
tr.set_from_file("images/high-signal" + lock + ".png")
|
tr.set_from_file("images/high-signal" + lock + ".png")
|
||||||
elif wireless_signal > 50:
|
elif wireless_signal > 50:
|
||||||
@@ -183,6 +190,15 @@ class TrayIconInfo():
|
|||||||
tr.set_from_file("images/no-signal.png")
|
tr.set_from_file("images/no-signal.png")
|
||||||
# If we have no signal, we should try to reconnect.
|
# If we have no signal, we should try to reconnect.
|
||||||
self.auto_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):
|
def auto_reconnect(self):
|
||||||
''' Automatically reconnects to a network if needed
|
''' Automatically reconnects to a network if needed
|
||||||
|
|||||||
29
gui.py
29
gui.py
@@ -131,6 +131,7 @@ language['after_script'] = _('Run script after connect')
|
|||||||
language['disconnect_script'] = _('Run disconnect script')
|
language['disconnect_script'] = _('Run disconnect script')
|
||||||
language['script_settings'] = _('Scripts')
|
language['script_settings'] = _('Scripts')
|
||||||
language['use_ics'] = _('Activate Internet Connection Sharing')
|
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['default_wired'] = _('Use as default profile (overwrites any previous default)')
|
||||||
language['use_debug_mode'] = _('Enable debug mode')
|
language['use_debug_mode'] = _('Enable debug mode')
|
||||||
language['use_global_dns'] = _('Use global DNS servers')
|
language['use_global_dns'] = _('Use global DNS servers')
|
||||||
@@ -224,7 +225,7 @@ class LabelEntry(gtk.HBox):
|
|||||||
self.auto_hide_text = value
|
self.auto_hide_text = value
|
||||||
|
|
||||||
def show_characters(self,widget=None,event=None):
|
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:
|
if self.auto_hide_text and widget:
|
||||||
self.entry.set_visibility(True)
|
self.entry.set_visibility(True)
|
||||||
|
|
||||||
@@ -342,7 +343,7 @@ class PrettyWirelessNetworkEntry(PrettyNetworkEntry):
|
|||||||
if strength is not None:
|
if strength is not None:
|
||||||
strength = int(strength)
|
strength = int(strength)
|
||||||
else:
|
else:
|
||||||
dbm_strength = -1
|
strength = -1
|
||||||
if dbm_strength is not None:
|
if dbm_strength is not None:
|
||||||
dbm_strength = int(dbm_strength)
|
dbm_strength = int(dbm_strength)
|
||||||
else:
|
else:
|
||||||
@@ -794,11 +795,11 @@ class WirelessNetworkEntry(NetworkEntry):
|
|||||||
display_type = daemon.GetSignalDisplayType()
|
display_type = daemon.GetSignalDisplayType()
|
||||||
if daemon.GetWPADriver() == 'ralink legacy' or display_type == 1:
|
if daemon.GetWPADriver() == 'ralink legacy' or display_type == 1:
|
||||||
ending = "dBm"
|
ending = "dBm"
|
||||||
start = "-"
|
disp_strength = str(dbm_strength)
|
||||||
else:
|
else:
|
||||||
ending = "%"
|
ending = "%"
|
||||||
start = ""
|
disp_strength = str(strength)
|
||||||
self.lblStrength.set_label(start + str(strength) + ending)
|
self.lblStrength.set_label(disp_strength + ending)
|
||||||
|
|
||||||
def setMACAddress(self,address):
|
def setMACAddress(self,address):
|
||||||
self.lblMAC.set_label(str(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>')
|
self.set_label(self.essid + ' <span color="#666666">' + str(type) + '</span>')
|
||||||
if on and not type:
|
if on and not type:
|
||||||
self.lblEncryption.set_label(language['secured'])
|
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:
|
if not on:
|
||||||
self.lblEncryption.set_label(language['unsecured'])
|
self.lblEncryption.set_label(language['unsecured'])
|
||||||
|
|
||||||
@@ -912,7 +914,9 @@ class appGui:
|
|||||||
'''shows a dialog that creates a new adhoc network'''
|
'''shows a dialog that creates a new adhoc network'''
|
||||||
#create a new adhoc network here.
|
#create a new adhoc network here.
|
||||||
print 'create adhoc network'
|
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_has_separator(False)
|
||||||
dialog.set_size_request(400,-1)
|
dialog.set_size_request(400,-1)
|
||||||
self.useEncryptionCheckbox = gtk.CheckButton(language['use_wep_encryption'])
|
self.useEncryptionCheckbox = gtk.CheckButton(language['use_wep_encryption'])
|
||||||
@@ -1144,19 +1148,24 @@ class appGui:
|
|||||||
network = wireless.GetCurrentNetwork()
|
network = wireless.GetCurrentNetwork()
|
||||||
if network:
|
if network:
|
||||||
strength = wireless.GetCurrentSignalStrength()
|
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)
|
network = str(network)
|
||||||
|
if daemon.GetSignalDisplayType() == 0:
|
||||||
strength = str(strength)
|
strength = str(strength)
|
||||||
|
else:
|
||||||
|
strength = str(dbm_strength)
|
||||||
ip = str(wireless_ip)
|
ip = str(wireless_ip)
|
||||||
self.statusID=self.status_bar.push(1, language['connected_to_wireless'].replace
|
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))
|
('$C',wireless_ip))
|
||||||
if not daemon.GetDebugMode():
|
if not daemon.GetDebugMode():
|
||||||
config.EnableLogging()
|
config.EnableLogging()
|
||||||
return True
|
return True
|
||||||
wired_ip = wired.GetWiredIP()
|
wired_ip = wired.GetWiredIP()
|
||||||
if wired_ip:
|
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))
|
self.statusID = self.status_bar.push(1,language['connected_to_wired'].replace('$A',wired_ip))
|
||||||
if not daemon.GetDebugMode():
|
if not daemon.GetDebugMode():
|
||||||
config.EnableLogging()
|
config.EnableLogging()
|
||||||
|
|||||||
@@ -208,6 +208,17 @@ class Wireless(Controller):
|
|||||||
self.wpa_driver)
|
self.wpa_driver)
|
||||||
return wiface.GetSignalStrength()
|
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):
|
def GetCurrentNetwork(self):
|
||||||
""" Get current network name.
|
""" Get current network name.
|
||||||
|
|||||||
16
wnettools.py
16
wnettools.py
@@ -526,9 +526,7 @@ class WirelessInterface(Interface):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if network.get('key') != None:
|
if network.get('key') != None:
|
||||||
iwpriv = misc.Run('iwpriv ' + self.iface + ' get_site_survey')
|
lines = self._GetRalinkInfo()
|
||||||
lines = iwpriv.splitlines()
|
|
||||||
lines = lines[2:]
|
|
||||||
for x in lines:
|
for x in lines:
|
||||||
info = x.split()
|
info = x.split()
|
||||||
if len(info) < 5:
|
if len(info) < 5:
|
||||||
@@ -589,6 +587,18 @@ class WirelessInterface(Interface):
|
|||||||
|
|
||||||
return strength
|
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):
|
def GetCurrentNetwork(self):
|
||||||
""" Get the essid of the current network.
|
""" Get the essid of the current network.
|
||||||
|
|||||||
Reference in New Issue
Block a user