/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

  • Committer: David Planella
  • Date: 2011-03-06 08:24:07 UTC
  • mfrom: (718 trunk)
  • mto: This revision was merged to the branch mainline in revision 719.
  • Revision ID: david.planella@ubuntu.com-20110306082407-y9zwkjje5oue9egw
Added preliminary internationalization support. Merged from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
import gtk
11
11
import gobject
12
 
import pango
13
12
import re
14
13
from xml.sax.saxutils import escape
 
14
 
 
15
from bzrlib.config import parse_username
15
16
from bzrlib.revision import NULL_REVISION
16
17
 
17
18
from time import (strftime, localtime)
29
30
PARENTS = 10
30
31
CHILDREN = 11
31
32
TAGS = 12
 
33
AUTHORS = 13
32
34
 
33
35
class TreeModel(gtk.GenericTreeModel):
34
36
 
35
 
    
36
37
    def __init__ (self, branch, line_graph_data):
37
38
        gtk.GenericTreeModel.__init__(self)
38
39
        self.revisions = {}
39
 
        self.branch = branch
 
40
        self.branch = branch
40
41
        self.repository = branch.repository
41
42
        self.line_graph_data = line_graph_data
42
43
 
43
 
        if self.branch.supports_tags():
 
44
        if self.branch.supports_tags():
44
45
            self.tags = self.branch.tags.get_reverse_tag_dict()
45
46
        else:
46
47
            self.tags = {}
54
55
 
55
56
    def on_get_flags(self):
56
57
        return gtk.TREE_MODEL_LIST_ONLY
57
 
    
 
58
 
58
59
    def on_get_n_columns(self):
59
 
        return 13
60
 
    
 
60
        return 14
 
61
 
61
62
    def on_get_column_type(self, index):
62
63
        if index == REVID: return gobject.TYPE_STRING
63
64
        if index == NODE: return gobject.TYPE_PYOBJECT
72
73
        if index == PARENTS: return gobject.TYPE_PYOBJECT
73
74
        if index == CHILDREN: return gobject.TYPE_PYOBJECT
74
75
        if index == TAGS: return gobject.TYPE_PYOBJECT
75
 
        
 
76
        if index == AUTHORS: return gobject.TYPE_STRING
 
77
 
76
78
    def on_get_iter(self, path):
77
79
        return path[0]
78
 
    
 
80
 
79
81
    def on_get_path(self, rowref):
80
82
        return rowref
81
 
    
 
83
 
82
84
    def on_get_value(self, rowref, column):
83
85
        if len(self.line_graph_data) > 0:
84
86
            (revid, node, lines, parents,
108
110
            self.revisions[revid] = revision
109
111
        else:
110
112
            revision = self.revisions[revid]
111
 
        
 
113
 
112
114
        if column == REVISION: return revision
113
115
        if column == SUMMARY: return escape(revision.get_summary())
114
116
        if column == MESSAGE: return escape(revision.message)
115
 
        if column == COMMITTER: return re.sub('<.*@.*>', '', 
116
 
                                             revision.committer).strip(' ')
117
 
        if column == TIMESTAMP: 
 
117
        if column == COMMITTER: return parse_username(revision.committer)[0]
 
118
        if column == TIMESTAMP:
118
119
            return strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp))
 
120
        if column == AUTHORS:
 
121
            return ", ".join([
 
122
                parse_username(author)[0] for author in revision.get_apparent_authors()])
119
123
 
120
124
    def on_iter_next(self, rowref):
121
125
        if rowref < len(self.line_graph_data) - 1:
122
126
            return rowref+1
123
127
        return None
124
 
    
 
128
 
125
129
    def on_iter_children(self, parent):
126
130
        if parent is None: return 0
127
131
        return None
128
 
    
 
132
 
129
133
    def on_iter_has_child(self, rowref):
130
134
        return False
131
 
    
 
135
 
132
136
    def on_iter_n_children(self, rowref):
133
137
        if rowref is None: return len(self.line_graph_data)
134
138
        return 0
135
 
    
 
139
 
136
140
    def on_iter_nth_child(self, parent, n):
137
141
        if parent is None: return n
138
142
        return None
139
 
    
 
143
 
140
144
    def on_iter_parent(self, child):
141
145
        return None