71
65
vbox.set_focus_child(paned)
75
def construct_loading_msg(self):
76
image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
80
label_loading = gtk.Label(_("Please wait, loading ancestral graph..."))
81
label_loading.set_alignment(0.0, 0.5)
84
self.loading_msg_box = gtk.HBox()
85
self.loading_msg_box.set_spacing(5)
86
self.loading_msg_box.set_border_width(5)
87
self.loading_msg_box.pack_start(image_loading, False, False)
88
self.loading_msg_box.pack_start(label_loading, True, True)
89
self.loading_msg_box.show()
91
return self.loading_msg_box
93
69
def construct_top(self):
94
70
"""Construct the top-half of the window."""
95
self.treeview = TreeView(self.branch, self.start, self.maxnum)
97
self.treeview.connect("revision-selected",
98
self._treeselection_changed_cb)
100
self.treeview.connect('revisions-loaded',
101
lambda x: self.loading_msg_box.hide())
71
scrollwin = gtk.ScrolledWindow()
72
scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
73
scrollwin.set_shadow_type(gtk.SHADOW_IN)
76
self.treeview = gtk.TreeView()
77
self.treeview.set_rules_hint(True)
78
self.treeview.set_search_column(4)
79
self.treeview.connect("cursor-changed", self._treeview_cursor_cb)
80
self.treeview.connect("row-activated", self._treeview_row_activated_cb)
81
scrollwin.add(self.treeview)
103
82
self.treeview.show()
84
cell = CellRendererGraph()
85
column = gtk.TreeViewColumn()
86
column.set_resizable(True)
87
column.pack_start(cell, expand=False)
88
column.add_attribute(cell, "node", 1)
89
column.add_attribute(cell, "in-lines", 2)
90
column.add_attribute(cell, "out-lines", 3)
91
self.treeview.append_column(column)
93
cell = gtk.CellRendererText()
94
cell.set_property("width-chars", 40)
95
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
96
column = gtk.TreeViewColumn("Message")
97
column.set_resizable(True)
98
column.pack_start(cell, expand=True)
99
column.add_attribute(cell, "text", 4)
100
self.treeview.append_column(column)
102
cell = gtk.CellRendererText()
103
cell.set_property("width-chars", 40)
104
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
105
column = gtk.TreeViewColumn("Committer")
106
column.set_resizable(True)
107
column.pack_start(cell, expand=True)
108
column.add_attribute(cell, "text", 5)
109
self.treeview.append_column(column)
111
cell = gtk.CellRendererText()
112
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
113
column = gtk.TreeViewColumn("Date")
114
column.set_resizable(True)
115
column.pack_start(cell, expand=True)
116
column.add_attribute(cell, "text", 6)
117
self.treeview.append_column(column)
107
121
def construct_navigation(self):
108
122
"""Construct the navigation buttons."""
135
149
def construct_bottom(self):
136
150
"""Construct the bottom half of the window."""
137
from bzrlib.plugins.gtk.logview import LogView
138
self.logview = LogView(None, True, [], True)
151
scrollwin = gtk.ScrolledWindow()
152
scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
153
scrollwin.set_shadow_type(gtk.SHADOW_NONE)
139
154
(width, height) = self.get_size()
140
self.logview.set_size_request(width, int(height / 2.5))
142
self.logview.set_show_callback(self._show_clicked_cb)
143
self.logview.set_go_callback(self._go_clicked_cb)
146
def _treeselection_changed_cb(self, selection, *args):
147
"""callback for when the treeview changes."""
148
revision = self.treeview.get_revision()
149
parents = self.treeview.get_parents()
150
children = self.treeview.get_children()
152
if revision is not None:
153
self.back_button.set_sensitive(len(parents) > 0)
154
self.fwd_button.set_sensitive(len(children) > 0)
156
if self.branch.supports_tags():
157
tagdict = self.branch.tags.get_reverse_tag_dict()
158
if tagdict.has_key(revision.revision_id):
159
tags = tagdict[revision.revision_id]
160
self.logview.set_revision(revision, tags, children)
155
scrollwin.set_size_request(width, int(height / 2.5))
158
vbox = gtk.VBox(False, spacing=6)
159
vbox.set_border_width(6)
160
scrollwin.add_with_viewport(vbox)
163
table = gtk.Table(rows=4, columns=2)
164
table.set_row_spacings(6)
165
table.set_col_spacings(6)
166
vbox.pack_start(table, expand=False, fill=True)
169
align = gtk.Alignment(0.0, 0.5)
171
label.set_markup("<b>Revision:</b>")
173
table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
177
align = gtk.Alignment(0.0, 0.5)
178
self.revid_label = gtk.Label()
179
self.revid_label.set_selectable(True)
180
align.add(self.revid_label)
181
table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
182
self.revid_label.show()
185
align = gtk.Alignment(0.0, 0.5)
187
label.set_markup("<b>Committer:</b>")
189
table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
193
align = gtk.Alignment(0.0, 0.5)
194
self.committer_label = gtk.Label()
195
self.committer_label.set_selectable(True)
196
align.add(self.committer_label)
197
table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
198
self.committer_label.show()
201
align = gtk.Alignment(0.0, 0.5)
203
label.set_markup("<b>Branch nick:</b>")
205
table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
209
align = gtk.Alignment(0.0, 0.5)
210
self.branchnick_label = gtk.Label()
211
self.branchnick_label.set_selectable(True)
212
align.add(self.branchnick_label)
213
table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
214
self.branchnick_label.show()
217
align = gtk.Alignment(0.0, 0.5)
219
label.set_markup("<b>Timestamp:</b>")
221
table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
225
align = gtk.Alignment(0.0, 0.5)
226
self.timestamp_label = gtk.Label()
227
self.timestamp_label.set_selectable(True)
228
align.add(self.timestamp_label)
229
table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
230
self.timestamp_label.show()
233
self.parents_table = gtk.Table(rows=1, columns=2)
234
self.parents_table.set_row_spacings(3)
235
self.parents_table.set_col_spacings(6)
236
self.parents_table.show()
237
vbox.pack_start(self.parents_table, expand=False, fill=True)
238
self.parents_widgets = []
241
label.set_markup("<b>Parents:</b>")
242
align = gtk.Alignment(0.0, 0.5)
244
self.parents_table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
248
self.message_buffer = gtk.TextBuffer()
249
textview = gtk.TextView(self.message_buffer)
250
textview.set_editable(False)
251
textview.set_wrap_mode(gtk.WRAP_WORD)
252
textview.modify_font(pango.FontDescription("Monospace"))
253
vbox.pack_start(textview, expand=True, fill=True)
258
def set_branch(self, branch, start, maxnum):
259
"""Set the branch and start position for this window.
261
Creates a new TreeModel and populates it with information about
262
the new branch before updating the window title and model of the
267
# [ revision, node, last_lines, lines, message, committer, timestamp ]
268
self.model = gtk.ListStore(gobject.TYPE_PYOBJECT,
269
gobject.TYPE_PYOBJECT,
270
gobject.TYPE_PYOBJECT,
271
gobject.TYPE_PYOBJECT,
277
(self.revisions, colours, self.children, self.parent_ids,
278
merge_sorted) = distances(branch, start)
279
for (index, (revision, node, lines)) in enumerate(graph(
280
self.revisions, colours, merge_sorted)):
281
# FIXME: at this point we should be able to show the graph order
282
# and lines with no message or commit data - and then incrementally
283
# fill the timestamp, committer etc data as desired.
284
message = revision.message.split("\n")[0]
285
if revision.committer is not None:
286
timestamp = format_date(revision.timestamp, revision.timezone)
289
self.model.append([revision, node, last_lines, lines,
290
message, revision.committer, timestamp])
291
self.index[revision] = index
293
if maxnum is not None and index > maxnum:
296
self.set_title(branch.nick + " - bzrk")
297
self.treeview.set_model(self.model)
299
def _treeview_cursor_cb(self, *args):
300
"""Callback for when the treeview cursor changes."""
301
(path, col) = self.treeview.get_cursor()
302
revision = self.model[path][0]
304
self.back_button.set_sensitive(len(self.parent_ids[revision]) > 0)
305
self.fwd_button.set_sensitive(len(self.children[revision]) > 0)
307
if revision.committer is not None:
309
committer = revision.committer
310
timestamp = format_date(revision.timestamp, revision.timezone)
311
message = revision.message
313
branchnick = revision.properties['branch-nick']
323
self.revid_label.set_text(revision.revision_id)
324
self.branchnick_label.set_text(branchnick)
326
self.committer_label.set_text(committer)
327
self.timestamp_label.set_text(timestamp)
328
self.message_buffer.set_text(message)
330
for widget in self.parents_widgets:
331
self.parents_table.remove(widget)
333
self.parents_widgets = []
334
self.parents_table.resize(max(len(self.parent_ids[revision]), 1), 2)
336
for idx, parent_id in enumerate(self.parent_ids[revision]):
337
align = gtk.Alignment(0.0, 0.0)
338
self.parents_widgets.append(align)
339
self.parents_table.attach(align, 1, 2, idx, idx + 1,
340
gtk.EXPAND | gtk.FILL, gtk.FILL)
343
hbox = gtk.HBox(False, spacing=6)
348
image.set_from_stock(
349
gtk.STOCK_JUMP_TO, gtk.ICON_SIZE_SMALL_TOOLBAR)
352
button = gtk.Button()
354
button.connect("clicked", self._go_clicked_cb, parent_id)
355
hbox.pack_start(button, expand=False, fill=True)
359
image.set_from_stock(
360
gtk.STOCK_FIND, gtk.ICON_SIZE_SMALL_TOOLBAR)
363
button = gtk.Button()
365
button.set_sensitive(self.app is not None)
366
button.connect("clicked", self._show_clicked_cb,
367
revision.revision_id, parent_id)
368
hbox.pack_start(button, expand=False, fill=True)
371
label = gtk.Label(parent_id)
372
label.set_selectable(True)
373
hbox.pack_start(label, expand=False, fill=True)
162
377
def _back_clicked_cb(self, *args):
163
378
"""Callback for when the back button is clicked."""
379
(path, col) = self.treeview.get_cursor()
380
revision = self.model[path][0]
381
if not len(self.parent_ids[revision]):
384
for parent_id in self.parent_ids[revision]:
385
parent = self.revisions[parent_id]
386
if same_branch(revision, parent):
387
self.treeview.set_cursor(self.index[parent])
390
next = self.revisions[self.parent_ids[revision][0]]
391
self.treeview.set_cursor(self.index[next])
392
self.treeview.grab_focus()
166
394
def _fwd_clicked_cb(self, *args):
167
395
"""Callback for when the forward button is clicked."""
168
self.treeview.forward()
170
def _go_clicked_cb(self, revid):
396
(path, col) = self.treeview.get_cursor()
397
revision = self.model[path][0]
398
if not len(self.children[revision]):
401
for child in self.children[revision]:
402
if same_branch(child, revision):
403
self.treeview.set_cursor(self.index[child])
406
prev = list(self.children[revision])[0]
407
self.treeview.set_cursor(self.index[prev])
408
self.treeview.grab_focus()
410
def _go_clicked_cb(self, widget, revid):
171
411
"""Callback for when the go button for a parent is clicked."""
172
self.treeview.set_revision(revid)
412
self.treeview.set_cursor(self.index[self.revisions[revid]])
413
self.treeview.grab_focus()
174
def _show_clicked_cb(self, revid, parentid):
415
def _show_clicked_cb(self, widget, revid, parentid):
175
416
"""Callback for when the show button for a parent is clicked."""
176
self.treeview.show_diff(self.branch, revid, parentid)
417
if self.app is not None:
418
self.app.show_diff(self.branch, revid, parentid)
177
419
self.treeview.grab_focus()
421
def _treeview_row_activated_cb(self, widget, path, col):
422
# TODO: more than one parent
423
"""Callback for when a treeview row gets activated."""
424
revision = self.model[path][0]
425
parent_id = self.parent_ids[revision][0]
426
if self.app is not None:
427
self.app.show_diff(self.branch, revision.revision_id, parent_id)
428
self.treeview.grab_focus()