/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
1
# -*- coding: UTF-8 -*-
2
"""Revision history view.
3
4
"""
5
486.1.1 by matkor at laptop-hp
Fix for presenting log in olive-gtk.
6
__copyright__ = "Copyright © 2005 Canonical Ltd."
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
7
__author__    = "Daniel Schierbeck <daniel.schierbeck@gmail.com>"
8
314 by Daniel Schierbeck
Moved branch locking into treeview.
9
import sys
10
import string
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
11
import gtk
12
import gobject
13
import pango
14
import re
303 by Daniel Schierbeck
Made basic signaling work.
15
import treemodel
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
16
475.1.2 by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n().
17
from bzrlib.plugins.gtk import _i18n
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
18
from linegraph import linegraph, same_branch
19
from graphcell import CellRendererGraph
20
from treemodel import TreeModel
330.4.3 by Daniel Schierbeck
Switched to using NULL_REVISION instead of None.
21
from bzrlib.revision import NULL_REVISION
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
22
423.1.13 by Gary van der Merwe
Move viz loading msg from branchwin to treeview.
23
class TreeView(gtk.VBox):
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
24
346 by Daniel Schierbeck
Added revno-column-visible property to treeview.
25
    __gproperties__ = {
352 by Daniel Schierbeck
Added branch property to treeview.
26
        'branch': (gobject.TYPE_PYOBJECT,
27
                   'Branch',
28
                   'The Bazaar branch being visualized',
29
                   gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_WRITABLE),
30
356 by Daniel Schierbeck
Made revision a property on TreeView.
31
        'revision': (gobject.TYPE_PYOBJECT,
32
                     'Revision',
33
                     'The currently selected revision',
34
                     gobject.PARAM_READWRITE),
35
395.1.2 by Daniel Schierbeck
Added revision-number property to the TreeView.
36
        'revision-number': (gobject.TYPE_STRING,
37
                            'Revision number',
38
                            'The number of the selected revision',
39
                            '',
40
                            gobject.PARAM_READABLE),
41
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
42
        'children': (gobject.TYPE_PYOBJECT,
43
                     'Child revisions',
44
                     'Children of the currently selected revision',
45
                     gobject.PARAM_READABLE),
46
47
        'parents': (gobject.TYPE_PYOBJECT,
48
                    'Parent revisions',
49
                    'Parents to the currently selected revision',
50
                    gobject.PARAM_READABLE),
51
346 by Daniel Schierbeck
Added revno-column-visible property to treeview.
52
        'revno-column-visible': (gobject.TYPE_BOOLEAN,
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
53
                                 'Revision number column',
346 by Daniel Schierbeck
Added revno-column-visible property to treeview.
54
                                 'Show revision number column',
55
                                 True,
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
56
                                 gobject.PARAM_READWRITE),
57
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
58
        'graph-column-visible': (gobject.TYPE_BOOLEAN,
59
                                 'Graph column',
60
                                 'Show graph column',
61
                                 True,
62
                                 gobject.PARAM_READWRITE),
63
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
64
        'date-column-visible': (gobject.TYPE_BOOLEAN,
360 by Daniel Schierbeck
Fixed wrong text in date property.
65
                                 'Date',
66
                                 'Show date column',
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
67
                                 False,
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
68
                                 gobject.PARAM_READWRITE),
69
70
        'compact': (gobject.TYPE_BOOLEAN,
71
                    'Compact view',
72
                    'Break ancestry lines to save space',
73
                    True,
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
74
                    gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
75
76
        'mainline-only': (gobject.TYPE_BOOLEAN,
77
                    'Mainline only',
78
                    'Only show the mainline history.',
79
                    False,
80
                    gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE),
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
81
346 by Daniel Schierbeck
Added revno-column-visible property to treeview.
82
    }
83
307 by Daniel Schierbeck
Made load notification work again.
84
    __gsignals__ = {
345 by Daniel Schierbeck
Made treeview columns instance variables.
85
        'revisions-loaded': (gobject.SIGNAL_RUN_FIRST, 
86
                             gobject.TYPE_NONE,
87
                             ()),
88
        'revision-selected': (gobject.SIGNAL_RUN_FIRST,
89
                              gobject.TYPE_NONE,
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
90
                              ()),
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
91
        'revision-activated': (gobject.SIGNAL_RUN_FIRST,
92
                              gobject.TYPE_NONE,
93
                              (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)),
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
94
        'tag-added': (gobject.SIGNAL_RUN_FIRST,
95
                              gobject.TYPE_NONE,
96
                              (gobject.TYPE_STRING, gobject.TYPE_STRING))
307 by Daniel Schierbeck
Made load notification work again.
97
    }
98
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
99
    def __init__(self, branch, start, maxnum, compact=True):
322 by Jelmer Vernooij
Add docstrings.
100
        """Create a new TreeView.
101
102
        :param branch: Branch object for branch to show.
103
        :param start: Revision id of top revision.
104
        :param maxnum: Maximum number of revisions to display, 
105
                       None for no limit.
329 by Jelmer Vernooij
Make broken_line_length setting from higher up.
106
        :param broken_line_length: After how much lines to break 
107
                                   branches.
322 by Jelmer Vernooij
Add docstrings.
108
        """
423.1.13 by Gary van der Merwe
Move viz loading msg from branchwin to treeview.
109
        gtk.VBox.__init__(self, spacing=0)
110
111
        self.pack_start(self.construct_loading_msg(), expand=False, fill=True)
112
        self.connect('revisions-loaded', 
113
                lambda x: self.loading_msg_box.hide())
114
115
        self.scrolled_window = gtk.ScrolledWindow()
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
116
        self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC,
117
                                        gtk.POLICY_AUTOMATIC)
