/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: Martin Pool
  • Date: 2011-01-27 02:44:12 UTC
  • Revision ID: mbp@canonical.com-20110127024412-rd71r44qgzjur317
Store line numbers as ints in the gannotate ListStore.

Fixes bug 707482, where the pygtk bindings seem to have become more strict in Natty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
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
 
583
587
                path = model.get_path(row)
584
588
                self._view.set_cursor(path)
585
589
                self._view.scroll_to_cell(path, use_align=True)
586
 
                break
 
590
                break
 
 
b'\\ No newline at end of file'