/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: Chad MILLER
  • Date: 2008-05-01 12:06:26 UTC
  • mto: (511.5.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: chad@mysql.com-20080501120626-8k0ay6jee6tfz1sz
Make "vizualize" use the GUI progress bar defined in the parent 'ui' module.

Update the progress bar so that one need not specify both the total steps and 
the current step with every update.

Remove extraneous signaling and put related progress-bar element close to its
use.

TODO:  Given a nested-progress-bar object, one should be able to use it as a
factory of sub-bars.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
import pango
14
14
import re
15
15
import treemodel
 
16
from bzrlib import ui
16
17
 
17
18
from linegraph import linegraph, same_branch
18
19
from graphcell import CellRendererGraph
81
82
    }
82
83
 
83
84
    __gsignals__ = {
84
 
        'revisions-loaded': (gobject.SIGNAL_RUN_FIRST, 
85
 
                             gobject.TYPE_NONE,
86
 
                             ()),
87
85
        'revision-selected': (gobject.SIGNAL_RUN_FIRST,
88
86
                              gobject.TYPE_NONE,
89
87
                              ()),
107
105
        """
108
106
        gtk.VBox.__init__(self, spacing=0)
109
107
 
110
 
        self.pack_start(self.construct_loading_msg(), expand=False, fill=True)
111
 
        self.connect('revisions-loaded', 
112
 
                lambda x: self.loading_msg_box.hide())
113
 
 
114
108
        self.scrolled_window = gtk.ScrolledWindow()
115
109
        self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
116
110
                                        gtk.POLICY_AUTOMATIC)
119
113
        self.pack_start(self.scrolled_window, expand=True, fill=True)
120
114
 
121
115
        self.scrolled_window.add(self.construct_treeview())
122
 
        
123
116
 
124
117
        self.iter = None
125
118
        self.branch = branch
222
215
        self.emit('tag-added', tag, revid)
223
216
        
224
217
    def refresh(self):
225
 
        self.loading_msg_box.show()
226
218
        gobject.idle_add(self.populate, self.get_revision())
227
219
 
228
220
    def update(self):
276
268
                       should be broken.
277
269
        """
278
270
 
279
 
        if self.compact:
280
 
            broken_line_length = 32
281
 
        else:
282
 
            broken_line_length = None
283
 
        
284
 
        show_graph = self.graph_column.get_visible()
285
 
 
286
 
        self.branch.lock_read()
287
 
        (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
288
 
                                                        self.start,
289
 
                                                        self.maxnum, 
290
 
                                                        broken_line_length,
291
 
                                                        show_graph,
292
 
                                                        self.mainline_only)
293
 
 
294
 
        self.model = TreeModel(self.branch, linegraphdata)
295
 
        self.graph_cell.columns_len = columns_len
296
 
        width = self.graph_cell.get_size(self.treeview)[2]
297
 
        if width > 500:
298
 
            width = 500
299
 
        self.graph_column.set_fixed_width(width)
300
 
        self.graph_column.set_max_width(width)
301
 
        self.index = index
302
 
        self.treeview.set_model(self.model)
303
 
 
304
 
        if not revision or revision == NULL_REVISION:
305
 
            self.treeview.set_cursor(0)
306
 
        else:
307
 
            self.set_revision(revision)
308
 
 
309
 
        self.emit('revisions-loaded')
310
 
 
311
 
        return False
 
271
        loading_progress = ui.ui_factory.nested_progress_bar()
 
272
        loading_progress.update(msg="Loading ancestry graph", total=5)
 
273
 
 
274
        try:
 
275
            if self.compact:
 
276
                broken_line_length = 32
 
277
            else:
 
278
                broken_line_length = None
 
279
            
 
280
            show_graph = self.graph_column.get_visible()
 
281
 
 
282
            self.branch.lock_read()
 
283
            (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
 
284
                                                            self.start,
 
285
                                                            self.maxnum, 
 
286
                                                            loading_progress,
 
287
                                                            broken_line_length,
 
288
                                                            show_graph,
 
289
                                                            self.mainline_only)
 
290
 
 
291
            self.model = TreeModel(self.branch, linegraphdata)
 
292
            self.graph_cell.columns_len = columns_len
 
293
            width = self.graph_cell.get_size(self.treeview)[2]
 
294
            if width > 500:
 
295
                width = 500
 
296
            self.graph_column.set_fixed_width(width)
 
297
            self.graph_column.set_max_width(width)
 
298
            self.index = index
 
299
            self.treeview.set_model(self.model)
 
300
 
 
301
            if not revision or revision == NULL_REVISION:
 
302
                self.treeview.set_cursor(0)
 
303
            else:
 
304
                self.set_revision(revision)
 
305
 
 
306
            return False
 
307
 
 
308
        finally:
 
309
            loading_progress.finished()
312
310
 
313
311
    def construct_treeview(self):
314
312
        self.treeview = gtk.TreeView()
391
389
        self.treeview.append_column(self.date_column)
392
390
        
393
391
        return self.treeview
394
 
    
395
 
    def construct_loading_msg(self):
396
 
        image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
397
 
                                                 gtk.ICON_SIZE_BUTTON)
398
 
        image_loading.show()
399
 
        
400
 
        label_loading = gtk.Label(_("Please wait, loading ancestral graph..."))
401
 
        label_loading.set_alignment(0.0, 0.5)
402
 
        label_loading.show()
403
 
        
404
 
        self.loading_msg_box = gtk.HBox()
405
 
        self.loading_msg_box.set_spacing(5)
406
 
        self.loading_msg_box.set_border_width(5)        
407
 
        self.loading_msg_box.pack_start(image_loading, False, False)
408
 
        self.loading_msg_box.pack_start(label_loading, True, True)
409
 
        self.loading_msg_box.show()
410
 
        
411
 
        return self.loading_msg_box
412
392
 
413
393
    def _on_selection_changed(self, treeview):
414
394
        """callback for when the treeview changes."""