423.1.13 by Gary van der Merwe
Move viz loading msg from branchwin to treeview.
118
        self.scrolled_window.set_shadow_type(gtk.SHADOW_IN)
119
        self.scrolled_window.show()
120
        self.pack_start(self.scrolled_window, expand=True, fill=True)
121
122
        self.scrolled_window.add(self.construct_treeview())
123
        
303 by Daniel Schierbeck
Made basic signaling work.
124
423.7.3 by Daniel Schierbeck
Moved tag writing logic inside the branchview treemodel.
125
        self.iter = None
316 by Daniel Schierbeck
Removed viz.TreeView.set_branch()
126
        self.branch = branch
423.7.3 by Daniel Schierbeck
Moved tag writing logic inside the branchview treemodel.
127
        self.revision = None
316 by Daniel Schierbeck
Removed viz.TreeView.set_branch()
128
401.1.1 by Daniel Schierbeck
Added update() method to TreeView.
129
        self.start = start
130
        self.maxnum = maxnum
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
131
        self.compact = compact
401.1.1 by Daniel Schierbeck
Added update() method to TreeView.
132
133
        gobject.idle_add(self.populate)
316 by Daniel Schierbeck
Removed viz.TreeView.set_branch()
134
392 by Daniel Schierbeck
Fixed performance issue by only releasing the branch lock when the treeview is destroyed. This will surely fuck up the tagging code.
135
        self.connect("destroy", lambda x: self.branch.unlock())
136
347 by Daniel Schierbeck
Added property getter and setter method to the treeview.
137
    def do_get_property(self, property):
138
        if property.name == 'revno-column-visible':
352 by Daniel Schierbeck
Added branch property to treeview.
139
            return self.revno_column.get_visible()
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
140
        elif property.name == 'graph-column-visible':
141
            return self.graph_column.get_visible()
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
142
        elif property.name == 'date-column-visible':
143
            return self.date_column.get_visible()
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
144
        elif property.name == 'compact':
145
            return self.compact
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
146
        elif property.name == 'mainline-only':
147
            return self.mainline_only
352 by Daniel Schierbeck
Added branch property to treeview.
148
        elif property.name == 'branch':
149
            return self.branch
356 by Daniel Schierbeck
Made revision a property on TreeView.
150
        elif property.name == 'revision':
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
151
            return self.model.get_value(self.iter, treemodel.REVISION)
395.1.2 by Daniel Schierbeck
Added revision-number property to the TreeView.
152
        elif property.name == 'revision-number':
153
            return self.model.get_value(self.iter, treemodel.REVNO)
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
154
        elif property.name == 'children':
