/usr/lib/python2.7/dist-packages/keysign/SignPages.py is in gnome-keysign 0.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | #!/usr/bin/env python
# Copyright 2014 Andrei Macavei <andrei.macavei89@gmail.com>
# Copyright 2014, 2015 Tobias Mueller <muelli@cryptobitch.de>
#
# This file is part of GNOME Keysign.
#
# GNOME Keysign is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNOME Keysign is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNOME Keysign. If not, see <http://www.gnu.org/licenses/>.
from itertools import islice
import logging
import sys
from gi.repository import GObject, Gtk, GLib
from datetime import datetime
from compat import gtkbutton
from scan_barcode import BarcodeReaderGTK, ScalingImage
log = logging.getLogger(__name__)
# Pages for "Get Key" Tab
class ScanFingerprintPage(Gtk.HBox):
def __init__(self):
super(ScanFingerprintPage, self).__init__()
self.set_spacing(10)
# set up labels
leftLabel = Gtk.Label()
leftLabel.set_markup('Type fingerprint')
rightLabel = Gtk.Label()
rightLabel.set_markup('... or scan QR code')
# set up text editor
self.textview = Gtk.TextView()
self.textbuffer = self.textview.get_buffer()
# set up scrolled window
scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.add(self.textview)
# set up webcam frame
scanFrame = Gtk.Frame(label='QR Scanner')
scanFrame = BarcodeReaderGTK()
scanFrame.set_size_request(150,150)
scanFrame.show()
self.barcode_scanner = scanFrame
# set up load button: this will be used to load a qr code from a file
self.loadButton = Gtk.Button('Open Image')
self.loadButton.set_image(Gtk.Image.new_from_icon_name('gtk-open', Gtk.IconSize.BUTTON))
self.loadButton.connect('clicked', self.on_loadbutton_clicked)
self.loadButton.set_always_show_image(True)
# set up left box
leftBox = Gtk.VBox(spacing=10)
leftBox.pack_start(leftLabel, False, False, 0)
leftBox.pack_start(scrolledwindow, True, True, 0)
# set up right box
rightBox = Gtk.VBox(spacing=10)
rightBox.pack_start(rightLabel, False, False, 0)
rightBox.pack_start(scanFrame, True, True, 0)
rightBox.pack_start(self.loadButton, False, False, 0)
# pack up
self.pack_start(leftBox, True, True, 0)
self.pack_start(rightBox, True, True, 0)
def get_text(self):
'''Returns the contents of the fingerprint
input widget. Note that this function does
not format or validate anything.
'''
start_iter = self.textbuffer.get_start_iter()
end_iter = self.textbuffer.get_end_iter()
raw_text = self.textbuffer.get_text(start_iter, end_iter, False)
return raw_text
def on_loadbutton_clicked(self, *args, **kwargs):
print("load")
def on_barcode (self, barcode_reader, barcode, gstmessage, pixbuf):
self.emit ("barcode_scanned", barcode, gstmessage, pixbuf)
class SignKeyPage(Gtk.HBox):
def __init__(self, key, image=None):
super(SignKeyPage, self).__init__()
self.set_spacing(5)
self.mainLabel = Gtk.Label()
self.mainLabel.set_line_wrap(True)
self.pack_start(self.mainLabel, False, True, 0)
self.barcode_image = ScalingImage()
self.pack_start(self.barcode_image, True, True, 0)
self.display_downloaded_key(key, None, image)
def display_downloaded_key(self, key, scanned_fpr, image):
# FIXME: If the two fingerprints don't match, the button
# should be disabled
key_text = GLib.markup_escape_text("{}".format(key))
markup = """\
Signing the following key
<b>{0}</b>
Press 'Next' if you have checked the ID of the person
and you want to sign all UIDs on this key.""".format(key_text)
self.mainLabel.set_markup(markup)
self.mainLabel.show()
# The image *can* be None, if the user typed the fingerprint manually,
# e.g. did not use Web cam to scan a QR-code
if image:
self.barcode_image.set_from_pixbuf(image)
class PostSignPage(Gtk.VBox):
def __init__(self):
super(PostSignPage, self).__init__()
self.set_spacing(10)
# setup the label
signedLabel = Gtk.Label()
signedLabel.set_text('The key was signed and an email was sent to key owner! What next?')
# setup the buttons
sendBackButton = Gtk.Button(' Resend email ')
sendBackButton.set_image(Gtk.Image.new_from_icon_name("gtk-network", Gtk.IconSize.BUTTON))
sendBackButton.set_always_show_image(True)
sendBackButton.set_halign(Gtk.Align.CENTER)
saveButton = Gtk.Button(' Save key locally ')
saveButton.set_image(Gtk.Image.new_from_icon_name("gtk-save", Gtk.IconSize.BUTTON))
saveButton.set_always_show_image(True)
saveButton.set_halign(Gtk.Align.CENTER)
emailButton = Gtk.Button('Revoke signature')
emailButton.set_image(Gtk.Image.new_from_icon_name("gtk-clear", Gtk.IconSize.BUTTON))
emailButton.set_always_show_image(True)
emailButton.set_halign(Gtk.Align.CENTER)
# pack them into a container for alignment
container = Gtk.VBox(spacing=3)
container.pack_start(signedLabel, False, False, 5)
container.pack_start(sendBackButton, False, False, 0)
container.pack_start(saveButton, False, False, 0)
container.pack_start(emailButton, False, False, 0)
container.set_valign(Gtk.Align.CENTER)
self.pack_start(container, True, False, 0)
|