/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: Jelmer Vernooij
  • Date: 2008-03-28 19:26:53 UTC
  • mto: (450.1.13 trunk)
  • mto: This revision was merged to the branch mainline in revision 458.
  • Revision ID: jelmer@samba.org-20080328192653-trzptkwahx1tulz9
Add module for preferences code.

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:
126
124
            # bar?
127
125
            print("gannotate: Line number %d does't exist. Defaulting to "
128
126
                  "line 1." % lineno)
129
 
            return
 
127
            return
130
128
        else:
131
129
            row = lineno - 1
132
130
 
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)
 
131
        self.annoview.set_cursor(row)
 
132
        self.annoview.scroll_to_cell(row, use_align=True)
 
133
 
136
134
 
137
135
    def _annotate(self, tree, file_id):
138
136
        current_revision = FakeRevision(CURRENT_REVISION)
140
138
        current_revision.timestamp = time.time()
141
139
        current_revision.message = '[Not yet committed]'
142
140
        current_revision.parent_ids = tree.get_parent_ids()
143
 
        current_revision.properties['branch-nick'] = self.branch._get_nick(local=True)
 
141
        current_revision.properties['branch-nick'] = self.branch.nick
144
142
        current_revno = '%d?' % (self.branch.revno() + 1)
145
143
        repository = self.branch.repository
146
144
        if self.revision_id == CURRENT_REVISION:
168
166
    def _highlight_annotation(self, model, path, iter, now):
169
167
        revision_id, = model.get(iter, REVISION_ID_COL)
170
168
        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)
 
169
        model.set(iter, HIGHLIGHT_COLOR_COL,
 
170
                  self.annotate_colormap.get_color(revision, now))
174
171
 
175
172
    def _selected_revision(self):
176
173
        (path, col) = self.annoview.get_cursor()
180
177
 
181
178
    def _activate_selected_revision(self, w):
182
179
        rev_id = self._selected_revision()
183
 
        if not rev_id or rev_id == NULL_REVISION:
 
180
        if rev_id is None:
184
181
            return
185
182
        selected = self.revisions[rev_id]
186
183
        self.revisionview.set_revision(selected)
195
192
        self.revisionview = self._create_log_view()
196
193
        self.annoview = self._create_annotate_view()
197
194
 
198
 
        vbox = Gtk.VBox(homogeneous=False, spacing=0)
 
195
        vbox = gtk.VBox(False)
199
196
        vbox.show()
200
197
 
201
 
        sw = Gtk.ScrolledWindow()
202
 
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
203
 
        sw.set_shadow_type(Gtk.ShadowType.IN)
 
198
        sw = gtk.ScrolledWindow()
 
199
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
200
        sw.set_shadow_type(gtk.SHADOW_IN)
204
201
        sw.add(self.annoview)
205
202
        self.annoview.gwindow = self
206
203
        sw.show()
207
204
 
208
 
        swbox = Gtk.VBox()
209
 
        swbox.pack_start(sw, True, True, 0)
 
205
        swbox = gtk.VBox()
 
206
        swbox.pack_start(sw)
210
207
        swbox.show()
211
208
 
212
 
        hbox = Gtk.HBox(homogeneous=False, spacing=6)
 
209
        hbox = gtk.HBox(False, 6)
213
210
        self.back_button = self._create_back_button()
214
 
        hbox.pack_start(self.back_button, False, True, 0)
 
211
        hbox.pack_start(self.back_button, expand=False, fill=True)
215
212
        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)
 
213
        hbox.pack_start(self.forward_button, expand=False, fill=True)
221
214
        hbox.show()
222
 
        vbox.pack_start(hbox, False, True, 0)
223
 
 
224
 
        self.pane = pane = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
 
215
        vbox.pack_start(hbox, expand=False, fill=True)
 
216
        
 
217
        self.pane = pane = gtk.VPaned()
225
218
        pane.add1(swbox)
226
219
        pane.add2(self.revisionview)
227
220
        pane.show()
228
 
        vbox.pack_start(pane, True, True, 0)
 
221
        vbox.pack_start(pane, expand=True, fill=True)
229
222
 
