/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 viz/branchwin.py

  • Committer: Gary van der Merwe
  • Date: 2007-09-09 17:52:49 UTC
  • mto: (256.2.37 gtk)
  • mto: This revision was merged to the branch mainline in revision 289.
  • Revision ID: garyvdm@gmail.com-20070909175249-c9jz52xlc98lsvve
Implement a TreeModel that loads revisions incrementaly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
import gtk
13
13
import gobject
14
14
import pango
 
15
import treemodel
15
16
 
16
17
from bzrlib.osutils import format_date
17
18
 
18
19
from linegraph import linegraph, same_branch
19
20
from graphcell import CellRendererGraph
 
21
from treemodel import TreeModel
20
22
 
21
23
 
22
24
class BranchWindow(gtk.Window):
86
88
        column = gtk.TreeViewColumn("Revision No")
87
89
        column.set_resizable(True)
88
90
        column.pack_start(cell, expand=True)
89
 
        column.add_attribute(cell, "text", 9)
 
91
        column.add_attribute(cell, "text", treemodel.REVNO)
90
92
        self.treeview.append_column(column)
91
93
 
92
94
        cell = CellRendererGraph()
93
95
        column = gtk.TreeViewColumn()
94
96
        column.set_resizable(True)
95
97
        column.pack_start(cell, expand=False)
96
 
        column.add_attribute(cell, "node", 1)
97
 
        column.add_attribute(cell, "in-lines", 2)
98
 
        column.add_attribute(cell, "out-lines", 3)
 
98
        column.add_attribute(cell, "node", treemodel.NODE)
 
99
        column.add_attribute(cell, "in-lines", treemodel.LAST_LINES)
 
100
        column.add_attribute(cell, "out-lines", treemodel.LINES)
99
101
        self.treeview.append_column(column)
100
102
 
101
103
        cell = gtk.CellRendererText()
104
106
        column = gtk.TreeViewColumn("Message")
105
107
        column.set_resizable(True)
106
108
        column.pack_start(cell, expand=True)
107
 
        column.add_attribute(cell, "text", 6)
 
109
        column.add_attribute(cell, "text", treemodel.MESSAGE)
108
110
        self.treeview.append_column(column)
109
111
 
110
112
        cell = gtk.CellRendererText()
113
115
        column = gtk.TreeViewColumn("Committer")
114
116
        column.set_resizable(True)
115
117
        column.pack_start(cell, expand=True)
116
 
        column.add_attribute(cell, "text", 7)
 
118
        column.add_attribute(cell, "text", treemodel.COMMITER)
117
119
        self.treeview.append_column(column)
118
120
 
119
121
        cell = gtk.CellRendererText()
121
123
        column = gtk.TreeViewColumn("Date")
122
124
        column.set_resizable(True)
123
125
        column.pack_start(cell, expand=True)
124
 
        column.add_attribute(cell, "text", 8)
 
126
        column.add_attribute(cell, "text", treemodel.TIMESTAMP)
125
127
        self.treeview.append_column(column)
126
128
 
127
129
        return scrollwin
173
175
        treeview itself.
174
176
        """
175
177
        self.branch = branch
176
 
 
177
 
        # [ revision, node, last_lines, lines, message, committer, timestamp ]
178
 
        self.model = gtk.ListStore(gobject.TYPE_PYOBJECT,
179
 
                                   gobject.TYPE_PYOBJECT,
180
 
                                   gobject.TYPE_PYOBJECT,
181
 
                                   gobject.TYPE_PYOBJECT,
182
 
                                   gobject.TYPE_PYOBJECT,
183
 
                                   gobject.TYPE_PYOBJECT,
184
 
                                   str, str, str, str)
185
178
        self.set_title(branch.nick + " - bzrk")
186
179
        gobject.idle_add(self.populate_model, start, maxnum)
187
180
 
189
182
        (linegraphdata, index) = linegraph(self.branch,
190
183
                                           start,
191
184
                                           maxnum)
192
 
        print "linegraph compleate"
 
185
        self.model = TreeModel(self.branch, linegraphdata)
193
186
        self.index = index
194
 
        self.revisions = []
195
 
        
196
 
        last_lines = []
197
 
        for (index,(revid,
198
 
                    node,
199
 
                    lines,
200
 
                    parents,
201
 
                    children,
202
 
                    revno_sequence)) in enumerate(linegraphdata):
203
 
            # FIXME: at this point we should be able to show the graph order
204
 
            # and lines with no message or commit data - and then incrementally
205
 
            # fill the timestamp, committer etc data as desired.
206
 
            
207
 
            revision = self.branch.repository.get_revisions([revid])[0]
208
 
            self.revisions.append(revision)
209
 
            
210
 
            message = revision.message.split("\n")[0]
211
 
            
212
 
            if revision.committer is not None:
213
 
                timestamp = format_date(revision.timestamp, revision.timezone)
214
 
            else:
215
 
                timestamp = None
216
 
            revno_string = ".".join(["%d" % (revno) for revno in revno_sequence])
217
 
            
218
 
            self.model.append([revision,
219
 
                               node,
220
 
                               last_lines,
221
 
                               lines,
222
 
                               parents,
223
 
                               children, 
224
 
                               message,
225
 
                               revision.committer,
226
 
                               timestamp,
227
 
                               revno_string])
228
 
            last_lines = lines
229
187
        self.treeview.set_model(self.model)
230
188
 
231
189
    def _treeview_cursor_cb(self, *args):
232
190
        """Callback for when the treeview cursor changes."""
233
191
        (path, col) = self.treeview.get_cursor()
234
 
        revision = self.model[path][0]
235
 
        parents = self.model[path][4]
236
 
        children = self.model[path][5]
 
192
        iter = self.model.get_iter(path)
 
193
        revision = self.model.get_value(iter, treemodel.REVISION)
 
194
        parents = self.model.get_value(iter, treemodel.PARENTS)
 
195
        children = self.model.get_value(iter, treemodel.CHILDREN)
237
196
 
238
197
        self.back_button.set_sensitive(len(parents) > 0)
239
198
        self.fwd_button.set_sensitive(len(children) > 0)