/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: Curtis Hovey
  • Date: 2011-08-12 20:25:28 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110812202528-4xf4a2t23urx50d2
Updated gst to gtk3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.revision import NULL_REVISION, CURRENT_REVISION
28
28
 
29
29
from bzrlib.plugins.gtk.annotate.colormap import AnnotateColorSaturation
30
 
from bzrlib.plugins.gtk.i18n import _i18n
31
30
from bzrlib.plugins.gtk.revisionview import RevisionView
32
31
from bzrlib.plugins.gtk.window import Window
33
32
 
50
49
        self.plain = plain
51
50
        self._branch = branch
52
51
 
53
 
        super(GAnnotateWindow, self).__init__(parent=parent)
 
52
        Window.__init__(self, parent)
54
53
 
55
54
        self.set_icon(
56
55
            self.render_icon_pixbuf(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON))
130
129
        else:
131
130
            row = lineno - 1
132
131
 
133
 
        tree_path = Gtk.TreePath(path=row)
134
 
        self.annoview.set_cursor(tree_path, None, False)
 
132
        tree_path = Gtk.TreePath.new_from_string(str(row))
 
133
        self.annoview.set_cursor(tree_path, None, None)
135
134
        self.annoview.scroll_to_cell(tree_path, use_align=True)
136
135
 
 
136
 
137
137
    def _annotate(self, tree, file_id):
138
138
        current_revision = FakeRevision(CURRENT_REVISION)
139
139
        current_revision.committer = self.branch.get_config().username()
168
168
    def _highlight_annotation(self, model, path, iter, now):
169
169
        revision_id, = model.get(iter, REVISION_ID_COL)
170
170
        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)
 
171
        model.set(iter, HIGHLIGHT_COLOR_COL,
 
172
                  self.annotate_colormap.get_color(revision, now))
174
173
 
175
174
    def _selected_revision(self):
176
175
        (path, col) = self.annoview.get_cursor()
221
220
        hbox.show()
222
221
        vbox.pack_start(hbox, False, True, 0)
223
222
 
224
 
        self.pane = pane = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
 
223
        self.pane = pane = Gtk.VPaned()
225
224
        pane.add1(swbox)
226
225
        pane.add2(self.revisionview)
227
226
        pane.show()
249
248
        self._search.set_target(self.annoview, LINE_NUM_COL)
250
249
 
251
250
    def line_diff(self, tv, path, tvc):
252
 
        row = path.get_indices()[0]
 
251
        row = path[0]
253
252
        revision = self.annotations[row]
254
253
        repository = self.branch.repository
255
254
        if revision.revision_id == CURRENT_REVISION:
398
397
        rev_id = self._selected_revision()
399
398
        if self.file_id in target_tree:
400
399
            offset = self.get_scroll_offset(target_tree)
401
 
            path, col = self.annoview.get_cursor()
402
 
            (row,) = path.get_indices()
 
400
            (row,), col = self.annoview.get_cursor()
403
401
            self.annotate(target_tree, self.branch, self.file_id)
404
402
            new_row = row+offset
405
403
            if new_row < 0:
406
404
                new_row = 0
407
 
            new_path = Gtk.TreePath(path=new_row)
408
 
            self.annoview.set_cursor(new_path, None, False)
 
405
            self.annoview.set_cursor(new_row)
409
406
            return True
410
407
        else:
411
408
            return False
413
410
    def get_scroll_offset(self, tree):
414
411
        old = self.tree.get_file(self.file_id)
415
412
        new = tree.get_file(self.file_id)
416
 
        path, col = self.annoview.get_cursor()
417
 
        (row,) = path.get_indices()
 
413
        (row,), col = self.annoview.get_cursor()
418
414
        matcher = patiencediff.PatienceSequenceMatcher(None, old.readlines(),
419
415
                                                       new.readlines())
420
416
        for i, j, n in matcher.get_matching_blocks():
457
453
            self.__cache[revision_id] = revision
458
454
        return self.__cache[revision_id]
459
455
 
460
 
 
461
456
class SearchBox(Gtk.HBox):
462
457
    """A button box for searching in text or lines of annotations"""
463
458
    def __init__(self):
464
 
        super(SearchBox, self).__init__(homogeneous=False, spacing=6)
 
459
        Gtk.HBox.__init__(self, homogeneous=False, spacing=6)
465
460
 
466
461
        # Close button
467
462
        button = Gtk.Button()
469
464
        image.set_from_stock('gtk-stop', Gtk.IconSize.BUTTON)
470
465
        button.set_image(image)
471
466
        button.set_relief(Gtk.ReliefStyle.NONE)
472
 
        button.connect("clicked", lambda w: self.hide())
 
467
        button.connect("clicked", lambda w: self.hide_all())
473
468
        self.pack_start(button, False, False, 0)
474
469
 
475
470
        # Search entry
484
479
        self.pack_start(entry, False, False, 0)
485
480
 
486
481
        # Next/previous buttons
487
 
        button = Gtk.Button(_i18n('_Next'), use_underline=True)
 
482
        button = Gtk.Button('_Next')
488
483
        image = Gtk.Image()
489
484
        image.set_from_stock('gtk-go-forward', Gtk.IconSize.BUTTON)
490
485
        button.set_image(image)
492
487
                       'forward')
493
488
        self.pack_start(button, False, False, 0)
494
489
 
495
 
        button = Gtk.Button(_i18n('_Previous'), use_underline=True)
 
490
        button = Gtk.Button('_Previous')
496
491
        image = Gtk.Image()
497
492
        image.set_from_stock('gtk-go-back', Gtk.IconSize.BUTTON)
498
493
        button.set_image(image)
594
589
        for row in iterate(model, start):
595
590
            if self._match(model, row, self._column):
596
591
                path = model.get_path(row)
597
 
                self._view.set_cursor(path, None, False)
 
592
                self._view.set_cursor(path)
598
593
                self._view.scroll_to_cell(path, use_align=True)
599
594
                break