/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
0.1.1 by Dan Loda
First working version of xannotate.
1
# Copyright (C) 2005 Dan Loda <danloda@gmail.com>
175 by Jelmer Vernooij
Add very simple gmissing command.
2
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
0.1.1 by Dan Loda
First working version of xannotate.
3
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
import pygtk
19
pygtk.require("2.0")
20
import gtk
21
import pango
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
22
import gobject
0.1.1 by Dan Loda
First working version of xannotate.
23
24
from bzrlib.osutils import format_date
412.1.8 by Daniel Schierbeck
Only import the bdecode function from the bzrlib.util.bencode package.
25
from bzrlib.util.bencode import bdecode
0.1.1 by Dan Loda
First working version of xannotate.
26
330.3.1 by Daniel Schierbeck
Renamed logview 'revisionview'.
27
class RevisionView(gtk.Notebook):
0.1.1 by Dan Loda
First working version of xannotate.
28
    """ Custom widget for commit log details.
29
30
    A variety of bzr tools may need to implement such a thing. This is a
31
    start.
32
    """
33
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
34
    __gproperties__ = {
35
        'branch': (
36
            gobject.TYPE_PYOBJECT,
37
            'Branch',
38
            'The branch holding the revision being displayed',
39
            gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_WRITABLE
40
        ),
41
42
        'revision': (
43
            gobject.TYPE_PYOBJECT,
44
            'Revision',
45
            'The revision being displayed',
412.1.2 by Daniel Schierbeck
Moved retrieval of tags into the revisionview itself.
46
            gobject.PARAM_READWRITE
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
47
        ),
48
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
49
        'children': (
50
            gobject.TYPE_PYOBJECT,
51
            'Children',
52
            'Child revisions',
53
            gobject.PARAM_READWRITE
54
        ),
55
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
56
        'file-id': (
57
            gobject.TYPE_PYOBJECT,
58
            'File Id',
59
            'The file id',
60
            gobject.PARAM_READWRITE
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
61
        )
62
    }
63
64
412.1.2 by Daniel Schierbeck
Moved retrieval of tags into the revisionview itself.
65
    def __init__(self, branch=None):
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
66
        gtk.Notebook.__init__(self)
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
67
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
68
        self._create_general()
69
        self._create_relations()
278.1.45 by John Arbash Meinel
Switch to a new tab for per-file messages.
70
        self._create_file_info_view()
324.2.9 by Daniel Schierbeck
Made 'General' the default page of the logview.
71
72
        self.set_current_page(0)
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
73
        
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
74
        self._show_callback = None
75
        self._clicked_callback = None
0.1.1 by Dan Loda
First working version of xannotate.
76
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
77
        self._revision = None
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
78
        self._branch = branch
79
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
80
        self.update_tags()
412.1.2 by Daniel Schierbeck
Moved retrieval of tags into the revisionview itself.
81
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
82
        self.set_file_id(None)
0.1.1 by Dan Loda
First working version of xannotate.
83
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
84
    def do_get_property(self, property):
85
        if property.name == 'branch':
86
            return self._branch
87
        elif property.name == 'revision':
88
            return self._revision
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
89
        elif property.name == 'children':
90
            return self._children
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
91
        elif property.name == 'file-id':
92
            return self._file_id
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
93
        else:
94
            raise AttributeError, 'unknown property %s' % property.name
95
96
    def do_set_property(self, property, value):
97
        if property.name == 'branch':
98
            self._branch = value
99
        elif property.name == 'revision':
100
            self._set_revision(value)
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
101
        elif property.name == 'children':
102
            self.set_children(value)
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
103
        elif property.name == 'file-id':
104
            self._file_id = value
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
105
        else:
106
            raise AttributeError, 'unknown property %s' % property.name
107
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
108
    def set_show_callback(self, callback):
109
        self._show_callback = callback
110
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
111
    def set_file_id(self, file_id):
