/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 bzr-notify

  • Committer: rodney.dawes at canonical
  • Date: 2008-10-25 06:02:09 UTC
  • Revision ID: rodney.dawes@canonical.com-20081025060209-irlizouino63cs1m
        * preferences/__init__.py:
        Remove the dialog separator
        Remove useless extra call to self._create_pages()
        Make the default window size smaller
        Set the default border width on various widgets
        Set the current notebook page to the first one

        * preferences/identity.py:
        Set various border widths appropriately
        Align the labels to the left
        Remove the unneeded bold markup from the labels
        Change the "User Id" label to "E-Mail"
        Align the radio group labels to the top of the groups

        * preferences/plugins.py:
        Set various border widths appropriately
        Set the default paned position to something more sensible
        Set the shadow type on the treeview's scrolled window to in
        Align the Author and Version labels to the left

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
"""Run the bzr tray icon.
 
4
 
 
5
This is a background program which will pop up a notification on the users
 
6
screen when a commit occurs.
 
7
"""
 
8
 
 
9
from bzrlib.plugin import load_plugins
 
10
load_plugins()
 
11
 
 
12
from bzrlib.plugins.gtk import open_display, icon_path
 
13
 
 
14
from bzrlib.plugins.gtk.notify import NotifyPopupMenu
 
15
gtk = open_display()
 
16
menu = NotifyPopupMenu()
 
17
icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
 
18
icon.connect('popup-menu', menu.display)
 
19
icon.set_visible(False)
 
20
 
 
21
import cgi
 
22
import dbus
 
23
import dbus.service
 
24
import pynotify
 
25
from bzrlib.bzrdir import BzrDir
 
26
from bzrlib import errors
 
27
from bzrlib.osutils import format_date
 
28
from bzrlib.transport import get_transport
 
29
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
 
30
        import dbus.glib
 
31
BROADCAST_INTERFACE = "org.bazaarvcs.plugins.dbus.Broadcast"
 
32
bus = dbus.SessionBus()
 
33
 
 
34
def hide_icon():
 
35
        icon.set_visible(False)
 
36
 
 
37
def catch_branch(revision_id, urls):
 
38
        # TODO: show all the urls, or perhaps choose the 'best'.
 
39
        url = urls[0]
 
40
        try:
 
41
                if isinstance(revision_id, unicode):
 
42
                        revision_id = revision_id.encode('utf8')
 
43
                transport = get_transport(url)
 
44
                a_dir = BzrDir.open_from_transport(transport)
 
45
                branch = a_dir.open_branch()
 
46
                revno = branch.revision_id_to_revno(revision_id)
 
47
                revision = branch.repository.get_revision(revision_id)
 
48
                summary = 'New revision %d in %s' % (revno, url)
 
49
                body  = 'Committer: %s\n' % revision.committer
 
50
                body += 'Date: %s\n' % format_date(revision.timestamp,
 
51
                        revision.timezone)
 
52
                body += '\n'
 
53
                body += revision.message
 
54
                body = cgi.escape(body)
 
55
                nw = pynotify.Notification(summary, body)
 
56
                def start_viz(notification=None, action=None, data=None):
 
57
                        """Start the viz program."""
 
58
                        pp = start_viz_window(branch, revision_id)
 
59
                        pp.show()
 
60
                def start_branch(notification=None, action=None, data=None):
 
61
                        """Start a Branch dialog"""
 
62
                        from bzrlib.plugins.gtk.branch import BranchDialog
 
63
                        bd = BranchDialog(remote_path=url)
 
64
                        bd.run()
 
65
                nw.add_action("inspect", "Inspect", start_viz, None)
 
66
                nw.add_action("branch", "Branch", start_branch, None)
 
67
                icon.set_visible(True)
 
68
                gobject.timeout_add(5000, hide_icon)
 
69
                nw.set_timeout(5000)
 
70
                nw.show()
 
71
        except Exception, e:
 
72
                print e
 
73
                raise
 
74
bus.add_signal_receiver(catch_branch,
 
75
                                                dbus_interface=BROADCAST_INTERFACE,
 
76
                                                signal_name="Revision")
 
77
pynotify.init("bzr-notify")
 
78
gtk.main()