/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: 2007-07-15 15:22:29 UTC
  • Revision ID: jelmer@samba.org-20070715152229-clmlen0vpd8d2pzx
Add docstrings, remove unused code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
class GAnnotateWindow(gtk.Window):
45
45
    """Annotate window."""
46
46
 
47
 
    def __init__(self, all=False, plain=False, parent=None):
 
47
    def __init__(self, all=False, plain=False):
48
48
        self.all = all
49
49
        self.plain = plain
50
 
        self._parent = parent
51
50
        
52
51
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
53
 
 
54
 
        self.connect("key-press-event", self._on_key_pressed)
55
52
        
56
53
        self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON))
57
54
        self.annotate_colormap = AnnotateColorSaturation()
69
66
        self.revision_id = getattr(tree, 'get_revision_id', 
70
67
                                   lambda: CURRENT_REVISION)()
71
68
        
72
 
        # [revision id, line number, author, revno, highlight color, line]
 
69
        # [revision id, line number, committer, revno, highlight color, line]
73
70
        self.annomodel = gtk.ListStore(gobject.TYPE_STRING,
74
71
                                       gobject.TYPE_STRING,
75
72
                                       gobject.TYPE_STRING,
84
81
            for line_no, (revision, revno, line)\
85
82
                    in enumerate(self._annotate(tree, file_id)):
86
83
                if revision.revision_id == last_seen and not self.all:
87
 
                    revno = author = ""
 
84
                    revno = committer = ""
88
85
                else:
89
86
                    last_seen = revision.revision_id
90
 
                    author = revision.get_apparent_author()
 
87
                    committer = revision.committer
91
88
 
92
89
                if revision.revision_id not in self.revisions:
93
90
                    self.revisions[revision.revision_id] = revision
94
91
 
95
92
                self.annomodel.append([revision.revision_id,
96
93
                                       line_no + 1,
97
 
                                       author,
 
94
                                       committer,
98
95
                                       revno,
99
96
                                       None,
100
97
                                       line.rstrip("\r\n")
394
391
            if i + n >= row:
395
392
                return j - i
396
393
 
397
 
    def _on_key_pressed(self, widget, event):
398
 
        """ Key press event handler. """
399
 
        keyname = gtk.gdk.keyval_name(event.keyval)
400
 
        func = getattr(self, '_on_key_press_' + keyname, None)
401
 
        if func:
402
 
            return func(event)
403
 
 
404
 
    def _on_key_press_w(self, event):
405
 
        if event.state & gtk.gdk.CONTROL_MASK:
406
 
            self.destroy()
407
 
            if self._parent is None:
408
 
                gtk.main_quit()
409
 
 
410
 
    def _on_key_press_q(self, event):
411
 
        if event.state & gtk.gdk.CONTROL_MASK:
412
 
            gtk.main_quit()
413
 
    
414
 
 
415
394
 
416
395
 
417
396
class FakeRevision:
429
408
        self.timezone = 0
430
409
        self.properties = {}
431
410
 
432
 
    def get_apparent_author(self):
433
 
        return self.committer
434
 
 
435
411
 
436
412
class RevisionCache(object):
437
413
    """A caching revision source"""