/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: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
"""
5
5
 
6
 
__copyright__ = "Copyright © 2005 Canonical Ltd."
 
6
__copyright__ = "Copyright � 2005 Canonical Ltd."
7
7
__author__    = "Daniel Schierbeck <daniel.schierbeck@gmail.com>"
8
8
 
9
9
import sys
13
13
import pango
14
14
import re
15
15
import treemodel
16
 
from bzrlib import ui
17
16
 
18
17
from bzrlib.plugins.gtk import _i18n
19
 
from bzrlib.plugins.gtk.ui import GtkProgressBar, ProgressPanel
20
18
from linegraph import linegraph, same_branch
21
19
from graphcell import CellRendererGraph
22
20
from treemodel import TreeModel
23
21
from bzrlib.revision import NULL_REVISION
24
22
 
25
 
 
26
23
class TreeView(gtk.VBox):
27
24
 
28
25
    __gproperties__ = {
85
82
    }
86
83
 
87
84
    __gsignals__ = {
 
85
        'revisions-loaded': (gobject.SIGNAL_RUN_FIRST, 
 
86
                             gobject.TYPE_NONE,
 
87
                             ()),
88
88
        'revision-selected': (gobject.SIGNAL_RUN_FIRST,
89
89
                              gobject.TYPE_NONE,
90
90
                              ()),
108
108
        """
109
109
        gtk.VBox.__init__(self, spacing=0)
110
110
 
111
 
        loading_msg_widget = ProgressPanel()
112
 
        ui.ui_factory.set_nested_progress_bar_widget(loading_msg_widget.get_progress_bar)
113
 
        self.pack_start(loading_msg_widget, expand=False, fill=True)
 
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
114
 
115
115
        self.scrolled_window = gtk.ScrolledWindow()
116
116
        self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
120
120
        self.pack_start(self.scrolled_window, expand=True, fill=True)
121
121
 
122
122
        self.scrolled_window.add(self.construct_treeview())
 
123
        
123
124
 
124
125
        self.iter = None
125
126
        self.branch = branch
222
223
        self.emit('tag-added', tag, revid)
223
224
        
224
225
    def refresh(self):
 
226
        self.loading_msg_box.show()
225
227
        gobject.idle_add(self.populate, self.get_revision())
226
228
 
227
229
    def update(self):
275
277
                       should be broken.
