26
from bzrlib.plugins.gtk import icon_path
27
from bzrlib.plugins.gtk import crypt
25
28
from bzrlib.osutils import format_date
26
29
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
31
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)
32
subprocess.Popen(['sensible-browser', uri], close_fds=True)
50
34
gtk.link_button_set_uri_hook(_open_link)
52
class BugsTab(gtk.VBox):
36
class BugsTab(gtk.Table):
54
38
def __init__(self):
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)
39
super(BugsTab, self).__init__(rows=5, columns=2)
40
self.set_row_spacings(6)
41
self.set_col_spacings(6)
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.")
45
for c in self.get_children():
48
self.hide_all() # Only shown when there are bugs
126
50
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)
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)
139
61
class SignatureTab(gtk.VBox):
222
144
"This revision has not been signed.")
224
146
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():
147
key = crypt.verify(crypttext)
149
if key.is_available():
238
150
if key.is_trusted():
239
151
if key.get_display_name() == self.revision.committer:
240
152
self.signature_image.set_from_file(icon_path("sign-ok.png"))
260
172
trust = key.get_trust()
262
if trust <= seahorse.TRUST_NEVER:
174
if trust <= crypt.TRUST_NEVER:
263
175
trust_text = 'never trusted'
264
elif trust == seahorse.TRUST_UNKNOWN:
176
elif trust == crypt.TRUST_UNKNOWN:
265
177
trust_text = 'not trusted'
266
elif trust == seahorse.TRUST_MARGINAL:
178
elif trust == crypt.TRUST_MARGINAL:
267
179
trust_text = 'marginally trusted'
268
elif trust == seahorse.TRUST_FULL:
180
elif trust == crypt.TRUST_FULL:
269
181
trust_text = 'fully trusted'
270
elif trust == seahorse.TRUST_ULTIMATE:
182
elif trust == crypt.TRUST_ULTIMATE:
271
183
trust_text = 'ultimately trusted'
273
185
self.signature_key_id_label.show()
458
371
def _update_signature(self, widget, param):
459
if self.get_current_page() == PAGE_SIGNATURE:
460
self.signature_table.set_revision(self._revision)
462
def _update_bugs(self, widget, param):
463
self.bugs_page.set_revision(self._revision)
464
label = self.get_tab_label(self.bugs_page)
465
label.set_sensitive(self.bugs_page.get_num_bugs() != 0)
372
self.signature_table.set_revision(self._revision)
467
374
def set_children(self, children):
468
375
self._add_parents_or_children(children,
469
376
self.children_widgets,
470
377
self.children_table)
472
def _switch_page_cb(self, notebook, page, page_num):
473
if page_num == PAGE_SIGNATURE:
474
self.signature_table.set_revision(self._revision)
478
379
def _show_clicked_cb(self, widget, revid, parentid):
479
380
"""Callback for when the show button for a parent is clicked."""
480
381
self._show_callback(revid, parentid)