25
26
from bzrlib.plugins.gtk import icon_path
27
from bzrlib.plugins.gtk import crypt
26
28
from bzrlib.osutils import format_date
27
29
from bzrlib.util.bencode import bdecode
30
from bzrlib.plugins.gtk import seahorse
42
31
def _open_link(widget, uri):
43
for cmd in ['sensible-browser', 'xdg-open']:
44
if webbrowser._iscommand(cmd):
45
webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
32
subprocess.Popen(['sensible-browser', uri], close_fds=True)
48
34
gtk.link_button_set_uri_hook(_open_link)
50
class BugsTab(gtk.VBox):
36
class BugsTab(gtk.Table):
52
38
def __init__(self):
53
super(BugsTab, self).__init__(False, 6)
55
table = gtk.Table(rows=2, columns=2)
57
table.set_row_spacings(6)
58
table.set_col_spacing(0, 16)
61
image.set_from_file(icon_path("bug.png"))
62
table.attach(image, 0, 1, 0, 1, gtk.FILL)
64
align = gtk.Alignment(0.0, 0.1)
65
self.label = gtk.Label()
67
table.attach(align, 1, 2, 0, 1, gtk.FILL)
69
treeview = self.construct_treeview()
70
table.attach(treeview, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND)
72
self.set_border_width(6)
73
self.pack_start(table, expand=False)
78
def set_revision(self, revision):
83
bugs_text = revision.properties.get('bugs', '')
84
for bugline in bugs_text.splitlines():
85
(url, status) = bugline.split(" ")
87
self.add_bug(url, status)
89
if self.num_bugs == 0:
91
elif self.num_bugs == 1:
96
self.label.set_markup("<b>Bugs fixed</b>\n" +
97
"This revision claims to fix " +
98
"%d %s." % (self.num_bugs, label))
100
def construct_treeview(self):
101
self.bugs = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
102
self.treeview = gtk.TreeView(self.bugs)
103
self.treeview.set_headers_visible(False)
105
uri_column = gtk.TreeViewColumn('Bug URI', gtk.CellRendererText(), text=0)
106
self.treeview.append_column(uri_column)
108
self.treeview.connect('row-activated', self.on_row_activated)
110
win = gtk.ScrolledWindow()
111
win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
112
win.set_shadow_type(gtk.SHADOW_IN)
113
win.add(self.treeview)
39
super(BugsTab, self).__init__(rows=5, columns=2)
40
self.set_row_spacings(6)
41
self.set_col_spacings(6)
120
self.set_sensitive(False)
121
self.label.set_markup("<b>No bugs fixed</b>\n" +
122
"This revision does not claim to fix any bugs.")
45
for c in self.get_children():
48
self.hide_all() # Only shown when there are bugs
124
50
def add_bug(self, url, status):
126
self.bugs.append([url, status])
127
self.set_sensitive(True)
129
def get_num_bugs(self):
132
def on_row_activated(self, treeview, path, column):
133
uri = self.bugs.get_value(self.bugs.get_iter(path), 0)
134
_open_link(self, uri)
51
button = gtk.LinkButton(url, url)
52
self.attach(button, 0, 1, self.count, self.count + 1,
53
gtk.EXPAND | gtk.FILL, gtk.FILL)
54
status_label = gtk.Label(status)
55
self.attach(status_label, 1, 2, self.count, self.count + 1,
56
gtk.EXPAND | gtk.FILL, gtk.FILL)
137
61
class SignatureTab(gtk.VBox):
139
def __init__(self, repository):
142
self.repository = repository
144
66
super(SignatureTab, self).__init__(False, 6)
145
67
signature_box = gtk.Table(rows=3, columns=3)
146
signature_box.set_col_spacing(0, 16)
147
signature_box.set_col_spacing(1, 12)
148
signature_box.set_row_spacings(6)
68
signature_box.set_col_spacing(0, 12)
69
signature_box.set_col_spacing(1, 6)
150
71
self.signature_image = gtk.Image()
151
72
signature_box.attach(self.signature_image, 0, 1, 0, 1, gtk.FILL)
153
align = gtk.Alignment(0.0, 0.1)
154
74
self.signature_label = gtk.Label()
75
align = gtk.Alignment(0.0, 0.5)
155
76
align.add(self.signature_label)
156
77
signature_box.attach(align, 1, 3, 0, 1, gtk.FILL)
158
align = gtk.Alignment(0.0, 0.5)
79
align = gtk.Alignment(1.0, 0.5)
159
80
self.signature_key_id_label = gtk.Label()
160
81
self.signature_key_id_label.set_markup("<b>Key Id:</b>")
161
82
align.add(self.signature_key_id_label)
180
101
signature_box.attach(align, 2, 3, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
182
103
align = gtk.Alignment(0.0, 0.5)
104
self.signature_trust = gtk.Label()
105
self.signature_trust.set_selectable(True)
106
align.add(self.signature_trust)
107
signature_box.attach(align, 2, 3, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
109
align = gtk.Alignment(1.0, 0.5)
183
110
self.signature_trust_label = gtk.Label()
184
111
self.signature_trust_label.set_markup("<b>Trust:</b>")
185
112
align.add(self.signature_trust_label)
186
113
signature_box.attach(align, 1, 2, 3, 4, gtk.FILL, gtk.FILL)
188
align = gtk.Alignment(0.0, 0.5)
189
self.signature_trust = gtk.Label()
190
self.signature_trust.set_selectable(True)
191
align.add(self.signature_trust)
192
signature_box.attach(align, 2, 3, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
194
115
self.set_border_width(6)
195
116
self.pack_start(signature_box, expand=False)
198
def set_revision(self, revision):
199
self.revision = revision
200
revid = revision.revision_id
202
if self.repository.has_signature_for_revision_id(revid):
203
crypttext = self.repository.get_signature_text(revid)
204
self.show_signature(crypttext)
206
self.show_no_signature()
208
119
def show_no_signature(self):
209
120
self.signature_key_id_label.hide()
210
121
self.signature_key_id.set_text("")
220
131
"This revision has not been signed.")
222
133
def show_signature(self, crypttext):
223
key = seahorse.verify(crypttext)
225
if key and key.is_available():
227
if key.get_display_name() == self.revision.committer:
228
self.signature_image.set_from_file(icon_path("sign-ok.png"))
229
self.signature_label.set_markup("<b>Authenticity confirmed</b>\n" +
230
"This revision has been signed with " +
233
self.signature_image.set_from_file(icon_path("sign-bad.png"))
234
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
235
"Revision committer is not the same as signer.")
237
self.signature_image.set_from_file(icon_path("sign-bad.png"))
238
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
239
"This revision has been signed, but the " +
240
"key is not trusted.")
134
key = crypt.verify(crypttext)
136
if not key.is_available():
137
self.show_no_signature()
138
self.signature_image.set_from_file(icon_path("sign-bad.png"))
139
self.signature_label.set_markup("<b>Authentication error</b>\n" +
140
"Signature key not available")
144
self.signature_image.set_from_file(icon_path("sign-ok.png"))
145
self.signature_label.set_markup("<b>Authenticity confirmed</b>\n" +
146
"This revision has been signed by " +
242
self.show_no_signature()
243
149
self.signature_image.set_from_file(icon_path("sign-bad.png"))
244
150
self.signature_label.set_markup("<b>Authenticity cannot be confirmed</b>\n" +
245
"Signature key not available.")
151
"This revision has been signed by " +
152
"an untrusted party.")
248
154
trust = key.get_trust()
250
if trust <= seahorse.TRUST_NEVER:
156
if trust <= crypt.TRUST_NEVER:
251
157
trust_text = 'never trusted'
252
elif trust == seahorse.TRUST_UNKNOWN:
158
elif trust == crypt.TRUST_UNKNOWN:
253
159
trust_text = 'not trusted'
254
elif trust == seahorse.TRUST_MARGINAL:
160
elif trust == crypt.TRUST_MARGINAL:
255
161
trust_text = 'marginally trusted'
256
elif trust == seahorse.TRUST_FULL:
162
elif trust == crypt.TRUST_FULL:
257
163
trust_text = 'fully trusted'
258
elif trust == seahorse.TRUST_ULTIMATE:
164
elif trust == crypt.TRUST_ULTIMATE:
259
165
trust_text = 'ultimately trusted'
261
167
self.signature_key_id_label.show()
262
168
self.signature_key_id.set_text(key.get_id())
264
fingerprint = key.get_fingerprint()
265
if fingerprint == "":
266
fingerprint = '<span foreground="dim grey">N/A</span>'
268
170
self.signature_fingerprint_label.show()
269
self.signature_fingerprint.set_markup(fingerprint)
171
self.signature_fingerprint.set_text(key.get_fingerprint())
271
173
self.signature_trust_label.show()
272
174
self.signature_trust.set_text('This key is ' + trust_text)
275
177
class RevisionView(gtk.Notebook):
276
178
""" Custom widget for commit log details.
446
346
def _update_signature(self, widget, param):
447
if self.get_current_page() == PAGE_SIGNATURE:
448
self.signature_table.set_revision(self._revision)
347
revid = self._revision.revision_id
450
def _update_bugs(self, widget, param):
451
self.bugs_page.set_revision(self._revision)
452
label = self.get_tab_label(self.bugs_page)
453
label.set_sensitive(self.bugs_page.get_num_bugs() != 0)
349
if self._branch.repository.has_signature_for_revision_id(revid):
350
signature_text = self._branch.repository.get_signature_text(revid)
351
self.signature_table.show_signature(signature_text)
353
self.signature_table.show_no_signature()
455
355
def set_children(self, children):
456
356
self._add_parents_or_children(children,
457
357
self.children_widgets,
458
358
self.children_table)
460
def _switch_page_cb(self, notebook, page, page_num):
461
if page_num == PAGE_SIGNATURE:
462
self.signature_table.set_revision(self._revision)
466
360
def _show_clicked_cb(self, widget, revid, parentid):
467
361
"""Callback for when the show button for a parent is clicked."""
468
362
self._show_callback(revid, parentid)