/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 viz/diffwin.py

  • Committer: Jelmer Vernooij
  • Date: 2006-05-19 16:37:13 UTC
  • Revision ID: jelmer@samba.org-20060519163713-be77b31c72cbc7e8
Move visualisation code to a separate directory, preparing for bundling 
the GTK+ plugins for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from bzrlib.delta import compare_trees
25
25
from bzrlib.diff import show_diff_trees
26
 
from bzrlib.errors import NoSuchFile
27
26
 
28
27
 
29
28
class DiffWindow(gtk.Window):
33
32
    differences between two revisions on a branch.
34
33
    """
35
34
 
36
 
    def __init__(self):
 
35
    def __init__(self, app=None):
37
36
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
38
37
        self.set_border_width(0)
39
38
        self.set_title("bzrk diff")
40
39
 
 
40
        self.app = app
 
41
 
41
42
        # Use two thirds of the screen by default
42
43
        screen = self.get_screen()
43
44
        monitor = screen.get_monitor_geometry(0)
50
51
    def construct(self):
51
52
        """Construct the window contents."""
52
53
        hbox = gtk.HBox(spacing=6)
53
 
        hbox.set_border_width(0)
 
54
        hbox.set_border_width(12)
54
55
        self.add(hbox)
55
56
        hbox.show()
56
57
 
99
100
        scrollwin.add(sourceview)
100
101
        sourceview.show()
101
102
 
102
 
    def set_diff(self, description, rev_tree, parent_tree):
 
103
    def set_diff(self, branch, revid, parentid):
103
104
        """Set the differences showed by this window.
104
105
 
105
106
        Compares the two trees and populates the window with the
106
107
        differences.
107
108
        """
108
 
        self.rev_tree = rev_tree
109
 
        self.parent_tree = parent_tree
 
109
        self.rev_tree = branch.repository.revision_tree(revid)
 
110
        self.parent_tree = branch.repository.revision_tree(parentid)
110
111
 
111
112
        self.model.clear()
112
113
        delta = compare_trees(self.parent_tree, self.rev_tree)
127
128
            titer = self.model.append(None, [ "Renamed", None ])
128
129
            for oldpath, newpath, id, kind, text_modified, meta_modified \
129
130
                    in delta.renamed:
130
 
                self.model.append(titer, [ oldpath, newpath ])
 
131
                self.model.append(titer, [ oldpath, oldpath ])
131
132
 
132
133
        if len(delta.modified):
133
134
            titer = self.model.append(None, [ "Modified", None ])
135
136
                self.model.append(titer, [ path, path ])
136
137
 
137
138
        self.treeview.expand_all()
138
 
        self.set_title(description + " - bzrk diff")
139
 
 
140
 
    def set_file(self, file_path):
141
 
        tv_path = None
142
 
        for data in self.model:
143
 
            for child in data.iterchildren():
144
 
                if child[0] == file_path or child[1] == file_path:
145
 
                    tv_path = child.path
146
 
                    break
147
 
        if tv_path is None:
148
 
            raise NoSuchFile(file_path)
149
 
        self.treeview.set_cursor(tv_path)
150
 
        self.treeview.scroll_to_cell(tv_path)
 
139
        self.set_title(revid + " - " + branch.nick + " - bzrk diff")
151
140
 
152
141
    def _treeview_cursor_cb(self, *args):
153
142
        """Callback for when the treeview cursor changes."""