/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: Martin Pool
  • Date: 2010-05-27 03:07:30 UTC
  • mfrom: (688.1.5 201956-help)
  • Revision ID: mbp@canonical.com-20100527030730-os0opv1xroetccm9
Make find/goto more discoverable

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
9
11
import gtk
10
12
import gobject
11
13
import pango
12
 
 
 
14
import re
 
15
import treemodel
13
16
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
14
23
from bzrlib.revision import NULL_REVISION
15
24
 
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
 
 
22
25
 
23
26
class TreeView(gtk.VBox):
24
27
 
222
225
    def add_tag(self, tag, revid=None):
223
226
        if revid is None: revid = self.revision.revision_id
224
227
 
225
 
        if lock.release(self.branch):
 
228
        try:
 
229
            self.branch.unlock()
 
230
 
226
231
            try:
227
 
                lock.acquire(self.branch, lock.WRITE)
 
232
                self.branch.lock_write()
228
233
                self.model.add_tag(tag, revid)
229
234
            finally:
230
 
                lock.release(self.branch)
231
 
 
232
 
            lock.acquire(self.branch, lock.READ)
233
 
 
234
 
            self.emit('tag-added', tag, revid)
235
 
 
 
235
                self.branch.unlock()
 
236
 
 
237
        finally:
 
238
            self.branch.lock_read()
 
239
 
 
240
        self.emit('tag-added', tag, revid)
 
241
        
236
242
    def refresh(self):
237
243
        gobject.idle_add(self.populate, self.get_revision())
238
244
 
298
304
                broken_line_length = 32
299
305
            else:
300
306
                broken_line_length = None
301
 
 
 
307
            
302
308
            show_graph = self.graph_column.get_visible()
303
309
 
304
310
            self.branch.lock_read()
310
316
                                                            self.mainline_only,
311
317
                                                            self.progress_bar)
312
318
 
313
 
            self.model = treemodel.TreeModel(self.branch, linegraphdata)
 
319
            self.model = TreeModel(self.branch, linegraphdata)
314
320
            self.graph_cell.columns_len = columns_len
315
321
            width = self.graph_cell.get_size(self.treeview)[2]
316
322
            if width > 500:
334
340
        self.treeview = gtk.TreeView()
335
341
 
336
342
        self.treeview.set_rules_hint(True)
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
 
 
 
343
        self.treeview.set_search_column(treemodel.REVNO)
 
344
        
350
345
        # Fix old PyGTK bug - by JAM
351
346
        set_tooltip = getattr(self.treeview, 'set_tooltip_column', None)
352
347
        if set_tooltip is not None:
403
398
        cell = gtk.CellRendererText()
404
399
        cell.set_property("width-chars", 15)
405
400
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
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)
 
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)
413
408
 
414
409
        cell = gtk.CellRendererText()
415
410
        cell.set_property("width-chars", 20)
422
417
        self.date_column.pack_start(cell, expand=True)
423
418
        self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP)
424
419
        self.treeview.append_column(self.date_column)
425
 
 
 
420
        
426
421
        return self.treeview
427
 
 
 
422
    
428
423
    def _on_selection_changed(self, treeview):
429
424
        """callback for when the treeview changes."""
430
425
        (path, focus) = treeview.get_cursor()