283
283
self.buffer.set_text(decoded.encode('UTF-8'))
286
class DiffWindow(Window):
286
class DiffWidget(gtk.HPaned):
289
This object represents and manages a single window containing the
290
differences between two revisions on a branch.
293
def __init__(self, parent=None):
294
Window.__init__(self, parent)
295
self.set_border_width(0)
296
self.set_title("bzrk diff")
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)
307
def _get_button_bar(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()
318
self.pane = gtk.HPaned()
319
self.vbox.pack_end(self.pane, expand=True, fill=True)
320
hbox = self._get_button_bar()
322
self.vbox.pack_start(hbox, expand=False, fill=True)
291
super(DiffWidget, self).__init__()
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)
332
300
self.model = gtk.TreeStore(str, str)
344
312
column.add_attribute(cell, "text", 0)
345
313
self.treeview.append_column(column)
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
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)
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.
365
333
Compares the two trees and populates the window with the
368
# The diffs of the selected file: a scrollable source or
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 ])
403
369
self.treeview.expand_all()
404
self.set_title(description + " - bzrk diff")
405
self.diff_view.show_diff(None)
407
371
def set_file(self, file_path):
428
392
self.diff_view.show_diff(specific_files)
395
class DiffWindow(Window):
398
This object represents and manages a single window containing the
399
differences between two revisions on a branch.
402
def __init__(self, parent=None):
403
Window.__init__(self, parent)
404
self.set_border_width(0)
405
self.set_title("bzrk diff")
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)
417
"""Construct the window contents."""
418
self.vbox = gtk.VBox()
421
hbox = self._get_button_bar()
423
self.vbox.pack_start(hbox, expand=False, fill=True)
424
self.diff = DiffWidget()
425
self.vbox.add(self.diff)
428
def _get_button_bar(self):
431
def set_diff_text(self, description, lines):
432
self.diff.set_diff_text(lines)
433
self.set_title(description + " - bzrk diff")
435
def set_diff(self, description, rev_tree, parent_tree):
436
"""Set the differences showed by this window.
438
Compares the two trees and populates the window with the
441
self.diff.set_diff(rev_tree, parent_tree)
442
self.set_title(description + " - bzrk diff")
444
def set_file(self, file_path):
445
self.diff.set_file(file_path)
431
448
class MergeDirectiveWindow(DiffWindow):
433
450
def __init__(self, directive, parent=None):