/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: Jelmer Vernooij
  • Date: 2010-02-28 15:19:15 UTC
  • mfrom: (674.1.1 bzr-gtk)
  • Revision ID: jelmer@samba.org-20100228151915-bvwflj8ongj2fwqd
Merge qense's indicator application work, but don't require appindicator to be installed.

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