/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
399.1.9 by Daniel Schierbeck
Merged with trunk.
22
import gobject
423.14.1 by Jelmer Vernooij
Add bugs tab to display bug status change metadata.
23
import subprocess
0.1.1 by Dan Loda
First working version of xannotate.
24
25
from bzrlib.osutils import format_date
412.1.8 by Daniel Schierbeck
Only import the bdecode function from the bzrlib.util.bencode package.
26
from bzrlib.util.bencode import bdecode
0.1.1 by Dan Loda
First working version of xannotate.
27
423.14.2 by Jelmer Vernooij
Move bugs tab to separate widget.
28
def _open_link(widget, uri):
29
    subprocess.Popen(['sensible-browser', uri], close_fds=True)
30
31
gtk.link_button_set_uri_hook(_open_link)
32
33
class BugsTab(gtk.Table):
34
    def __init__(self):
35
        super(BugsTab, self).__init__(rows=5, columns=2)
36
        self.set_row_spacings(6)
37
        self.set_col_spacings(6)
448 by Jelmer Vernooij
Add bugs tab in branch view.
38
        self.clear()
423.14.2 by Jelmer Vernooij
Move bugs tab to separate widget.
39
40
    def clear(self):
41
        for c in self.get_children():
42
            self.remove(c)
43
        self.count = 0
448 by Jelmer Vernooij
Add bugs tab in branch view.
44
        self.hide_all() # Only shown when there are bugs
423.14.2 by Jelmer Vernooij
Move bugs tab to separate widget.
45
46
    def add_bug(self, url, status):
47
        button = gtk.LinkButton(url, url)
48
        self.attach(button, 0, 1, self.count, self.count + 1,
49
                              gtk.EXPAND | gtk.FILL, gtk.FILL)
50
        status_label = gtk.Label(status)
51
        self.attach(status_label, 1, 2, self.count, self.count + 1,
52
                              gtk.EXPAND | gtk.FILL, gtk.FILL)
53
        self.count += 1
448 by Jelmer Vernooij
Add bugs tab in branch view.
54
        self.show_all()
423.14.2 by Jelmer Vernooij
Move bugs tab to separate widget.
55
56
399.1.15 by Jelmer Vernooij
Move signature tab to a separate class.
57
class SignatureTab(gtk.VBox):
58
    def __init__(self):
59
        from gpg import GPGSubprocess
60
        self.gpg = GPGSubprocess()
61
        super(SignatureTab, self).__init__(False, 6)
62
        signature_box = gtk.Table(rows=1, columns=2)
63
        signature_box.set_col_spacing(0, 12)
64
65
        self.signature_image = gtk.Image()
66
        signature_box.attach(self.signature_image, 0, 1, 0, 1, gtk.FILL)
67
68
        self.signature_label = gtk.Label()
69
        signature_box.attach(self.signature_label, 1, 2, 0, 1, gtk.FILL)
70
71
        signature_info = gtk.Table(rows=1, columns=2)
72
        signature_info.set_row_spacings(6)
73
        signature_info.set_col_spacings(6)
74
75
        align = gtk.Alignment(1.0, 0.5)
76
        label = gtk.Label()
77
        label.set_markup("<b>Key Id:</b>")
78
        align.add(label)
79
        signature_info.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
80
81
        align = gtk.Alignment(0.0, 0.5)
82
        self.signature_key_id = gtk.Label()
83
        self.signature_key_id.set_selectable(True)
84
        align.add(self.signature_key_id)
85
        signature_info.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
86
87
        self.set_border_width(6)
88
        self.pack_start(signature_box, expand=False)
89
        self.pack_start(signature_info, expand=False)
90
        self.show_all()
91
399.1.16 by Jelmer Vernooij
Move logic showing images to the SignatureTab widget.
92
    def show_no_signature(self):
93
        self.signature_key_id.set_text("")
94
        self.signature_image.set_from_file("icons/sign-unknown.png")
95
        self.signature_label.set_text("This revision has not been signed.")
96
97
    def show_signature(self, text):
98
        signature = self.gpg.verify(text)
99
100
        if signature.key_id is not None:
101
            self.signature_key_id.set_text(signature.key_id)
102
103
        if signature.is_valid():
104
            self.signature_image.set_from_file("icons/sign-ok.png")
105
            self.signature_label.set_text("This revision has been signed.")
106
        else:
