/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: Aaron Bentley
  • Date: 2006-06-15 03:01:40 UTC
  • mto: This revision was merged to the branch mainline in revision 60.
  • Revision ID: aaron.bentley@utoronto.ca-20060615030140-8ed89f08505ef311
Fix gannotate now that configobj.validator is deleted

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
import gtk
16
16
import pango
17
 
import sys
18
17
 
19
18
try:
20
19
    import gtksourceview
22
21
except ImportError:
23
22
    have_gtksourceview = False
24
23
 
25
 
import bzrlib
26
 
 
 
24
from bzrlib.delta import compare_trees
27
25
from bzrlib.diff import show_diff_trees
28
 
from bzrlib.errors import NoSuchFile
29
26
 
30
27
 
31
28
class DiffWindow(gtk.Window):
51
48
 
52
49
    def construct(self):
53
50
        """Construct the window contents."""
54
 
        # The   window  consists  of   a  pane   containing:  the
55
 
        # hierarchical list  of files on  the left, and  the diff
56
 
        # for the currently selected file on the right.
57
 
        pane = gtk.HPaned()
58
 
        self.add(pane)
59
 
        pane.show()
 
51
        hbox = gtk.HBox(spacing=6)
 
52
        hbox.set_border_width(0)
 
53
        self.add(hbox)
 
54
        hbox.show()
60
55
 
61
 
        # The file hierarchy: a scrollable treeview
62
56
        scrollwin = gtk.ScrolledWindow()
63
57
        scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
64
58
        scrollwin.set_shadow_type(gtk.SHADOW_IN)
65
 
        pane.pack1(scrollwin)
 
59
        hbox.pack_start(scrollwin, expand=False, fill=True)
66
60
        scrollwin.show()
67
61
 
68
62
        self.model = gtk.TreeStore(str, str)
80
74
        column.add_attribute(cell, "text", 0)
81
75
        self.treeview.append_column(column)
82
76
 
83
 
        # The diffs of the  selected file: a scrollable source or
84
 
        # text view
 
77
 
85
78
        scrollwin = gtk.ScrolledWindow()
86
79
        scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
87
80
        scrollwin.set_shadow_type(gtk.SHADOW_IN)
88
 
        pane.pack2(scrollwin)
 
81
        hbox.pack_start(scrollwin, expand=True, fill=True)
89
82
        scrollwin.show()
90
83
 
91
84
        if have_gtksourceview:
115
108
        self.parent_tree = parent_tree
116
109
 
117
110
        self.model.clear()
118
 
        delta = self.rev_tree.changes_from(self.parent_tree)
 
111
        delta = compare_trees(self.parent_tree, self.rev_tree)
119
112
 
120
113
        self.model.append(None, [ "Complete Diff", "" ])
121
114
 
133
126
            titer = self.model.append(None, [ "Renamed", None ])
134
127
            for oldpath, newpath, id, kind, text_modified, meta_modified \
135
128
                    in delta.renamed:
136
 
                self.model.append(titer, [ oldpath, newpath ])
 
129
                self.model.append(titer, [ oldpath, oldpath ])
137
130
 
138
131
        if len(delta.modified):
139
132
            titer = self.model.append(None, [ "Modified", None ])
143
136
        self.treeview.expand_all()
144
137
        self.set_title(description + " - bzrk diff")
145
138
 
146
 
    def set_file(self, file_path):
147
 
        tv_path = None
148
 
        for data in self.model:
149
 
            for child in data.iterchildren():
150
 
                if child[0] == file_path or child[1] == file_path:
151
 
                    tv_path = child.path
152
 
                    break
153
 
        if tv_path is None:
154
 
            raise NoSuchFile(file_path)
155
 
        self.treeview.set_cursor(tv_path)
156
 
        self.treeview.scroll_to_cell(tv_path)
157
 
 
158
139
    def _treeview_cursor_cb(self, *args):
159
140
        """Callback for when the treeview cursor changes."""
160
141
        (path, col) = self.treeview.get_cursor()
166
147
 
167
148
        s = StringIO()
168
149
        show_diff_trees(self.parent_tree, self.rev_tree, s, specific_files)
169
 
        self.buffer.set_text(s.getvalue().decode(sys.getdefaultencoding(), 'replace'))
 
150
        self.buffer.set_text(s.getvalue())