/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
226 by Jelmer Vernooij
Add context menu in bzrk.
1
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
"""Simple popup menu for revisions."""
17
18
try:
19
    import pygtk
20
    pygtk.require("2.0")
21
except:
22
    pass
23
24
import bzrlib
25
import gtk
26
27
class RevisionPopupMenu(gtk.Menu):
28
    def __init__(self, repository, revid):
29
        super(RevisionPopupMenu, self).__init__()
30
        self.create_items()
31
        self.repository = repository
32
        self.revid = revid
33
34
    def create_items(self):
35
        item = gtk.MenuItem("View _Diff")
36
        item.connect('activate', self.show_diff)
37
        self.append(item)
38
        self.show_all()
39
40
    def show_diff(self, item):
41
        from bzrlib.plugins.gtk.diff import DiffWindow
42
        window = DiffWindow()
43
        parentid = self.repository.revision_parents(self.revid)[0]
44
        (parent_tree, rev_tree) = self.repository.revision_trees([parentid, 
45
                                                                   self.revid])
46
        window.set_diff(self.revid, rev_tree, parent_tree)
47
        window.show()