155
            return self.model.get_value(self.iter, treemodel.CHILDREN)
156
        elif property.name == 'parents':
157
            return self.model.get_value(self.iter, treemodel.PARENTS)
347 by Daniel Schierbeck
Added property getter and setter method to the treeview.
158
        else:
159
            raise AttributeError, 'unknown property %s' % property.name
160
161
    def do_set_property(self, property, value):
162
        if property.name == 'revno-column-visible':
163
            self.revno_column.set_visible(value)
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
164
        elif property.name == 'graph-column-visible':
165
            self.graph_column.set_visible(value)
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
166
        elif property.name == 'date-column-visible':
167
            self.date_column.set_visible(value)
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
168
        elif property.name == 'compact':
169
            self.compact = value
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
170
        elif property.name == 'mainline-only':
171
            self.mainline_only = value
352 by Daniel Schierbeck
Added branch property to treeview.
172
        elif property.name == 'branch':
173
            self.branch = value
356 by Daniel Schierbeck
Made revision a property on TreeView.
174
        elif property.name == 'revision':
175
            self.set_revision_id(value.revision_id)
347 by Daniel Schierbeck
Added property getter and setter method to the treeview.
176
        else:
177
            raise AttributeError, 'unknown property %s' % property.name
178
303 by Daniel Schierbeck
Made basic signaling work.
179
    def get_revision(self):
322 by Jelmer Vernooij
Add docstrings.
180
        """Return revision id of currently selected revision, or None."""
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
181
        return self.get_property('revision')
182
183
    def set_revision(self, revision):
184
        self.set_property('revision', revision)
303 by Daniel Schierbeck
Made basic signaling work.
185
356 by Daniel Schierbeck
Made revision a property on TreeView.
186
    def set_revision_id(self, revid):
322 by Jelmer Vernooij
Add docstrings.
187
        """Change the currently selected revision.
188
189
        :param revid: Revision id of revision to display.
190
        """
305 by Daniel Schierbeck
Moved revision selection to the new view.
191
        self.treeview.set_cursor(self.index[revid])
192
        self.treeview.grab_focus()
193
303 by Daniel Schierbeck
Made basic signaling work.
194
    def get_children(self):
322 by Jelmer Vernooij
Add docstrings.
195
        """Return the children of the currently selected revision.
196
197
        :return: list of revision ids.
198
        """
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
199
        return self.get_property('children')
303 by Daniel Schierbeck
Made basic signaling work.
200
201
    def get_parents(self):
322 by Jelmer Vernooij
Add docstrings.
202
        """Return the parents of the currently selected revision.
203
204
        :return: list of revision ids.
205
        """
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
206
        return self.get_property('parents')
423.7.3 by Daniel Schierbeck
Moved tag writing logic inside the branchview treemodel.
207
208
    def add_tag(self, tag, revid=None):
209
        if revid is None: revid = self.revision.revision_id
210
211
        try:
212
            self.branch.unlock()
213
214
            try:
215
                self.branch.lock_write()
216
                self.model.add_tag(tag, revid)
217
            finally:
218
                self.branch.unlock()
219
220
        finally:
221
            self.branch.lock_read()
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
222
223
        self.emit('tag-added', tag, revid)
316 by Daniel Schierbeck
Removed viz.TreeView.set_branch()
224
        
401.1.2 by Daniel Schierbeck
Allowed the treeview to be refreshed.
225
    def refresh(self):
423.1.13 by Gary van der Merwe
Move viz loading msg from branchwin to treeview.
226
        self.loading_msg_box.show()
401.1.2 by Daniel Schierbeck
Allowed the treeview to be refreshed.
227
        gobject.idle_add(self.populate, self.get_revision())
401.1.1 by Daniel Schierbeck
Added update() method to TreeView.
228
404 by Daniel Schierbeck
Made the refresh use proper locking.
229
    def update(self):
230
        try:
231
            self.branch.unlock()
232
            try:
233
                self.branch.lock_write()
234
                self.branch.update()
235
            finally:
236
                self.branch.unlock()
237
        finally:
238
            self.branch.lock_read()
239
304 by Daniel Schierbeck
Made forward/back buttons work again.
240
    def back(self):