112
        """Set a specific file id that we want to track.
113
114
        This just effects the display of a per-file commit message.
115
        If it is set to None, then all commit messages will be shown.
116
        """
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
117
        self.set_property('file-id', file_id)
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
118
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
119
    def set_revision(self, revision):
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
120
        if revision != self._revision:
121
            self.set_property('revision', revision)
122
123
    def get_revision(self):
124
        return self.get_property('revision')
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
125
412.1.15 by Daniel Schierbeck
Removed redundant method argument.
126
    def _set_revision(self, revision):
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
127
        if revision is None: return
128
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
129
        self._revision = revision
192 by Jelmer Vernooij
Allow committer to be None.
130
        if revision.committer is not None:
131
            self.committer.set_text(revision.committer)
132
        else:
133
            self.committer.set_text("")
259 by Aaron Bentley
Add author support to gannotate and log viewer
134
        author = revision.properties.get('author', '')
135
        if author != '':
136
            self.author.set_text(author)
137
            self.author.show()
138
            self.author_label.show()
139
        else:
140
            self.author.hide()
141
            self.author_label.hide()
142
197 by Jelmer Vernooij
Fix some warnings when displaying ghost revisions. Reported by John.
143
        if revision.timestamp is not None:
144
            self.timestamp.set_text(format_date(revision.timestamp,
145
                                                revision.timezone))
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
146
        try:
147
            self.branchnick_label.set_text(revision.properties['branch-nick'])
148
        except KeyError:
149
            self.branchnick_label.set_text("")
150
256.2.23 by Gary van der Merwe
Show Children
151
        self._add_parents_or_children(revision.parent_ids,
152
                                      self.parents_widgets,
153
                                      self.parents_table)
154
        
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
155
        file_info = revision.properties.get('file-info', None)
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
156
        if file_info is not None:
412.1.8 by Daniel Schierbeck
Only import the bdecode function from the bzrlib.util.bencode package.
157
            file_info = bdecode(file_info.encode('UTF-8'))
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
158
159
        if file_info:
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
160
            if self._file_id is None:
161
                text = []
162
                for fi in file_info:
163
                    text.append('%(path)s\n%(message)s' % fi)
164
                self.file_info_buffer.set_text('\n'.join(text))
165
                self.file_info_box.show()
166
            else:
167
                text = []
168
                for fi in file_info:
169
                    if fi['file_id'] == self._file_id:
170
                        text.append(fi['message'])
171
                if text:
172
                    self.file_info_buffer.set_text('\n'.join(text))
173
                    self.file_info_box.show()
174
                else:
175
                    self.file_info_box.hide()
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
176
        else:
177
            self.file_info_box.hide()
178
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
179
    def update_tags(self):
180
        if self._branch is not None and self._branch.supports_tags():
181
            self._tagdict = self._branch.tags.get_reverse_tag_dict()
182
        else:
183
            self._tagdict = {}
184
185
        self._add_tags()
186
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
187
    def set_children(self, children):
188
        self._add_parents_or_children(children,
189
                                      self.children_widgets,
190
                                      self.children_table)
191
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
192
    def _show_clicked_cb(self, widget, revid, parentid):
193
        """Callback for when the show button for a parent is clicked."""
194
        self._show_callback(revid, parentid)
195
196
    def _go_clicked_cb(self, widget, revid):
197
        """Callback for when the go button for a parent is clicked."""
198
412.1.4 by Daniel Schierbeck
Made tag list smarter.
199
    def _add_tags(self, *args):
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
200
        if self._revision is None: return
201
412.1.4 by Daniel Schierbeck
Made tag list smarter.
202
        if self._tagdict.has_key(self._revision.revision_id):
203
            tags = self._tagdict[self._revision.revision_id]
204
        else:
205
            tags = []
206
            
241 by Jelmer Vernooij
Show tags in bzr viz.
207
        if tags == []:
208
            self.tags_list.hide()
209
            self.tags_label.hide()
210
            return
211
423.3.1 by Daniel Schierbeck
Made the tag list be a comma-separated line instead of a vertically stacked box.
212
        self.tags_list.set_text(", ".join(tags))
