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

Testing/Experimental:

- Emit a dbus signal when an autoscan is called, so that the GUI can update if needed.

Experimental:
- Merged a few changes from the testing branch.
This commit is contained in:
imdano
2008-05-04 18:10:47 +00:00
parent e6ffa892ff
commit 0d1ba53bb1
4 changed files with 31 additions and 9 deletions

View File

@@ -652,6 +652,12 @@ class ConnectionWizard(dbus.service.Object):
""" """
pass pass
@dbus.service.method('org.wicd.daemon')
@dbus.service.signal(dbus_interface='org.wicd.daemon', signature='')
def SendScanSignal(self):
""" Emits a signal announcing a scan has occurred. """
pass
########## WIRELESS FUNCTIONS ########## WIRELESS FUNCTIONS
################################# #################################

20
gui.py
View File

@@ -69,7 +69,6 @@ except:
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless') wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired') wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
vpn_session = dbus.Interface(proxy_obj, 'org.wicd.daemon.vpn')
config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config') config = dbus.Interface(proxy_obj, 'org.wicd.daemon.config')
_ = misc.get_gettext() _ = misc.get_gettext()
@@ -821,7 +820,7 @@ class WiredNetworkEntry(NetworkEntry):
def edit_scripts(self, widget=None, event=None): def edit_scripts(self, widget=None, event=None):
""" Launch the script editting dialog. """ """ Launch the script editting dialog. """
profile = self.combo_profile_names.get_active_text() profile = self.combo_profile_names.get_active_text()
os.spawnlpe(os.P_WAIT, "gksudo", "gksudo", "./configscript.py", os.spawnlpe(os.P_WAIT, "gksudo", "gksudo", "-m", "You must enter your password to configure scripts.", "./configscript.py",
profile, "wired", os.environ) profile, "wired", os.environ)
def check_enable(self): def check_enable(self):
@@ -1020,7 +1019,7 @@ class WirelessNetworkEntry(NetworkEntry):
if dbm_strength is not None: if dbm_strength is not None:
dbm_strength = int(dbm_strength) dbm_strength = int(dbm_strength)
else: else:
dbm_strength = -1 dbm_strength = -100
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:
# Use the -xx dBm signal strength to display a signal icon # Use the -xx dBm signal strength to display a signal icon
@@ -1091,7 +1090,7 @@ class WirelessNetworkEntry(NetworkEntry):
def edit_scripts(self, widget=None, event=None): def edit_scripts(self, widget=None, event=None):
""" Launch the script editting dialog. """ """ Launch the script editting dialog. """
result = os.spawnlpe(os.P_WAIT, "gksudo", "gksudo", "./configscript.py", result = os.spawnlpe(os.P_WAIT, "gksudo", "gksudo", "-m", "You must enter your password to configure scripts.", "./configscript.py",
str(self.networkID), "wireless", os.environ) str(self.networkID), "wireless", os.environ)
def update_autoconnect(self, widget=None): def update_autoconnect(self, widget=None):
@@ -1194,7 +1193,6 @@ class appGui:
self.window.set_icon_from_file(wpath.etc + "wicd.png") self.window.set_icon_from_file(wpath.etc + "wicd.png")
self.statusID = None self.statusID = None
self.first_dialog_load = True self.first_dialog_load = True
self.vpn_connection_pipe = None
self.is_visible = True self.is_visible = True
self.pulse_active = False self.pulse_active = False
self.standalone = standalone self.standalone = standalone
@@ -1673,6 +1671,16 @@ class appGui:
def set_status(self, msg): def set_status(self, msg):
""" Sets the status bar message for the GUI. """ """ Sets the status bar message for the GUI. """
self.statusID = self.status_bar.push(1, msg) self.statusID = self.status_bar.push(1, msg)
def dbus_refresh_networks(self):
""" Calls for a non-fresh update of the gui window.
This method is called after the daemon runs an automatic
rescan.
"""
print 'got rescan signal'
self.refresh_networks(fresh=False)
def refresh_networks(self, widget=None, fresh=True, hidden=None): def refresh_networks(self, widget=None, fresh=True, hidden=None):
""" Refreshes the network list. """ Refreshes the network list.
@@ -2011,4 +2019,6 @@ class appGui:
if __name__ == '__main__': if __name__ == '__main__':
app = appGui(standalone=True) app = appGui(standalone=True)
bus.add_signal_receiver(app.dbus_refresh_networks, 'SendScanSignal',
'org.wicd.daemon')
gtk.main() gtk.main()

View File

@@ -154,7 +154,7 @@ class ConnectionStatus():
""" """
wired_ip = None wired_ip = None
wifi_ip = None wifi_ip = None
try: try:
if daemon.GetSuspend(): if daemon.GetSuspend():
print "Suspended." print "Suspended."
@@ -191,10 +191,10 @@ class ConnectionStatus():
self.auto_reconnect(from_wireless) self.auto_reconnect(from_wireless)
self.update_state(state) self.update_state(state)
except dbus.exceptions.DBusException, e: except dbus.exceptions.DBusException, e:
print 'DBus Error: ' + str(e) print 'Ignoring DBus Error: ' + str(e)
finally: finally:
return True return True
def update_state(self, state, wired_ip=None, wifi_ip=None): def update_state(self, state, wired_ip=None, wifi_ip=None):
""" Set the current connection state. """ """ Set the current connection state. """
# Set our connection state/info. # Set our connection state/info.
@@ -272,8 +272,9 @@ class ConnectionStatus():
if daemon.GetSuspend(): if daemon.GetSuspend():
return True return True
wireless.Scan() wireless.Scan()
daemon.SendScanSignal()
except dbus.exceptions.DBusException: except dbus.exceptions.DBusException:
pass print 'dbus exception while attempting rescan'
finally: finally:
return True return True

View File

@@ -389,12 +389,15 @@ class TrayIcon:
pb = gtk.gdk.pixbuf_new_from_file_at_size(self._get_img(n_id), pb = gtk.gdk.pixbuf_new_from_file_at_size(self._get_img(n_id),
20, 20) 20, 20)
image.set_from_pixbuf(pb) image.set_from_pixbuf(pb)
del pb
item.set_image(image) item.set_image(image)
del image
item.connect("activate", network_selected, type_, n_id) item.connect("activate", network_selected, type_, n_id)
net_menu.append(item) net_menu.append(item)
item.show() item.show()
if is_connecting: if is_connecting:
item.set_sensitive(False) item.set_sensitive(False)
del item
def _get_img(self, net_id): def _get_img(self, net_id):
""" Determines which image to use for the wireless entries. """ """ Determines which image to use for the wireless entries. """
@@ -462,6 +465,8 @@ class TrayIcon:
""" Toggles the wicd GUI. """ """ Toggles the wicd GUI. """
if not self.gui_win: if not self.gui_win:
self.gui_win = gui.appGui() self.gui_win = gui.appGui()
bus.add_signal_receiver(self.gui_win.dbus_refresh_networks,
'SendScanSignal', 'org.wicd.daemon')
elif not self.gui_win.is_visible: elif not self.gui_win.is_visible:
self.gui_win.show_win() self.gui_win.show_win()
else: else: