16
17
from bzrlib.osutils import format_date
18
19
from linegraph import linegraph, same_branch
19
20
from graphcell import CellRendererGraph
21
from treemodel import TreeModel
22
24
class BranchWindow(gtk.Window):
86
88
column = gtk.TreeViewColumn("Revision No")
87
89
column.set_resizable(True)
88
90
column.pack_start(cell, expand=True)
89
column.add_attribute(cell, "text", 9)
91
column.add_attribute(cell, "text", treemodel.REVNO)
90
92
self.treeview.append_column(column)
92
94
cell = CellRendererGraph()
93
95
column = gtk.TreeViewColumn()
94
96
column.set_resizable(True)
95
97
column.pack_start(cell, expand=False)
96
column.add_attribute(cell, "node", 1)
97
column.add_attribute(cell, "in-lines", 2)
98
column.add_attribute(cell, "out-lines", 3)
98
column.add_attribute(cell, "node", treemodel.NODE)
99
column.add_attribute(cell, "in-lines", treemodel.LAST_LINES)
100
column.add_attribute(cell, "out-lines", treemodel.LINES)
99
101
self.treeview.append_column(column)
101
103
cell = gtk.CellRendererText()
104
106
column = gtk.TreeViewColumn("Message")
105
107
column.set_resizable(True)
106
108
column.pack_start(cell, expand=True)
107
column.add_attribute(cell, "text", 6)
109
column.add_attribute(cell, "text", treemodel.MESSAGE)
108
110
self.treeview.append_column(column)
110
112
cell = gtk.CellRendererText()
113
115
column = gtk.TreeViewColumn("Committer")
114
116
column.set_resizable(True)
115
117
column.pack_start(cell, expand=True)
116
column.add_attribute(cell, "text", 7)
118
column.add_attribute(cell, "text", treemodel.COMMITER)
117
119
self.treeview.append_column(column)
119
121
cell = gtk.CellRendererText()
121
123
column = gtk.TreeViewColumn("Date")
122
124
column.set_resizable(True)
123
125
column.pack_start(cell, expand=True)
124
column.add_attribute(cell, "text", 8)
126
column.add_attribute(cell, "text", treemodel.TIMESTAMP)
125
127
self.treeview.append_column(column)
175
177
self.branch = branch
177
# [ revision, node, last_lines, lines, message, committer, timestamp ]
178
self.model = gtk.ListStore(gobject.TYPE_PYOBJECT,
179
gobject.TYPE_PYOBJECT,
180
gobject.TYPE_PYOBJECT,
181
gobject.TYPE_PYOBJECT,
182
gobject.TYPE_PYOBJECT,
183
gobject.TYPE_PYOBJECT,
185
178
self.set_title(branch.nick + " - bzrk")
186
179
gobject.idle_add(self.populate_model, start, maxnum)
189
182
(linegraphdata, index) = linegraph(self.branch,
192
print "linegraph compleate"
185
self.model = TreeModel(self.branch, linegraphdata)
193
186
self.index = index
202
revno_sequence)) in enumerate(linegraphdata):
203
# FIXME: at this point we should be able to show the graph order
204
# and lines with no message or commit data - and then incrementally
205
# fill the timestamp, committer etc data as desired.
207
revision = self.branch.repository.get_revisions([revid])[0]
208
self.revisions.append(revision)
210
message = revision.message.split("\n")[0]
212
if revision.committer is not None:
213
timestamp = format_date(revision.timestamp, revision.timezone)
216
revno_string = ".".join(["%d" % (revno) for revno in revno_sequence])
218
self.model.append([revision,
229
187
self.treeview.set_model(self.model)
231
189
def _treeview_cursor_cb(self, *args):
232
190
"""Callback for when the treeview cursor changes."""
233
191
(path, col) = self.treeview.get_cursor()
234
revision = self.model[path][0]
235
parents = self.model[path][4]
236
children = self.model[path][5]
192
iter = self.model.get_iter(path)
193
revision = self.model.get_value(iter, treemodel.REVISION)
194
parents = self.model.get_value(iter, treemodel.PARENTS)
195
children = self.model.get_value(iter, treemodel.CHILDREN)
238
197
self.back_button.set_sensitive(len(parents) > 0)
239
198
self.fwd_button.set_sensitive(len(children) > 0)