25
from bzrlib import trace
26
24
from bzrlib.osutils import format_date
28
from bzrlib.bencode import bdecode
30
from bzrlib.util.bencode import bdecode
31
from bzrlib.testament import Testament
33
from bzrlib.plugins.gtk import icon_path
36
from bzrlib.plugins.gtk import seahorse
48
def _open_link(widget, uri):
49
for cmd in ['sensible-browser', 'xdg-open']:
50
if webbrowser._iscommand(cmd):
51
webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
54
gtk.link_button_set_uri_hook(_open_link)
56
class BugsTab(gtk.VBox):
59
super(BugsTab, self).__init__(False, 6)
61
table = gtk.Table(rows=2, columns=2)
63
table.set_row_spacings(6)
64
table.set_col_spacing(0, 16)
67
image.set_from_file(icon_path("bug.png"))
68
table.attach(image, 0, 1, 0, 1, gtk.FILL)
70
align = gtk.Alignment(0.0, 0.1)
71
self.label = gtk.Label()
73
table.attach(align, 1, 2, 0, 1, gtk.FILL)
75
treeview = self.construct_treeview()
76
table.attach(treeview, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND)
78
self.set_border_width(6)
79
self.pack_start(table, expand=False)
84
def set_revision(self, revision):
89
bugs_text = revision.properties.get('bugs', '')
90
for bugline in bugs_text.splitlines():
91
(url, status) = bugline.split(" ")
93
self.add_bug(url, status)
95
if self.num_bugs == 0:
97
elif self.num_bugs == 1:
102
self.label.set_markup("<b>Bugs fixed</b>\n" +
103
"This revision claims to fix " +
104
"%d %s." % (self.num_bugs, label))
106
def construct_treeview(self):
107
self.bugs = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
108
self.treeview = gtk.TreeView(self.bugs)
109
self.treeview.set_headers_visible(False)
111
uri_column = gtk.TreeViewColumn('Bug URI', gtk.CellRendererText(), text=0)
112
self.treeview.append_column(uri_column)
114
self.treeview.connect('row-activated', self.on_row_activated)
116
win = gtk.ScrolledWindow()
117
win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
118
win.set_shadow_type(gtk.SHADOW_IN)
119
win.add(self.treeview)
126
self.set_sensitive(False)
127
self.label.set_markup("<b>No bugs fixed</b>\n" +
128
"This revision does not claim to fix any bugs.")
130
def add_bug(self, url, status):
132
self.bugs.append([url, status])
133
self.set_sensitive(True)
135
def get_num_bugs(self):
138
def on_row_activated(self, treeview, path, column):
139
uri = self.bugs.get_value(self.bugs.get_iter(path), 0)
140
_open_link(self, uri)
143
class SignatureTab(gtk.VBox):
145
def __init__(self, repository):
148
self.repository = repository
150
super(SignatureTab, self).__init__(False, 6)
151
signature_box = gtk.Table(rows=3, columns=3)
152
signature_box.set_col_spacing(0, 16)
153
signature_box.set_col_spacing(1, 12)
154
signature_box.set_row_spacings(6)
156
self.signature_image = gtk.Image()
157
signature_box.attach(self.signature_image, 0, 1, 0, 1, gtk.FILL)
159
align = gtk.Alignment(0.0, 0.1)
160
self.signature_label = gtk.Label()
161
align.add(self.signature_label)
162
signature_box.attach(align, 1, 3, 0, 1, gtk.FILL)
164
align = gtk.Alignment(0.0, 0.5)
165
self.signature_key_id_label = gtk.Label()
166
self.signature_key_id_label.set_markup("<b>Key Id:</b>")
167
align.add(self.signature_key_id_label)
168
signature_box.attach(align, 1, 2, 1, 2, gtk.FILL, gtk.FILL)
170
align = gtk.Alignment(0.0, 0.5)
171
self.signature_key_id = gtk.Label()
172
self.signature_key_id.set_selectable(True)
173
align.add(self.signature_key_id)
174
signature_box.attach(align, 2, 3, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
176
align = gtk.Alignment(0.0, 0.5)
177
self.signature_fingerprint_label = gtk.Label()
178
self.signature_fingerprint_label.set_markup("<b>Fingerprint:</b>")
179
align.add(self.signature_fingerprint_label)
180
signature_box.attach(align, 1, 2, 2, 3, gtk.FILL, gtk.FILL)
182
align = gtk.Alignment(0.0, 0.5)
183
self.signature_fingerprint = gtk.Label()
184
self.signature_fingerprint.set_selectable(True)
185
align.add(self.signature_fingerprint)
186
signature_box.attach(align, 2, 3, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
188
align = gtk.Alignment(0.0, 0.5)
189
self.signature_trust_label = gtk.Label()
190
self.signature_trust_label.set_markup("<b>Trust:</b>")
191
align.add(self.signature_trust_label)
192
signature_box.attach(align, 1, 2, 3, 4, gtk.FILL, gtk.FILL)
194
align = gtk.Alignment(0.0, 0.5)
195
self.signature_trust = gtk.Label()
196
self.signature_trust.set_selectable(True)
197
align.add(self.signature_trust)
198
signature_box.attach(align, 2, 3, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
200
self.set_border_width(6)
201
self.pack_start(signature_box, expand=False)
204
def set_revision(self, revision):
205
self.revision = revision
206
revid = revision.revision_id
208
if self.repository.has_signature_for_revision_id(revid):
209
crypttext = self.repository.get_signature_text(revid)
210
self.show_signature(crypttext)
212
self.show_no_signature()
214
def show_no_signature(self):
215
self.signature_key_id_label.hide()
216
self.signature_key_id.set_text("")
218
self.signature_fingerprint_label.hide()
219
self.signature_fingerprint.set_text("")
221
self.signature_trust_label.hide()
222
self.signature_trust.set_text("")
224
self.signature_image.set_from_file(icon_path("sign-unknown.png"))
225
self.signature_label.set_markup("<b>Authenticity unknown</b>\n" +
226
"This revision has not been signed.")
228
def show_signature(self, crypttext):
229
(cleartext, key) = seahorse.verify(crypttext)
231
assert cleartext is not None
233
inv = self.repository.get_inventory(self.revision.revision_id)
234
expected_testament = Testament(self.revision, inv).as_short_text()
235
if expected_testament != cleartext:
236
self.signature_image.set_from_file(icon_path("sign-bad.png"))
237
self.signature_label.set_markup("<b>Signature does not match repository data</b>\n" +
238
"The signature plaintext is different from the expected testament plaintext.")
241
if key and key.is_available():
243
if key.get_display_name() == self.revision.committer:
244
self.signature_image.set_from_file(icon_path("sign-ok.png"))
245
self.signature_label.set_markup("<b>Authenticity confirmed</b>\n" +
246
"This revision has been signed with " +
249
self.signature_image.set_from_file(icon_path("sign-bad.png"))
250
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
251
"Revision committer is not the same as signer.")
253
self.signature_image.set_from_file(icon_path("sign-bad.png"))
254
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
255
"This revision has been signed, but the " +
256
"key is not trusted.")
258
self.show_no_signature()
259
self.signature_image.set_from_file(icon_path("sign-bad.png"))
260
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
261
"Signature key not available.")
264
trust = key.get_trust()
266
if trust <= seahorse.TRUST_NEVER:
267
trust_text = 'never trusted'
268
elif trust == seahorse.TRUST_UNKNOWN:
269
trust_text = 'not trusted'
270
elif trust == seahorse.TRUST_MARGINAL:
271
trust_text = 'marginally trusted'
272
elif trust == seahorse.TRUST_FULL:
273
trust_text = 'fully trusted'
274
elif trust == seahorse.TRUST_ULTIMATE:
275
trust_text = 'ultimately trusted'
277
self.signature_key_id_label.show()
278
self.signature_key_id.set_text(key.get_id())
280
fingerprint = key.get_fingerprint()
281
if fingerprint == "":
282
fingerprint = '<span foreground="dim grey">N/A</span>'
284
self.signature_fingerprint_label.show()
285
self.signature_fingerprint.set_markup(fingerprint)
287
self.signature_trust_label.show()
288
self.signature_trust.set_text('This key is ' + trust_text)
25
from bzrlib.util.bencode import bdecode
291
27
class RevisionView(gtk.Notebook):
292
28
""" Custom widget for commit log details.
571
269
self.append_page(vbox, tab_label=gtk.Label("Relations"))
574
def _create_signature(self):
575
self.signature_table = SignatureTab(self._repository)
576
self.append_page(self.signature_table, tab_label=gtk.Label('Signature'))
577
self.connect_after('notify::revision', self._update_signature)
579
272
def _create_headers(self):
580
273
self.table = gtk.Table(rows=5, columns=2)
581
274
self.table.set_row_spacings(6)
582
275
self.table.set_col_spacings(6)
583
276
self.table.show()
278
align = gtk.Alignment(1.0, 0.5)
587
279
label = gtk.Label()
588
label.set_alignment(1.0, 0.5)
589
280
label.set_markup("<b>Revision Id:</b>")
590
self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
282
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
286
align = gtk.Alignment(0.0, 0.5)
593
287
revision_id = gtk.Label()
594
revision_id.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
595
revision_id.set_alignment(0.0, 0.5)
596
288
revision_id.set_selectable(True)
597
289
self.connect('notify::revision',
598
290
lambda w, p: revision_id.set_text(self._revision.revision_id))
599
self.table.attach(revision_id, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
291
align.add(revision_id)
292
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
600
294
revision_id.show()
296
align = gtk.Alignment(1.0, 0.5)
603
297
self.author_label = gtk.Label()
604
self.author_label.set_alignment(1.0, 0.5)
605
298
self.author_label.set_markup("<b>Author:</b>")
606
self.table.attach(self.author_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
299
align.add(self.author_label)
300
self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
607
302
self.author_label.show()
304
align = gtk.Alignment(0.0, 0.5)
609
305
self.author = gtk.Label()
610
self.author.set_ellipsize(pango.ELLIPSIZE_END)
611
self.author.set_alignment(0.0, 0.5)
612
306
self.author.set_selectable(True)
613
self.table.attach(self.author, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
307
align.add(self.author)
308
self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
614
310
self.author.show()
615
311
self.author.hide()
313
align = gtk.Alignment(1.0, 0.5)
618
314
label = gtk.Label()
619
label.set_alignment(1.0, 0.5)
620
315
label.set_markup("<b>Committer:</b>")
621
self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
317
self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
321
align = gtk.Alignment(0.0, 0.5)
624
322
self.committer = gtk.Label()
625
self.committer.set_ellipsize(pango.ELLIPSIZE_END)
626
self.committer.set_alignment(0.0, 0.5)
627
323
self.committer.set_selectable(True)
628
self.table.attach(self.committer, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
324
align.add(self.committer)
325
self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
629
327
self.committer.show()
329
align = gtk.Alignment(0.0, 0.5)
331
label.set_markup("<b>Branch nick:</b>")
333
self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
337
align = gtk.Alignment(0.0, 0.5)
632
338
self.branchnick_label = gtk.Label()
633
self.branchnick_label.set_alignment(1.0, 0.5)
634
self.branchnick_label.set_markup("<b>Branch nick:</b>")
635
self.table.attach(self.branchnick_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
339
self.branchnick_label.set_selectable(True)
340
align.add(self.branchnick_label)
341
self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
636
342
self.branchnick_label.show()
638
self.branchnick = gtk.Label()
639
self.branchnick.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
640
self.branchnick.set_alignment(0.0, 0.5)
641
self.branchnick.set_selectable(True)
642
self.table.attach(self.branchnick, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
643
self.branchnick.show()
345
align = gtk.Alignment(1.0, 0.5)
646
346
label = gtk.Label()
647
label.set_alignment(1.0, 0.5)
648
347
label.set_markup("<b>Timestamp:</b>")
649
self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
349
self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
353
align = gtk.Alignment(0.0, 0.5)
652
354
self.timestamp = gtk.Label()
653
self.timestamp.set_ellipsize(pango.ELLIPSIZE_END)
654
self.timestamp.set_alignment(0.0, 0.5)
655
355
self.timestamp.set_selectable(True)
656
self.table.attach(self.timestamp, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
356
align.add(self.timestamp)
357
self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
657
359
self.timestamp.show()
361
align = gtk.Alignment(1.0, 0.5)
660
362
self.tags_label = gtk.Label()
661
self.tags_label.set_alignment(1.0, 0.5)
662
363
self.tags_label.set_markup("<b>Tags:</b>")
663
self.table.attach(self.tags_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
364
align.add(self.tags_label)
366
self.table.attach(align, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
664
367
self.tags_label.show()
666
self.tags_list = gtk.Label()
667
self.tags_list.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
668
self.tags_list.set_alignment(0.0, 0.5)
669
self.table.attach(self.tags_list, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
369
align = gtk.Alignment(0.0, 0.5)
370
self.tags_list = gtk.VBox()
371
align.add(self.tags_list)
372
self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
670
374
self.tags_list.show()
375
self.tags_widgets = []
672
377
self.connect('notify::revision', self._add_tags)
674
379
return self.table
676
382
def _create_parents(self):
677
383
hbox = gtk.HBox(True, 3)