/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: 2012-03-29 13:15:14 UTC
  • mfrom: (786.1.1 register-lazy)
  • Revision ID: jelmer@samba.org-20120329131514-knrl1w2wzntx89rv
Use lazy registration.

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