25
24
from bzrlib.osutils import format_date
26
25
from bzrlib.util.bencode import bdecode
27
from bzrlib.testament import Testament
29
from bzrlib.plugins.gtk import icon_path
32
from bzrlib.plugins.gtk import seahorse
44
def _open_link(widget, uri):
45
for cmd in ['sensible-browser', 'xdg-open']:
46
if webbrowser._iscommand(cmd):
47
webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
50
gtk.link_button_set_uri_hook(_open_link)
52
class BugsTab(gtk.VBox):
55
super(BugsTab, self).__init__(False, 6)
57
table = gtk.Table(rows=2, columns=2)
59
table.set_row_spacings(6)
60
table.set_col_spacing(0, 16)
63
image.set_from_file(icon_path("bug.png"))
64
table.attach(image, 0, 1, 0, 1, gtk.FILL)
66
align = gtk.Alignment(0.0, 0.1)
67
self.label = gtk.Label()
69
table.attach(align, 1, 2, 0, 1, gtk.FILL)
71
treeview = self.construct_treeview()
72
table.attach(treeview, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND)
74
self.set_border_width(6)
75
self.pack_start(table, expand=False)
80
def set_revision(self, revision):
85
bugs_text = revision.properties.get('bugs', '')
86
for bugline in bugs_text.splitlines():
87
(url, status) = bugline.split(" ")
89
self.add_bug(url, status)
91
if self.num_bugs == 0:
93
elif self.num_bugs == 1:
98
self.label.set_markup("<b>Bugs fixed</b>\n" +
99
"This revision claims to fix " +
100
"%d %s." % (self.num_bugs, label))
102
def construct_treeview(self):
103
self.bugs = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
104
self.treeview = gtk.TreeView(self.bugs)
105
self.treeview.set_headers_visible(False)
107
uri_column = gtk.TreeViewColumn('Bug URI', gtk.CellRendererText(), text=0)
108
self.treeview.append_column(uri_column)
110
self.treeview.connect('row-activated', self.on_row_activated)
112
win = gtk.ScrolledWindow()
113
win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
114
win.set_shadow_type(gtk.SHADOW_IN)
115
win.add(self.treeview)
122
self.set_sensitive(False)
123
self.label.set_markup("<b>No bugs fixed</b>\n" +
124
"This revision does not claim to fix any bugs.")
126
def add_bug(self, url, status):
128
self.bugs.append([url, status])
129
self.set_sensitive(True)
131
def get_num_bugs(self):
134
def on_row_activated(self, treeview, path, column):
135
uri = self.bugs.get_value(self.bugs.get_iter(path), 0)
136
_open_link(self, uri)
139
class SignatureTab(gtk.VBox):
141
def __init__(self, repository):
144
self.repository = repository
146
super(SignatureTab, self).__init__(False, 6)
147
signature_box = gtk.Table(rows=3, columns=3)
148
signature_box.set_col_spacing(0, 16)
149
signature_box.set_col_spacing(1, 12)
150
signature_box.set_row_spacings(6)
152
self.signature_image = gtk.Image()
153
signature_box.attach(self.signature_image, 0, 1, 0, 1, gtk.FILL)
155
align = gtk.Alignment(0.0, 0.1)
156
self.signature_label = gtk.Label()
157
align.add(self.signature_label)
158
signature_box.attach(align, 1, 3, 0, 1, gtk.FILL)
160
align = gtk.Alignment(0.0, 0.5)
161
self.signature_key_id_label = gtk.Label()
162
self.signature_key_id_label.set_markup("<b>Key Id:</b>")
163
align.add(self.signature_key_id_label)
164
signature_box.attach(align, 1, 2, 1, 2, gtk.FILL, gtk.FILL)
166
align = gtk.Alignment(0.0, 0.5)
167
self.signature_key_id = gtk.Label()
168
self.signature_key_id.set_selectable(True)
169
align.add(self.signature_key_id)
170
signature_box.attach(align, 2, 3, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
172
align = gtk.Alignment(0.0, 0.5)
173
self.signature_fingerprint_label = gtk.Label()
174
self.signature_fingerprint_label.set_markup("<b>Fingerprint:</b>")
175
align.add(self.signature_fingerprint_label)
176
signature_box.attach(align, 1, 2, 2, 3, gtk.FILL, gtk.FILL)
178
align = gtk.Alignment(0.0, 0.5)
179
self.signature_fingerprint = gtk.Label()
180
self.signature_fingerprint.set_selectable(True)
181
align.add(self.signature_fingerprint)
182
signature_box.attach(align, 2, 3, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
184
align = gtk.Alignment(0.0, 0.5)
185
self.signature_trust_label = gtk.Label()
186
self.signature_trust_label.set_markup("<b>Trust:</b>")
187
align.add(self.signature_trust_label)
188
signature_box.attach(align, 1, 2, 3, 4, gtk.FILL, gtk.FILL)
190
align = gtk.Alignment(0.0, 0.5)
191
self.signature_trust = gtk.Label()
192
self.signature_trust.set_selectable(True)
193
align.add(self.signature_trust)
194
signature_box.attach(align, 2, 3, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
196
self.set_border_width(6)
197
self.pack_start(signature_box, expand=False)
200
def set_revision(self, revision):
201
self.revision = revision
202
revid = revision.revision_id
204
if self.repository.has_signature_for_revision_id(revid):
205
crypttext = self.repository.get_signature_text(revid)
206
self.show_signature(crypttext)
208
self.show_no_signature()
210
def show_no_signature(self):
211
self.signature_key_id_label.hide()
212
self.signature_key_id.set_text("")
214
self.signature_fingerprint_label.hide()
215
self.signature_fingerprint.set_text("")
217
self.signature_trust_label.hide()
218
self.signature_trust.set_text("")
220
self.signature_image.set_from_file(icon_path("sign-unknown.png"))
221
self.signature_label.set_markup("<b>Authenticity unknown</b>\n" +
222
"This revision has not been signed.")
224
def show_signature(self, crypttext):
225
(cleartext, key) = seahorse.verify(crypttext)
227
assert cleartext is not None
229
inv = self.repository.get_inventory(self.revision.revision_id)
230
expected_testament = Testament(self.revision, inv).as_short_text()
231
if expected_testament != cleartext:
232
self.signature_image.set_from_file(icon_path("sign-bad.png"))
233
self.signature_label.set_markup("<b>Signature does not match repository data</b>\n" +
234
"The signature plaintext is different from the expected testament plaintext.")
237
if key and key.is_available():
239
if key.get_display_name() == self.revision.committer:
240
self.signature_image.set_from_file(icon_path("sign-ok.png"))
241
self.signature_label.set_markup("<b>Authenticity confirmed</b>\n" +
242
"This revision has been signed with " +
245
self.signature_image.set_from_file(icon_path("sign-bad.png"))
246
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
247
"Revision committer is not the same as signer.")
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
"This revision has been signed, but the " +
252
"key is not trusted.")
254
self.show_no_signature()
255
self.signature_image.set_from_file(icon_path("sign-bad.png"))
256
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
257
"Signature key not available.")
260
trust = key.get_trust()
262
if trust <= seahorse.TRUST_NEVER:
263
trust_text = 'never trusted'
264
elif trust == seahorse.TRUST_UNKNOWN:
265
trust_text = 'not trusted'
266
elif trust == seahorse.TRUST_MARGINAL:
267
trust_text = 'marginally trusted'
268
elif trust == seahorse.TRUST_FULL:
269
trust_text = 'fully trusted'
270
elif trust == seahorse.TRUST_ULTIMATE:
271
trust_text = 'ultimately trusted'
273
self.signature_key_id_label.show()
274
self.signature_key_id.set_text(key.get_id())
276
fingerprint = key.get_fingerprint()
277
if fingerprint == "":
278
fingerprint = '<span foreground="dim grey">N/A</span>'
280
self.signature_fingerprint_label.show()
281
self.signature_fingerprint.set_markup(fingerprint)
283
self.signature_trust_label.show()
284
self.signature_trust.set_text('This key is ' + trust_text)
287
27
class RevisionView(gtk.Notebook):
288
28
""" Custom widget for commit log details.