17
18
from bzrlib.plugins.gtk import _i18n
19
from bzrlib.plugins.gtk.ui import GtkProgressBar, ProgressPanel
18
20
from linegraph import linegraph, same_branch
19
21
from graphcell import CellRendererGraph
20
22
from treemodel import TreeModel
21
23
from bzrlib.revision import NULL_REVISION
23
26
class TreeView(gtk.VBox):
25
28
__gproperties__ = {
109
109
gtk.VBox.__init__(self, spacing=0)
111
self.pack_start(self.construct_loading_msg(), expand=False, fill=True)
112
self.connect('revisions-loaded',
113
lambda x: self.loading_msg_box.hide())
111
loading_msg_widget = ProgressPanel()
112
if getattr(ui.ui_factory, "set_nested_progress_bar_widget", None) is not None:
113
ui.ui_factory.set_nested_progress_bar_widget(loading_msg_widget.get_progress_bar)
114
self.pack_start(loading_msg_widget, expand=False, fill=True)
115
116
self.scrolled_window = gtk.ScrolledWindow()
116
117
self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
223
223
self.emit('tag-added', tag, revid)
225
225
def refresh(self):
226
self.loading_msg_box.show()
227
226
gobject.idle_add(self.populate, self.get_revision())
229
228
def update(self):
277
276
should be broken.
281
broken_line_length = 32
283
broken_line_length = None
285
show_graph = self.graph_column.get_visible()
287
self.branch.lock_read()
288
(linegraphdata, index, columns_len) = linegraph(self.branch.repository,
289
(self.start,) , # Sequence of start revisions
295
self.model = TreeModel(self.branch, linegraphdata)
296
self.graph_cell.columns_len = columns_len
297
width = self.graph_cell.get_size(self.treeview)[2]
300
self.graph_column.set_fixed_width(width)
301
self.graph_column.set_max_width(width)
303
self.treeview.set_model(self.model)
305
if not revision or revision == NULL_REVISION:
306
self.treeview.set_cursor(0)
308
self.set_revision(revision)
310
self.emit('revisions-loaded')
279
self.progress_bar = ui.ui_factory.nested_progress_bar()
280
self.progress_bar.update("Loading ancestry graph", 0, 5)
284
broken_line_length = 32
286
broken_line_length = None
288
show_graph = self.graph_column.get_visible()
290
self.branch.lock_read()
291
(linegraphdata, index, columns_len) = linegraph(self.branch.repository.get_graph(),
299
self.model = TreeModel(self.branch, linegraphdata)
300
self.graph_cell.columns_len = columns_len
301
width = self.graph_cell.get_size(self.treeview)[2]
304
self.graph_column.set_fixed_width(width)
305
self.graph_column.set_max_width(width)
307
self.treeview.set_model(self.model)
309
if not revision or revision == NULL_REVISION:
310
self.treeview.set_cursor(0)
312
self.set_revision(revision)
316
self.progress_bar.finished()
314
318
def construct_treeview(self):
315
319
self.treeview = gtk.TreeView()
322
326
if set_tooltip is not None:
323
327
set_tooltip(treemodel.MESSAGE)
329
self._prev_cursor_path = None
325
330
self.treeview.connect("cursor-changed",
326
331
self._on_selection_changed)
395
400
return self.treeview
397
def construct_loading_msg(self):
398
image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
399
gtk.ICON_SIZE_BUTTON)
402
label_loading = gtk.Label(
403
_i18n("Please wait, loading ancestral graph..."))
404
label_loading.set_alignment(0.0, 0.5)
407
self.loading_msg_box = gtk.HBox()
408
self.loading_msg_box.set_spacing(5)
409
self.loading_msg_box.set_border_width(5)
410
self.loading_msg_box.pack_start(image_loading, False, False)
411
self.loading_msg_box.pack_start(label_loading, True, True)
412
self.loading_msg_box.show()
414
return self.loading_msg_box
416
402
def _on_selection_changed(self, treeview):
417
403
"""callback for when the treeview changes."""
418
404
(path, focus) = treeview.get_cursor()
405
if (path is not None) and (path != self._prev_cursor_path):
406
self._prev_cursor_path = path # avoid emitting twice per click
420
407
self.iter = self.model.get_iter(path)
421
408
self.emit('revision-selected')
423
410
def _on_revision_selected(self, widget, event):
424
from bzrlib.plugins.gtk.revisionmenu import RevisionPopupMenu
411
from bzrlib.plugins.gtk.revisionmenu import RevisionMenu
425
412
if event.button == 3:
426
menu = RevisionPopupMenu(self.branch.repository,
413
menu = RevisionMenu(self.branch.repository,
427
414
[self.get_revision().revision_id],
429
416
menu.connect('tag-added', lambda w, t, r: self.add_tag(t, r))