/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: David Planella
  • Date: 2010-08-21 09:32:13 UTC
  • mto: This revision was merged to the branch mainline in revision 719.
  • Revision ID: david.planella@ubuntu.com-20100821093213-njpqd5sploa8n71m
Adapted desktop entries for translation

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
 
19
25
import gtk
 
26
import bzrlib
 
27
 
 
28
 
 
29
def has_dbus():
 
30
    return (getattr(bzrlib.plugins, "dbus", None) is not None)
 
31
 
 
32
 
 
33
def has_avahi():
 
34
    return (getattr(bzrlib.plugins, "avahi", None) is not None)
 
35
 
20
36
 
21
37
class NotifyPopupMenu(gtk.Menu):
22
38
    def __init__(self):
24
40
        self.create_items()
25
41
 
26
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)
 
46
        self.append(item)
 
47
        self.append(gtk.SeparatorMenuItem())
27
48
        try:
28
49
            from bzrlib.plugins.dbus.activity import LanGateway
29
50
            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
51
        except ImportError:
35
 
            pass
 
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)
36
57
 
 
58
        item = gtk.CheckMenuItem('Announce _branches on LAN')
 
59
        item.connect('toggled', self.toggle_announce_branches)
 
60
        self.append(item)
 
61
        self.append(gtk.SeparatorMenuItem())
37
62
        try:
38
63
            from bzrlib.plugins.avahi.share import ZeroConfServer
39
64
            from bzrlib import urlutils
40
65
            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
66
        except ImportError:
46
 
            pass
 
67
            item.set_sensitive(False)
47
68
 
48
69
        item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)
49
70
        item.connect('activate', self.show_preferences)
74
95
            self.zeroconfserver.close()
75
96
 
76
97
    def show_about(self, item):
77
 
        from about import AboutDialog
 
98
        from bzrlib.plugins.gtk.about import AboutDialog
78
99
        dialog = AboutDialog()
79
100
        dialog.run()
80
101
 
81
102
    def show_preferences(self, item):
82
 
        from preferences import PreferencesWindow
 
103
        from bzrlib.plugins.gtk.preferences import PreferencesWindow
83
104
        prefs = PreferencesWindow()
84
105
        prefs.run()
85
106