mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
Make sure daemon alerts tray to change status during connection process.
Specify which network is being connected to in both the tray tooltip and gui statusbar Clean up code in wicd.py. Refactor Edgy/DapperTrayIcon class names to something less Ubuntu-specific. Fix typo in EggTrayIcon that would keep gui from opening.
This commit is contained in:
@@ -434,7 +434,6 @@ class ConnectionWizard(dbus.service.Object):
|
|||||||
Scans for wireless networks and also for hidden networks defined in
|
Scans for wireless networks and also for hidden networks defined in
|
||||||
wireless-settings.conf
|
wireless-settings.conf
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
hidden_network_list = self.GetHiddenNetworkList()
|
hidden_network_list = self.GetHiddenNetworkList()
|
||||||
master_scan = self.Scan()
|
master_scan = self.Scan()
|
||||||
@@ -1471,6 +1470,8 @@ class ConnectionStatus():
|
|||||||
if not wireless_found: # No connection at all
|
if not wireless_found: # No connection at all
|
||||||
if not conn.CheckIfConnecting():
|
if not conn.CheckIfConnecting():
|
||||||
self.auto_reconnect()
|
self.auto_reconnect()
|
||||||
|
else:
|
||||||
|
self.status_changed = True
|
||||||
# Send a D-Bus signal announcing status has changed if necessary.
|
# Send a D-Bus signal announcing status has changed if necessary.
|
||||||
if self.status_changed:
|
if self.status_changed:
|
||||||
conn.StatusChanged()
|
conn.StatusChanged()
|
||||||
@@ -1489,8 +1490,7 @@ class ConnectionStatus():
|
|||||||
conn.SetCurrentInterface('')
|
conn.SetCurrentInterface('')
|
||||||
self.status_changed = True
|
self.status_changed = True
|
||||||
|
|
||||||
if conn.GetAutoReconnect() and \
|
if conn.GetAutoReconnect() and not conn.CheckIfConnecting() and \
|
||||||
not conn.CheckIfConnecting() and \
|
|
||||||
not conn.GetForcedDisconnect():
|
not conn.GetForcedDisconnect():
|
||||||
print 'Starting automatic reconnect process'
|
print 'Starting automatic reconnect process'
|
||||||
# First try connecting through ethernet
|
# First try connecting through ethernet
|
||||||
|
|||||||
21
gui.py
21
gui.py
@@ -318,10 +318,10 @@ class PrettyNetworkEntry(gtk.HBox):
|
|||||||
'''adds an image and a connect button to a NetworkEntry'''
|
'''adds an image and a connect button to a NetworkEntry'''
|
||||||
def __init__(self,expander):
|
def __init__(self,expander):
|
||||||
gtk.HBox.__init__(self)
|
gtk.HBox.__init__(self)
|
||||||
#add the stuff to the hbox (self)
|
# Add the stuff to the hbox (self)
|
||||||
self.expander = expander
|
self.expander = expander
|
||||||
self.expander.show()
|
self.expander.show()
|
||||||
self.expander.higherLevel = self #do this so that the expander can access the stuff inside me
|
self.expander.higherLevel = self # Do this so that the expander can access the stuff inside me
|
||||||
self.tempVBox = gtk.VBox(False,1)
|
self.tempVBox = gtk.VBox(False,1)
|
||||||
self.tempVBox.show()
|
self.tempVBox.show()
|
||||||
self.connectButton = LinkButton()
|
self.connectButton = LinkButton()
|
||||||
@@ -362,7 +362,7 @@ class PrettyWirelessNetworkEntry(PrettyNetworkEntry):
|
|||||||
self.setChannel(wireless.GetWirelessProperty(networkID,'channel'))
|
self.setChannel(wireless.GetWirelessProperty(networkID,'channel'))
|
||||||
self.setEncryption(wireless.GetWirelessProperty(networkID,'encryption'),
|
self.setEncryption(wireless.GetWirelessProperty(networkID,'encryption'),
|
||||||
wireless.GetWirelessProperty(networkID,'encryption_method'))
|
wireless.GetWirelessProperty(networkID,'encryption_method'))
|
||||||
#show everything
|
# Show everything
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
def setSignalStrength(self,strength, dbm_strength):
|
def setSignalStrength(self,strength, dbm_strength):
|
||||||
@@ -460,7 +460,7 @@ class NetworkEntry(gtk.Expander):
|
|||||||
self.vboxTop.pack_end(self.expanderAdvanced,fill=False,expand=False)
|
self.vboxTop.pack_end(self.expanderAdvanced,fill=False,expand=False)
|
||||||
self.expanderAdvanced.add(self.vboxAdvanced)
|
self.expanderAdvanced.add(self.vboxAdvanced)
|
||||||
self.expanderScripts.add(self.vboxScripts)
|
self.expanderScripts.add(self.vboxScripts)
|
||||||
#connect the events to the actions
|
# Connect the events to the actions
|
||||||
self.checkboxStaticIP.connect("toggled",self.toggleIPCheckbox)
|
self.checkboxStaticIP.connect("toggled",self.toggleIPCheckbox)
|
||||||
self.checkboxStaticDNS.connect("toggled",self.toggleDNSCheckbox)
|
self.checkboxStaticDNS.connect("toggled",self.toggleDNSCheckbox)
|
||||||
self.checkboxGlobalDNS.connect("toggled",self.toggleGlobalDNSCheckbox)
|
self.checkboxGlobalDNS.connect("toggled",self.toggleGlobalDNSCheckbox)
|
||||||
@@ -481,8 +481,8 @@ class NetworkEntry(gtk.Expander):
|
|||||||
#fill it in with a .1 at the end
|
#fill it in with a .1 at the end
|
||||||
gateway.set_text('.'.join(ip_parts[0:3]) + '.1')
|
gateway.set_text('.'.join(ip_parts[0:3]) + '.1')
|
||||||
|
|
||||||
if stringToNone(netmask.get_text()) == None: #make sure the netmask is blank
|
if stringToNone(netmask.get_text()) == None: # Make sure the netmask is blank
|
||||||
netmask.set_text('255.255.255.0') #fill in the most common one
|
netmask.set_text('255.255.255.0') # Fill in the most common one
|
||||||
|
|
||||||
def resetStaticCheckboxes(self):
|
def resetStaticCheckboxes(self):
|
||||||
#enable the right stuff
|
#enable the right stuff
|
||||||
@@ -885,12 +885,13 @@ class WiredProfileChooser:
|
|||||||
print 'reading profile ', wiredNetEntry.comboProfileNames.get_active_text()
|
print 'reading profile ', wiredNetEntry.comboProfileNames.get_active_text()
|
||||||
config.ReadWiredNetworkProfile(wiredNetEntry.comboProfileNames.get_active_text())
|
config.ReadWiredNetworkProfile(wiredNetEntry.comboProfileNames.get_active_text())
|
||||||
wired.ConnectWired()
|
wired.ConnectWired()
|
||||||
dialog.destroy()
|
|
||||||
else:
|
else:
|
||||||
if stoppopcheckbox.get_active() == True:
|
if stoppopcheckbox.get_active() == True:
|
||||||
# Stops the pop-up from reappearing if cancelled
|
# Stops the pop-up from reappearing if cancelled
|
||||||
wired.use_default_profile = 1
|
wired.use_default_profile = 1
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
|
|
||||||
class appGui:
|
class appGui:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
gladefile = "data/wicd.glade"
|
gladefile = "data/wicd.glade"
|
||||||
@@ -1181,9 +1182,11 @@ class appGui:
|
|||||||
if self.statusID:
|
if self.statusID:
|
||||||
self.status_bar.remove(1,self.statusID)
|
self.status_bar.remove(1,self.statusID)
|
||||||
if wirelessConnecting:
|
if wirelessConnecting:
|
||||||
self.statusID = self.status_bar.push(1,language[str(wireless.CheckWirelessConnectingMessage())])
|
self.statusID = self.status_bar.push(1,wireless.GetCurrentNetwork() + ': ' +
|
||||||
|
language[str(wireless.CheckWirelessConnectingMessage())])
|
||||||
if wiredConnecting:
|
if wiredConnecting:
|
||||||
self.statusID = self.status_bar.push(1,language[str(wired.CheckWiredConnectingMessage())])
|
self.statusID = self.status_bar.push(1,language['wired_network'] + ': ' +
|
||||||
|
language[str(wired.CheckWiredConnectingMessage())])
|
||||||
else:
|
else:
|
||||||
self.network_list.set_sensitive(True)
|
self.network_list.set_sensitive(True)
|
||||||
self.status_area.hide_all()
|
self.status_area.hide_all()
|
||||||
|
|||||||
91
wicd.py
91
wicd.py
@@ -10,9 +10,10 @@ class TrayIcon() -- Parent class of TrayIconGUI and IconConnectionInfo.
|
|||||||
class TrayConnectionInfo() -- Child class of TrayIcon which provides
|
class TrayConnectionInfo() -- Child class of TrayIcon which provides
|
||||||
and updates connection status.
|
and updates connection status.
|
||||||
class TrayIconGUI() -- Child class of TrayIcon which implements the tray.
|
class TrayIconGUI() -- Child class of TrayIcon which implements the tray.
|
||||||
icon itself. Parent class of EdgyTrayIconGUI and DapperTrayIconGUI.
|
icon itself. Parent class of StatusTrayIconGUI and EggTrayIconGUI.
|
||||||
class EdgyTrayIconGUI() -- Implements the tray icon using a gtk.StatusIcon.
|
class StatusTrayIconGUI() -- Implements the tray icon using a
|
||||||
class DapperTrayIconGUI() -- Implements the tray icon using egg.trayicon.
|
gtk.StatusIcon.
|
||||||
|
class EggTrayIconGUI() -- Implements the tray icon using egg.trayicon.
|
||||||
def usage() -- Prints usage information.
|
def usage() -- Prints usage information.
|
||||||
def main() -- Runs the wicd frontend main loop.
|
def main() -- Runs the wicd frontend main loop.
|
||||||
|
|
||||||
@@ -35,15 +36,11 @@ def main() -- Runs the wicd frontend main loop.
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import locale
|
|
||||||
import gettext
|
|
||||||
import signal
|
|
||||||
import getopt
|
import getopt
|
||||||
|
|
||||||
# Import egg.trayicon if we're using an older gtk version
|
# Import egg.trayicon if we're using an older gtk version
|
||||||
@@ -67,7 +64,8 @@ if sys.platform == 'linux2':
|
|||||||
import dl
|
import dl
|
||||||
libc = dl.open('/lib/libc.so.6')
|
libc = dl.open('/lib/libc.so.6')
|
||||||
libc.call('prctl', 15, 'wicd\0', 0, 0, 0) # 15 is PR_SET_NAME
|
libc.call('prctl', 15, 'wicd\0', 0, 0, 0) # 15 is PR_SET_NAME
|
||||||
except:
|
except Exception:
|
||||||
|
print 'Failed to rename wicd process'
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -81,7 +79,7 @@ try:
|
|||||||
print 'Attempting to connect tray to daemon...'
|
print 'Attempting to connect tray to daemon...'
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
||||||
print 'Success.'
|
print 'Success.'
|
||||||
except:
|
except Exception:
|
||||||
print 'Daemon not running...'
|
print 'Daemon not running...'
|
||||||
misc.PromptToStartDaemon()
|
misc.PromptToStartDaemon()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -96,14 +94,20 @@ 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...')
|
language['connecting'] = _('Connecting')
|
||||||
|
language['wired'] = _('wired network')
|
||||||
|
|
||||||
class TrayIcon():
|
class TrayIcon():
|
||||||
|
"""Base Tray Icon class
|
||||||
|
|
||||||
|
Base Class for implementing a tray icon to display network status.
|
||||||
|
|
||||||
|
"""
|
||||||
def __init__(self, use_tray):
|
def __init__(self, use_tray):
|
||||||
if USE_EGG:
|
if USE_EGG:
|
||||||
self.tr = self.DapperTrayIconGUI(use_tray)
|
self.tr = self.EggTrayIconGUI(use_tray)
|
||||||
else:
|
else:
|
||||||
self.tr = self.EdgyTrayIconGUI(use_tray)
|
self.tr = self.StatusTrayIconGUI(use_tray)
|
||||||
self.icon_info = self.TrayConnectionInfo(self.tr)
|
self.icon_info = self.TrayConnectionInfo(self.tr)
|
||||||
|
|
||||||
|
|
||||||
@@ -122,14 +126,19 @@ class TrayIcon():
|
|||||||
def wired_profile_chooser(self):
|
def wired_profile_chooser(self):
|
||||||
"""Launch the wired profile chooser."""
|
"""Launch the wired profile chooser."""
|
||||||
daemon.SetNeedWiredProfileChooser(False)
|
daemon.SetNeedWiredProfileChooser(False)
|
||||||
chooser = gui.WiredProfileChooser()
|
gui.WiredProfileChooser()
|
||||||
|
|
||||||
def update_tray_icon(self):
|
def update_tray_icon(self):
|
||||||
"""Updates the tray icon and current connection status"""
|
"""Updates the tray icon and current connection status"""
|
||||||
|
|
||||||
# If we're currently connecting, we can shortcut all other checks
|
# If we're currently connecting, we can shortcut all other checks
|
||||||
if daemon.CheckIfConnecting():
|
if daemon.CheckIfConnecting():
|
||||||
self.tr.set_tooltip(language['connecting'])
|
if wireless.CheckIfWirelessConnecting():
|
||||||
|
cur_network = wireless.GetCurrentNetwork()
|
||||||
|
else:
|
||||||
|
cur_network = language['wired_network']
|
||||||
|
self.tr.set_tooltip(language['connecting'] + " to " +
|
||||||
|
cur_network + "...")
|
||||||
self.tr.set_from_file(wpath.images + "no-signal.png")
|
self.tr.set_from_file(wpath.images + "no-signal.png")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -141,7 +150,8 @@ class TrayIcon():
|
|||||||
if cur_iface == wire_iface:
|
if cur_iface == wire_iface:
|
||||||
wired_ip = wired.GetWiredIP()
|
wired_ip = wired.GetWiredIP()
|
||||||
self.tr.set_from_file(wpath.images + "wired.png")
|
self.tr.set_from_file(wpath.images + "wired.png")
|
||||||
self.tr.set_tooltip(language['connected_to_wired'].replace('$A',
|
self.tr.set_tooltip(language['connected_to_wired'].
|
||||||
|
replace('$A',
|
||||||
wired_ip))
|
wired_ip))
|
||||||
|
|
||||||
# Check for a wireless connection
|
# Check for a wireless connection
|
||||||
@@ -193,7 +203,11 @@ class TrayIcon():
|
|||||||
|
|
||||||
|
|
||||||
class TrayIconGUI():
|
class TrayIconGUI():
|
||||||
def __init__(self):
|
"""Base Tray Icon class
|
||||||
|
|
||||||
|
Implements methods and variables used by both egg/StatusIcon tray icons.
|
||||||
|
"""
|
||||||
|
def __init__(self, use_tray):
|
||||||
menu = """
|
menu = """
|
||||||
<ui>
|
<ui>
|
||||||
<menubar name="Menubar">
|
<menubar name="Menubar">
|
||||||
@@ -220,8 +234,11 @@ class TrayIcon():
|
|||||||
self.manager = gtk.UIManager()
|
self.manager = gtk.UIManager()
|
||||||
self.manager.insert_action_group(actg, 0)
|
self.manager.insert_action_group(actg, 0)
|
||||||
self.manager.add_ui_from_string(menu)
|
self.manager.add_ui_from_string(menu)
|
||||||
self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent
|
self.menu = (self.manager.get_widget('/Menubar/Menu/About').
|
||||||
|
props.parent)
|
||||||
self.gui_win = None
|
self.gui_win = None
|
||||||
|
self.current_icon_path = None
|
||||||
|
self.use_tray = use_tray
|
||||||
|
|
||||||
def on_activate(self, data=None):
|
def on_activate(self, data=None):
|
||||||
"""Opens the wicd GUI"""
|
"""Opens the wicd GUI"""
|
||||||
@@ -239,8 +256,8 @@ class TrayIcon():
|
|||||||
"""Opens the About Dialog"""
|
"""Opens the About Dialog"""
|
||||||
dialog = gtk.AboutDialog()
|
dialog = gtk.AboutDialog()
|
||||||
dialog.set_name('wicd tray icon')
|
dialog.set_name('wicd tray icon')
|
||||||
dialog.set_version('0.4')
|
dialog.set_version('1.0')
|
||||||
dialog.set_comments('an icon that shows your network connectivity')
|
dialog.set_comments('An icon that shows your network connectivity')
|
||||||
dialog.set_website('http://wicd.sourceforge.net')
|
dialog.set_website('http://wicd.sourceforge.net')
|
||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
@@ -263,10 +280,15 @@ class TrayIcon():
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class DapperTrayIconGUI(TrayIconGUI):
|
class EggTrayIconGUI(TrayIconGUI):
|
||||||
|
"""Tray Icon for gtk < 2.10
|
||||||
|
|
||||||
|
Uses the deprecated egg.trayicon module to implement the tray icon.
|
||||||
|
|
||||||
|
"""
|
||||||
def __init__(self, use_tray=True):
|
def __init__(self, use_tray=True):
|
||||||
"""Initializes the tray icon"""
|
"""Initializes the tray icon"""
|
||||||
TrayIcon.TrayIconGUI.__init__(self)
|
TrayIcon.TrayIconGUI.__init__(self, use_tray)
|
||||||
self.use_tray = use_tray
|
self.use_tray = use_tray
|
||||||
if not use_tray:
|
if not use_tray:
|
||||||
self.toggle_wicd_gui()
|
self.toggle_wicd_gui()
|
||||||
@@ -287,16 +309,16 @@ class TrayIcon():
|
|||||||
def tray_clicked(self, widget, event):
|
def tray_clicked(self, widget, event):
|
||||||
"""Handles tray mouse click events"""
|
"""Handles tray mouse click events"""
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
self.open_wicd_gui()
|
self.toggle_wicd_gui()
|
||||||
if event.button == 3:
|
if event.button == 3:
|
||||||
self.menu.popup(None, None, None, event.button, event.time)
|
self.menu.popup(None, None, None, event.button, event.time)
|
||||||
|
|
||||||
def set_from_file(self, str):
|
def set_from_file(self, val):
|
||||||
"""Calls set_from_file on the gtk.Image for the tray icon"""
|
"""Calls set_from_file on the gtk.Image for the tray icon"""
|
||||||
if not self.use_tray: return
|
if not self.use_tray: return
|
||||||
self.pic.set_from_file(str)
|
self.pic.set_from_file(val)
|
||||||
|
|
||||||
def set_tooltip(self, str):
|
def set_tooltip(self, val):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Sets the tooltip for the gtk.ToolTips associated with this
|
Sets the tooltip for the gtk.ToolTips associated with this
|
||||||
@@ -304,13 +326,17 @@ class TrayIcon():
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if not self.use_tray: return
|
if not self.use_tray: return
|
||||||
self.tooltip.set_tip(self.eb, str)
|
self.tooltip.set_tip(self.eb, val)
|
||||||
|
|
||||||
|
|
||||||
class EdgyTrayIconGUI(gtk.StatusIcon, TrayIconGUI):
|
class StatusTrayIconGUI(gtk.StatusIcon, TrayIconGUI):
|
||||||
"""Class for creating the wicd tray icon"""
|
"""Class for creating the wicd tray icon on gtk > 2.10
|
||||||
|
|
||||||
|
Uses gtk.StatusIcon to implement a tray icon.
|
||||||
|
|
||||||
|
"""
|
||||||
def __init__(self, use_tray=True):
|
def __init__(self, use_tray=True):
|
||||||
TrayIcon.TrayIconGUI.__init__(self)
|
TrayIcon.TrayIconGUI.__init__(self, use_tray)
|
||||||
self.use_tray = use_tray
|
self.use_tray = use_tray
|
||||||
if not use_tray:
|
if not use_tray:
|
||||||
self.toggle_wicd_gui()
|
self.toggle_wicd_gui()
|
||||||
@@ -339,6 +365,7 @@ class TrayIcon():
|
|||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
"""Print usage information."""
|
||||||
print """
|
print """
|
||||||
wicd 1.40
|
wicd 1.40
|
||||||
wireless (and wired) connection daemon front-end.
|
wireless (and wired) connection daemon front-end.
|
||||||
@@ -365,11 +392,11 @@ def main(argv):
|
|||||||
usage()
|
usage()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
for o, a in opts:
|
for opt, a in opts:
|
||||||
if o in ('-h', '--help'):
|
if opt in ('-h', '--help'):
|
||||||
usage()
|
usage()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if o in ('-n', '--no-tray'):
|
if opt in ('-n', '--no-tray'):
|
||||||
use_tray = False
|
use_tray = False
|
||||||
|
|
||||||
# Redirect stderr and stdout for logging purposes
|
# Redirect stderr and stdout for logging purposes
|
||||||
|
|||||||
Reference in New Issue
Block a user