16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""Notification area icon and notification for Bazaar."""
19
from gi.repository import Gtk
24
return (getattr(bzrlib.plugins, "dbus", None) is not None)
28
return (getattr(bzrlib.plugins, "avahi", None) is not None)
31
class NotifyPopupMenu(Gtk.Menu):
21
class NotifyPopupMenu(gtk.Menu):
33
22
def __init__(self):
34
23
super(NotifyPopupMenu, self).__init__()
35
24
self.create_items()
37
26
def create_items(self):
38
from bzrlib import errors
39
item = Gtk.CheckMenuItem('_Gateway to LAN')
40
item.connect('toggled', self.toggle_lan_gateway)
42
self.append(Gtk.SeparatorMenuItem())
44
28
from bzrlib.plugins.dbus.activity import LanGateway
45
29
self.langateway = LanGateway()
30
item = gtk.CheckMenuItem('_Gateway to LAN')
31
item.connect('toggled', self.toggle_lan_gateway)
33
self.append(gtk.SeparatorMenuItem())
46
34
except ImportError:
47
item.set_sensitive(False)
48
except errors.BzrError:
49
# FIXME: Should only catch errors that indicate a lan-notify
50
# process is already running.
51
item.set_sensitive(False)
53
item = Gtk.CheckMenuItem('Announce _branches on LAN')
54
item.connect('toggled', self.toggle_announce_branches)
56
self.append(Gtk.SeparatorMenuItem())
58
38
from bzrlib.plugins.avahi.share import ZeroConfServer
59
39
from bzrlib import urlutils
60
40
self.zeroconfserver = ZeroConfServer(urlutils.normalize_url('.'))
41
item = gtk.CheckMenuItem('Announce _branches on LAN')
42
item.connect('toggled', self.toggle_announce_branches)
44
self.append(gtk.SeparatorMenuItem())
61
45
except ImportError:
62
item.set_sensitive(False)
64
item = Gtk.ImageMenuItem(Gtk.STOCK_PREFERENCES, None)
48
item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)
65
49
item.connect('activate', self.show_preferences)
67
item = Gtk.ImageMenuItem(Gtk.STOCK_ABOUT, None)
51
item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, None)
68
52
item.connect('activate', self.show_about)
70
self.append(Gtk.SeparatorMenuItem())
71
item = Gtk.ImageMenuItem(Gtk.STOCK_QUIT, None)
72
item.connect('activate', Gtk.main_quit)
54
self.append(gtk.SeparatorMenuItem())
55
item = gtk.ImageMenuItem(gtk.STOCK_QUIT, None)
56
item.connect('activate', gtk.main_quit)
76
60
def display(self, icon, event_button, event_time):
77
self.popup(None, None, Gtk.status_icon_position_menu,
61
self.popup(None, None, gtk.status_icon_position_menu,
78
62
event_button, event_time, icon)
80
64
def toggle_lan_gateway(self, item):