/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-13 03:06:56 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110813030656-10hwf8adkrg0mbbp
Updated gmissing 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):
 
81
        # XXX sinzui 2011-08-12: maybe path.get_indices()[0]?
77
82
        return path[0]
78
 
    
 
83
 
79
84
    def on_get_path(self, rowref):
80
85
        return rowref
81
 
    
 
86
 
82
87
    def on_get_value(self, rowref, column):
83
88
        if len(self.line_graph_data) > 0:
84
89
            (revid, node, lines, parents,
108
113
            self.revisions[revid] = revision
109
114
        else:
110
115
            revision = self.revisions[revid]
111
 
        
 
116
 
112
117
        if column == REVISION: return revision
113
118
        if column == SUMMARY: return escape(revision.get_summary())
114
119
        if column == MESSAGE: return escape(revision.message)
115
 
        if column == COMMITTER: return re.sub('<.*@.*>', '', 
116
 
                                             revision.committer).strip(' ')
117
 
        if column == TIMESTAMP: 
 
120
        if column == COMMITTER: return parse_username(revision.committer)[0]
 
121
        if column == TIMESTAMP:
118
122
            return strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp))
 
123
        if column == AUTHORS:
 
124
            return ", ".join([
 
125
                parse_username(author)[0] for author in revision.get_apparent_authors()])
119
126
 
120
127
    def on_iter_next(self, rowref):
121
128
        if rowref < len(self.line_graph_data) - 1:
122
129
            return rowref+1
123
130
        return None
124
 
    
 
131
 
125
132
    def on_iter_children(self, parent):
126
133
        if parent is None: return 0
127
134
        return None
128
 
    
 
135
 
129
136
    def on_iter_has_child(self, rowref):
130
137
        return False
131
 
    
 
138
 
132
139
    def on_iter_n_children(self, rowref):
133
140
        if rowref is None: return len(self.line_graph_data)
134
141
        return 0
135
 
    
 
142
 
136
143
    def on_iter_nth_child(self, parent, n):
137
144
        if parent is None: return n
138
145
        return None
139
 
    
 
146
 
140
147
    def on_iter_parent(self, child):
141
148
        return None