/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to notify.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-06 14:53:44 UTC
  • Revision ID: jelmer@samba.org-20110406145344-m6s0i7q7ssjwhmwq
Support use without gtk.Spinner, which is only available in pygtk >= 2.22.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
"""Notification area icon and notification for Bazaar."""
18
18
 
19
 
from gi.repository import Gtk
 
19
try:
 
20
    import pygtk
 
21
    pygtk.require("2.0")
 
22
except:
 
23
    pass
 
24
 
 
25
import gtk
20
26
import bzrlib
21
27
 
22
28
 
28
34
    return (getattr(bzrlib.plugins, "avahi", None) is not None)
29
35
 
30
36
 
31
 
class NotifyPopupMenu(Gtk.Menu):
32
 
 
33
 
    SHOW_WIDGETS = True
 
37
class NotifyPopupMenu(gtk.Menu):
34
38
 
35
39
    def __init__(self):
36
40
        super(NotifyPopupMenu, self).__init__()
38
42
 
39
43
    def create_items(self):
40
44
        from bzrlib import errors
41
 
        item = Gtk.CheckMenuItem.new_with_mnemonic('_Gateway to LAN')
 
45
        item = gtk.CheckMenuItem('_Gateway to LAN')
42
46
        item.connect('toggled', self.toggle_lan_gateway)
43
47
        self.append(item)
44
 
        self.append(Gtk.SeparatorMenuItem())
 
48
        self.append(gtk.SeparatorMenuItem())
45
49
        try:
46
50
            from bzrlib.plugins.dbus.activity import LanGateway
47
51
            self.langateway = LanGateway()
48
52
        except ImportError:
49
53
            item.set_sensitive(False)
50
54
        except errors.BzrError:
51
 
            # FIXME: Should only catch errors that indicate a lan-notify
 
55
            # FIXME: Should only catch errors that indicate a lan-notify 
52
56
            # process is already running.
53
57
            item.set_sensitive(False)
54
58
 
55
 
        item = Gtk.CheckMenuItem.new_with_mnemonic(
56
 
            'Announce _branches on LAN')
 
59
        item = gtk.CheckMenuItem('Announce _branches on LAN')
57
60
        item.connect('toggled', self.toggle_announce_branches)
58
61
        self.append(item)
59
 
        self.append(Gtk.SeparatorMenuItem())
 
62
        self.append(gtk.SeparatorMenuItem())
60
63
        try:
61
64
            from bzrlib.plugins.avahi.share import ZeroConfServer
62
65
            from bzrlib import urlutils
64
67
        except ImportError:
65
68
            item.set_sensitive(False)
66
69
 
67
 
        item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_PREFERENCES, None)
 
70
        item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)
68
71
        item.connect('activate', self.show_preferences)
69
72
        self.append(item)
70
 
        item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ABOUT, None)
 
73
        item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, None)
71
74
        item.connect('activate', self.show_about)
72
75
        self.append(item)
73
 
        self.append(Gtk.SeparatorMenuItem())
74
 
        item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, None)
75
 
        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)
76
79
        self.append(item)
77
 
        if self.SHOW_WIDGETS:
78
 
            self.show_all()
 
80
        self.show_all()
79
81
 
80
82
    def display(self, icon, event_button, event_time):
81
 
        self.popup(None, None, Gtk.status_icon_position_menu,
 
83
        self.popup(None, None, gtk.status_icon_position_menu, 
82
84
               event_button, event_time, icon)
83
85
 
84
86
    def toggle_lan_gateway(self, item):
102
104
        from bzrlib.plugins.gtk.preferences import PreferencesWindow
103
105
        prefs = PreferencesWindow()
104
106
        prefs.run()
 
107