1
# Copyright (C) 2007 by Robert Collins
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Notification area icon and notification for Bazaar."""
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):
39
super(NotifyPopupMenu, self).__init__()
42
def create_items(self):
43
from bzrlib import errors
44
item = gtk.CheckMenuItem('_Gateway to LAN')
45
item.connect('toggled', self.toggle_lan_gateway)
47
self.append(gtk.SeparatorMenuItem())
49
from bzrlib.plugins.dbus.activity import LanGateway
50
self.langateway = LanGateway()
52
item.set_sensitive(False)
53
except errors.BzrError:
54
# FIXME: Should only catch errors that indicate a lan-notify
55
# process is already running.
56
item.set_sensitive(False)
58
item = gtk.CheckMenuItem('Announce _branches on LAN')
59
item.connect('toggled', self.toggle_announce_branches)
61
self.append(gtk.SeparatorMenuItem())
63
from bzrlib.plugins.avahi.share import ZeroConfServer
64
from bzrlib import urlutils
65
self.zeroconfserver = ZeroConfServer(urlutils.normalize_url('.'))
67
item.set_sensitive(False)
69
item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)
70
item.connect('activate', self.show_preferences)
72
item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, None)
73
item.connect('activate', self.show_about)
75
self.append(gtk.SeparatorMenuItem())
76
item = gtk.ImageMenuItem(gtk.STOCK_QUIT, None)
77
item.connect('activate', gtk.main_quit)
81
def display(self, icon, event_button, event_time):
82
self.popup(None, None, gtk.status_icon_position_menu,
83
event_button, event_time, icon)
85
def toggle_lan_gateway(self, item):
87
self.langateway.start()
89
self.langateway.stop()
91
def toggle_announce_branches(self, item):
93
self.zeroconfserver.start()
95
self.zeroconfserver.close()
97
def show_about(self, item):
98
from bzrlib.plugins.gtk.about import AboutDialog
99
dialog = AboutDialog()
102
def show_preferences(self, item):
103
from bzrlib.plugins.gtk.preferences import PreferencesWindow
104
prefs = PreferencesWindow()