81
83
self.treeview.connect("row-activated", self._treeview_row_activated_cb)
82
84
self.treeview.connect("button-release-event",
83
85
self._treeview_row_mouseclick)
86
self.treeview.set_property('fixed-height-mode', True)
84
87
scrollwin.add(self.treeview)
85
88
self.treeview.show()
87
cell = CellRendererGraph()
88
column = gtk.TreeViewColumn()
90
cell = gtk.CellRendererText()
91
cell.set_property("width-chars", 15)
92
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
93
column = gtk.TreeViewColumn("Revision No")
89
94
column.set_resizable(True)
90
column.pack_start(cell, expand=False)
91
column.add_attribute(cell, "node", 1)
92
column.add_attribute(cell, "in-lines", 2)
93
column.add_attribute(cell, "out-lines", 3)
95
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
96
column.set_fixed_width(cell.get_size(self.treeview)[2])
97
column.pack_start(cell, expand=True)
98
column.add_attribute(cell, "text", treemodel.REVNO)
94
99
self.treeview.append_column(column)
101
self.graph_cell = CellRendererGraph()
102
self.graph_column = gtk.TreeViewColumn()
103
self.graph_column.set_resizable(True)
104
self.graph_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
105
self.graph_column.pack_start(self.graph_cell, expand=False)
106
self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE)
107
self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES)
108
self.graph_column.add_attribute(self.graph_cell, "out-lines", treemodel.LINES)
109
self.treeview.append_column(self.graph_column)
96
111
cell = gtk.CellRendererText()
97
112
cell.set_property("width-chars", 40)
98
113
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
99
114
column = gtk.TreeViewColumn("Message")
100
115
column.set_resizable(True)
116
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
117
column.set_fixed_width(cell.get_size(self.treeview)[2])
101
118
column.pack_start(cell, expand=True)
102
column.add_attribute(cell, "text", 4)
119
column.add_attribute(cell, "text", treemodel.MESSAGE)
103
120
self.treeview.append_column(column)
105
122
cell = gtk.CellRendererText()
107
124
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
108
125
column = gtk.TreeViewColumn("Committer")
109
126
column.set_resizable(True)
127
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
128
column.set_fixed_width(cell.get_size(self.treeview)[2])
110
129
column.pack_start(cell, expand=True)
111
column.add_attribute(cell, "text", 5)
130
column.add_attribute(cell, "text", treemodel.COMMITER)
112
131
self.treeview.append_column(column)
114
133
cell = gtk.CellRendererText()
134
cell.set_property("width-chars", 40)
115
135
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
116
136
column = gtk.TreeViewColumn("Date")
117
137
column.set_resizable(True)
138
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
139
column.set_fixed_width(cell.get_size(self.treeview)[2])
118
140
column.pack_start(cell, expand=True)
119
column.add_attribute(cell, "text", 6)
141
column.add_attribute(cell, "text", treemodel.TIMESTAMP)
120
142
self.treeview.append_column(column)
170
192
self.branch = branch
172
# [ revision, node, last_lines, lines, message, committer, timestamp ]
173
self.model = gtk.ListStore(gobject.TYPE_PYOBJECT,
174
gobject.TYPE_PYOBJECT,
175
gobject.TYPE_PYOBJECT,
176
gobject.TYPE_PYOBJECT,
179
193
self.set_title(branch.nick + " - bzrk")
180
194
gobject.idle_add(self.populate_model, start, maxnum)
182
196
def populate_model(self, start, maxnum):
186
(self.revisions, colours, self.children, self.parent_ids,
187
merge_sorted) = distances(self.branch.repository, start,
189
for (index, (revision, node, lines)) in enumerate(graph(
190
self.revisions, colours, merge_sorted)):
191
# FIXME: at this point we should be able to show the graph order
192
# and lines with no message or commit data - and then incrementally
193
# fill the timestamp, committer etc data as desired.
194
message = revision.message.split("\n")[0]
195
if revision.committer is not None:
196
timestamp = format_date(revision.timestamp, revision.timezone)
199
self.model.append([revision, node, last_lines, lines,
200
message, revision.committer, timestamp])
201
self.index[revision] = index
203
if maxnum is not None and index > maxnum:
197
(linegraphdata, index, columns_len) = linegraph(self.branch,
200
self.model = TreeModel(self.branch, linegraphdata)
201
self.graph_cell.columns_len = columns_len
202
width = self.graph_cell.get_size(self.treeview)[2]
203
self.graph_column.set_fixed_width(width)
204
self.graph_column.set_max_width(width)
205
206
self.treeview.set_model(self.model)
206
207
self.treeview.get_selection().select_path(0)
222
223
def _on_key_press_q(self, event):
223
224
if event.state & gtk.gdk.CONTROL_MASK:
226
227
def _treeselection_changed_cb(self, selection, *args):
227
228
"""Callback for when the treeview changes."""
228
229
(model, selected_rows) = selection.get_selected_rows()
229
230
if len(selected_rows) > 0:
230
revision = self.model[selected_rows[0]][0]
232
self.back_button.set_sensitive(len(self.parent_ids[revision]) > 0)
233
self.fwd_button.set_sensitive(len(self.children[revision]) > 0)
231
iter = self.model.get_iter(selected_rows[0])
232
revision = self.model.get_value(iter, treemodel.REVISION)
233
parents = self.model.get_value(iter, treemodel.PARENTS)
234
children = self.model.get_value(iter, treemodel.CHILDREN)
236
self.back_button.set_sensitive(len(parents) > 0)
237
self.fwd_button.set_sensitive(len(children) > 0)
235
239
if self.branch.supports_tags():
236
240
tagdict = self.branch.tags.get_reverse_tag_dict()
237
241
if tagdict.has_key(revision.revision_id):
238
242
tags = tagdict[revision.revision_id]
239
self.logview.set_revision(revision, tags)
243
self.logview.set_revision(revision, tags, children)
241
245
def _back_clicked_cb(self, *args):
242
246
"""Callback for when the back button is clicked."""
243
247
(path, col) = self.treeview.get_cursor()
244
248
revision = self.model[path][0]
245
if not len(self.parent_ids[revision]):
249
parents = self.model[path][4]
248
for parent_id in self.parent_ids[revision]:
249
parent = self.revisions[parent_id]
253
for parent_id in parents:
254
parent = self.revisions[self.index[parent_id]]
250
255
if same_branch(revision, parent):
251
self.treeview.set_cursor(self.index[parent])
256
self.treeview.set_cursor(self.index[parent_id])
254
next = self.revisions[self.parent_ids[revision][0]]
255
self.treeview.set_cursor(self.index[next])
259
self.treeview.set_cursor(self.index[parents[0]])
256
260
self.treeview.grab_focus()
258
262
def _fwd_clicked_cb(self, *args):
259
263
"""Callback for when the forward button is clicked."""
260
264
(path, col) = self.treeview.get_cursor()
261
265
revision = self.model[path][0]
262
if not len(self.children[revision]):
266
children = self.model[path][5]
267
if not len(children):
265
for child in self.children[revision]:
270
for child_id in children:
271
child = self.revisions[self.index[child_id]]
266
272
if same_branch(child, revision):
267
self.treeview.set_cursor(self.index[child])
273
self.treeview.set_cursor(self.index[child_id])
270
prev = list(self.children[revision])[0]
271
self.treeview.set_cursor(self.index[prev])
276
self.treeview.set_cursor(self.index[children[0]])
272
277
self.treeview.grab_focus()
274
279
def _go_clicked_cb(self, revid):
275
280
"""Callback for when the go button for a parent is clicked."""
276
self.treeview.set_cursor(self.index[self.revisions[revid]])
281
self.treeview.set_cursor(self.index[revid])
277
282
self.treeview.grab_focus()
279
284
def show_diff(self, branch, revid, parentid):