/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: 2011-04-10 18:44:39 UTC
  • mto: This revision was merged to the branch mainline in revision 730.
  • Revision ID: jelmer@samba.org-20110410184439-g7hqaacexqtviq13
Move i18n support to a separate file, so gettext files aren't loaded unless bzr-gtk is used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__copyright__ = "Copyright © 2005 Canonical Ltd."
7
7
__author__    = "Daniel Schierbeck <daniel.schierbeck@gmail.com>"
8
8
 
9
 
import sys
10
 
import string
11
9
import gtk
12
10
import gobject
13
11
import pango
14
 
import re
15
 
import treemodel
 
12
 
16
13
from bzrlib import ui
17
 
 
18
 
from bzrlib.plugins.gtk import _i18n
19
 
from bzrlib.plugins.gtk.ui import GtkProgressBar, ProgressPanel
20
 
from linegraph import linegraph, same_branch
21
 
from graphcell import CellRendererGraph
22
 
from treemodel import TreeModel
23
14
from bzrlib.revision import NULL_REVISION
24
15
 
 
16
from bzrlib.plugins.gtk import lock
 
17
from bzrlib.plugins.gtk.ui import ProgressPanel
 
18
from bzrlib.plugins.gtk.branchview import treemodel
 
19
from bzrlib.plugins.gtk.branchview.linegraph import linegraph, same_branch
 
20
from bzrlib.plugins.gtk.branchview.graphcell import CellRendererGraph
 
21
 
25
22
 
26
23
class TreeView(gtk.VBox):
27
24
 
225
222
    def add_tag(self, tag, revid=None):
226
223
        if revid is None: revid = self.revision.revision_id
227
224
 
228
 
        try:
229
 
            self.branch.unlock()
230
 
 
 
225
        if lock.release(self.branch):
231
226
            try:
232
 
                self.branch.lock_write()
 
227
                lock.acquire(self.branch, lock.WRITE)
233
228
                self.model.add_tag(tag, revid)
234
229
            finally:
235
 
                self.branch.unlock()
236
 
 
237
 
        finally:
238
 
            self.branch.lock_read()
239
 
 
240
 
        self.emit('tag-added', tag, revid)
241
 
        
 
230
                lock.release(self.branch)
 
231
 
 
232
            lock.acquire(self.branch, lock.READ)
 
233
 
 
234
            self.emit('tag-added', tag, revid)
 
235
 
242
236
    def refresh(self):
243
237
        gobject.idle_add(self.populate, self.get_revision())
244
238
 
304
298
                broken_line_length = 32
305
299
            else:
306
300
                broken_line_length = None
307
 
            
 
301
 
308
302
            show_graph = self.graph_column.get_visible()
309
303
 
310
304
            self.branch.lock_read()
316
310
                                                            self.mainline_only,
317
311
                                                            self.progress_bar)
318
312
 
319
 
            self.model = TreeModel(self.branch, linegraphdata)
 
313
            self.model = treemodel.TreeModel(self.branch, linegraphdata)
320
314
            self.graph_cell.columns_len = columns_len
321
315
            width = self.graph_cell.get_size(self.treeview)[2]
322
316
            if width > 500:
340
334
        self.treeview = gtk.TreeView()
341
335
 
342
336
        self.treeview.set_rules_hint(True)
343
 
        self.treeview.set_search_column(treemodel.REVNO)
344
 
        
 
337
        # combined revno/summary interactive search
 
338
        #
 
339
        # the row in a treemodel is considered "matched" if a REVNO *starts*
 
340
        # from the key (that is the key is found in a REVNO at the offset 0)
 
341
        # or if a MESSAGE *contains* the key anywhere (that is, the key is
 
342
        # found case insensitively in a MESSAGE at any offset)
 
343
        def search_equal_func(model, column, key, iter):
 
344
            return (model.get_value(iter, treemodel.REVNO).find(key) != 0
 
345
                and model.get_value(iter, treemodel.MESSAGE).lower().find(key.lower()) == -1)
 
346
 
 
347
        self.treeview.set_search_equal_func(search_equal_func)
 
348
        self.treeview.set_enable_search(True)
 
349
 
345
350
        # Fix old PyGTK bug - by JAM
346
351
        set_tooltip = getattr(self.treeview, 'set_tooltip_column', None)
347
352
        if set_tooltip is not None:
398
403
        cell = gtk.CellRendererText()
399
404
        cell.set_property("width-chars", 15)
400
405
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
401
 
        self.committer_column = gtk.TreeViewColumn("Committer")
402
 
        self.committer_column.set_resizable(False)
403
 
        self.committer_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
404
 
        self.committer_column.set_fixed_width(200)
405
 
        self.committer_column.pack_start(cell, expand=True)
406
 
        self.committer_column.add_attribute(cell, "text", treemodel.COMMITTER)
407
 
        self.treeview.append_column(self.committer_column)
 
406
        self.authors_column = gtk.TreeViewColumn("Author(s)")
 
407
        self.authors_column.set_resizable(False)
 
408
        self.authors_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
 
409
        self.authors_column.set_fixed_width(200)
 
410
        self.authors_column.pack_start(cell, expand=True)
 
411
        self.authors_column.add_attribute(cell, "text", treemodel.AUTHORS)
 
412
        self.treeview.append_column(self.authors_column)
408
413
 
409
414
        cell = gtk.CellRendererText()
410
415
        cell.set_property("width-chars", 20)
417
422
        self.date_column.pack_start(cell, expand=True)
418
423
        self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP)
419
424
        self.treeview.append_column(self.date_column)
420
 
        
 
425
 
421
426
        return self.treeview
422
 
    
 
427
 
423
428
    def _on_selection_changed(self, treeview):
424
429
        """callback for when the treeview changes."""
425
430
        (path, focus) = treeview.get_cursor()