mirror of
https://github.com/gryf/wicd.git
synced 2026-01-06 22:04:19 +01:00
experimental:
- Use gobject.timeout_add_seconds instead of gobject.timeout_add when possible - Merge some fixes from pluggablebackends - Replace os.system usage with subprocess.call.
This commit is contained in:
11
wicd/gui.py
11
wicd/gui.py
@@ -56,7 +56,7 @@ else:
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
proxy_obj, daemon, wireless, wired, bus = [None for x in range(0, 5)]
|
||||
proxy_obj = daemon = wireless = wired = bus = None
|
||||
language = misc.get_language_list_gui()
|
||||
|
||||
def setup_dbus(dbus_man=None):
|
||||
@@ -84,6 +84,7 @@ def setup_dbus(dbus_man=None):
|
||||
wired = dbus_ifaces['wired']
|
||||
return True
|
||||
|
||||
|
||||
def error(parent, message):
|
||||
""" Shows an error dialog """
|
||||
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
|
||||
@@ -91,6 +92,14 @@ def error(parent, message):
|
||||
dialog.set_markup(message)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
def alert(parent, message):
|
||||
""" Shows an error dialog """
|
||||
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
|
||||
gtk.BUTTONS_OK)
|
||||
dialog.set_markup(message)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
########################################
|
||||
##### GTK EXTENSION CLASSES
|
||||
|
||||
@@ -134,7 +134,7 @@ def WriteLine(my_file, text):
|
||||
|
||||
def ExecuteScript(script):
|
||||
""" Execute a command and send its output to the bit bucket. """
|
||||
os.system("%s > /dev/null 2>&1" % script)
|
||||
call("%s > /dev/null 2>&1" % script)
|
||||
|
||||
def ReadFile(filename):
|
||||
""" read in a file and return it's contents as a string """
|
||||
|
||||
@@ -289,7 +289,14 @@ def main():
|
||||
|
||||
"""
|
||||
monitor = ConnectionStatus()
|
||||
gobject.timeout_add(2500, monitor.update_connection_status)
|
||||
if daemon.GetCurrentBackend() == "ioctl":
|
||||
to_time = 2.5
|
||||
else:
|
||||
to_time = 4
|
||||
try:
|
||||
gobject.timeout_add_seconds(to_time, monitor.update_connection_status)
|
||||
except:
|
||||
gobject.timeout_add(to_time * 1000, monitor.update_connection_status)
|
||||
|
||||
mainloop = gobject.MainLoop()
|
||||
mainloop.run()
|
||||
|
||||
@@ -591,7 +591,10 @@ class WicdDaemon(dbus.service.Object):
|
||||
print "Attempting to autoconnect with wired interface..."
|
||||
self.auto_connecting = True
|
||||
time.sleep(1.5)
|
||||
gobject.timeout_add(3000, self._monitor_wired_autoconnect)
|
||||
try:
|
||||
gobject.timeout_add_seconds(3, self._monitor_wired_autoconnect)
|
||||
except:
|
||||
gobject.timeout_add(3000, self._monitor_wired_autoconnect)
|
||||
return True
|
||||
|
||||
def _monitor_wired_autoconnect(self):
|
||||
@@ -1025,7 +1028,7 @@ class WirelessDaemon(dbus.service.Object):
|
||||
|
||||
def _wireless_autoconnect(self):
|
||||
""" Attempts to autoconnect to a wireless network. """
|
||||
print "No wired connection present, attempting to autoconnect" + \
|
||||
print "No wired connection present, attempting to autoconnect " + \
|
||||
"to wireless network"
|
||||
if self.wifi.wireless_interface is None:
|
||||
print 'Autoconnect failed because wireless interface returned None'
|
||||
|
||||
Reference in New Issue
Block a user