/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: 2008-06-29 18:12:29 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629181229-1l2m4cf7vvbyh8qg
Simplify progress bar code, use embedded progress bar inside viz window.

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