/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 Albisetti
  • Date: 2008-03-04 22:13:43 UTC
  • mto: This revision was merged to the branch mainline in revision 439.
  • Revision ID: argentina@gmail.com-20080304221343-ixbdn2uf87z3jnfl
Added custom colored context icons

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import time
18
18
 
19
 
from gi.repository import GObject
20
 
from gi.repository import Gdk
21
 
from gi.repository import Gtk
22
 
from gi.repository import Pango
 
19
import pygtk
 
20
pygtk.require("2.0")
 
21
import gobject
 
22
import gtk
 
23
import pango
23
24
import re
24
25
 
25
 
from bzrlib import patiencediff
 
26
from bzrlib import patiencediff, tsort
26
27
from bzrlib.errors import NoSuchRevision
27
28
from bzrlib.revision import NULL_REVISION, CURRENT_REVISION
28
29
 
29
 
from bzrlib.plugins.gtk.annotate.colormap import AnnotateColorSaturation
30
 
from bzrlib.plugins.gtk.i18n import _i18n
 
30
from colormap import AnnotateColorMap, AnnotateColorSaturation
31
31
from bzrlib.plugins.gtk.revisionview import RevisionView
32
32
from bzrlib.plugins.gtk.window import Window
33
33
 
45
45
class GAnnotateWindow(Window):
46
46
    """Annotate window."""
47
47
 
48
 
    def __init__(self, all=False, plain=False, parent=None, branch=None):
 
48
    def __init__(self, all=False, plain=False, parent=None):
49
49
        self.all = all
50
50
        self.plain = plain
51
 
        self._branch = branch
52
 
 
53
 
        super(GAnnotateWindow, self).__init__(parent=parent)
54
 
 
55
 
        self.set_icon(
56
 
            self.render_icon_pixbuf(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON))
 
51
        
 
52
        Window.__init__(self, parent)
 
53
        
 
54
        self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON))
57
55
        self.annotate_colormap = AnnotateColorSaturation()
58
56
 
59
57
        self._create()
69
67
        self.revisionview.set_file_id(file_id)
70
68
        self.revision_id = getattr(tree, 'get_revision_id', 
71
69
                                   lambda: CURRENT_REVISION)()
72
 
 
 
70
        
73
71
        # [revision id, line number, author, revno, highlight color, line]
74
 
        self.annomodel = Gtk.ListStore(GObject.TYPE_STRING,
75
 
                                       GObject.TYPE_INT,
76
 
                                       GObject.TYPE_STRING,
77
 
                                       GObject.TYPE_STRING,
78
 
                                       GObject.TYPE_STRING,
79
 
                                       GObject.TYPE_STRING)
80
 
 
 
72
        self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
 
73
                                       gobject.TYPE_STRING,
 
74
                                       gobject.TYPE_STRING,
 
75
                                       gobject.TYPE_STRING,
 
76
                                       gobject.TYPE_STRING,
 
77
                                       gobject.TYPE_STRING)
 
78
        
81
79
        last_seen = None
82
80
        try:
83
81
            branch.lock_read()
87
85
            for revision_id, revno in revno_map.iteritems():
88
86
                self.dotted[revision_id] = '.'.join(str(num) for num in revno)
89
87
            for line_no, (revision, revno, line)\
90
 
                in enumerate(self._annotate(tree, file_id)):
 
88
                    in enumerate(self._annotate(tree, file_id)):
91
89
                if revision.revision_id == last_seen and not self.all:
92
90
                    revno = author = ""
93
91
                else:
94
92
                    last_seen = revision.revision_id
95
 
                    author = ", ".join(revision.get_apparent_authors())
 
93
                    author = revision.get_apparent_author()
96
94
 
97
95
                if revision.revision_id not in self.revisions:
98
96
                    self.revisions[revision.revision_id] = revision
103
101
                                       revno,
104
102
                                       None,
105
103
                                       line.rstrip("\r\n")
106
 
                                       ])
 
104
                                      ])
107
105
                self.annotations.append(revision)
108
106
 
109
107
            if not self.plain:
115
113
 
116
114
        self.annoview.set_model(self.annomodel)
117
115
        self.annoview.grab_focus()
118
 
        my_revno = self.dotted.get(self.revision_id, 'current')
119
 
        title = '%s (%s) - gannotate' % (self.tree.id2path(file_id), my_revno)