322 by Jelmer Vernooij
Add docstrings.
241
        """Signal handler for the Back button."""
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
242
        parents = self.get_parents()
304 by Daniel Schierbeck
Made forward/back buttons work again.
243
        if not len(parents):
244
            return
245
246
        for parent_id in parents:
247
            parent_index = self.index[parent_id]
248
            parent = self.model[parent_index][treemodel.REVISION]
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
249
            if same_branch(self.get_revision(), parent):
395.1.2 by Daniel Schierbeck
Added revision-number property to the TreeView.
250
                self.set_revision(parent)
304 by Daniel Schierbeck
Made forward/back buttons work again.
251
                break
252
        else:
395.1.2 by Daniel Schierbeck
Added revision-number property to the TreeView.
253
            self.set_revision_id(parents[0])
304 by Daniel Schierbeck
Made forward/back buttons work again.
254
255
    def forward(self):
322 by Jelmer Vernooij
Add docstrings.
256
        """Signal handler for the Forward button."""
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
257
        children = self.get_children()
304 by Daniel Schierbeck
Made forward/back buttons work again.
258
        if not len(children):
259
            return
260
261
        for child_id in children:
262
            child_index = self.index[child_id]
263
            child = self.model[child_index][treemodel.REVISION]
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
264
            if same_branch(child, self.get_revision()):
395.1.2 by Daniel Schierbeck
Added revision-number property to the TreeView.
265
                self.set_revision(child)
304 by Daniel Schierbeck
Made forward/back buttons work again.
266
                break
267
        else:
395.1.2 by Daniel Schierbeck
Added revision-number property to the TreeView.
268
            self.set_revision_id(children[0])
304 by Daniel Schierbeck
Made forward/back buttons work again.
269
401.1.2 by Daniel Schierbeck
Allowed the treeview to be refreshed.
270
    def populate(self, revision=None):
322 by Jelmer Vernooij
Add docstrings.
271
        """Fill the treeview with contents.
272
273
        :param start: Revision id of revision to start with.
274
        :param maxnum: Maximum number of revisions to display, or None 
275
                       for no limit.
329 by Jelmer Vernooij
Make broken_line_length setting from higher up.
276
        :param broken_line_length: After how much lines branches \
277
                       should be broken.
322 by Jelmer Vernooij
Add docstrings.
278
        """
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
279
280
        if self.compact:
281
            broken_line_length = 32
282
        else:
283
            broken_line_length = None
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
284
        
285
        show_graph = self.graph_column.get_visible()
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
286
392 by Daniel Schierbeck
Fixed performance issue by only releasing the branch lock when the treeview is destroyed. This will surely fuck up the tagging code.
287
        self.branch.lock_read()
288
        (linegraphdata, index, columns_len) = linegraph(self.branch.repository,
486.1.1 by matkor at laptop-hp
Fix for presenting log in olive-gtk.
289
                                                        (self.start,) , # Sequence of start revisions
401.1.1 by Daniel Schierbeck
Added update() method to TreeView.
290
                                                        self.maxnum, 
423.1.18 by Gary van der Merwe
Add options to viz treeview to not show the line graph, and to only show the main line.
291
                                                        broken_line_length,
292
                                                        show_graph,
293
                                                        self.mainline_only)
392 by Daniel Schierbeck
Fixed performance issue by only releasing the branch lock when the treeview is destroyed. This will surely fuck up the tagging code.
294
423.5.1 by Ali Sabil
Added tags visualization in the graph
295
        self.model = TreeModel(self.branch, linegraphdata)
392 by Daniel Schierbeck
Fixed performance issue by only releasing the branch lock when the treeview is destroyed. This will surely fuck up the tagging code.
296
        self.graph_cell.columns_len = columns_len
297
        width = self.graph_cell.get_size(self.treeview)[2]
403 by Daniel Schierbeck
Set a maximum width on the graph column.
298
        if width > 500:
299
            width = 500
392 by Daniel Schierbeck
Fixed performance issue by only releasing the branch lock when the treeview is destroyed. This will surely fuck up the tagging code.
300
        self.graph_column.set_fixed_width(width)
301
        self.graph_column.set_max_width(width)
302
        self.index = index
303
        self.treeview.set_model(self.model)
