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