bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
| 
211
by Jelmer Vernooij
 Move notification area code into separate file.  | 
1  | 
# Copyright (C) 2007 by Robert Collins
 | 
2  | 
#                       Jelmer Vernooij
 | 
|
3  | 
#
 | 
|
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.
 | 
|
8  | 
||
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.
 | 
|
13  | 
||
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."""
 | 
|
18  | 
||
19  | 
import gtk  | 
|
20  | 
||
21  | 
class NotifyPopupMenu(gtk.Menu):  | 
|
22  | 
def __init__(self):  | 
|
23  | 
super(NotifyPopupMenu, self).__init__()  | 
|
24  | 
self.create_items()  | 
|
25  | 
||
26  | 
def create_items(self):  | 
|
27  | 
try:  | 
|
28  | 
from bzrlib.plugins.dbus.activity import LanGateway  | 
|
29  | 
self.langateway = LanGateway()  | 
|
30  | 
item = gtk.CheckMenuItem('_Gateway to LAN')  | 
|
31  | 
item.connect('toggled', self.toggle_lan_gateway)  | 
|
32  | 
self.append(item)  | 
|
33  | 
self.append(gtk.SeparatorMenuItem())  | 
|
34  | 
except ImportError:  | 
|
35  | 
            pass
 | 
|
36  | 
||
37  | 
try:  | 
|
38  | 
from bzrlib.plugins.avahi.share import ZeroConfServer  | 
|
39  | 
from bzrlib import urlutils  | 
|
40  | 
self.zeroconfserver = ZeroConfServer(urlutils.normalize_url('.'))  | 
|
41  | 
item = gtk.CheckMenuItem('Announce _branches on LAN')  | 
|
42  | 
item.connect('toggled', self.toggle_announce_branches)  | 
|
43  | 
self.append(item)  | 
|
44  | 
self.append(gtk.SeparatorMenuItem())  | 
|
45  | 
except ImportError:  | 
|
46  | 
            pass
 | 
|
47  | 
||
48  | 
item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)  | 
|
49  | 
item.connect('activate', self.show_preferences)  | 
|
50  | 
self.append(item)  | 
|
| 
221
by Jelmer Vernooij
 Add simple about dialog.  | 
51  | 
item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, None)  | 
52  | 
item.connect('activate', self.show_about)  | 
|
53  | 
self.append(item)  | 
|
| 
211
by Jelmer Vernooij
 Move notification area code into separate file.  | 
54  | 
self.append(gtk.SeparatorMenuItem())  | 
| 
223
by Jelmer Vernooij
 Add icon for Bazaar preferences.  | 
55  | 
item = gtk.ImageMenuItem(gtk.STOCK_QUIT, None)  | 
| 
211
by Jelmer Vernooij
 Move notification area code into separate file.  | 
56  | 
item.connect('activate', gtk.main_quit)  | 
57  | 
self.append(item)  | 
|
58  | 
self.show_all()  | 
|
59  | 
||
60  | 
def display(self, icon, event_button, event_time):  | 
|
61  | 
self.popup(None, None, gtk.status_icon_position_menu,  | 
|
62  | 
event_button, event_time, icon)  | 
|
63  | 
||
64  | 
def toggle_lan_gateway(self, item):  | 
|
65  | 
if item.get_active():  | 
|
66  | 
self.langateway.start()  | 
|
67  | 
else:  | 
|
68  | 
self.langateway.stop()  | 
|
69  | 
||
70  | 
def toggle_announce_branches(self, item):  | 
|
71  | 
if item.get_active():  | 
|
72  | 
self.zeroconfserver.start()  | 
|
73  | 
else:  | 
|
74  | 
self.zeroconfserver.close()  | 
|
75  | 
||
| 
221
by Jelmer Vernooij
 Add simple about dialog.  | 
76  | 
def show_about(self, item):  | 
77  | 
from about import AboutDialog  | 
|
78  | 
dialog = AboutDialog()  | 
|
79  | 
dialog.run()  | 
|
80  | 
||
| 
211
by Jelmer Vernooij
 Move notification area code into separate file.  | 
81  | 
def show_preferences(self, item):  | 
| 
213
by Jelmer Vernooij
 Show preferences dialog from notify area icon, fix GPG display.  | 
82  | 
from preferences import PreferencesWindow  | 
83  | 
prefs = PreferencesWindow()  | 
|
84  | 
prefs.run()  | 
|
| 
211
by Jelmer Vernooij
 Move notification area code into separate file.  | 
85  |