/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: Jelmer Vernooij
  • Date: 2008-06-29 16:11:12 UTC
  • mfrom: (475.2.2 gtk)
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629161112-3j4zp0r0e7cv6cds
Merge Chad's progress bar in viz patch.

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