1
# dialog_apt_key.py.in - edit the apt keys
3
# Copyright (c) 2004 Canonical
5
# Author: Michael Vogt <mvo@debian.org>
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU General Public License as
9
# published by the Free Software Foundation; either version 2 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29
from subprocess import PIPE
33
def dummy(e): return e
37
N_("Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>")
38
N_("Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>")
41
"""This class is currently not used anymore"""
42
def __init__(self, parent, datadir):
44
if os.path.exists("../data/dialogs.glade"):
45
self.gladexml = gtk.glade.XML("../data/dialogs.glade")
47
self.gladexml = gtk.glade.XML("%s/dialogs.glade", datadir)
48
self.main = self.gladexml.get_widget("dialog_apt_key")
49
self.main.set_transient_for(parent)
51
self.gladexml.signal_connect("on_button_key_add_clicked",
52
self.on_button_key_add_clicked)
53
self.gladexml.signal_connect("on_button_key_remove_clicked",
54
self.on_button_key_remove_clicked)
55
self.gladexml.signal_connect("on_button_apt_key_update_clicked",
56
self.on_button_apt_key_update_clicked)
58
# create apt-key object (abstraction for the apt-key command)
59
self.apt_key = apt_key()
62
self.treeview_apt_key = self.gladexml.get_widget("treeview_apt_key")
63
self.liststore_apt_key = gtk.ListStore(str)
64
self.treeview_apt_key.set_model(self.liststore_apt_key)
65
# Create columns and append them.
66
tr = gtk.CellRendererText()
67
tr.set_property("xpad", 10)
68
tr.set_property("ypad", 10)
69
c0 = gtk.TreeViewColumn("Key", tr, text=0)
70
self.treeview_apt_key.append_column(c0)
71
self.update_key_list()
73
def on_button_apt_key_update_clicked(self, widget):
75
self.update_key_list()
77
def on_button_key_add_clicked(self, widget):
78
chooser = gtk.FileChooserDialog(title=_("Choose a key-file"),
80
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_REJECT,
81
gtk.STOCK_OK,gtk.RESPONSE_ACCEPT))
84
if res == gtk.RESPONSE_ACCEPT:
85
#print chooser.get_filename()
86
if not self.apt_key.add(chooser.get_filename()):
87
dialog_error(self.main,
88
_("Error importing selected file"),
89
_("The selected file may not be a GPG key file "
90
"or it might be corrupt."))
91
self.update_key_list()
93
def on_button_key_remove_clicked(self, widget):
94
selection = self.treeview_apt_key.get_selection()
95
(model,a_iter) = selection.get_selected()
98
key = model.get_value(a_iter,0)
99
if not self.apt_key.rm(key[:8]):
101
_("Error removing the key"),
102
_("The key you selected could not be removed. "
103
"Please report this as a bug."))
104
self.update_key_list()
106
def update_key_list(self):
107
self.liststore_apt_key.clear()
108
for key in self.apt_key.list():
109
self.liststore_apt_key.append([key])
112
res = self.main.run()
116
if __name__ == "__main__":
117
ui = dialog_apt_key(None)