120
 
        self.set_title(title)
121
116
 
122
117
    def jump_to_line(self, lineno):
123
118
        if lineno > len(self.annomodel) or lineno < 1:
126
121
            # bar?
127
122
            print("gannotate: Line number %d does't exist. Defaulting to "
128
123
                  "line 1." % lineno)
129
 
            return
 
124
            return
130
125
        else:
131
126
            row = lineno - 1
132
127
 
133
 
        tree_path = Gtk.TreePath(path=row)
134
 
        self.annoview.set_cursor(tree_path, None, False)
135
 
        self.annoview.scroll_to_cell(tree_path, use_align=True)
 
128
        self.annoview.set_cursor(row)
 
129
        self.annoview.scroll_to_cell(row, use_align=True)
 
130
 
136
131
 
137
132
    def _annotate(self, tree, file_id):
138
133
        current_revision = FakeRevision(CURRENT_REVISION)
140
135
        current_revision.timestamp = time.time()
141
136
        current_revision.message = '[Not yet committed]'
142
137
        current_revision.parent_ids = tree.get_parent_ids()
143
 
        current_revision.properties['branch-nick'] = self.branch._get_nick(local=True)
 
138
        current_revision.properties['branch-nick'] = self.branch.nick
144
139
        current_revno = '%d?' % (self.branch.revno() + 1)
145
140
        repository = self.branch.repository
146
141
        if self.revision_id == CURRENT_REVISION:
168
163
    def _highlight_annotation(self, model, path, iter, now):
169
164
        revision_id, = model.get(iter, REVISION_ID_COL)
170
165
        revision = self.revisions[revision_id]
171
 
        # XXX sinzui 2011-08-12: What does get_color return?
172
 
        color = self.annotate_colormap.get_color(revision, now)
173
 
        model.set_value(iter, HIGHLIGHT_COLOR_COL, color)
 
166
        model.set(iter, HIGHLIGHT_COLOR_COL,
 
167
                  self.annotate_colormap.get_color(revision, now))
174
168
 
175
169
    def _selected_revision(self):
176
170
        (path, col) = self.annoview.get_cursor()
180
174
 
181
175
    def _activate_selected_revision(self, w):
182
176
        rev_id = self._selected_revision()
183
 
        if not rev_id or rev_id == NULL_REVISION:
 
177
        if rev_id is None:
184
178
            return
185
179
        selected = self.revisions[rev_id]
186
180
        self.revisionview.set_revision(selected)
195
189
        self.revisionview = self._create_log_view()
196
190
        self.annoview = self._create_annotate_view()
197
191
 
198
 
        vbox = Gtk.VBox(homogeneous=False, spacing=0)
 
192
        vbox = gtk.VBox(False)
199
193
        vbox.show()
200
194
 
201
 
        sw = Gtk.ScrolledWindow()
202
 
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
203
 
        sw.set_shadow_type(Gtk.ShadowType.IN)
 
195
        sw = gtk.ScrolledWindow()
 
196
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
197
        sw.set_shadow_type(gtk.SHADOW_IN)
204
198
        sw.add(self.annoview)
205
199
        self.annoview.gwindow = self
206
200
        sw.show()
207
201
 
208
 
        swbox = Gtk.VBox()
209
 
        swbox.pack_start(sw, True, True, 0)
 
202
        swbox = gtk.VBox()
 
203
        swbox.pack_start(sw)
210
204
        swbox.show()
211
205
 
212
 
        hbox = Gtk.HBox(homogeneous=False, spacing=6)
 
206
        hbox = gtk.HBox(False, 6)
213
207
        self.back_button = self._create_back_button()
214
 
        hbox.pack_start(self.back_button, False, True, 0)
 
208
        hbox.pack_start(self.back_button, expand=False, fill=True)
215
209
        self.forward_button = self._create_forward_button()
216
 
        hbox.pack_start(self.forward_button, False, True, 0)
217
 
        self.find_button = self._create_find_button()
218
 
        hbox.pack_start(self.find_button, False, True, 0)
219
 
        self.goto_button = self._create_goto_button()
220
 
        hbox.pack_start(self.goto_button, False, True, 0)
 
210
        hbox.pack_start(self.forward_button, expand=False, fill=True)
221
211
        hbox.show()
