1
# Copyright (C) 2007 by Jelmer Vernooij <jelmer@samba.org>
 
 
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.
 
 
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.
 
 
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."""
 
 
27
class RevisionPopupMenu(gtk.Menu):
 
 
28
    def __init__(self, repository, revids, branch=None):
 
 
29
        super(RevisionPopupMenu, self).__init__()
 
 
31
        self.repository = repository
 
 
35
    def create_items(self):
 
 
36
        if len(self.revids) == 1:
 
 
37
            item = gtk.MenuItem("View _Diff")
 
 
38
            item.connect('activate', self.show_diff)
 
 
42
            item = gtk.MenuItem("_Push")
 
 
43
            item.connect('activate', self.show_push)
 
 
47
    def show_diff(self, item):
 
 
48
        from bzrlib.plugins.gtk.diff import DiffWindow
 
 
50
        parentid = self.repository.revision_parents(self.revids[0])[0]
 
 
51
        (parent_tree, rev_tree) = self.repository.revision_trees(
 
 
52
            [parentid, self.revids[0]])
 
 
53
        window.set_diff(self.revids[0], rev_tree, parent_tree)
 
 
56
    def show_push(self, item):
 
 
57
        from bzrlib.plugins.gtk.push import PushDialog
 
 
58
        dialog = PushDialog(self.repository, self.revids[0], self.branch)