230
223
        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,
 
224
        swbox.pack_start(self._search, expand=False, fill=True)
 
225
        accels = gtk.AccelGroup()
 
226
        accels.connect_group(gtk.keysyms.f, gtk.gdk.CONTROL_MASK,
 
227
                             gtk.ACCEL_LOCKED,
235
228
                             self._search_by_text)
236
 
        accels.connect(Gdk.KEY_g, Gdk.ModifierType.CONTROL_MASK,
237
 
                             Gtk.AccelFlags.LOCKED,
 
229
        accels.connect_group(gtk.keysyms.g, gtk.gdk.CONTROL_MASK,
 
230
                             gtk.ACCEL_LOCKED,
238
231
                             self._search_by_line)
239
232
        self.add_accel_group(accels)
240
233
 
241
234
        self.add(vbox)
242
235
 
243
 
    def _search_by_text(self, *ignored): # (accel_group, window, key, modifiers):
 
236
    def _search_by_text(self, accel_group, window, key, modifiers):
244
237
        self._search.show_for('text')
245
238
        self._search.set_target(self.annoview, TEXT_LINE_COL)
246
239
 
247
 
    def _search_by_line(self, *ignored): # accel_group, window, key, modifiers):
 
240
    def _search_by_line(self, accel_group, window, key, modifiers):
248
241
        self._search.show_for('line')
249
242
        self._search.set_target(self.annoview, LINE_NUM_COL)
250
243
 
251
244
    def line_diff(self, tv, path, tvc):
252
 
        row = path.get_indices()[0]
 
245
        row = path[0]
253
246
        revision = self.annotations[row]
254
247
        repository = self.branch.repository
255
248
        if revision.revision_id == CURRENT_REVISION:
262
255
            else:
263
256
                tree2 = repository.revision_tree(NULL_REVISION)
264
257
        from bzrlib.plugins.gtk.diff import DiffWindow
265
 
        window = DiffWindow(self)
 
258
        window = DiffWindow()
266
259
        window.set_diff("Diff for line %d" % (row+1), tree1, tree2)
267
260
        window.set_file(tree1.id2path(self.file_id))
268
261
        window.show()
269
262
 
270
263
 
271
264
    def _create_annotate_view(self):
272
 
        tv = Gtk.TreeView()
 
265
        tv = gtk.TreeView()
273
266
        tv.set_rules_hint(False)
274
267
        tv.connect("cursor-changed", self._activate_selected_revision)
275
268
        tv.show()
276
269
        tv.connect("row-activated", self.line_diff)
277
270
 
278
 
        cell = Gtk.CellRendererText()
 
271
        cell = gtk.CellRendererText()
279
272
        cell.set_property("xalign", 1.0)
280
273
        cell.set_property("ypad", 0)
281
274
        cell.set_property("family", "Monospace")
282
 
        cell.set_property(
283
 
            "cell-background-rgba",
284
 
            tv.get_style_context().get_background_color(Gtk.StateType.NORMAL))
285
 
        col = Gtk.TreeViewColumn()
 
275
        cell.set_property("cell-background-gdk",
 
276
                          tv.get_style().bg[gtk.STATE_NORMAL])
 
277
        col = gtk.TreeViewColumn()
286
278
        col.set_resizable(False)
287
 
        col.pack_start(cell, True)
 
279
        col.pack_start(cell, expand=True)
288
280
        col.add_attribute(cell, "text", LINE_NUM_COL)
289
281
        tv.append_column(col)
290
282
 
291
 
        style_context = self.get_style_context()
292
 
 
293
 
        cell = Gtk.CellRendererText()
 
283
        cell = gtk.CellRendererText()
294
284
        cell.set_property("ypad", 0)
295
 
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
296
 
        cell.set_property(
297
 
            "cell-background-rgba",
298
 
            style_context.get_background_color(Gtk.StateType.NORMAL))
299
 
        col = Gtk.TreeViewColumn("Committer")
 
285
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
 
286
        cell.set_property("cell-background-gdk",
 
287
                          self.get_style().bg[gtk.STATE_NORMAL])
 
288
        col = gtk.TreeViewColumn("Committer")
300
289
        col.set_resizable(True)
301
 
        col.pack_start(cell, True)
 
290
        col.pack_start(cell, expand=True)
302
291
        col.add_attribute(cell, "text", COMMITTER_COL)
303
292
        tv.append_column(col)
304
293
 
305
 
        cell = Gtk.CellRendererText()
 
294
        cell = gtk.CellRendererText()
306
295
        cell.set_property("xalign", 1.0)
307
296
        cell.set_property("ypad", 0)
308
 
        cell.set_property(
309
 
            "cell-background-rgba",
310
 
            style_context.get_background_color(Gtk.StateType.NORMAL))
311
 
        col = Gtk.TreeViewColumn("Revno")
 
297
        cell.set_property("cell-background-gdk",
 
298
                          self.get_style().bg[gtk.STATE_NORMAL])
 
299
        col = gtk.TreeViewColumn("Revno")
312
300
        col.set_resizable(False)
313
 
        col.pack_start(cell, True)
 
301
        col.pack_start(cell, expand=True)
314
302
        col.add_attribute(cell, "markup", REVNO_COL)
315
303
        tv.append_column(col)
316
304
 
317
 
        cell = Gtk.CellRendererText()
 
305
        cell = gtk.CellRendererText()
318
306
        cell.set_property("ypad", 0)
319
307
        cell.set_property("family", "Monospace")
320
 
        col = Gtk.TreeViewColumn()
 
308
        col = gtk.TreeViewColumn()
321
309
        col.set_resizable(False)
322
 
        col.pack_start(cell, True)
 
310
        col.pack_start(cell, expand=True)
323
311
#        col.add_attribute(cell, "foreground", HIGHLIGHT_COLOR_COL)
324
312
        col.add_attribute(cell, "background", HIGHLIGHT_COLOR_COL)
325
313
        col.add_attribute(cell, "text", TEXT_LINE_COL)
326
314
        tv.append_column(col)
327
315
 
328
 
        # interactive substring search
329
 
        def search_equal_func(model, column, key, iter):
330
 
            return model.get_value(iter, TEXT_LINE_COL).lower().find(key.lower()) == -1
331
 
 
332
 
        tv.set_enable_search(True)
333
 
        tv.set_search_equal_func(search_equal_func, None)
 
316
        # FIXME: Now that C-f is now used for search by text we
 
317
        # may as well disable the auto search.
 
318
        tv.set_search_column(LINE_NUM_COL)
334
319
 
335
320
        return tv
336
321
 
337
322
    def _create_log_view(self):
338
 
        lv = RevisionView(self._branch)
 
323
        lv = RevisionView()
339
324
        lv.show()
340
325
        return lv
341
326
 
342
327
    def _create_back_button(self):
343
 
        button = Gtk.Button()
 
328
        button = gtk.Button()
344
329
        button.set_use_stock(True)
345
330
        button.set_label("gtk-go-back")
346
331
        button.connect("clicked", lambda w: self.go_back())
347
 
        button.set_relief(Gtk.ReliefStyle.NONE)
 
332
        button.set_relief(gtk.RELIEF_NONE)
348
333
        button.show()
349
334
        return button
350
335
 
351
336
    def _create_forward_button(self):
352
 
        button = Gtk.Button()
 
337
        button = gtk.Button()
353
338
        button.set_use_stock(True)
354
339
        button.set_label("gtk-go-forward")
355
340
        button.connect("clicked", lambda w: self.go_forward())
356
 
        button.set_relief(Gtk.ReliefStyle.NONE)
 
341
        button.set_relief(gtk.RELIEF_NONE)
357
342
        button.show()
358
343
        button.set_sensitive(False)
359
344
        return button
360
345
 
361
 
    def _create_find_button(self):
362
 
        button = Gtk.Button()
363
 
        button.set_use_stock(True)
364
 
        button.set_label("gtk-find")
365
 
        button.set_tooltip_text("Search for text (Ctrl+F)")
366
 
        button.connect("clicked", self._search_by_text)
367
 
        button.set_relief(Gtk.ReliefStyle.NONE)
368
 
        button.show()
369
 
        button.set_sensitive(True)
370
 
        return button
371
 
 
372
 
    def _create_goto_button(self):
373
 
        button = Gtk.Button()
374
 
        button.set_label("Goto Line")
375
 
        button.set_tooltip_text("Scroll to a line by entering its number (Ctrl+G)")
376
 
        button.connect("clicked", self._search_by_line)
377
 
        button.set_relief(Gtk.ReliefStyle.NONE)
378
 
        button.show()
379
 
        button.set_sensitive(True)
380
 
        return button
381
 
 
382
346
    def go_back(self):
383
347
        last_tree = self.tree
384
348
        rev_id = self._selected_revision()
403
367
        rev_id = self._selected_revision()
404
368
        if self.file_id in target_tree:
405
369
            offset = self.get_scroll_offset(target_tree)
406
 
            path, col = self.annoview.get_cursor()
407
 
            (row,) = path.get_indices()
 
370
            (row,), col = self.annoview.get_cursor()
408
371
            self.annotate(target_tree, self.branch, self.file_id)
409
372
            new_row = row+offset
410
373
            if new_row < 0:
411
374
                new_row = 0
412
 
            new_path = Gtk.TreePath(path=new_row)
413
 
            self.annoview.set_cursor(new_path, None, False)
 
375
            self.annoview.set_cursor(new_row)
414
376
            return True
415
377
        else:
416
378
            return False
418
380
    def get_scroll_offset(self, tree):
419
381
        old = self.tree.get_file(self.file_id)
420
382
        new = tree.get_file(self.file_id)
421
 
        path, col = self.annoview.get_cursor()
422
 
        (row,) = path.get_indices()
 
383
        (row,), col = self.annoview.get_cursor()
423
384
        matcher = patiencediff.PatienceSequenceMatcher(None, old.readlines(),
424
385
                                                       new.readlines())
425
386
        for i, j, n in matcher.get_matching_blocks():
427
388
                return j - i
428
389
 
429
390
 
430
 
class FakeRevision(object):
 
391
class FakeRevision:
431
392
    """ A fake revision.
432
393
 
433
394
    For when a revision is referenced but not present.
442
403
        self.timezone = 0
443
404
        self.properties = {}
444
405
 
445
 
    def get_apparent_authors(self):
446
 
        return [self.committer]
 
406
    def get_apparent_author(self):
 
407
        return self.committer
447
408
 
448
409
 
449
410
class RevisionCache(object):
450
411
    """A caching revision source"""
451
 
 
452
412
    def __init__(self, real_source, seed_cache=None):
453
413
        self.__real_source = real_source
454
414
        if seed_cache is None:
462
422
            self.__cache[revision_id] = revision
463
423
        return self.__cache[revision_id]
464
424
 
465
 
 
466
 
class SearchBox(Gtk.HBox):
 
425
class SearchBox(gtk.HBox):
467
426
    """A button box for searching in text or lines of annotations"""
468
427
    def __init__(self):
469
 
        super(SearchBox, self).__init__(homogeneous=False, spacing=6)
 
428
        gtk.HBox.__init__(self, False, 6)
470
429
 
471
430
        # Close button
472
 
        button = Gtk.Button()
473
 
        image = Gtk.Image()
474
 
        image.set_from_stock('gtk-stop', Gtk.IconSize.BUTTON)
 
431
        button = gtk.Button()
 
432
        image = gtk.Image()
 
433
        image.set_from_stock('gtk-stop', gtk.ICON_SIZE_BUTTON)
475
434
        button.set_image(image)
476
 
        button.set_relief(Gtk.ReliefStyle.NONE)
477
 
        button.connect("clicked", lambda w: self.hide())
478
 
        self.pack_start(button, False, False, 0)
 
435
        button.set_relief(gtk.RELIEF_NONE)
 
436
        button.connect("clicked", lambda w: self.hide_all())
 
437
        self.pack_start(button, expand=False, fill=False)
479
438
 
480
439
        # Search entry
481
 
        label = Gtk.Label()
 
440
        label = gtk.Label()
482
441
        self._label = label
483
 
        self.pack_start(label, False, False, 0)
 
442
        self.pack_start(label, expand=False, fill=False)
484
443
 
485
 
        entry = Gtk.Entry()
 
444
        entry = gtk.Entry()
486
445
        self._entry = entry
487
446
        entry.connect("activate", lambda w, d: self._do_search(d),
488
447
                      'forward')
489
 
        self.pack_start(entry, False, False, 0)
 
448
        self.pack_start(entry, expand=False, fill=False)
490
449
 
491
450
        # Next/previous buttons
492
 
        button = Gtk.Button(_i18n('_Next'), use_underline=True)
493
 
        image = Gtk.Image()
494
 
        image.set_from_stock('gtk-go-forward', Gtk.IconSize.BUTTON)
 
451
        button = gtk.Button('_Next')
 
452
        image = gtk.Image()
 
453
        image.set_from_stock('gtk-go-forward', gtk.ICON_SIZE_BUTTON)
495
454
        button.set_image(image)
496
455
        button.connect("clicked", lambda w, d: self._do_search(d),
497
456
                       'forward')
498
 
        self.pack_start(button, False, False, 0)
 
457
        self.pack_start(button, expand=False, fill=False)
499
458
 
500
 
        button = Gtk.Button(_i18n('_Previous'), use_underline=True)
501
 
        image = Gtk.Image()
502
 
        image.set_from_stock('gtk-go-back', Gtk.IconSize.BUTTON)
 
459
        button = gtk.Button('_Previous')
 
460
        image = gtk.Image()
 
461
        image.set_from_stock('gtk-go-back', gtk.ICON_SIZE_BUTTON)
503
462
        button.set_image(image)
504
463
        button.connect("clicked", lambda w, d: self._do_search(d),
505
464
                       'backward')
506
 
        self.pack_start(button, False, False, 0)
 
465
        self.pack_start(button, expand=False, fill=False)
507
466
 
508
467
        # Search options
509
 
        check = Gtk.CheckButton('Match case')
 
468
        check = gtk.CheckButton('Match case')
510
469
        self._match_case = check
511
 
        self.pack_start(check, False, False, 0)
 
470
        self.pack_start(check, expand=False, fill=False)
512
471
 
513
 
        check = Gtk.CheckButton('Regexp')
 
472
        check = gtk.CheckButton('Regexp')
514
473
        check.connect("toggled", lambda w: self._set_label())
515
474
        self._regexp = check
516
 
        self.pack_start(check, False, False, 0)
 
475
        self.pack_start(check, expand=False, fill=False)
517
476
 
518
477
        self._view = None
519
478
        self._column = None
546
505
 
547
506
    def _match(self, model, iterator, column):
548
507
        matching_case = self._match_case.get_active()
549
 
        cell_value, = model.get(iterator, column)
 
508
        string, = model.get(iterator, column)
550
509
        key = self._entry.get_text()
551
 
        if column == LINE_NUM_COL:
552
 
            # FIXME: For goto-line there are faster algorithms than searching 
553
 
            # every line til we find the right one! -- mbp 2011-01-27
554
 
            return key.strip() == str(cell_value)
555
 
        elif self._regexp.get_active():
 
510
        if self._regexp.get_active():
556
511
            if matching_case:
557
 
                match = re.compile(key).search(cell_value, 1)
 
512
                match = re.compile(key).search(string, 1)
558
513
            else:
559
 
                match = re.compile(key, re.I).search(cell_value, 1)
 
514
                match = re.compile(key, re.I).search(string, 1)
560
515
        else:
561
516
            if not matching_case:
562
 
                cell_value = cell_value.lower()
 
517
                string = string.lower()
563
518
                key = key.lower()
564
 
            match = cell_value.find(key) != -1
 
519
            match = string.find(key) != -1
565
520
 
566
521
        return match
567
522
 
599
554
        for row in iterate(model, start):
600
555
            if self._match(model, row, self._column):
601
556
                path = model.get_path(row)
602
 
                self._view.set_cursor(path, None, False)
 
557
                self._view.set_cursor(path)
603
558
                self._view.scroll_to_cell(path, use_align=True)
604
559
                break