222
 
        vbox.pack_start(hbox, False, True, 0)
223
 
 
224
 
        self.pane = pane = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
 
212
        vbox.pack_start(hbox, expand=False, fill=True)
 
213
        
 
214
        self.pane = pane = gtk.VPaned()
225
215
        pane.add1(swbox)
226
216
        pane.add2(self.revisionview)
227
217
        pane.show()
228
 
        vbox.pack_start(pane, True, True, 0)
 
218
        vbox.pack_start(pane, expand=True, fill=True)
229
219
 
230
220
        self._search = SearchBox()
231
 
        swbox.pack_start(self._search, False, True, 0)
232
 
        accels = Gtk.AccelGroup()
233
 
        accels.connect(Gdk.KEY_f, Gdk.ModifierType.CONTROL_MASK,
234
 
                             Gtk.AccelFlags.LOCKED,
 
221
        swbox.pack_start(self._search, expand=False, fill=True)
 
222
        accels = gtk.AccelGroup()
 
223
        accels.connect_group(gtk.keysyms.f, gtk.gdk.CONTROL_MASK,
 
224
                             gtk.ACCEL_LOCKED,
235
225
                             self._search_by_text)
236
 
        accels.connect(Gdk.KEY_g, Gdk.ModifierType.CONTROL_MASK,
237
 
                             Gtk.AccelFlags.LOCKED,
 
226
        accels.connect_group(gtk.keysyms.g, gtk.gdk.CONTROL_MASK,
 
227
                             gtk.ACCEL_LOCKED,
238
228
                             self._search_by_line)
239
229
        self.add_accel_group(accels)
240
230
 
241
231
        self.add(vbox)
242
232
 
243
 
    def _search_by_text(self, *ignored): # (accel_group, window, key, modifiers):
 
233
    def _search_by_text(self, accel_group, window, key, modifiers):
244
234
        self._search.show_for('text')
245
235
        self._search.set_target(self.annoview, TEXT_LINE_COL)
246
236
 
247
 
    def _search_by_line(self, *ignored): # accel_group, window, key, modifiers):
 
237
    def _search_by_line(self, accel_group, window, key, modifiers):
248
238
        self._search.show_for('line')
249
239
        self._search.set_target(self.annoview, LINE_NUM_COL)
250
240
 
251
 
    def line_diff(self, tv, path, tvc):
252
 
        row = path.get_indices()[0]
 
241
    def row_diff(self, tv, path, tvc):
 
242
        row = path[0]
253
243
        revision = self.annotations[row]
254
244
        repository = self.branch.repository
255
245
        if revision.revision_id == CURRENT_REVISION:
262
252
            else:
263
253
                tree2 = repository.revision_tree(NULL_REVISION)
264
254
        from bzrlib.plugins.gtk.diff import DiffWindow
265
 
        window = DiffWindow(self)
266
 
        window.set_diff("Diff for line %d" % (row+1), tree1, tree2)
 
255
        window = DiffWindow()
 
256
        window.set_diff("Diff for row %d" % (row+1), tree1, tree2)
267
257
        window.set_file(tree1.id2path(self.file_id))
268
258
        window.show()
269
259
 
270
260
 
271
261
    def _create_annotate_view(self):
272
 
        tv = Gtk.TreeView()
 
262
        tv = gtk.TreeView()
273
263
        tv.set_rules_hint(False)
274
264
        tv.connect("cursor-changed", self._activate_selected_revision)
275
265
        tv.show()
276
 
        tv.connect("row-activated", self.line_diff)
 
266
        tv.connect("row-activated", self.row_diff)
277
267
 
278
 
        cell = Gtk.CellRendererText()
 
268
        cell = gtk.CellRendererText()
279
269
        cell.set_property("xalign", 1.0)
280
270
        cell.set_property("ypad", 0)
281
271
        cell.set_property("family", "Monospace")
282
272
        cell.set_property("cell-background-gdk",
283
 
                          tv.get_style().bg[Gtk.StateType.NORMAL])
284
 
        col = Gtk.TreeViewColumn()
 
273
                          tv.get_style().bg[gtk.STATE_NORMAL])
 
274
        col = gtk.TreeViewColumn()
285
275
        col.set_resizable(False)
286
 
        col.pack_start(cell, True)
 
276
        col.pack_start(cell, expand=True)
287
277
        col.add_attribute(cell, "text", LINE_NUM_COL)
288
278
        tv.append_column(col)
289
279
 
290
 
        cell = Gtk.CellRendererText()
 
280
        cell = gtk.CellRendererText()
291
281
        cell.set_property("ypad", 0)
292
 
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
 
282
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
293
283
        cell.set_property("cell-background-gdk",
294
 
                          self.get_style().bg[Gtk.StateType.NORMAL])
295
 
        col = Gtk.TreeViewColumn("Committer")
 
284
                          self.get_style().bg[gtk.STATE_NORMAL])
 
