/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to revisionview.py

  • Committer: Daniel Schierbeck
  • Date: 2008-03-31 23:55:37 UTC
  • mto: (450.1.16 trunk)
  • mto: This revision was merged to the branch mainline in revision 458.
  • Revision ID: daniel.schierbeck@gmail.com-20080331235537-jv72rvl1wq1a8h53
Made the signature code use the Seahorse D-Bus service.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import pango
22
22
import gobject
23
23
import subprocess
 
24
import dbus
24
25
 
25
26
from bzrlib.plugins.gtk import icon_path
26
27
from bzrlib.osutils import format_date
59
60
class SignatureTab(gtk.VBox):
60
61
 
61
62
    def __init__(self):
62
 
        from gpg import GPGSubprocess
63
 
        self.gpg = GPGSubprocess()
 
63
        bus = dbus.SessionBus()
 
64
        seahorse_object = bus.get_object('org.gnome.seahorse', '/org/gnome/seahorse/crypto')
 
65
        self.seahorse = dbus.Interface(seahorse_object, 'org.gnome.seahorse.CryptoService')
64
66
        super(SignatureTab, self).__init__(False, 6)
65
67
        signature_box = gtk.Table(rows=2, columns=3)
66
68
        signature_box.set_col_spacing(0, 12)
97
99
        self.signature_label.set_text("This revision has not been signed.")
98
100
 
99
101
    def show_signature(self, text):
 
102
        (cleartext, signer) = self.seahorse.VerifyText('openpgp', 0x00000001, text)
 
103
 
100
104
        self.signature_key_id_label.show()
101
 
        signature = self.gpg.verify(text)
102
 
 
103
 
        if signature.key_id is not None:
104
 
            self.signature_key_id.set_text(signature.key_id)
105
 
 
106
 
        if signature.is_valid():
107
 
            self.signature_image.set_from_file(icon_path("sign-ok.png"))
108
 
            self.signature_label.set_text("This revision has been signed.")
109
 
        else:
110
 
            self.signature_image.set_from_file(icon_path("sign-bad.png"))
111
 
            self.signature_label.set_text("This revision has been signed, " + 
112
 
                    "but the authenticity of the signature cannot be verified.")
 
105
        self.signature_key_id.set_text(signer.split(':')[1])
 
106
 
 
107
        self.signature_image.set_from_file(icon_path("sign-ok.png"))
 
108
        self.signature_label.set_text("This revision has been signed.")
113
109
 
114
110
 
115
111
class RevisionView(gtk.Notebook):
376
372
        vbox.show()
377
373
 
378
374
    def _create_signature(self):
379
 
        try:
380
 
            self.signature_table = SignatureTab()
381
 
        except ImportError: # No GPG module installed
382
 
            self.signature_table = None
383
 
            return
 
375
        self.signature_table = SignatureTab()
384
376
        self.append_page(self.signature_table, tab_label=gtk.Label('Signature'))
385
377
        self.connect_after('notify::revision', self._update_signature)
386
378