107
            self.signature_image.set_from_file("icons/sign-bad.png")
108
            self.signature_label.set_text("This revision has been signed, " + 
109
                    "but the authenticity of the signature cannot be verified.")
110
399.1.15 by Jelmer Vernooij
Move signature tab to a separate class.
111
330.3.1 by Daniel Schierbeck
Renamed logview 'revisionview'.
112
class RevisionView(gtk.Notebook):
0.1.1 by Dan Loda
First working version of xannotate.
113
    """ Custom widget for commit log details.
114
115
    A variety of bzr tools may need to implement such a thing. This is a
116
    start.
117
    """
118
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
119
    __gproperties__ = {
120
        'branch': (
121
            gobject.TYPE_PYOBJECT,
122
            'Branch',
123
            'The branch holding the revision being displayed',
124
            gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_WRITABLE
125
        ),
126
127
        'revision': (
128
            gobject.TYPE_PYOBJECT,
129
            'Revision',
130
            'The revision being displayed',
412.1.2 by Daniel Schierbeck
Moved retrieval of tags into the revisionview itself.
131
            gobject.PARAM_READWRITE
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
132
        ),
133
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
134
        'children': (
135
            gobject.TYPE_PYOBJECT,
136
            'Children',
137
            'Child revisions',
138
            gobject.PARAM_READWRITE
139
        ),
140
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
141
        'file-id': (
142
            gobject.TYPE_PYOBJECT,
143
            'File Id',
144
            'The file id',
145
            gobject.PARAM_READWRITE
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
146
        )
147
    }
148
149
412.1.2 by Daniel Schierbeck
Moved retrieval of tags into the revisionview itself.
150
    def __init__(self, branch=None):
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
151
        gtk.Notebook.__init__(self)
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
152
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
153
        self._create_general()
154
        self._create_relations()
399.1.6 by Daniel Schierbeck
Made signature page label singular.
155
        self._create_signature()
278.1.45 by John Arbash Meinel
Switch to a new tab for per-file messages.
156
        self._create_file_info_view()
423.14.1 by Jelmer Vernooij
Add bugs tab to display bug status change metadata.
157
        self._create_bugs()
324.2.9 by Daniel Schierbeck
Made 'General' the default page of the logview.
158
159
        self.set_current_page(0)
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
160
        
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
161
        self._show_callback = None
162
        self._clicked_callback = None
0.1.1 by Dan Loda
First working version of xannotate.
163
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
164
        self._revision = None
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
165
        self._branch = branch
166
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
167
        self.update_tags()
412.1.2 by Daniel Schierbeck
Moved retrieval of tags into the revisionview itself.
168
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
169
        self.set_file_id(None)
0.1.1 by Dan Loda
First working version of xannotate.
170
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
171
    def do_get_property(self, property):
172
        if property.name == 'branch':
173
            return self._branch
174
        elif property.name == 'revision':
175
            return self._revision
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
176
        elif property.name == 'children':
177
            return self._children
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
178
        elif property.name == 'file-id':
179
            return self._file_id
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
180
        else:
181
            raise AttributeError, 'unknown property %s' % property.name
182
183
    def do_set_property(self, property, value):
184
        if property.name == 'branch':
185
            self._branch = value
186
        elif property.name == 'revision':
187
            self._set_revision(value)
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
188
        elif property.name == 'children':
189
            self.set_children(value)
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
190
        elif property.name == 'file-id':
191
            self._file_id = value
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
192
        else:
193
            raise AttributeError, 'unknown property %s' % property.name
194
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
195
    def set_show_callback(self, callback):
196
        self._show_callback = callback
197
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
198
    def set_file_id(self, file_id):
199
        """Set a specific file id that we want to track.
200
201
        This just effects the display of a per-file commit message.
202
        If it is set to None, then all commit messages will be shown.
203
        """
412.1.7 by Daniel Schierbeck
Added file-id property to the revisionview.
204
        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.
205
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
206
    def set_revision(self, revision):
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
207
        if revision != self._revision:
208
            self.set_property('revision', revision)
209
210
    def get_revision(self):
211
        return self.get_property('revision')
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
212
412.1.15 by Daniel Schierbeck
Removed redundant method argument.
213
    def _set_revision(self, revision):
412.1.1 by Daniel Schierbeck
Added branch and revision properties to the revisionview widget.
214
        if revision is None: return