401.1.2 by Daniel Schierbeck
Allowed the treeview to be refreshed.
304
464.2.1 by Adrian Wilkins
Detect the reserved null: revision in appropriate places.
305
        if not revision or revision == NULL_REVISION:
401.1.2 by Daniel Schierbeck
Allowed the treeview to be refreshed.
306
            self.treeview.set_cursor(0)
307
        else:
308
            self.set_revision(revision)
309
392 by Daniel Schierbeck
Fixed performance issue by only releasing the branch lock when the treeview is destroyed. This will surely fuck up the tagging code.
310
        self.emit('revisions-loaded')
304 by Daniel Schierbeck
Made forward/back buttons work again.
311
312
        return False
313
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
314
    def construct_treeview(self):
315
        self.treeview = gtk.TreeView()
316
317
        self.treeview.set_rules_hint(True)
330.1.2 by Daniel Schierbeck
Replaced literal column index with equivalent symbol.
318
        self.treeview.set_search_column(treemodel.REVNO)
330.5.2 by Szilveszter Farkas (Phanatic)
Fixed set_tooltip_column() related issue.
319
        
330.5.5 by Szilveszter Farkas (Phanatic)
Use better fix by John.
320
        # Fix old PyGTK bug - by JAM
321
        set_tooltip = getattr(self.treeview, 'set_tooltip_column', None)
322
        if set_tooltip is not None:
423.4.3 by Daniel Schierbeck
Made the MESSAGE column be the tooltip column.
323
            set_tooltip(treemodel.MESSAGE)
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
324
391 by Daniel Schierbeck
Moved away from the changed signal on the treeview.
325
        self.treeview.connect("cursor-changed",
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
326
                self._on_selection_changed)
327
328
        self.treeview.connect("row-activated", 
329
                self._on_revision_activated)
330
331
        self.treeview.connect("button-release-event", 
332
                self._on_revision_selected)
333
334
        self.treeview.set_property('fixed-height-mode', True)
335
336
        self.treeview.show()
337
338
        cell = gtk.CellRendererText()
339
        cell.set_property("width-chars", 15)
340
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
345 by Daniel Schierbeck
Made treeview columns instance variables.
341
        self.revno_column = gtk.TreeViewColumn("Revision No")
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
342
        self.revno_column.set_resizable(False)
345 by Daniel Schierbeck
Made treeview columns instance variables.
343
        self.revno_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
344
        self.revno_column.set_fixed_width(cell.get_size(self.treeview)[2])
345
        self.revno_column.pack_start(cell, expand=True)
346
        self.revno_column.add_attribute(cell, "text", treemodel.REVNO)
347
        self.treeview.append_column(self.revno_column)
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
348
349
        self.graph_cell = CellRendererGraph()
350
        self.graph_column = gtk.TreeViewColumn()
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
351
        self.graph_column.set_resizable(False)
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
352
        self.graph_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
353
        self.graph_column.pack_start(self.graph_cell, expand=True)
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
354
        self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE)
423.5.1 by Ali Sabil
Added tags visualization in the graph
355
        self.graph_column.add_attribute(self.graph_cell, "tags", treemodel.TAGS)
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
356
        self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES)
357
        self.graph_column.add_attribute(self.graph_cell, "out-lines", treemodel.LINES)
358
        self.treeview.append_column(self.graph_column)
359
360
        cell = gtk.CellRendererText()
361
        cell.set_property("width-chars", 65)
362
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
423.4.1 by Daniel Schierbeck
Renamed the MESSAGE column to SUMMARY.
363
        self.summary_column = gtk.TreeViewColumn("Summary")
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
364
        self.summary_column.set_resizable(False)
365
        self.summary_column.set_expand(True)
423.4.1 by Daniel Schierbeck
Renamed the MESSAGE column to SUMMARY.
366
        self.summary_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
367
        self.summary_column.set_fixed_width(cell.get_size(self.treeview)[2])
368
        self.summary_column.pack_start(cell, expand=True)
369
        self.summary_column.add_attribute(cell, "markup", treemodel.SUMMARY)
370
        self.treeview.append_column(self.summary_column)
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
371
372
        cell = gtk.CellRendererText()
