/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 annotate/gannotate.py

  • Committer: David Planella
  • Date: 2011-03-06 08:24:07 UTC
  • mfrom: (718 trunk)
  • mto: This revision was merged to the branch mainline in revision 719.
  • Revision ID: david.planella@ubuntu.com-20110306082407-y9zwkjje5oue9egw
Added preliminary internationalization support. Merged from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import pango
24
24
import re
25
25
 
26
 
from bzrlib import patiencediff, tsort
 
26
from bzrlib import patiencediff
27
27
from bzrlib.errors import NoSuchRevision
28
28
from bzrlib.revision import NULL_REVISION, CURRENT_REVISION
29
29
 
30
 
from colormap import AnnotateColorMap, AnnotateColorSaturation
 
30
from colormap import AnnotateColorSaturation
31
31
from bzrlib.plugins.gtk.revisionview import RevisionView
32
32
from bzrlib.plugins.gtk.window import Window
33
33
 
49
49
        self.all = all
50
50
        self.plain = plain
51
51
        self._branch = branch
52
 
        
 
52
 
53
53
        Window.__init__(self, parent)
54
 
        
 
54
 
55
55
        self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON))
56
56
        self.annotate_colormap = AnnotateColorSaturation()
57
57
 
68
68
        self.revisionview.set_file_id(file_id)
69
69
        self.revision_id = getattr(tree, 'get_revision_id', 
70
70
                                   lambda: CURRENT_REVISION)()
71
 
        
 
71
 
72
72
        # [revision id, line number, author, revno, highlight color, line]
73
73
        self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
74
 
                                       gobject.TYPE_STRING,
 
74
                                       gobject.TYPE_INT,
75
75
                                       gobject.TYPE_STRING,
76
76
                                       gobject.TYPE_STRING,
77
77
                                       gobject.TYPE_STRING,
78
78
                                       gobject.TYPE_STRING)
79
 
        
 
79
 
80
80
        last_seen = None
81
81
        try:
82
82
            branch.lock_read()
86
86
            for revision_id, revno in revno_map.iteritems():
87
87
                self.dotted[revision_id] = '.'.join(str(num) for num in revno)
88
88
            for line_no, (revision, revno, line)\
89
 
                    in enumerate(self._annotate(tree, file_id)):
 
89
                in enumerate(self._annotate(tree, file_id)):
90
90
                if revision.revision_id == last_seen and not self.all:
91
91
                    revno = author = ""
92
92
                else:
102
102
                                       revno,
103
103
                                       None,
104
104
                                       line.rstrip("\r\n")
105
 
                                      ])
 
105
                                       ])
106
106
                self.annotations.append(revision)
107
107
 
108
108
            if not self.plain:
125
125
            # bar?
126
126
            print("gannotate: Line number %d does't exist. Defaulting to "
127
127
                  "line 1." % lineno)
128
 
            return
 
128
            return
129
129
        else:
130
130
            row = lineno - 1
131
131
 
218
218
        hbox.pack_start(self.goto_button, expand=False, fill=True)
219
219
        hbox.show()
220
220
        vbox.pack_start(hbox, expand=False, fill=True)
221
 
        
 
221
 
222
222
        self.pane = pane = gtk.VPaned()
223
223
        pane.add1(swbox)
224
224
        pane.add2(self.revisionview)
260
260
            else:
261
261
                tree2 = repository.revision_tree(NULL_REVISION)
262
262
        from bzrlib.plugins.gtk.diff import DiffWindow
263
 
        window = DiffWindow()
 
263
        window = DiffWindow(self)
264
264
        window.set_diff("Diff for line %d" % (row+1), tree1, tree2)
265
265
        window.set_file(tree1.id2path(self.file_id))
266
266
        window.show()
532
532
 
533
533
    def _match(self, model, iterator, column):
534
534
        matching_case = self._match_case.get_active()
535
 
        string, = model.get(iterator, column)
 
535
        cell_value, = model.get(iterator, column)
536
536
        key = self._entry.get_text()
537
 
        if self._regexp.get_active():
 
537
        if column == LINE_NUM_COL:
 
538
            # FIXME: For goto-line there are faster algorithms than searching 
 
539
            # every line til we find the right one! -- mbp 2011-01-27
 
540
            return key.strip() == str(cell_value)
 
541
        elif self._regexp.get_active():
538
542
            if matching_case:
539
 
                match = re.compile(key).search(string, 1)
 
543
                match = re.compile(key).search(cell_value, 1)
540
544
            else:
541
 
                match = re.compile(key, re.I).search(string, 1)
 
545
                match = re.compile(key, re.I).search(cell_value, 1)
542
546
        else:
543
547
            if not matching_case:
544
 
                string = string.lower()
 
548
                cell_value = cell_value.lower()
545
549
                key = key.lower()
546
 
            match = string.find(key) != -1
 
550
            match = cell_value.find(key) != -1
547
551
 
548
552
        return match
549
553