215
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
216
        self._revision = revision
192 by Jelmer Vernooij
Allow committer to be None.
217
        if revision.committer is not None:
218
            self.committer.set_text(revision.committer)
219
        else:
220
            self.committer.set_text("")
259 by Aaron Bentley
Add author support to gannotate and log viewer
221
        author = revision.properties.get('author', '')
222
        if author != '':
223
            self.author.set_text(author)
224
            self.author.show()
225
            self.author_label.show()
226
        else:
227
            self.author.hide()
228
            self.author_label.hide()
229
197 by Jelmer Vernooij
Fix some warnings when displaying ghost revisions. Reported by John.
230
        if revision.timestamp is not None:
231
            self.timestamp.set_text(format_date(revision.timestamp,
232
                                                revision.timezone))
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
233
        try:
234
            self.branchnick_label.set_text(revision.properties['branch-nick'])
235
        except KeyError:
236
            self.branchnick_label.set_text("")
237
256.2.23 by Gary van der Merwe
Show Children
238
        self._add_parents_or_children(revision.parent_ids,
239
                                      self.parents_widgets,
240
                                      self.parents_table)
241
        
278.1.3 by John Arbash Meinel
Have the ability to tell the log view that we only care about a specific file_id.
242
        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.
243
        if file_info is not None:
412.1.8 by Daniel Schierbeck
Only import the bdecode function from the bzrlib.util.bencode package.
244
            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.
245
246
        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.
247
            if self._file_id is None:
248
                text = []
249
                for fi in file_info:
250
                    text.append('%(path)s\n%(message)s' % fi)
251
                self.file_info_buffer.set_text('\n'.join(text))
252
                self.file_info_box.show()
253
            else:
254
                text = []
255
                for fi in file_info:
256
                    if fi['file_id'] == self._file_id:
257
                        text.append(fi['message'])
258
                if text:
259
                    self.file_info_buffer.set_text('\n'.join(text))
260
                    self.file_info_box.show()
261
                else:
262
                    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.
263
        else:
264
            self.file_info_box.hide()
265
423.14.3 by Jelmer Vernooij
Always show bugs tab.
266
        self.bugs_table.clear()
423.14.1 by Jelmer Vernooij
Add bugs tab to display bug status change metadata.
267
        bugs_text = revision.properties.get('bugs', None)
268
        if bugs_text:
269
            for bugline in bugs_text.splitlines():
270
                (url, status) = bugline.split(" ")
423.14.2 by Jelmer Vernooij
Move bugs tab to separate widget.
271
                self.bugs_table.add_bug(url, status)
423.14.1 by Jelmer Vernooij
Add bugs tab to display bug status change metadata.
272
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
273
    def update_tags(self):
274
        if self._branch is not None and self._branch.supports_tags():
275
            self._tagdict = self._branch.tags.get_reverse_tag_dict()
276
        else:
277
            self._tagdict = {}
278
279
        self._add_tags()
280
399.1.13 by Daniel Schierbeck
Merged with mainline.
281
    def _update_signature(self, widget, param):
282
        revid = self._revision.revision_id
283
284
        if self._branch.repository.has_signature_for_revision_id(revid):
285
            signature_text = self._branch.repository.get_signature_text(revid)
399.1.16 by Jelmer Vernooij
Move logic showing images to the SignatureTab widget.
286
            self.signature_table.show_signature(signature_text)
399.1.13 by Daniel Schierbeck
Merged with mainline.
287
        else:
399.1.16 by Jelmer Vernooij
Move logic showing images to the SignatureTab widget.
288
            self.signature_table.show_no_signature()
399.1.13 by Daniel Schierbeck
Merged with mainline.
289
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
290
    def set_children(self, children):
291
        self._add_parents_or_children(children,
292
                                      self.children_widgets,
293
                                      self.children_table)
294
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
295
    def _show_clicked_cb(self, widget, revid, parentid):
296
        """Callback for when the show button for a parent is clicked."""
297
        self._show_callback(revid, parentid)
298
299
    def _go_clicked_cb(self, widget, revid):
300
        """Callback for when the go button for a parent is clicked."""
301
412.1.4 by Daniel Schierbeck
Made tag list smarter.
302
    def _add_tags(self, *args):
399.1.13 by Daniel Schierbeck
Merged with mainline.
303
        if self._revision is None:
