Commit d35791d1 authored by nkour's avatar nkour

ChooseGPGKeyDialog no longer creates another loop

parent aecbf2ff
......@@ -1329,9 +1329,10 @@ _('Without a connection, you can not edit your personal information.')
_('There was a problem retrieving your GPG secret keys.')).get_response()
return
secret_keys['None'] = 'None'
w = dialogs.ChooseGPGKeyDialog(_('Passphrase'), _('Choose your OpenPGP key'), secret_keys)
keyID = w.run()
if keyID == -1:
instance = dialogs.ChooseGPGKeyDialog(_('Passphrase'),
_('Choose your OpenPGP key'), secret_keys)
keyID = instance.keyID
if keyID is None:
return
checkbutton = self.xml.get_widget('gpg_save_password_checkbutton')
gpg_key_label = self.xml.get_widget('gpg_key_label')
......
......@@ -149,38 +149,20 @@ class PassphraseDialog:
self.passphrase = -1
self.window.set_title(titletext)
self.xml.get_widget('message_label').set_text(labeltext)
self.xml.get_widget('save_passphrase_checkbutton').set_label(checkbuttontext)
self.xml.get_widget('save_passphrase_checkbutton').set_label(
checkbuttontext)
self.xml.signal_autoconnect(self)
self.window.show_all()
class ChooseGPGKeyDialog:
'''Class for GPG key dialog'''
def run(self):
'''Wait for Ok button to be pressed and return the selected key'''
rep = self.window.run()
if rep == gtk.RESPONSE_OK:
selection = self.keys_treeview.get_selection()
(model, iter) = selection.get_selected()
keyID = [model.get_value(iter, 0), model.get_value(iter, 1)]
else:
keyID = -1
self.window.destroy()
return keyID
def fill_tree(self, list, selected):
model = self.keys_treeview.get_model()
for keyID in list.keys():
iter = model.append((keyID, list[keyID]))
if keyID == selected:
path = model.get_path(iter)
self.keys_treeview.set_cursor(path)
def __init__(self, title_text, prompt_text, secret_keys, selected = None):
#list : {keyID: userName, ...}
xml = gtk.glade.XML(GTKGUI_GLADE, 'choose_gpg_key_dialog', APP)
self.window = xml.get_widget('choose_gpg_key_dialog')
self.window.set_title(title_text)
self.keys_treeview = xml.get_widget('keys_treeview')
self.keyID = None
prompt_label = xml.get_widget('prompt_label')
prompt_label.set_text(prompt_text)
model = gtk.ListStore(str, str)
......@@ -193,9 +175,28 @@ class ChooseGPGKeyDialog:
self.keys_treeview.insert_column_with_attributes(-1, _('Contact name'),
renderer, text = 1)
self.fill_tree(secret_keys, selected)
xml.signal_autoconnect(self)
self.window.show_all()
def on_choose_gpg_key_dialog_response(self, widget, response_id):
'''If OK button was pressed return the selected key'''
if response_id == gtk.RESPONSE_OK:
selection = self.keys_treeview.get_selection()
(model, iter) = selection.get_selected()
self.keyID = [ model[iter][0], model[iter][1] ]
self.window.destroy()
def fill_tree(self, list, selected):
model = self.keys_treeview.get_model()
for keyID in list.keys():
iter = model.append((keyID, list[keyID]))
if keyID == selected:
path = model.get_path(iter)
self.keys_treeview.set_cursor(path)
class ChangeStatusMessageDialog:
def __init__(self, plugin, show):
self.show = show
......
......@@ -9629,7 +9629,7 @@ Custom</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="modal">True</property>
<property name="default_width">550</property>
<property name="default_height">300</property>
<property name="resizable">True</property>
......@@ -9641,6 +9641,7 @@ Custom</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">True</property>
<signal name="key_press_event" handler="on_Passphrase_key_press_event" last_modification_time="Thu, 07 Oct 2004 14:25:48 GMT"/>
<signal name="response" handler="on_choose_gpg_key_dialog_response" last_modification_time="Fri, 22 Jul 2005 22:35:39 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="vbox33">
......
......@@ -724,10 +724,10 @@ class RosterWindow:
keyID = attached_keys[2*i+1]
public_keys = gajim.connections[account].ask_gpg_keys()
public_keys['None'] = 'None'
w = dialogs.ChooseGPGKeyDialog(_('Assign OpenPGP Key'), _('Select a key to apply to the contact'),
public_keys, keyID)
keyID = w.run()
if keyID == -1:
instance = dialogs.ChooseGPGKeyDialog(_('Assign OpenPGP Key'),
_('Select a key to apply to the contact'), public_keys, keyID)
keyID = instance.keyID
if keyID is None:
return
if keyID[0] == 'None':
if user.jid in keys:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment