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 |
|
619.1.1
by Vincent Ladeuil
Fix bug #290618 by using the right facilities. |
20 |
import bzrlib |
21 |
||
619
by Jelmer Vernooij
Add notifications tab in preferences dialog. |
22 |
|
23 |
def has_dbus(): |
|
24 |
return (getattr(bzrlib.plugins, "dbus", None) is not None) |
|
25 |
||
619.1.1
by Vincent Ladeuil
Fix bug #290618 by using the right facilities. |
26 |
|
619
by Jelmer Vernooij
Add notifications tab in preferences dialog. |
27 |
def has_avahi(): |
28 |
return (getattr(bzrlib.plugins, "avahi", None) is not None) |
|
211
by Jelmer Vernooij
Move notification area code into separate file. |
29 |
|
619.1.1
by Vincent Ladeuil
Fix bug #290618 by using the right facilities. |
30 |
|
211
by Jelmer Vernooij
Move notification area code into separate file. |
31 |
class NotifyPopupMenu(gtk.Menu): |
32 |
def __init__(self): |
|
33 |
super(NotifyPopupMenu, self).__init__() |
|
34 |
self.create_items() |
|
35 |
||
36 |
def create_items(self): |
|
619
by Jelmer Vernooij
Add notifications tab in preferences dialog. |
37 |
item = gtk.CheckMenuItem('_Gateway to LAN') |
38 |
item.connect('toggled', self.toggle_lan_gateway) |
|
39 |
self.append(item) |
|
40 |
self.append(gtk.SeparatorMenuItem()) |
|
211
by Jelmer Vernooij
Move notification area code into separate file. |
41 |
try: |
42 |
from bzrlib.plugins.dbus.activity import LanGateway |
|
43 |
self.langateway = LanGateway() |
|
44 |
except ImportError: |
|
619
by Jelmer Vernooij
Add notifications tab in preferences dialog. |
45 |
item.set_sensitive(False) |
211
by Jelmer Vernooij
Move notification area code into separate file. |
46 |
|
619
by Jelmer Vernooij
Add notifications tab in preferences dialog. |
47 |
item = gtk.CheckMenuItem('Announce _branches on LAN') |
48 |
item.connect('toggled', self.toggle_announce_branches) |
|
49 |
self.append(item) |
|
50 |
self.append(gtk.SeparatorMenuItem()) |
|
211
by Jelmer Vernooij
Move notification area code into separate file. |
51 |
try: |
52 |
from bzrlib.plugins.avahi.share import ZeroConfServer |
|
53 |
from bzrlib import urlutils |
|
54 |
self.zeroconfserver = ZeroConfServer(urlutils.normalize_url('.')) |
|
55 |
except ImportError: |
|
619
by Jelmer Vernooij
Add notifications tab in preferences dialog. |
56 |
item.set_sensitive(False) |
211
by Jelmer Vernooij
Move notification area code into separate file. |
57 |
|
58 |
item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None) |
|
59 |
item.connect('activate', self.show_preferences) |
|
60 |
self.append(item) |
|
221
by Jelmer Vernooij
Add simple about dialog. |
61 |
item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, None) |
62 |
item.connect('activate', self.show_about) |
|
63 |
self.append(item) |
|
211
by Jelmer Vernooij
Move notification area code into separate file. |
64 |
self.append(gtk.SeparatorMenuItem()) |
223
by Jelmer Vernooij
Add icon for Bazaar preferences. |
65 |
item = gtk.ImageMenuItem(gtk.STOCK_QUIT, None) |
211
by Jelmer Vernooij
Move notification area code into separate file. |
66 |
item.connect('activate', gtk.main_quit) |
67 |
self.append(item) |
|
68 |
self.show_all() |
|
69 |
||
70 |
def display(self, icon, event_button, event_time): |
|
71 |
self.popup(None, None, gtk.status_icon_position_menu, |
|
72 |
event_button, event_time, icon) |
|
73 |
||
74 |
def toggle_lan_gateway(self, item): |
|
75 |
if item.get_active(): |
|
76 |
self.langateway.start() |
|
77 |
else: |
|
78 |
self.langateway.stop() |
|
79 |
||
80 |
def toggle_announce_branches(self, item): |
|
81 |
if item.get_active(): |
|
82 |
self.zeroconfserver.start() |
|
83 |
else: |
|
84 |
self.zeroconfserver.close() |
|
85 |
||
221
by Jelmer Vernooij
Add simple about dialog. |
86 |
def show_about(self, item): |
553.1.3
by Jelmer Vernooij
Use absolute imports. |
87 |
from bzrlib.plugins.gtk.about import AboutDialog |
221
by Jelmer Vernooij
Add simple about dialog. |
88 |
dialog = AboutDialog() |
89 |
dialog.run() |
|
90 |
||
211
by Jelmer Vernooij
Move notification area code into separate file. |
91 |
def show_preferences(self, item): |
553.1.3
by Jelmer Vernooij
Use absolute imports. |
92 |
from bzrlib.plugins.gtk.preferences import PreferencesWindow |
213
by Jelmer Vernooij
Show preferences dialog from notify area icon, fix GPG display. |
93 |
prefs = PreferencesWindow() |
94 |
prefs.run() |
|
211
by Jelmer Vernooij
Move notification area code into separate file. |
95 |