373
        cell.set_property("width-chars", 15)
374
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
345 by Daniel Schierbeck
Made treeview columns instance variables.
375
        self.committer_column = gtk.TreeViewColumn("Committer")
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
376
        self.committer_column.set_resizable(False)
345 by Daniel Schierbeck
Made treeview columns instance variables.
377
        self.committer_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
378
        self.committer_column.set_fixed_width(200)
345 by Daniel Schierbeck
Made treeview columns instance variables.
379
        self.committer_column.pack_start(cell, expand=True)
423.4.4 by Daniel Schierbeck
Renamed COMMITER column into the correct COMMITTER.
380
        self.committer_column.add_attribute(cell, "text", treemodel.COMMITTER)
345 by Daniel Schierbeck
Made treeview columns instance variables.
381
        self.treeview.append_column(self.committer_column)
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
382
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
383
        cell = gtk.CellRendererText()
359 by Daniel Schierbeck
Simplified date format.
384
        cell.set_property("width-chars", 20)
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
385
        cell.set_property("ellipsize", pango.ELLIPSIZE_END)
386
        self.date_column = gtk.TreeViewColumn("Date")
387
        self.date_column.set_visible(False)
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
388
        self.date_column.set_resizable(False)
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
389
        self.date_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
496.2.1 by Daniel Schierbeck
Made the columns have more suitable sizes.
390
        self.date_column.set_fixed_width(130)
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
391
        self.date_column.pack_start(cell, expand=True)
392
        self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP)
393
        self.treeview.append_column(self.date_column)
423.1.13 by Gary van der Merwe
Move viz loading msg from branchwin to treeview.
394
        
395
        return self.treeview
396
    
397
    def construct_loading_msg(self):
398
        image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
399
                                                 gtk.ICON_SIZE_BUTTON)
400
        image_loading.show()
401
        
475.1.2 by Vincent Ladeuil
Fix bug #187283 fix replacing _() by _i18n().
402
        label_loading = gtk.Label(
403
            _i18n("Please wait, loading ancestral graph..."))
423.1.13 by Gary van der Merwe
Move viz loading msg from branchwin to treeview.
404
        label_loading.set_alignment(0.0, 0.5)
405
        label_loading.show()
406
        
407
        self.loading_msg_box = gtk.HBox()
408
        self.loading_msg_box.set_spacing(5)
409
        self.loading_msg_box.set_border_width(5)        
410
        self.loading_msg_box.pack_start(image_loading, False, False)
411
        self.loading_msg_box.pack_start(label_loading, True, True)
412
        self.loading_msg_box.show()
413
        
414
        return self.loading_msg_box
357 by Daniel Schierbeck
Added support for showing the date column in the viz.
415
391 by Daniel Schierbeck
Moved away from the changed signal on the treeview.
416
    def _on_selection_changed(self, treeview):
303 by Daniel Schierbeck
Made basic signaling work.
417
        """callback for when the treeview changes."""
391 by Daniel Schierbeck
Moved away from the changed signal on the treeview.
418
        (path, focus) = treeview.get_cursor()
419
        if path is not None:
395.1.1 by Daniel Schierbeck
Cleaned up code in the TreeView, removing instance variables.
420
            self.iter = self.model.get_iter(path)
310 by Daniel Schierbeck
Moved to using custom signal for handling revision selections.
421
            self.emit('revision-selected')
422
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
423
    def _on_revision_selected(self, widget, event):
424
        from bzrlib.plugins.gtk.revisionmenu import RevisionPopupMenu
425
        if event.button == 3:
426
            menu = RevisionPopupMenu(self.branch.repository, 
312 by Daniel Schierbeck
Made right-clicking work again.
427
                [self.get_revision().revision_id],
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
428
                self.branch)
423.7.8 by Daniel Schierbeck
Made the revision popup menu correctly add tags.
429
            menu.connect('tag-added', lambda w, t, r: self.add_tag(t, r))
301 by Daniel Schierbeck
Initial work on extracting the TreeView from the branch window.
430
            menu.popup(None, None, None, event.button, event.get_time())
431
432
    def _on_revision_activated(self, widget, path, col):
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
433
        self.emit('revision-activated', path, col)