304
            return
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
305
412.1.4 by Daniel Schierbeck
Made tag list smarter.
306
        if self._tagdict.has_key(self._revision.revision_id):
307
            tags = self._tagdict[self._revision.revision_id]
308
        else:
309
            tags = []
310
            
241 by Jelmer Vernooij
Show tags in bzr viz.
311
        if tags == []:
312
            self.tags_list.hide()
313
            self.tags_label.hide()
314
            return
315
423.3.1 by Daniel Schierbeck
Made the tag list be a comma-separated line instead of a vertically stacked box.
316
        self.tags_list.set_text(", ".join(tags))
317
241 by Jelmer Vernooij
Show tags in bzr viz.
318
        self.tags_list.show_all()
319
        self.tags_label.show_all()
320
        
256.2.23 by Gary van der Merwe
Show Children
321
    def _add_parents_or_children(self, revids, widgets, table):
322
        while len(widgets) > 0:
323
            widget = widgets.pop()
324
            table.remove(widget)
325
        
326
        table.resize(max(len(revids), 1), 2)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
327
256.2.23 by Gary van der Merwe
Show Children
328
        for idx, revid in enumerate(revids):
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
329
            align = gtk.Alignment(0.0, 0.0)
256.2.23 by Gary van der Merwe
Show Children
330
            widgets.append(align)