276
278
        """
277
279
 
278
 
        self.progress_bar = ui.ui_factory.nested_progress_bar()
279
 
        self.progress_bar.update(msg="Loading ancestry graph", total_cnt=5)
280
 
 
281
 
        try:
282
 
            if self.compact:
283
 
                broken_line_length = 32
284
 
            else:
285
 
                broken_line_length = None
286
 
            
287
 
            show_graph = self.graph_column.get_visible()
288
 
 
289
 
            self.branch.lock_read()
290
 
            (linegraphdata, index, columns_len) = linegraph(self.branch.repository.get_graph(),
291
 
                                                            self.start,
292
 
                                                            self.maxnum, 
293
 
                                                            broken_line_length,
294
 
                                                            show_graph,
295
 
                                                            self.mainline_only,
296
 
                                                            self.progress_bar)
297
 
 
298
 
            self.model = TreeModel(self.branch, linegraphdata)
299
 
            self.graph_cell.columns_len = columns_len
300
 
            width = self.graph_cell.get_size(self.treeview)[2]
301
 
            if width > 500:
302
 
                width = 500
303
 
            self.graph_column.set_fixed_width(width)
304
 
            self.graph_column.set_max_width(width)
305
 
            self.index = index
306
 
            self.treeview.set_model(self.model)
307
 
 
308
 
            if not revision or revision == NULL_REVISION:
309
 
                self.treeview.set_cursor(0)
310
 
            else:
311
 
                self.set_revision(revision)
312
 
 
313
 
            return False
314
 
        finally:
315
 
            self.progress_bar.finished()
 
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,
 
289
                                                        self.start,
 
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
316
313
 
317
314
    def construct_treeview(self):
318
315
        self.treeview = gtk.TreeView()
342
339
        cell.set_property("width-chars", 15)
343
340
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
344
341
        self.revno_column = gtk.TreeViewColumn("Revision No")
345
 
        self.revno_column.set_resizable(False)
 
342
        self.revno_column.set_resizable(True)
346
343
        self.revno_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
347
344
        self.revno_column.set_fixed_width(cell.get_size(self.treeview)[2])
348
345
        self.revno_column.pack_start(cell, expand=True)
351
348
 
352
349
        self.graph_cell = CellRendererGraph()
353
350
        self.graph_column = gtk.TreeViewColumn()
354
 
        self.graph_column.set_resizable(False)
 
351
        self.graph_column.set_resizable(True)
355
352
        self.graph_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
356
 
        self.graph_column.pack_start(self.graph_cell, expand=True)
 
353
        self.graph_column.pack_start(self.graph_cell, expand=False)
357
354
        self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE)
358
355
        self.graph_column.add_attribute(self.graph_cell, "tags", treemodel.TAGS)
359
356
        self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES)
364
361
        cell.set_property("width-chars", 65)
365
362
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
366
363
        self.summary_column = gtk.TreeViewColumn("Summary")
367
 
        self.summary_column.set_resizable(False)
368
 
        self.summary_column.set_expand(True)
 
364
        self.summary_column.set_resizable(True)
369
365
        self.summary_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
370
366
        self.summary_column.set_fixed_width(cell.get_size(self.treeview)[2])
371
367
        self.summary_column.pack_start(cell, expand=True)
376
372
        cell.set_property("width-chars", 15)
377
373
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
378
374
        self.committer_column = gtk.TreeViewColumn("Committer")
379
 
        self.committer_column.set_resizable(False)
 
375
        self.committer_column.set_resizable(True)
380
376
        self.committer_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
381
 
        self.committer_column.set_fixed_width(200)
 
377
        self.committer_column.set_fixed_width(cell.get_size(self.treeview)[2])
382
378
        self.committer_column.pack_start(cell, expand=True)
383
379
        self.committer_column.add_attribute(cell, "text", treemodel.COMMITTER)
384
380
        self.treeview.append_column(self.committer_column)
388
384
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
389
385
        self.date_column = gtk.TreeViewColumn("Date")
390
386
        self.date_column.set_visible(False)
391
 
        self.date_column.set_resizable(False)
 
387
        self.date_column.set_resizable(True)
392
388
        self.date_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
393
 
        self.date_column.set_fixed_width(130)
 
389
        self.date_column.set_fixed_width(cell.get_size(self.treeview)[2])
394
390
        self.date_column.pack_start(cell, expand=True)
395
391
        self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP)
396
392
        self.treeview.append_column(self.date_column)
397
393
        
398
394
        return self.treeview
399
395
    
 
396
    def construct_loading_msg(self):
 
397
        image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
 
398
                                                 gtk.ICON_SIZE_BUTTON)
 
399
        image_loading.show()
 
400
        
 
401
        label_loading = gtk.Label(
 
402
            _i18n("Please wait, loading ancestral graph..."))
 
403
        label_loading.set_alignment(0.0, 0.5)
 
404
        label_loading.show()
 
405
        
 
406
        self.loading_msg_box = gtk.HBox()
 
407
        self.loading_msg_box.set_spacing(5)
 
408
        self.loading_msg_box.set_border_width(5)        
 
409
        self.loading_msg_box.pack_start(image_loading, False, False)
 
410
        self.loading_msg_box.pack_start(label_loading, True, True)
 
411
        self.loading_msg_box.show()
 
412
        
 
413
        return self.loading_msg_box
 
414
 
400
415
    def _on_selection_changed(self, treeview):
401
416
        """callback for when the treeview changes."""
402
417
        (path, focus) = treeview.get_cursor()