/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: Jelmer Vernooij
  • Date: 2008-01-26 23:48:18 UTC
  • mto: (423.1.10 trunk)
  • mto: This revision was merged to the branch mainline in revision 429.
  • Revision ID: jelmer@samba.org-20080126234818-q8tj21lrn588fg3c
Allow using the diff control as a widget

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
        self.buffer.set_text(decoded.encode('UTF-8'))
262
262
 
263
263
 
264
 
class DiffWindow(Window):
265
 
    """Diff window.
 
264
class DiffWidget(gtk.HPaned):
 
265
    """Diff widget
266
266
 
267
 
    This object represents and manages a single window containing the
268
 
    differences between two revisions on a branch.
269
267
    """
270
 
 
271
 
    def __init__(self, parent=None):
272
 
        Window.__init__(self, parent)
273
 
        self.set_border_width(0)
274
 
        self.set_title("bzrk diff")
275
 
 
276
 
        # Use two thirds of the screen by default
277
 
        screen = self.get_screen()
278
 
        monitor = screen.get_monitor_geometry(0)
279
 
        width = int(monitor.width * 0.66)
280
 
        height = int(monitor.height * 0.66)
281
 
        self.set_default_size(width, height)
282
 
 
283
 
        self.construct()
284
 
 
285
 
    def construct(self):
286
 
        """Construct the window contents."""
287
 
        # The   window  consists  of   a  pane   containing:  the
288
 
        # hierarchical list  of files on  the left, and  the diff
289
 
        # for the currently selected file on the right.
290
 
        pane = gtk.HPaned()
291
 
        self.add(pane)
292
 
        pane.show()
 
268
    def __init__(self):
 
269
        super(DiffWidget, self).__init__()
293
270
 
294
271
        # The file hierarchy: a scrollable treeview
295
272
        scrollwin = gtk.ScrolledWindow()
296
273
        scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
297
274
        scrollwin.set_shadow_type(gtk.SHADOW_IN)
298
 
        pane.pack1(scrollwin)
 
275
        self.pack1(scrollwin)
299
276
        scrollwin.show()
300
277
 
301
278
        self.model = gtk.TreeStore(str, str)
316
293
        # The diffs of the  selected file: a scrollable source or
317
294
        # text view
318
295
        self.diff_view = DiffView()
319
 
        pane.pack2(self.diff_view)
 
296
        self.pack2(self.diff_view)
320
297
        self.diff_view.show()
321
298
 
322
 
    def set_diff(self, description, rev_tree, parent_tree):
 
299
    def set_diff(self, rev_tree, parent_tree):
323
300
        """Set the differences showed by this window.
324
301
 
325
302
        Compares the two trees and populates the window with the
356
333
                self.model.append(titer, [ path, path ])
357
334
 
358
335
        self.treeview.expand_all()
359
 
        self.set_title(description + " - bzrk diff")
360
336
 
361
337
    def set_file(self, file_path):
362
338
        tv_path = None
382
358
        self.diff_view.show_diff(specific_files)
383
359
 
384
360
 
 
361
class DiffWindow(Window):
 
362
    """Diff window.
 
363
 
 
364
    This object represents and manages a single window containing the
 
365
    differences between two revisions on a branch.
 
366
    """
 
367
 
 
368
    def __init__(self, parent=None):
 
369
        Window.__init__(self, parent)
 
370
        self.set_border_width(0)
 
371
        self.set_title("bzrk diff")
 
372
 
 
373
        # Use two thirds of the screen by default
 
374
        screen = self.get_screen()
 
375
        monitor = screen.get_monitor_geometry(0)
 
376
        width = int(monitor.width * 0.66)
 
377
        height = int(monitor.height * 0.66)
 
378
        self.set_default_size(width, height)
 
379
 
 
380
        self.construct()
 
381
 
 
382
    def construct(self):
 
383
        """Construct the window contents."""
 
384
        self.diff = DiffWidget()
 
385
        self.add(self.diff)
 
386
        self.diff.show_all()
 
387
 
 
388
    def set_diff(self, description, rev_tree, parent_tree):
 
389
        """Set the differences showed by this window.
 
390
 
 
391
        Compares the two trees and populates the window with the
 
392
        differences.
 
393
        """
 
394
        self.diff.set_diff(rev_tree, parent_tree)
 
395
        self.set_title(description + " - bzrk diff")
 
396
 
 
397
    def set_file(self, file_path):
 
398
        self.diff.set_file(file_path)
 
399
 
 
400
 
385
401
def _iter_changes_to_status(source, target):
386
402
    """Determine the differences between trees.
387
403