331
            table.attach(align, 1, 2, idx, idx + 1,
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
332
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
333
            align.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
334
335
            hbox = gtk.HBox(False, spacing=6)
336
            align.add(hbox)
337
            hbox.show()
338
339
            image = gtk.Image()
340
            image.set_from_stock(
341
                gtk.STOCK_FIND, gtk.ICON_SIZE_SMALL_TOOLBAR)
342
            image.show()
343
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.
344
            if self._show_callback is not None:
345
                button = gtk.Button()
346
                button.add(image)
347
                button.connect("clicked", self._show_clicked_cb,
256.2.23 by Gary van der Merwe
Show Children
348
                               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.
349
                hbox.pack_start(button, expand=False, fill=True)
350
                button.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
351
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
352
            button = gtk.Button(revid)
353
            button.connect("clicked",
412.1.14 by Daniel Schierbeck
Fixed bug in the way the child buttons worked.
354
                    lambda w, r: self.set_revision(self._branch.repository.get_revision(r)), revid)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
355
            button.set_use_underline(False)
356
            hbox.pack_start(button, expand=False, fill=True)
357
            button.show()
0.1.1 by Dan Loda
First working version of xannotate.
358
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
359
    def _create_general(self):
0.1.1 by Dan Loda
First working version of xannotate.
360
        vbox = gtk.VBox(False, 6)
361
        vbox.set_border_width(6)
362
        vbox.pack_start(self._create_headers(), expand=False, fill=True)
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
363
        vbox.pack_start(self._create_message_view())
364
        self.append_page(vbox, tab_label=gtk.Label("General"))
365
        vbox.show()
366
367
    def _create_relations(self):
368
        vbox = gtk.VBox(False, 6)
369
        vbox.set_border_width(6)
291 by Jelmer Vernooij
Put children widget on a new line.
370
        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.
371
        vbox.pack_start(self._create_children(), expand=False, fill=True)
324.2.1 by Daniel Schierbeck
Turned the logview into a notebook.
372
        self.append_page(vbox, tab_label=gtk.Label("Relations"))
0.1.1 by Dan Loda
First working version of xannotate.
373
        vbox.show()
324.2.4 by Daniel Schierbeck
Added 'Changes' page to logview.
374
399.1.10 by Daniel Schierbeck
Improved implementation of the Signature page.
375
    def _create_signature(self):
399.1.15 by Jelmer Vernooij
Move signature tab to a separate class.
376
        try:
377
            self.signature_table = SignatureTab()
378
        except ImportError: # No GPG module installed
379
            self.signature_table = None
380
            return
381
        self.append_page(self.signature_table, tab_label=gtk.Label('Signature'))
399.1.10 by Daniel Schierbeck
Improved implementation of the Signature page.
382
        self.connect_after('notify::revision', self._update_signature)
383
0.1.1 by Dan Loda
First working version of xannotate.
384
    def _create_headers(self):
241 by Jelmer Vernooij
Show tags in bzr viz.
385
        self.table = gtk.Table(rows=5, columns=2)
0.1.1 by Dan Loda
First working version of xannotate.
386
        self.table.set_row_spacings(6)
387
        self.table.set_col_spacings(6)
388
        self.table.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
389
390
        align = gtk.Alignment(1.0, 0.5)
391
        label = gtk.Label()
392
        label.set_markup("<b>Revision Id:</b>")
393
        align.add(label)
394
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
395
        align.show()
396
        label.show()
397
398
        align = gtk.Alignment(0.0, 0.5)
412.1.5 by Daniel Schierbeck
Made the revision id label use signals when updating.
399
        revision_id = gtk.Label()
400
        revision_id.set_selectable(True)
401
        self.connect('notify::revision', 
402
                lambda w, p: revision_id.set_text(self._revision.revision_id))
403
        align.add(revision_id)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
404
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
405
        align.show()
412.1.5 by Daniel Schierbeck
Made the revision id label use signals when updating.
406
        revision_id.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
407
0.1.1 by Dan Loda
First working version of xannotate.
408
        align = gtk.Alignment(1.0, 0.5)
259 by Aaron Bentley
Add author support to gannotate and log viewer
409
        self.author_label = gtk.Label()
410
        self.author_label.set_markup("<b>Author:</b>")
411
        align.add(self.author_label)
412
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
413
        align.show()
414
        self.author_label.show()
415
416
        align = gtk.Alignment(0.0, 0.5)
417
        self.author = gtk.Label()
418
        self.author.set_selectable(True)
419
        align.add(self.author)
420
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
421
        align.show()
422
        self.author.show()
423
        self.author.hide()
424
425
        align = gtk.Alignment(1.0, 0.5)
0.1.1 by Dan Loda
First working version of xannotate.
426
        label = gtk.Label()
427
        label.set_markup("<b>Committer:</b>")
428
        align.add(label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
429
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
430
        align.show()
431
        label.show()
432
433
        align = gtk.Alignment(0.0, 0.5)
434
        self.committer = gtk.Label()
435
        self.committer.set_selectable(True)
436
        align.add(self.committer)
259 by Aaron Bentley
Add author support to gannotate and log viewer
437
        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.
438
        align.show()
439
        self.committer.show()
440
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
441
        align = gtk.Alignment(0.0, 0.5)
442
        label = gtk.Label()
443
        label.set_markup("<b>Branch nick:</b>")
444
        align.add(label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
445
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
446
        label.show()
447
        align.show()
448
449
        align = gtk.Alignment(0.0, 0.5)
450
        self.branchnick_label = gtk.Label()
451
        self.branchnick_label.set_selectable(True)
452
        align.add(self.branchnick_label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
453
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
454
        self.branchnick_label.show()
455
        align.show()
456
0.1.1 by Dan Loda
First working version of xannotate.
457
        align = gtk.Alignment(1.0, 0.5)
458
        label = gtk.Label()
459
        label.set_markup("<b>Timestamp:</b>")
460
        align.add(label)
259 by Aaron Bentley
Add author support to gannotate and log viewer
461
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
0.1.1 by Dan Loda
First working version of xannotate.
462
        align.show()
463
        label.show()
464
465
        align = gtk.Alignment(0.0, 0.5)
466
        self.timestamp = gtk.Label()
467
        self.timestamp.set_selectable(True)
468
        align.add(self.timestamp)
259 by Aaron Bentley
Add author support to gannotate and log viewer
469
        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.
470
        align.show()
471
        self.timestamp.show()
472
241 by Jelmer Vernooij
Show tags in bzr viz.
473
        align = gtk.Alignment(1.0, 0.5)
474
        self.tags_label = gtk.Label()
475
        self.tags_label.set_markup("<b>Tags:</b>")
476
        align.add(self.tags_label)
477
        align.show()
261 by Aaron Bentley
Fix tags formatting
478
        self.table.attach(align, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
241 by Jelmer Vernooij
Show tags in bzr viz.
479
        self.tags_label.show()
480
481
        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.
482
        self.tags_list = gtk.Label()
241 by Jelmer Vernooij
Show tags in bzr viz.
483
        align.add(self.tags_list)
261 by Aaron Bentley
Fix tags formatting
484
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
241 by Jelmer Vernooij
Show tags in bzr viz.
485
        align.show()
486
        self.tags_list.show()
487
412.1.4 by Daniel Schierbeck
Made tag list smarter.
488
        self.connect('notify::revision', self._add_tags)
489
0.1.1 by Dan Loda
First working version of xannotate.
490
        return self.table
256.2.23 by Gary van der Merwe
Show Children
491
    
291 by Jelmer Vernooij
Put children widget on a new line.
492
    def _create_parents(self):
493
        hbox = gtk.HBox(True, 3)
256.2.23 by Gary van der Merwe
Show Children
494
        
495
        self.parents_table = self._create_parents_or_children_table(
496
            "<b>Parents:</b>")
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
497
        self.parents_widgets = []
256.2.23 by Gary van der Merwe
Show Children
498
        hbox.pack_start(self.parents_table)
291 by Jelmer Vernooij
Put children widget on a new line.
499
500
        hbox.show()
501
        return hbox
502
503
    def _create_children(self):
504
        hbox = gtk.HBox(True, 3)
505
        self.children_table = self._create_parents_or_children_table(
506
            "<b>Children:</b>")
507
        self.children_widgets = []
508
        hbox.pack_start(self.children_table)
256.2.23 by Gary van der Merwe
Show Children
509
        hbox.show()
510
        return hbox
511
        
512
    def _create_parents_or_children_table(self, text):
513
        table = gtk.Table(rows=1, columns=2)
514
        table.set_row_spacings(3)
515
        table.set_col_spacings(6)
516
        table.show()
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
517
518
        label = gtk.Label()
256.2.23 by Gary van der Merwe
Show Children
519
        label.set_markup(text)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
520
        align = gtk.Alignment(0.0, 0.5)
521
        align.add(label)
256.2.23 by Gary van der Merwe
Show Children
522
        table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
523
        label.show()
524
        align.show()
525
256.2.23 by Gary van der Merwe
Show Children
526
        return table
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
527
0.1.1 by Dan Loda
First working version of xannotate.
528
    def _create_message_view(self):
412.1.6 by Daniel Schierbeck
Made the message buffer use signals when updating.
529
        msg_buffer = gtk.TextBuffer()
530
        self.connect('notify::revision',
531
                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.
532
        window = gtk.ScrolledWindow()
533
        window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
534
        window.set_shadow_type(gtk.SHADOW_IN)
412.1.6 by Daniel Schierbeck
Made the message buffer use signals when updating.
535
        tv = gtk.TextView(msg_buffer)
0.1.1 by Dan Loda
First working version of xannotate.
536
        tv.set_editable(False)
537
        tv.set_wrap_mode(gtk.WRAP_WORD)
399.1.13 by Daniel Schierbeck
Merged with mainline.
538
0.1.1 by Dan Loda
First working version of xannotate.
539
        tv.modify_font(pango.FontDescription("Monospace"))
540
        tv.show()
324.2.2 by Daniel Schierbeck
Surrounded the commit message textview with a scrolled window and added a shadow.
541
        window.add(tv)
542
        window.show()
543
        return window
0.1.1 by Dan Loda
First working version of xannotate.
544
423.14.1 by Jelmer Vernooij
Add bugs tab to display bug status change metadata.
545
    def _create_bugs(self):
423.14.2 by Jelmer Vernooij
Move bugs tab to separate widget.
546
        self.bugs_table = BugsTab()
423.14.1 by Jelmer Vernooij
Add bugs tab to display bug status change metadata.
547
        self.append_page(self.bugs_table, tab_label=gtk.Label('Bugs'))
548
278.1.2 by John Arbash Meinel
Add an extra box that pops up when we have per-file information.
549
    def _create_file_info_view(self):
278.1.45 by John Arbash Meinel
Switch to a new tab for per-file messages.
550
        self.file_info_box = gtk.VBox(False, 6)
551
        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.
552
        self.file_info_buffer = gtk.TextBuffer()
278.1.44 by John Arbash Meinel
Merge in trunk, and update logview per-file commit messages.
553
        window = gtk.ScrolledWindow()
554
        window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
555
        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.
556
        tv = gtk.TextView(self.file_info_buffer)
557
        tv.set_editable(False)
558
        tv.set_wrap_mode(gtk.WRAP_WORD)
559
        tv.modify_font(pango.FontDescription("Monospace"))
560
        tv.show()
278.1.44 by John Arbash Meinel
Merge in trunk, and update logview per-file commit messages.
561
        window.add(tv)
562
        window.show()
563
        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.
564
        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.
565
        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.
566