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