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