285
        col = gtk.TreeViewColumn("Committer")
296
286
        col.set_resizable(True)
297
 
        col.pack_start(cell, True)
 
287
        col.pack_start(cell, expand=True)
298
288
        col.add_attribute(cell, "text", COMMITTER_COL)
299
289
        tv.append_column(col)
300
290
 
301
 
        cell = Gtk.CellRendererText()
 
291
        cell = gtk.CellRendererText()
302
292
        cell.set_property("xalign", 1.0)
303
293
        cell.set_property("ypad", 0)
304
294
        cell.set_property("cell-background-gdk",
305
 
                          self.get_style().bg[Gtk.StateType.NORMAL])
306
 
        col = Gtk.TreeViewColumn("Revno")
 
295
                          self.get_style().bg[gtk.STATE_NORMAL])
 
296
        col = gtk.TreeViewColumn("Revno")
307
297
        col.set_resizable(False)
308
 
        col.pack_start(cell, True)
 
298
        col.pack_start(cell, expand=True)
309
299
        col.add_attribute(cell, "markup", REVNO_COL)
310
300
        tv.append_column(col)
311
301
 
312
 
        cell = Gtk.CellRendererText()
 
302
        cell = gtk.CellRendererText()
313
303
        cell.set_property("ypad", 0)
314
304
        cell.set_property("family", "Monospace")
315
 
        col = Gtk.TreeViewColumn()
 
305
        col = gtk.TreeViewColumn()
316
306
        col.set_resizable(False)
317
 
        col.pack_start(cell, True)
 
307
        col.pack_start(cell, expand=True)
318
308
#        col.add_attribute(cell, "foreground", HIGHLIGHT_COLOR_COL)
319
309
        col.add_attribute(cell, "background", HIGHLIGHT_COLOR_COL)
320
310
        col.add_attribute(cell, "text", TEXT_LINE_COL)
321
311
        tv.append_column(col)
322
312
 
323
 
        # interactive substring search
324
 
        def search_equal_func(model, column, key, iter):
325
 
            return model.get_value(iter, TEXT_LINE_COL).lower().find(key.lower()) == -1
326
 
 
327
 
        tv.set_enable_search(True)
328
 
        tv.set_search_equal_func(search_equal_func, None)
 
313
        # FIXME: Now that C-f is now used for search by text we
 
314
        # may as well disable the auto search.
 
315
        tv.set_search_column(LINE_NUM_COL)
329
316
 
330
317
        return tv
331
318
 
332
319
    def _create_log_view(self):
333
 
        lv = RevisionView(self._branch)
 
320
        lv = RevisionView()
334
321
        lv.show()
335
322
        return lv
336
323
 
337
324
    def _create_back_button(self):
338
 
        button = Gtk.Button()
 
325
        button = gtk.Button()
339
326
        button.set_use_stock(True)
340
327
        button.set_label("gtk-go-back")
341
328
        button.connect("clicked", lambda w: self.go_back())
342
 
        button.set_relief(Gtk.ReliefStyle.NONE)
 
329
        button.set_relief(gtk.RELIEF_NONE)
343
330
        button.show()
344
331
        return button
345
332
 
346
333
    def _create_forward_button(self):
347
 
        button = Gtk.Button()
 
334
        button = gtk.Button()
348
335
        button.set_use_stock(True)
349
336
        button.set_label("gtk-go-forward")
350
337
        button.connect("clicked", lambda w: self.go_forward())
351
 
        button.set_relief(Gtk.ReliefStyle.NONE)
 
338
        button.set_relief(gtk.RELIEF_NONE)
352
339
        button.show()
353
340
        button.set_sensitive(False)
354
341
        return button
355
342
 
356
 
    def _create_find_button(self):
