/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-02-23 04:55:56 UTC
  • mfrom: (423.1.16 trunk)
  • Revision ID: aaron@aaronbentley.com-20080223045556-xl3kf2v61crquq83
MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
283
283
        self.buffer.set_text(decoded.encode('UTF-8'))
284
284
 
285
285
 
286
 
class DiffWindow(Window):
287
 
    """Diff window.
 
286
class DiffWidget(gtk.HPaned):
 
287
    """Diff widget
288
288
 
289
 
    This object represents and manages a single window containing the
290
 
    differences between two revisions on a branch.
291
289
    """
292
 
 
293
 
    def __init__(self, parent=None):
294
 
        Window.__init__(self, parent)
295
 
        self.set_border_width(0)
296
 
        self.set_title("bzrk diff")
297
 
 
298
 
        # Use two thirds of the screen by default
299
 
        screen = self.get_screen()
300
 
        monitor = screen.get_monitor_geometry(0)
301
 
        width = int(monitor.width * 0.66)
302
 
        height = int(monitor.height * 0.66)
303
 
        self.set_default_size(width, height)
304
 
 
305
 
        self.construct()
306
 
 
307
 
    def _get_button_bar(self):
308
 
        return None
309
 
 
310
 
    def construct(self):
311
 
        """Construct the window contents."""
312
 
        # The   window  consists  of   a  pane   containing:  the
313
 
        # hierarchical list  of files on  the left, and  the diff
314
 
        # for the currently selected file on the right.
315
 
        self.vbox = gtk.VBox()
316
 
        self.add(self.vbox)
317
 
        self.vbox.show()
318
 
        self.pane = gtk.HPaned()
319
 
        self.vbox.pack_end(self.pane, expand=True, fill=True)
320
 
        hbox = self._get_button_bar()
321
 
        if hbox is not None:
322
 
            self.vbox.pack_start(hbox, expand=False, fill=True)
323
 
        self.pane.show()
 
290
    def __init__(self):
 
291
        super(DiffWidget, self).__init__()
324
292
 
325
293
        # The file hierarchy: a scrollable treeview
326
294
        scrollwin = gtk.ScrolledWindow()
327
295
        scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
328
296
        scrollwin.set_shadow_type(gtk.SHADOW_IN)
329
 
        self.pane.pack1(scrollwin)
 
297
        self.pack1(scrollwin)
330
298
        scrollwin.show()
331
299
 
332
300
        self.model = gtk.TreeStore(str, str)
344
312
        column.add_attribute(cell, "text", 0)
345
313
        self.treeview.append_column(column)
346
314
 
347
 
    def set_diff_text(self, description, lines):
 
315
    def set_diff_text(self, lines):
348
316
        # The diffs of the  selected file: a scrollable source or
349
317
        # text view
350
318
        self.diff_view = DiffFileView()
351
319
        self.diff_view.show()
352
 
        self.pane.pack2(self.diff_view)
 
320
        self.pack2(self.diff_view)
353
321
        self.model.append(None, [ "Complete Diff", "" ])
354
322
        self.diff_view._diffs[None] = ''.join(lines)
355
323
        for patch in parse_patches(lines):
359
327
            self.diff_view._diffs[newname] = str(patch)
360
328
        self.diff_view.show_diff(None)
361
329
 
362
 
    def set_diff(self, description, rev_tree, parent_tree):
 
330
    def set_diff(self, rev_tree, parent_tree):
363
331
        """Set the differences showed by this window.
364
332
 
365
333
        Compares the two trees and populates the window with the
366
334
        differences.
367
335
        """
368
 
        # The diffs of the  selected file: a scrollable source or
369
 
        # text view
370
336
        self.diff_view = DiffView()
371
 
        self.pane.pack2(self.diff_view)
 
337
        self.pack2(self.diff_view)
372
338
        self.diff_view.show()
373
339
        self.diff_view.set_trees(rev_tree, parent_tree)
374
340
        self.rev_tree = rev_tree
401
367
                self.model.append(titer, [ path, path ])
402
368
 
403
369
        self.treeview.expand_all()
404
 
        self.set_title(description + " - bzrk diff")
405
 
        self.diff_view.show_diff(None)
406
370
 
407
371
    def set_file(self, file_path):
408
372
        tv_path = None
428
392
        self.diff_view.show_diff(specific_files)
429
393
 
430
394
 
 
395
class DiffWindow(Window):
 
396
    """Diff window.
 
397
 
 
398
    This object represents and manages a single window containing the
 
399
    differences between two revisions on a branch.
 
400
    """
 
401
 
 
402
    def __init__(self, parent=None):
 
403
        Window.__init__(self, parent)
 
404
        self.set_border_width(0)
 
405
        self.set_title("bzrk diff")
 
406
 
 
407
        # Use two thirds of the screen by default
 
408
        screen = self.get_screen()
 
409
        monitor = screen.get_monitor_geometry(0)
 
410
        width = int(monitor.width * 0.66)
 
411
        height = int(monitor.height * 0.66)
 
412
        self.set_default_size(width, height)
 
413
 
 
414
        self.construct()
 
415
 
 
416
    def construct(self):
 
417
        """Construct the window contents."""
 
418
        self.vbox = gtk.VBox()
 
419
        self.add(self.vbox)
 
420
        self.vbox.show()
 
421
        hbox = self._get_button_bar()
 
422
        if hbox is not None:
 
423
            self.vbox.pack_start(hbox, expand=False, fill=True)
 
424
        self.diff = DiffWidget()
 
425
        self.vbox.add(self.diff)
 
426
        self.diff.show_all()
 
427
 
 
428
    def _get_button_bar(self):
 
429
        return None
 
430
 
 
431
    def set_diff_text(self, description, lines):
 
432
        self.diff.set_diff_text(lines)
 
433
        self.set_title(description + " - bzrk diff")
 
434
 
 
435
    def set_diff(self, description, rev_tree, parent_tree):
 
436
        """Set the differences showed by this window.
 
437
 
 
438
        Compares the two trees and populates the window with the
 
439
        differences.
 
440
        """
 
441
        self.diff.set_diff(rev_tree, parent_tree)
 
442
        self.set_title(description + " - bzrk diff")
 
443
 
 
444
    def set_file(self, file_path):
 
445
        self.diff.set_file(file_path)
 
446
 
 
447
 
431
448
class MergeDirectiveWindow(DiffWindow):
432
449
 
433
450
    def __init__(self, directive, parent=None):