1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-27 10:45:45 +01:00

added support for not displaying the tray icon or the GUI, only the notifications

This commit is contained in:
Adam Blackburn
2009-07-22 21:29:34 -05:00
parent a0ed8c4a44
commit e1fb4584f2

View File

@@ -121,13 +121,15 @@ class TrayIcon(object):
Base Class for implementing a tray icon to display network status. Base Class for implementing a tray icon to display network status.
""" """
def __init__(self, animate): def __init__(self, animate, displaytray=True):
if USE_EGG: if USE_EGG:
self.tr = self.EggTrayIconGUI() self.tr = self.EggTrayIconGUI()
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 self.tr.icon_info = self.icon_info
print 'displaytray %s' % displaytray
self.tr.visible(displaytray)
def is_embedded(self): def is_embedded(self):
if USE_EGG: if USE_EGG:
@@ -666,6 +668,18 @@ class TrayIcon(object):
""" """
self.tooltip.set_tip(self.eb, val) self.tooltip.set_tip(self.eb, val)
def visible(self, val):
""" Set if the icon is visible or not.
If val is True, makes the icon visible, if val is False,
hides the tray icon.
"""
if val:
self.tray.show_all()
else:
self.tray.hide_all()
if hasattr(gtk, "StatusIcon"): if hasattr(gtk, "StatusIcon"):
class StatusTrayIconGUI(gtk.StatusIcon, TrayIconGUI): class StatusTrayIconGUI(gtk.StatusIcon, TrayIconGUI):
@@ -696,6 +710,14 @@ class TrayIcon(object):
self.current_icon_path = path self.current_icon_path = path
gtk.StatusIcon.set_from_file(self, path) gtk.StatusIcon.set_from_file(self, path)
def visible(self, val):
""" Set if the icon is visible or not.
If val is True, makes the icon visible, if val is False,
hides the tray icon.
"""
self.set_visible(val)
def usage(): def usage():
""" Print usage information. """ """ Print usage information. """
@@ -764,8 +786,9 @@ def main(argv):
""" """
try: try:
opts, args = getopt.getopt(sys.argv[1:], 'nha', ['help', 'no-tray', opts, args = getopt.getopt(sys.argv[1:], 'nhao', ['help', 'no-tray',
'no-animate']) 'no-animate',
'only-notifications'])
except getopt.GetoptError: except getopt.GetoptError:
# Print help information and exit # Print help information and exit
usage() usage()
@@ -773,6 +796,7 @@ def main(argv):
use_tray = True use_tray = True
animate = True animate = True
display_app = True
for opt, a in opts: for opt, a in opts:
if opt in ('-h', '--help'): if opt in ('-h', '--help'):
usage() usage()
@@ -781,6 +805,10 @@ def main(argv):
use_tray = False use_tray = False
elif opt in ('-a', '--no-animate'): elif opt in ('-a', '--no-animate'):
animate = False animate = False
elif opt in ('-o', '--only-notifications'):
print "only displaying notifications"
use_tray = False
display_app = False
else: else:
usage() usage()
sys.exit(2) sys.exit(2)
@@ -789,14 +817,14 @@ def main(argv):
setup_dbus() setup_dbus()
atexit.register(on_exit) atexit.register(on_exit)
if not use_tray or not ICON_AVAIL: if display_app and not use_tray or not ICON_AVAIL:
the_gui = gui.appGui(standalone=True) the_gui = gui.appGui(standalone=True)
mainloop = gobject.MainLoop() mainloop = gobject.MainLoop()
mainloop.run() mainloop.run()
sys.exit(0) sys.exit(0)
# Set up the tray icon GUI and backend # Set up the tray icon GUI and backend
tray_icon = TrayIcon(animate) tray_icon = TrayIcon(animate, displaytray=display_app)
# Check to see if wired profile chooser was called before icon # Check to see if wired profile chooser was called before icon
# was launched (typically happens on startup or daemon restart). # was launched (typically happens on startup or daemon restart).