mirror of
https://github.com/gryf/wicd.git
synced 2026-02-20 17:05:46 +01:00
Added support for instantly enabling/disabling notifications when the preference is changed
This commit is contained in:
@@ -141,10 +141,12 @@ class WiredProfileChooser:
|
|||||||
|
|
||||||
class appGui(object):
|
class appGui(object):
|
||||||
""" The main wicd GUI class. """
|
""" The main wicd GUI class. """
|
||||||
def __init__(self, standalone=False):
|
def __init__(self, standalone=False, tray=None):
|
||||||
""" Initializes everything needed for the GUI. """
|
""" Initializes everything needed for the GUI. """
|
||||||
setup_dbus()
|
setup_dbus()
|
||||||
|
|
||||||
|
self.tray = tray
|
||||||
|
|
||||||
gladefile = os.path.join(wpath.share, "wicd.glade")
|
gladefile = os.path.join(wpath.share, "wicd.glade")
|
||||||
self.wTree = gtk.glade.XML(gladefile)
|
self.wTree = gtk.glade.XML(gladefile)
|
||||||
self.window = self.wTree.get_widget("window1")
|
self.window = self.wTree.get_widget("window1")
|
||||||
@@ -305,7 +307,7 @@ class appGui(object):
|
|||||||
def settings_dialog(self, widget, event=None):
|
def settings_dialog(self, widget, event=None):
|
||||||
""" Displays a general settings dialog. """
|
""" Displays a general settings dialog. """
|
||||||
if not self.pref:
|
if not self.pref:
|
||||||
self.pref = PreferencesDialog(self.wTree)
|
self.pref = PreferencesDialog(self, self.wTree)
|
||||||
else:
|
else:
|
||||||
self.pref.load_preferences_diag()
|
self.pref.load_preferences_diag()
|
||||||
if self.pref.run() == 1:
|
if self.pref.run() == 1:
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ def setup_dbus():
|
|||||||
|
|
||||||
class PreferencesDialog(object):
|
class PreferencesDialog(object):
|
||||||
""" Class for handling the wicd preferences dialog window. """
|
""" Class for handling the wicd preferences dialog window. """
|
||||||
def __init__(self, wTree):
|
def __init__(self, parent, wTree):
|
||||||
setup_dbus()
|
setup_dbus()
|
||||||
|
self.parent = parent
|
||||||
self.wTree = wTree
|
self.wTree = wTree
|
||||||
self.prep_settings_diag()
|
self.prep_settings_diag()
|
||||||
self.load_preferences_diag()
|
self.load_preferences_diag()
|
||||||
@@ -243,7 +244,11 @@ class PreferencesDialog(object):
|
|||||||
else:
|
else:
|
||||||
if os.path.exists(not_path):
|
if os.path.exists(not_path):
|
||||||
os.remove(not_path)
|
os.remove(not_path)
|
||||||
|
# if this GUI was started by a tray icon,
|
||||||
|
# instantly change the notifications there
|
||||||
|
if self.parent.tray:
|
||||||
|
self.parent.tray.icon_info.use_notify = \
|
||||||
|
self.notificationscheckbox.get_active()
|
||||||
|
|
||||||
def set_label(self, glade_str, label):
|
def set_label(self, glade_str, label):
|
||||||
""" Sets the label for the given widget in wicd.glade. """
|
""" Sets the label for the given widget in wicd.glade. """
|
||||||
|
|||||||
@@ -53,9 +53,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_NOTIFY = False
|
HAS_NOTIFY = False
|
||||||
|
|
||||||
USE_NOTIFY = os.path.exists(os.path.join(os.path.expanduser('~/.wicd'),
|
|
||||||
'USE_NOTIFICATIONS'))
|
|
||||||
|
|
||||||
# Wicd specific imports
|
# Wicd specific imports
|
||||||
from wicd import wpath
|
from wicd import wpath
|
||||||
from wicd import misc
|
from wicd import misc
|
||||||
@@ -130,6 +127,7 @@ class TrayIcon(object):
|
|||||||
else:
|
else:
|
||||||
self.tr = self.StatusTrayIconGUI()
|
self.tr = self.StatusTrayIconGUI()
|
||||||
self.icon_info = self.TrayConnectionInfo(self.tr, animate)
|
self.icon_info = self.TrayConnectionInfo(self.tr, animate)
|
||||||
|
self.tr.icon_info = self.icon_info
|
||||||
|
|
||||||
def is_embedded(self):
|
def is_embedded(self):
|
||||||
if USE_EGG:
|
if USE_EGG:
|
||||||
@@ -160,6 +158,10 @@ class TrayIcon(object):
|
|||||||
self.last_state = None
|
self.last_state = None
|
||||||
self.should_notify = True
|
self.should_notify = True
|
||||||
|
|
||||||
|
self.use_notify = os.path.exists(os.path.join(
|
||||||
|
os.path.expanduser('~/.wicd'),
|
||||||
|
'USE_NOTIFICATIONS'))
|
||||||
|
|
||||||
if DBUS_AVAIL:
|
if DBUS_AVAIL:
|
||||||
self.update_tray_icon()
|
self.update_tray_icon()
|
||||||
else:
|
else:
|
||||||
@@ -250,7 +252,8 @@ class TrayIcon(object):
|
|||||||
if not state or not info:
|
if not state or not info:
|
||||||
[state, info] = daemon.GetConnectionStatus()
|
[state, info] = daemon.GetConnectionStatus()
|
||||||
|
|
||||||
self.should_notify = (self.last_state != state) and HAS_NOTIFY and USE_NOTIFY
|
self.should_notify = (self.last_state != state) and \
|
||||||
|
HAS_NOTIFY and self.use_notify
|
||||||
|
|
||||||
self.last_state = state
|
self.last_state = state
|
||||||
|
|
||||||
@@ -599,7 +602,7 @@ class TrayIcon(object):
|
|||||||
def toggle_wicd_gui(self):
|
def toggle_wicd_gui(self):
|
||||||
""" 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(tray=self)
|
||||||
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:
|
||||||
|
|||||||
Reference in New Issue
Block a user