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
28
34
return (getattr(bzrlib.plugins, "avahi", None) is not None)
31
class NotifyPopupMenu(Gtk.Menu):
37
class NotifyPopupMenu(gtk.Menu):
35
38
def __init__(self):
36
39
super(NotifyPopupMenu, self).__init__()
37
40
self.create_items()
39
42
def create_items(self):
40
43
from bzrlib import errors
41
item = Gtk.CheckMenuItem.new_with_mnemonic('_Gateway to LAN')
44
item = gtk.CheckMenuItem('_Gateway to LAN')
42
45
item.connect('toggled', self.toggle_lan_gateway)
44
self.append(Gtk.SeparatorMenuItem())
47
self.append(gtk.SeparatorMenuItem())
46
49
from bzrlib.plugins.dbus.activity import LanGateway
47
50
self.langateway = LanGateway()
48
51
except ImportError:
49
52
item.set_sensitive(False)
50
53
except errors.BzrError:
51
# FIXME: Should only catch errors that indicate a lan-notify
54
# FIXME: Should only catch errors that indicate a lan-notify
52
55
# process is already running.
53
56
item.set_sensitive(False)
55
item = Gtk.CheckMenuItem.new_with_mnemonic(
56
'Announce _branches on LAN')
58
item = gtk.CheckMenuItem('Announce _branches on LAN')
57
59
item.connect('toggled', self.toggle_announce_branches)
59
self.append(Gtk.SeparatorMenuItem())
61
self.append(gtk.SeparatorMenuItem())
61
63
from bzrlib.plugins.avahi.share import ZeroConfServer
62
64
from bzrlib import urlutils
64
66
except ImportError:
65
67
item.set_sensitive(False)
67
item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_PREFERENCES, None)
69
item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)
68
70
item.connect('activate', self.show_preferences)
70
item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, None)
72
item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, None)
71
73
item.connect('activate', self.show_about)
73
self.append(Gtk.SeparatorMenuItem())
74
item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, None)
75
item.connect('activate', Gtk.main_quit)
75
self.append(gtk.SeparatorMenuItem())
76
item = gtk.ImageMenuItem(gtk.STOCK_QUIT, None)
77
item.connect('activate', gtk.main_quit)
80
81
def display(self, icon, event_button, event_time):
81
self.popup(None, None, Gtk.status_icon_position_menu,
82
self.popup(None, None, gtk.status_icon_position_menu,
82
83
event_button, event_time, icon)
84
85
def toggle_lan_gateway(self, item):