20
20
from bzrlib.plugins.gtk.branchview.graphcell import CellRendererGraph
23
class TreeView(gtk.VBox):
23
class TreeView(Gtk.VBox):
25
25
__gproperties__ = {
26
'branch': (gobject.TYPE_PYOBJECT,
26
'branch': (GObject.TYPE_PYOBJECT,
28
28
'The Bazaar branch being visualized',
29
gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_WRITABLE),
29
GObject.PARAM_CONSTRUCT_ONLY | GObject.PARAM_WRITABLE),
31
'revision': (gobject.TYPE_PYOBJECT,
31
'revision': (GObject.TYPE_PYOBJECT,
33
33
'The currently selected revision',
34
gobject.PARAM_READWRITE),
34
GObject.PARAM_READWRITE),
36
'revision-number': (gobject.TYPE_STRING,
36
'revision-number': (GObject.TYPE_STRING,
38
38
'The number of the selected revision',
40
gobject.PARAM_READABLE),
40
GObject.PARAM_READABLE),
42
'children': (gobject.TYPE_PYOBJECT,
42
'children': (GObject.TYPE_PYOBJECT,
44
44
'Children of the currently selected revision',
45
gobject.PARAM_READABLE),
45
GObject.PARAM_READABLE),
47
'parents': (gobject.TYPE_PYOBJECT,
47
'parents': (GObject.TYPE_PYOBJECT,
48
48
'Parent revisions',
49
49
'Parents to the currently selected revision',
50
gobject.PARAM_READABLE),
50
GObject.PARAM_READABLE),
52
'revno-column-visible': (gobject.TYPE_BOOLEAN,
52
'revno-column-visible': (GObject.TYPE_BOOLEAN,
53
53
'Revision number column',
54
54
'Show revision number column',
56
gobject.PARAM_READWRITE),
56
GObject.PARAM_READWRITE),
58
'graph-column-visible': (gobject.TYPE_BOOLEAN,
58
'graph-column-visible': (GObject.TYPE_BOOLEAN,
60
60
'Show graph column',
62
gobject.PARAM_READWRITE),
62
GObject.PARAM_READWRITE),
64
'date-column-visible': (gobject.TYPE_BOOLEAN,
64
'date-column-visible': (GObject.TYPE_BOOLEAN,
66
66
'Show date column',
68
gobject.PARAM_READWRITE),
68
GObject.PARAM_READWRITE),
70
'compact': (gobject.TYPE_BOOLEAN,
70
'compact': (GObject.TYPE_BOOLEAN,
72
72
'Break ancestry lines to save space',
74
gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
74
GObject.PARAM_CONSTRUCT | GObject.PARAM_READWRITE),
76
'mainline-only': (gobject.TYPE_BOOLEAN,
76
'mainline-only': (GObject.TYPE_BOOLEAN,
78
78
'Only show the mainline history.',
80
gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
80
GObject.PARAM_CONSTRUCT | GObject.PARAM_READWRITE),
85
'revision-selected': (gobject.SIGNAL_RUN_FIRST,
85
'revision-selected': (GObject.SignalFlags.RUN_FIRST,
88
'revision-activated': (gobject.SIGNAL_RUN_FIRST,
90
(gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)),
91
'tag-added': (gobject.SIGNAL_RUN_FIRST,
93
(gobject.TYPE_STRING, gobject.TYPE_STRING)),
94
'refreshed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
88
'revision-activated': (GObject.SignalFlags.RUN_FIRST,
90
(GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT)),
91
'tag-added': (GObject.SignalFlags.RUN_FIRST,
93
(GObject.TYPE_STRING, GObject.TYPE_STRING)),
94
'refreshed': (GObject.SignalFlags.RUN_FIRST, None,
105
105
:param broken_line_length: After how much lines to break
108
gtk.VBox.__init__(self, spacing=0)
108
super(TreeView, self).__init__(homogeneous=False, spacing=0)
110
110
self.progress_widget = ProgressPanel()
111
self.pack_start(self.progress_widget, expand=False, fill=True)
111
self.pack_start(self.progress_widget, False, True, 0)
112
112
if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None:
113
113
# We'are using our own ui, let's tell it to use our widget.
114
114
ui.ui_factory.set_progress_bar_widget(self.progress_widget)
116
self.scrolled_window = gtk.ScrolledWindow()
117
self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
118
gtk.POLICY_AUTOMATIC)
119
self.scrolled_window.set_shadow_type(gtk.SHADOW_IN)
116
self.scrolled_window = Gtk.ScrolledWindow()
117
self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
118
Gtk.PolicyType.AUTOMATIC)
119
self.scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
120
120
self.scrolled_window.show()
121
self.pack_start(self.scrolled_window, expand=True, fill=True)
121
self.pack_start(self.scrolled_window, True, True, 0)
123
123
self.scrolled_window.add(self.construct_treeview())
311
312
show_graph = self.graph_column.get_visible()
313
314
self.branch.lock_read()
314
(linegraphdata, index, columns_len) = linegraph(self.branch.repository.get_graph(),
315
(linegraphdata, index, columns_len) = linegraph(
316
self.branch.repository.get_graph(),
322
self.model.line_graph_data = linegraphdata
324
self.model.set_line_graph_data(linegraphdata)
323
325
self.graph_cell.columns_len = columns_len
324
width = self.graph_cell.get_size(self.treeview)[2]
326
width = self.graph_cell.get_preferred_width(self.treeview)[1]
330
# The get_preferred_width() call got an insane value.
327
332
self.graph_column.set_fixed_width(width)
328
333
self.graph_column.set_max_width(width)
329
334
self.index = index
330
335
self.treeview.set_model(self.model)
332
337
if not revision or revision == NULL_REVISION:
333
self.treeview.set_cursor(0)
338
self.treeview.set_cursor(Gtk.TreePath(path=0), None, False)
335
340
self.set_revision(revision)
376
379
self.treeview.show()
378
cell = gtk.CellRendererText()
381
cell = Gtk.CellRendererText()
379
382
cell.set_property("width-chars", 15)
380
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
381
self.revno_column = gtk.TreeViewColumn("Revision No")
383
cell.set_property("ellipsize", Pango.EllipsizeMode.END)
384
self.revno_column = Gtk.TreeViewColumn("Revision No")
382
385
self.revno_column.set_resizable(True)
383
self.revno_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
384
self.revno_column.set_fixed_width(cell.get_size(self.treeview)[2])
385
self.revno_column.pack_start(cell, expand=True)
386
self.revno_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
387
self.revno_column.set_fixed_width(
388
cell.get_preferred_width(self.treeview)[1])
389
self.revno_column.pack_start(cell, True)
386
390
self.revno_column.add_attribute(cell, "text", treemodel.REVNO)
387
391
self.treeview.append_column(self.revno_column)
389
393
self.graph_cell = CellRendererGraph()
390
self.graph_column = gtk.TreeViewColumn()
394
self.graph_column = Gtk.TreeViewColumn()
391
395
self.graph_column.set_resizable(True)
392
self.graph_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
393
self.graph_column.pack_start(self.graph_cell, expand=True)
394
self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE)
395
self.graph_column.add_attribute(self.graph_cell, "tags", treemodel.TAGS)
396
self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES)
397
self.graph_column.add_attribute(self.graph_cell, "out-lines", treemodel.LINES)
396
self.graph_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
397
self.graph_column.pack_start(self.graph_cell, True)
398
self.graph_column.add_attribute(
399
self.graph_cell, "node", treemodel.NODE)
400
self.graph_column.add_attribute(
401
self.graph_cell, "tags", treemodel.TAGS)
402
self.graph_column.add_attribute(
403
self.graph_cell, "in-lines", treemodel.LAST_LINES)
404
self.graph_column.add_attribute(
405
self.graph_cell, "out-lines", treemodel.LINES)
398
406
self.treeview.append_column(self.graph_column)
400
cell = gtk.CellRendererText()
408
cell = Gtk.CellRendererText()
401
409
cell.set_property("width-chars", 65)
402
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
403
self.summary_column = gtk.TreeViewColumn("Summary")
410
cell.set_property("ellipsize", Pango.EllipsizeMode.END)
411
self.summary_column = Gtk.TreeViewColumn("Summary")
404
412
self.summary_column.set_resizable(True)
405
413
self.summary_column.set_expand(True)
406
self.summary_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
407
self.summary_column.set_fixed_width(cell.get_size(self.treeview)[2])
408
self.summary_column.pack_start(cell, expand=True)
414
self.summary_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
415
self.summary_column.set_fixed_width(
416
cell.get_preferred_width(self.treeview)[1])
417
self.summary_column.pack_start(cell, True)
409
418
self.summary_column.add_attribute(cell, "markup", treemodel.SUMMARY)
410
419
self.treeview.append_column(self.summary_column)
412
cell = gtk.CellRendererText()
421
cell = Gtk.CellRendererText()
413
422
cell.set_property("width-chars", 15)
414
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
415
self.authors_column = gtk.TreeViewColumn("Author(s)")
423
cell.set_property("ellipsize", Pango.EllipsizeMode.END)
424
self.authors_column = Gtk.TreeViewColumn("Author(s)")
416
425
self.authors_column.set_resizable(False)
417
self.authors_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
426
self.authors_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
418
427
self.authors_column.set_fixed_width(200)
419
self.authors_column.pack_start(cell, expand=True)
428
self.authors_column.pack_start(cell, True)
420
429
self.authors_column.add_attribute(cell, "text", treemodel.AUTHORS)
421
430
self.treeview.append_column(self.authors_column)
423
cell = gtk.CellRendererText()
432
cell = Gtk.CellRendererText()
424
433
cell.set_property("width-chars", 20)
425
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
426
self.date_column = gtk.TreeViewColumn("Date")
434
cell.set_property("ellipsize", Pango.EllipsizeMode.END)
435
self.date_column = Gtk.TreeViewColumn("Date")
427
436
self.date_column.set_visible(False)
428
437
self.date_column.set_resizable(True)
429
self.date_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
438
self.date_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
430
439
self.date_column.set_fixed_width(130)
431
self.date_column.pack_start(cell, expand=True)
440
self.date_column.pack_start(cell, True)
432
441
self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP)
433
442
self.treeview.append_column(self.date_column)