/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to branchview/treeview.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-10 16:38:37 UTC
  • mto: This revision was merged to the branch mainline in revision 648.
  • Revision ID: v.ladeuil+lp@free.fr-20090610163837-8n8122j38ozwd5ef
Fix #385191 by using the new progress reporting API.

* ui.py:
(GtkProgressBar): Simplified, we don't need to inherit from
_BaseProgressBar.
(GtkProgressBar.update): Show the widget.
(ProgressBarWindow.__init__): Simplified. Don't show
unconditionally.
(ProgressBarWindow.update): Show the widget.
(ProgressPanel.update): Show the widget.
(GtkUIFactory.__init__): Simplified.
(GtkUIFactory._progress_all_finished): 

* branchview/treeview.py:
(TreeView.__init__): Set the progress reporting widget.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from bzrlib import ui
17
17
 
18
18
from bzrlib.plugins.gtk import _i18n
 
19
from bzrlib.plugins.gtk.ui import GtkProgressBar, ProgressPanel
19
20
from linegraph import linegraph, same_branch
20
21
from graphcell import CellRendererGraph
21
22
from treemodel import TreeModel
22
23
from bzrlib.revision import NULL_REVISION
23
24
 
 
25
 
24
26
class TreeView(gtk.VBox):
25
27
 
26
28
    __gproperties__ = {
91
93
                              (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)),
92
94
        'tag-added': (gobject.SIGNAL_RUN_FIRST,
93
95
                              gobject.TYPE_NONE,
94
 
                              (gobject.TYPE_STRING, gobject.TYPE_STRING))
 
96
                              (gobject.TYPE_STRING, gobject.TYPE_STRING)),
 
97
        'refreshed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
 
98
                              ())
95
99
    }
96
100
 
97
101
    def __init__(self, branch, start, maxnum, compact=True):
106
110
        """
107
111
        gtk.VBox.__init__(self, spacing=0)
108
112
 
 
113
        loading_msg_widget = ProgressPanel()
 
114
        # FIXME: Why is the following needed ? Are there really cases where we
 
115
        # use a TreeView without installing our own ui ? --vila 20090610
 
116
        if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None:
 
117
            ui.ui_factory.set_progress_bar_widget(loading_msg_widget)
 
118
        self.pack_start(loading_msg_widget, expand=False, fill=True)
 
119
 
109
120
        self.scrolled_window = gtk.ScrolledWindow()
110
121
        self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
111
122
                                        gtk.POLICY_AUTOMATIC)
118
129
        self.iter = None
119
130
        self.branch = branch
120
131
        self.revision = None
 
132
        self.index = {}
121
133
 
122
134
        self.start = start
123
135
        self.maxnum = maxnum
173
185
        """Return revision id of currently selected revision, or None."""
174
186
        return self.get_property('revision')
175
187
 
 
188
    def has_revision_id(self, revision_id):
 
189
        return (revision_id in self.index)
 
190
 
176
191
    def set_revision(self, revision):
177
192
        self.set_property('revision', revision)
178
193
 
269
284
                       should be broken.
270
285
        """
271
286
 
272
 
        loading_progress = ui.ui_factory.nested_progress_bar()
273
 
        loading_progress.update(msg="Loading ancestry graph", total=5)
 
287
        self.progress_bar = ui.ui_factory.nested_progress_bar()
 
288
        self.progress_bar.update("Loading ancestry graph", 0, 5)
274
289
 
275
290
        try:
276
291
            if self.compact:
287
302
                                                            broken_line_length,
288
303
                                                            show_graph,
289
304
                                                            self.mainline_only,
290
 
                                                            loading_progress)
 
305
                                                            self.progress_bar)
291
306
 
292
307
            self.model = TreeModel(self.branch, linegraphdata)
293
308
            self.graph_cell.columns_len = columns_len
304
319
            else:
305
320
                self.set_revision(revision)
306
321
 
 
322
            self.emit('refreshed')
307
323
            return False
308
324
        finally:
309
 
            loading_progress.finished()
 
325
            self.progress_bar.finished()
310
326
 
311
327
    def construct_treeview(self):
312
328
        self.treeview = gtk.TreeView()
319
335
        if set_tooltip is not None:
320
336
            set_tooltip(treemodel.MESSAGE)
321
337
 
 
338
        self._prev_cursor_path = None
322
339
        self.treeview.connect("cursor-changed",
323
340
                self._on_selection_changed)
324
341
 
390
407
        self.treeview.append_column(self.date_column)
391
408
        
392
409
        return self.treeview
393
 
 
 
410
    
394
411
    def _on_selection_changed(self, treeview):
395
412
        """callback for when the treeview changes."""
396
413
        (path, focus) = treeview.get_cursor()
397
 
        if path is not None:
 
414
        if (path is not None) and (path != self._prev_cursor_path):
 
415
            self._prev_cursor_path = path # avoid emitting twice per click
398
416
            self.iter = self.model.get_iter(path)
399
417
            self.emit('revision-selected')
400
418
 
401
419
    def _on_revision_selected(self, widget, event):
402
 
        from bzrlib.plugins.gtk.revisionmenu import RevisionPopupMenu
 
420
        from bzrlib.plugins.gtk.revisionmenu import RevisionMenu
403
421
        if event.button == 3:
404
 
            menu = RevisionPopupMenu(self.branch.repository, 
 
422
            menu = RevisionMenu(self.branch.repository, 
405
423
                [self.get_revision().revision_id],
406
424
                self.branch)
407
425
            menu.connect('tag-added', lambda w, t, r: self.add_tag(t, r))