357
 
        button = Gtk.Button()
358
 
        button.set_use_stock(True)
359
 
        button.set_label("gtk-find")
360
 
        button.set_tooltip_text("Search for text (Ctrl+F)")
361
 
        button.connect("clicked", self._search_by_text)
362
 
        button.set_relief(Gtk.ReliefStyle.NONE)
363
 
        button.show()
364
 
        button.set_sensitive(True)
365
 
        return button
366
 
 
367
 
    def _create_goto_button(self):
368
 
        button = Gtk.Button()
369
 
        button.set_label("Goto Line")
370
 
        button.set_tooltip_text("Scroll to a line by entering its number (Ctrl+G)")
371
 
        button.connect("clicked", self._search_by_line)
372
 
        button.set_relief(Gtk.ReliefStyle.NONE)
373
 
        button.show()
374
 
        button.set_sensitive(True)
375
 
        return button
376
 
 
377
343
    def go_back(self):
378
344
        last_tree = self.tree
379
345
        rev_id = self._selected_revision()
398
364
        rev_id = self._selected_revision()
399
365
        if self.file_id in target_tree:
400
366
            offset = self.get_scroll_offset(target_tree)
401
 
            path, col = self.annoview.get_cursor()
402
 
            (row,) = path.get_indices()
 
367
            (row,), col = self.annoview.get_cursor()
403
368
            self.annotate(target_tree, self.branch, self.file_id)
404
369
            new_row = row+offset
405
370
            if new_row < 0:
406
371
                new_row = 0
407
 
            new_path = Gtk.TreePath(path=new_row)
408
 
            self.annoview.set_cursor(new_path, None, False)
 
372
            self.annoview.set_cursor(new_row)
409
373
            return True
410
374
        else:
411
375
            return False
413
377
    def get_scroll_offset(self, tree):
414
378
        old = self.tree.get_file(self.file_id)
415
379
        new = tree.get_file(self.file_id)
416
 
        path, col = self.annoview.get_cursor()
417
 
        (row,) = path.get_indices()
 
380
        (row,), col = self.annoview.get_cursor()
418
381
        matcher = patiencediff.PatienceSequenceMatcher(None, old.readlines(),
419
382
                                                       new.readlines())
420
383
        for i, j, n in matcher.get_matching_blocks():
422
385
                return j - i
423
386
 
424
387
 
425
 
class FakeRevision(object):
 