213
241 by Jelmer Vernooij
Show tags in bzr viz.
214
        self.tags_list.show_all()
215
        self.tags_label.show_all()
216
        
256.2.23 by Gary van der Merwe
Show Children
217
    def _add_parents_or_children(self, revids, widgets, table):
218
        while len(widgets) > 0:
219
            widget = widgets.pop()
220
            table.remove(widget)
221
        
222
        table.resize(max(len(revids), 1), 2)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
223
256.2.23 by Gary van der Merwe
Show Children
224
        for idx, revid in enumerate(revids):
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
225
            align = gtk.Alignment(0.0, 0.0)
256.2.23 by Gary van der Merwe
Show Children
226
            widgets.append(align)
227
            table.attach(align, 1, 2, idx, idx + 1,
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
228
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
229
            align.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
230
231
            hbox = gtk.HBox(False, spacing=6)
232
            align.add(hbox)
233
            hbox.show()
234
235
            image = gtk.Image()
236
            image.set_from_stock(
237
                gtk.STOCK_FIND, gtk.ICON_SIZE_SMALL_TOOLBAR)
238
            image.show()
239
148 by Jelmer Vernooij
Clean up interface a bit: don't show diff button when no diff can be accessed, use label instead of button when there is no callback set.
240
            if self._show_callback is not None:
241
                button = gtk.Button()
242
                button.add(image)
243
                button.connect("clicked", self._show_clicked_cb,
256.2.23 by Gary van der Merwe
Show Children
244
                               self._revision.revision_id, revid)
148 by Jelmer Vernooij
Clean up interface a bit: don't show diff button when no diff can be accessed, use label instead of button when there is no callback set.
245
                hbox.pack_start(button, expand=False, fill=True)
246
                button.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
247
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
248
            button = gtk.Button(revid)
249
            button.connect("clicked",
412.1.14 by Daniel Schierbeck
Fixed bug in the way the child buttons worked.
250
                    lambda w, r: self.set_revision(self._branch.repository.get_revision(r)), revid)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
251
            button.set_use_underline(False)
252
            hbox.pack_start(button, expand=False, fill=True)
253
            button.show()
0.1.1 by Dan Loda
First working version of xannotate.
254
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
255
    def _create_general(self):
0.1.1 by Dan Loda
First working version of xannotate.
256
        vbox = gtk.VBox(False, 6)
257
        vbox.set_border_width(6)
258
        vbox.pack_start(self._create_headers(), expand=False, fill=True)
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
259
        vbox.pack_start(self._create_message_view())
260
        self.append_page(vbox, tab_label=gtk.Label("General"))
261
        vbox.show()
262
263
    def _create_relations(self):
264
        vbox = gtk.VBox(False, 6)
265
        vbox.set_border_width(6)
291 by Jelmer Vernooij
Put children widget on a new line.
266
        vbox.pack_start(self._create_parents(), expand=False, fill=True)
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
267
        vbox.pack_start(self._create_children(), expand=False, fill=True)
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
268
        self.append_page(vbox, tab_label=gtk.Label("Relations"))
0.1.1 by Dan Loda
First working version of xannotate.
269
        vbox.show()
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
270
0.1.1 by Dan Loda
First working version of xannotate.
271
    def _create_headers(self):
241 by Jelmer Vernooij
Show tags in bzr viz.
272
        self.table = gtk.Table(rows=5, columns=2)
0.1.1 by Dan Loda
First working version of xannotate.
273
        self.table.set_row_spacings(6)
274
        self.table.set_col_spacings(6)
275
        self.table.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
276
277
        align = gtk.Alignment(1.0, 0.5)
278
        label = gtk.Label()
279
        label.set_markup("<b>Revision Id:</b>")
280
        align.add(label)
281
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
282
        align.show()
283
        label.show()
284
285
        align = gtk.Alignment(0.0, 0.5)
412.1.5 by Daniel Schierbeck
Made the revision id label use signals when updating.
286
        revision_id = gtk.Label()
287
        revision_id.set_selectable(True)
288
        self.connect('notify::revision', 
289
                lambda w, p: revision_id.set_text(self._revision.revision_id))
290
        align.add(revision_id)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
291
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
292
        align.show()
412.1.5 by Daniel Schierbeck
Made the revision id label use signals when updating.
293
        revision_id.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
294
0.1.1 by Dan Loda
First working version of xannotate.
295
        align = gtk.Alignment(1.0, 0.5)
259 by Aaron Bentley
Add author support to gannotate and log viewer
296
        self.author_label = gtk.Label()
297
        self.author_label.set_markup("<b>Author:</b>")
298
        align.add(self.author_label)
299
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
300
        align.show()
301
        self.author_label.show()
302
303
        align = gtk.Alignment(0.0, 0.5)
304
        self.author = gtk.Label()
305
        self.author.set_selectable(True)
306
        align.add(self.author)
307
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
308
        align.show()
309
        self.author.show()
310
        self.author.hide()
311
312
        align = gtk.Alignment(1.0, 0.5)
0.1.1 by Dan Loda
First working version of xannotate.
313
        label = gtk.Label()
314
        label.set_markup("<b>Committer:</b>")
315
        align.add(label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
316
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
317
        align.show()
318
        label.show()
319
320
        align = gtk.Alignment(0.0, 0.5)
321
        self.committer = gtk.Label()
322
        self.committer.set_selectable(True)
323
        align.add(self.committer)
259 by Aaron Bentley
Add author support to gannotate and log viewer
324
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
325
        align.show()
326
        self.committer.show()
327
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
328
        align = gtk.Alignment(0.0, 0.5)
329
        label = gtk.Label()
330
        label.set_markup("<b>Branch nick:</b>")
331
        align.add(label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
332
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
333
        label.show()
334
        align.show()
335
336
        align = gtk.Alignment(0.0, 0.5)
337
        self.branchnick_label = gtk.Label()
338
        self.branchnick_label.set_selectable(True)
339
        align.add(self.branchnick_label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
340
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
341
        self.branchnick_label.show()
342
        align.show()
343
0.1.1 by Dan Loda
First working version of xannotate.
344
        align = gtk.Alignment(1.0, 0.5)
345
        label = gtk.Label()
346
        label.set_markup("<b>Timestamp:</b>")
347
        align.add(label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
348
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
349
        align.show()
350
        label.show()
351
352
        align = gtk.Alignment(0.0, 0.5)
353
        self.timestamp = gtk.Label()
354
        self.timestamp.set_selectable(True)
355
        align.add(self.timestamp)
259 by Aaron Bentley
Add author support to gannotate and log viewer
356
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
357
        align.show()
358
        self.timestamp.show()
359
241 by Jelmer Vernooij
Show tags in bzr viz.
360
        align = gtk.Alignment(1.0, 0.5)
361
        self.tags_label = gtk.Label()
362
        self.tags_label.set_markup("<b>Tags:</b>")
363
        align.add(self.tags_label)
364
        align.show()
261 by Aaron Bentley
Fix tags formatting
365
        self.table.attach(align, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
241 by Jelmer Vernooij
Show tags in bzr viz.
366
        self.tags_label.show()
367
368
        align = gtk.Alignment(0.0, 0.5)
423.3.1 by Daniel Schierbeck
Made the tag list be a comma-separated line instead of a vertically stacked box.
369
        self.tags_list = gtk.Label()
241 by Jelmer Vernooij
Show tags in bzr viz.
370
        align.add(self.tags_list)
261 by Aaron Bentley
Fix tags formatting
371
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
241 by Jelmer Vernooij
Show tags in bzr viz.
372
        align.show()
373
        self.tags_list.show()
374
412.1.4 by Daniel Schierbeck
Made tag list smarter.
375
        self.connect('notify::revision', self._add_tags)
376
0.1.1 by Dan Loda
First working version of xannotate.
377
        return self.table
378
256.2.23 by Gary van der Merwe
Show Children
379
    
291 by Jelmer Vernooij
Put children widget on a new line.
380
    def _create_parents(self):
381
        hbox = gtk.HBox(True, 3)
256.2.23 by Gary van der Merwe
Show Children
382
        
383
        self.parents_table = self._create_parents_or_children_table(
384
            "<b>Parents:</b>")
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
385
        self.parents_widgets = []
256.2.23 by Gary van der Merwe
Show Children
386
        hbox.pack_start(self.parents_table)
291 by Jelmer Vernooij
Put children widget on a new line.
387
388
        hbox.show()
389
        return hbox
390
391
    def _create_children(self):
392
        hbox = gtk.HBox(True, 3)
393
        self.children_table = self._create_parents_or_children_table(
394
            "<b>Children:</b>")
395
        self.children_widgets = []
396
        hbox.pack_start(self.children_table)
256.2.23 by Gary van der Merwe
Show Children
397
        hbox.show()
398
        return hbox
399
        
400
    def _create_parents_or_children_table(self, text):
401
        table = gtk.Table(rows=1, columns=2)
402
        table.set_row_spacings(3)
403
        table.set_col_spacings(6)
404
        table.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
405
406
        label = gtk.Label()
256.2.23 by Gary van der Merwe
Show Children
407
        label.set_markup(text)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
408
        align = gtk.Alignment(0.0, 0.5)
409
        align.add(label)
256.2.23 by Gary van der Merwe
Show Children
410
        table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
411
        label.show()
412
        align.show()
413
256.2.23 by Gary van der Merwe
Show Children
414
        return table
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
415
0.1.1 by Dan Loda
First working version of xannotate.
416
    def _create_message_view(self):
412.1.6 by Daniel Schierbeck
Made the message buffer use signals when updating.
417
        msg_buffer = gtk.TextBuffer()
418
        self.connect('notify::revision',
419
                lambda w, p: msg_buffer.set_text(self._revision.message))
324.2.2 by Daniel Schierbeck
Surrounded the commit message textview with a scrolled window and added a shadow.
420
        window = gtk.ScrolledWindow()
421
        window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
422
        window.set_shadow_type(gtk.SHADOW_IN)
412.1.6 by Daniel Schierbeck
Made the message buffer use signals when updating.
423
        tv = gtk.TextView(msg_buffer)
0.1.1 by Dan Loda
First working version of xannotate.
424
        tv.set_editable(False)
425
        tv.set_wrap_mode(gtk.WRAP_WORD)
426
        tv.modify_font(pango.FontDescription("Monospace"))
427
        tv.show()
324.2.2 by Daniel Schierbeck
Surrounded the commit message textview with a scrolled window and added a shadow.
428
        window.add(tv)
429
        window.show()
430
        return window
0.1.1 by Dan Loda
First working version of xannotate.
431
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
432
    def _create_file_info_view(self):
278.1.45 by John Arbash Meinel
Switch to a new tab for per-file messages.
433
        self.file_info_box = gtk.VBox(False, 6)
434
        self.file_info_box.set_border_width(6)
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
435
        self.file_info_buffer = gtk.TextBuffer()
278.1.44 by John Arbash Meinel
Merge in trunk, and update logview per-file commit messages.
436
        window = gtk.ScrolledWindow()
437
        window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
438
        window.set_shadow_type(gtk.SHADOW_IN)
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
439
        tv = gtk.TextView(self.file_info_buffer)
440
        tv.set_editable(False)
441
        tv.set_wrap_mode(gtk.WRAP_WORD)
442
        tv.modify_font(pango.FontDescription("Monospace"))
443
        tv.show()
278.1.44 by John Arbash Meinel
Merge in trunk, and update logview per-file commit messages.
444
        window.add(tv)
445
        window.show()
446
        self.file_info_box.pack_start(window)
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
447
        self.file_info_box.hide() # Only shown when there are per-file messages
278.1.45 by John Arbash Meinel
Switch to a new tab for per-file messages.
448
        self.append_page(self.file_info_box, tab_label=gtk.Label('Per-file'))
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
449