/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: Curtis Hovey
  • Date: 2011-08-12 20:25:28 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110812202528-4xf4a2t23urx50d2
Updated gst to gtk3.

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