388
class FakeRevision:
426
389
    """ A fake revision.
427
390
 
428
391
    For when a revision is referenced but not present.
437
400
        self.timezone = 0
438
401
        self.properties = {}
439
402
 
440
 
    def get_apparent_authors(self):
441
 
        return [self.committer]
 
403
    def get_apparent_author(self):
 
404
        return self.committer
442
405
 
443
406
 
444
407
class RevisionCache(object):
445
408
    """A caching revision source"""
446
 
 
447
409
    def __init__(self, real_source, seed_cache=None):
448
410
        self.__real_source = real_source
449
411
        if seed_cache is None:
457
419
            self.__cache[revision_id] = revision
458
420
        return self.__cache[revision_id]
459
421
 
460
 
 
461
 
class SearchBox(Gtk.HBox):
 
422
class SearchBox(gtk.HBox):
462
423
    """A button box for searching in text or lines of annotations"""
463
424
    def __init__(self):
464
 
        super(SearchBox, self).__init__(homogeneous=False, spacing=6)
 
425
        gtk.HBox.__init__(self, False, 6)
465
426
 
466
427
        # Close button
467
 
        button = Gtk.Button()
468
 
        image = Gtk.Image()
469
 
        image.set_from_stock('gtk-stop', Gtk.IconSize.BUTTON)
 
428
        button = gtk.Button()
 
429
        image = gtk.Image()
 
430
        image.set_from_stock('gtk-stop', gtk.ICON_SIZE_BUTTON)
470
431
        button.set_image(image)
471
 
        button.set_relief(Gtk.ReliefStyle.NONE)
472
 
        button.connect("clicked", lambda w: self.hide())
473
 
        self.pack_start(button, False, False, 0)
 
432
        button.set_relief(gtk.RELIEF_NONE)
 
433
        button.connect("clicked", lambda w: self.hide_all())
 
434
        self.pack_start(button, expand=False, fill=False)
474
435
 
475
436
        # Search entry
476
 
        label = Gtk.Label()
 
437
        label = gtk.Label()
477
438
        self._label = label
478
 
        self.pack_start(label, False, False, 0)
 
439
        self.pack_start(label, expand=False, fill=False)
479
440
 
480
 
        entry = Gtk.Entry()
 
441
        entry = gtk.Entry()
481
442
        self._entry = entry
482
443
        entry.connect("activate", lambda w, d: self._do_search(d),
483
444
                      'forward')
484
 
        self.pack_start(entry, False, False, 0)
 
445
        self.pack_start(entry, expand=False, fill=False)
485
446
 
486
447
        # Next/previous buttons
487
 
        button = Gtk.Button(_i18n('_Next'), use_underline=True)
488
 
        image = Gtk.Image()
489
 
        image.set_from_stock('gtk-go-forward', Gtk.IconSize.BUTTON)
 
448
        button = gtk.Button('_Next')
 
449
        image = gtk.Image()
 
450
        image.set_from_stock('gtk-go-forward', gtk.ICON_SIZE_BUTTON)
490
451
        button.set_image(image)
491
452
        button.connect("clicked", lambda w, d: self._do_search(d),
492
453
                       'forward')
493
 
        self.pack_start(button, False, False, 0)
 
454
        self.pack_start(button, expand=False, fill=False)
494
455
 
495
 
        button = Gtk.Button(_i18n('_Previous'), use_underline=True)
496
 
        image = Gtk.Image()
497
 
        image.set_from_stock('gtk-go-back', Gtk.IconSize.BUTTON)
 
456
        button = gtk.Button('_Previous')
 
457
        image = gtk.Image()
 
458
        image.set_from_stock('gtk-go-back', gtk.ICON_SIZE_BUTTON)
498
459
        button.set_image(image)
499
460
        button.connect("clicked", lambda w, d: self._do_search(d),
500
461
                       'backward')
501
 
        self.pack_start(button, False, False, 0)
 
462
        self.pack_start(button, expand=False, fill=False)
502
463
 
503
464
        # Search options
504
 
        check = Gtk.CheckButton('Match case')
 
465
        check = gtk.CheckButton('Match case')
505
466
        self._match_case = check
506
 
        self.pack_start(check, False, False, 0)
 
467
        self.pack_start(check, expand=False, fill=False)
507
468
 
508
 
        check = Gtk.CheckButton('Regexp')
 
469
        check = gtk.CheckButton('Regexp')
509
470
        check.connect("toggled", lambda w: self._set_label())
510
471
        self._regexp = check
511
 
        self.pack_start(check, False, False, 0)
 
472
        self.pack_start(check, expand=False, fill=False)
512
473
 
513
474
        self._view = None
514
475
        self._column = None
541
502
 
542
503
    def _match(self, model, iterator, column):
543
504
        matching_case = self._match_case.get_active()
544
 
        cell_value, = model.get(iterator, column)
 
505
        string, = model.get(iterator, column)
545
506
        key = self._entry.get_text()
546
 
        if column == LINE_NUM_COL:
547
 
            # FIXME: For goto-line there are faster algorithms than searching 
548
 
            # every line til we find the right one! -- mbp 2011-01-27
549
 
            return key.strip() == str(cell_value)
550
 
        elif self._regexp.get_active():
 
507
        if self._regexp.get_active():
551
508
            if matching_case:
552
 
                match = re.compile(key).search(cell_value, 1)
 
509
                match = re.compile(key).search(string, 1)
553
510
            else:
554
 
                match = re.compile(key, re.I).search(cell_value, 1)
 
511
                match = re.compile(key, re.I).search(string, 1)
555
512
        else:
556
513
            if not matching_case:
557
 
                cell_value = cell_value.lower()
 
514
                string = string.lower()
558
515
                key = key.lower()
559
 
            match = cell_value.find(key) != -1
 
516
            match = string.find(key) != -1
560
517
 
561
518
        return match
562
519
 
594
551
        for row in iterate(model, start):
595
552
            if self._match(model, row, self._column):
596
553
                path = model.get_path(row)
597
 
                self._view.set_cursor(path, None, False)
 
554
                self._view.set_cursor(path)
598
555
                self._view.scroll_to_cell(path, use_align=True)
599
556
                break