/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 diff.py

  • Committer: Aaron Bentley
  • Date: 2008-01-14 04:20:46 UTC
  • Revision ID: aaron@aaronbentley.com-20080114042046-d690w1m6qkpnm6bv
Add ghandle-patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from bzrlib.plugins.gtk.window import Window
38
38
 
39
39
 
40
 
class DiffView(gtk.ScrolledWindow):
41
 
    """This is the soft and chewy filling for a DiffWindow."""
 
40
class DiffFileView(gtk.ScrolledWindow):
42
41
 
43
42
    def __init__(self):
44
43
        gtk.ScrolledWindow.__init__(self)
45
 
 
46
44
        self.construct()
47
 
        self.rev_tree = None
48
 
        self.parent_tree = None
 
45
        self._diffs = {}
49
46
 
50
47
    def construct(self):
51
48
        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
134
131
 
135
132
            lang.set_tag_style(tag_id, style)
136
133
 
137
 
    @staticmethod
138
 
    def apply_colordiff_colors(lang):
 
134
    @classmethod
 
135
    def apply_colordiff_colors(klass, lang):
139
136
        """Set style colors for lang using the colordiff configuration file.
140
137
 
141
138
        Both ~/.colordiffrc and ~/.colordiffrc.bzr-gtk are read.
152
149
                except IOError, e:
153
150
                    warning('could not open file %s: %s' % (f, str(e)))
154
151
                else:
155
 
                    colors.update(DiffView.parse_colordiffrc(f))
 
152
                    colors.update(klass.parse_colordiffrc(f))
156
153
                    f.close()
157
154
 
158
155
        if not colors:
237
234
#            self.parent_tree.unlock()
238
235
 
239
236
    def show_diff(self, specific_files):
 
237
        self.buffer.set_text(self._diffs[None])
 
238
 
 
239
 
 
240
class DiffView(DiffFileView):
 
241
    """This is the soft and chewy filling for a DiffWindow."""
 
242
 
 
243
    def __init__(self):
 
244
        DiffFileView.__init__(self)
 
245
        self.rev_tree = None
 
246
        self.parent_tree = None
 
247
 
 
248
    def show_diff(self, specific_files):
240
249
        s = StringIO()
241
250
        show_diff_trees(self.parent_tree, self.rev_tree, s, specific_files,
242
251
                        old_label='', new_label='',
287
296
        # The   window  consists  of   a  pane   containing:  the
288
297
        # hierarchical list  of files on  the left, and  the diff
289
298
        # for the currently selected file on the right.
290
 
        pane = gtk.HPaned()
291
 
        self.add(pane)
292
 
        pane.show()
 
299
        self.pane = gtk.HPaned()
 
300
        self.add(self.pane)
 
301
        self.pane.show()
293
302
 
294
303
        # The file hierarchy: a scrollable treeview
295
304
        scrollwin = gtk.ScrolledWindow()
296
305
        scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
297
306
        scrollwin.set_shadow_type(gtk.SHADOW_IN)
298
 
        pane.pack1(scrollwin)
 
307
        self.pane.pack1(scrollwin)
299
308
        scrollwin.show()
300
309
 
301
310
        self.model = gtk.TreeStore(str, str)
313
322
        column.add_attribute(cell, "text", 0)
314
323
        self.treeview.append_column(column)
315
324
 
 
325
    def set_diff_text(self, description, text):
316
326
        # The diffs of the  selected file: a scrollable source or
317
327
        # text view
318
 
        self.diff_view = DiffView()
319
 
        pane.pack2(self.diff_view)
 
328
        self.diff_view = DiffFileView()
320
329
        self.diff_view.show()
 
330
        self.pane.pack2(self.diff_view)
 
331
        self.model.append(None, [ "Complete Diff", "" ])
 
332
        self.diff_view._diffs[None] = text
 
333
        
321
334
 
322
335
    def set_diff(self, description, rev_tree, parent_tree):
323
336
        """Set the differences showed by this window.
325
338
        Compares the two trees and populates the window with the
326
339
        differences.
327
340
        """
 
341
        # The diffs of the  selected file: a scrollable source or
 
342
        # text view
 
343
        self.diff_view = DiffView()
 
344
        self.pane.pack2(self.diff_view)
 
345
        self.diff_view.show()
328
346
        self.diff_view.set_trees(rev_tree, parent_tree)
329
347
        self.rev_tree = rev_tree
330
348
        self.parent_tree = parent_tree