1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-08 23:04:19 +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.
"""
def __init__(self, animate):
def __init__(self, animate, displaytray=True):
if USE_EGG:
self.tr = self.EggTrayIconGUI()
else:
self.tr = self.StatusTrayIconGUI()
self.icon_info = self.TrayConnectionInfo(self.tr, animate)
self.tr.icon_info = self.icon_info
print 'displaytray %s' % displaytray
self.tr.visible(displaytray)
def is_embedded(self):
if USE_EGG:
@@ -666,6 +668,18 @@ class TrayIcon(object):
"""
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"):
class StatusTrayIconGUI(gtk.StatusIcon, TrayIconGUI):
@@ -696,6 +710,14 @@ class TrayIcon(object):
self.current_icon_path = 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():
""" Print usage information. """
@@ -764,8 +786,9 @@ def main(argv):
"""
try:
opts, args = getopt.getopt(sys.argv[1:], 'nha', ['help', 'no-tray',
'no-animate'])
opts, args = getopt.getopt(sys.argv[1:], 'nhao', ['help', 'no-tray',
'no-animate',
'only-notifications'])
except getopt.GetoptError:
# Print help information and exit
usage()
@@ -773,6 +796,7 @@ def main(argv):
use_tray = True
animate = True
display_app = True
for opt, a in opts:
if opt in ('-h', '--help'):
usage()
@@ -781,6 +805,10 @@ def main(argv):
use_tray = False
elif opt in ('-a', '--no-animate'):
animate = False
elif opt in ('-o', '--only-notifications'):
print "only displaying notifications"
use_tray = False
display_app = False
else:
usage()
sys.exit(2)
@@ -789,14 +817,14 @@ def main(argv):
setup_dbus()
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)
mainloop = gobject.MainLoop()
mainloop.run()
sys.exit(0)
# 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
# was launched (typically happens on startup or daemon restart).