/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 branchview/treemodel.py

Merged with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
import gobject
12
12
import pango
13
13
import re
 
14
from xml.sax.saxutils import escape
14
15
 
15
16
from time import (strftime, localtime)
16
17
 
19
20
LINES = 2
20
21
LAST_LINES = 3
21
22
REVNO = 4
22
 
MESSAGE = 5
23
 
COMMITER = 6
24
 
TIMESTAMP = 7
25
 
REVISION = 8
26
 
PARENTS = 9
27
 
CHILDREN = 10
 
23
SUMMARY = 5
 
24
MESSAGE = 6
 
25
COMMITTER = 7
 
26
TIMESTAMP = 8
 
27
REVISION = 9
 
28
PARENTS = 10
 
29
CHILDREN = 11
28
30
 
29
31
class TreeModel(gtk.GenericTreeModel):
30
32
 
39
41
        return gtk.TREE_MODEL_LIST_ONLY
40
42
    
41
43
    def on_get_n_columns(self):
42
 
        return 11
 
44
        return 12
43
45
    
44
46
    def on_get_column_type(self, index):
45
47
        if index == REVID: return gobject.TYPE_STRING
47
49
        if index == LINES: return gobject.TYPE_PYOBJECT
48
50
        if index == LAST_LINES: return gobject.TYPE_PYOBJECT
49
51
        if index == REVNO: return gobject.TYPE_STRING
 
52
        if index == SUMMARY: return gobject.TYPE_STRING
50
53
        if index == MESSAGE: return gobject.TYPE_STRING
51
 
        if index == COMMITER: return gobject.TYPE_STRING
 
54
        if index == COMMITTER: return gobject.TYPE_STRING
52
55
        if index == TIMESTAMP: return gobject.TYPE_STRING
53
56
        if index == REVISION: return gobject.TYPE_PYOBJECT
54
57
        if index == PARENTS: return gobject.TYPE_PYOBJECT
61
64
        return rowref
62
65
    
63
66
    def on_get_value(self, rowref, column):
64
 
        (revid, node, lines, parents,
65
 
         children, revno_sequence) = self.line_graph_data[rowref]
 
67
        if len(self.line_graph_data) > 0:
 
68
            (revid, node, lines, parents,
 
69
             children, revno_sequence) = self.line_graph_data[rowref]
 
70
        else:
 
71
            (revid, node, lines, parents,
 
72
             children, revno_sequence) = (None, (0, 0), (), (),
 
73
                                          (), ())
66
74
        if column == REVID: return revid
67
75
        if column == NODE: return node
68
76
        if column == LINES: return lines
75
83
        if column == REVNO: return ".".join(["%d" % (revno)
76
84
                                      for revno in revno_sequence])
77
85
        
 
86
        if revid is None:
 
87
            return None
78
88
        if revid not in self.revisions:
79
89
            revision = self.repository.get_revisions([revid])[0]
80
90
            self.revisions[revid] = revision
82
92
            revision = self.revisions[revid]
83
93
        
84
94
        if column == REVISION: return revision
85
 
        if column == MESSAGE: return revision.message.split("\n")[0]
86
 
        if column == COMMITER: return re.sub('<.*@.*>', '', 
 
95
        if column == SUMMARY: return escape(revision.get_summary())
 
96
        if column == MESSAGE: return escape(revision.message)
 
97
        if column == COMMITTER: return re.sub('<.*@.*>', '', 
87
98
                                             revision.committer).strip(' ')
88
99
        if column == TIMESTAMP: 
89
100
            return strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp))