made PassphraseDialog's checkbutton and modality optional
This commit is contained in:
parent
2623c75ca0
commit
4ed6830870
|
@ -19,6 +19,7 @@
|
|||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<property name="has_separator">True</property>
|
||||
<signal name="destroy" handler="on_passphrase_dialog_destroy" last_modification_time="Sun, 11 Mar 2007 11:32:38 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox4">
|
||||
|
|
|
@ -238,23 +238,69 @@ class PassphraseDialog:
|
|||
passphrase = self.passphrase_entry.get_text().decode('utf-8')
|
||||
else:
|
||||
passphrase = -1
|
||||
save_passphrase_checkbutton = self.xml.\
|
||||
get_widget('save_passphrase_checkbutton')
|
||||
self.window.destroy()
|
||||
return passphrase, save_passphrase_checkbutton.get_active()
|
||||
|
||||
def __init__(self, titletext, labeltext, checkbuttontext):
|
||||
if self.check:
|
||||
save_passphrase_checkbutton = self.xml.\
|
||||
get_widget('save_passphrase_checkbutton')
|
||||
checked = save_passphrase_checkbutton.get_active()
|
||||
else:
|
||||
checked = False
|
||||
|
||||
self.window.destroy()
|
||||
return passphrase, checked
|
||||
|
||||
def __init__(self, titletext, labeltext, checkbuttontext=None, is_modal = True,
|
||||
ok_handler = None, cancel_handler = None):
|
||||
self.xml = gtkgui_helpers.get_glade('passphrase_dialog.glade')
|
||||
self.window = self.xml.get_widget('passphrase_dialog')
|
||||
self.passphrase_entry = self.xml.get_widget('passphrase_entry')
|
||||
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.ok = False
|
||||
|
||||
self.cancel_handler = cancel_handler
|
||||
self.is_modal = is_modal
|
||||
if not is_modal and ok_handler is not None:
|
||||
self.ok_handler = ok_handler
|
||||
okbutton = self.xml.get_widget('ok_button')
|
||||
okbutton.connect('clicked', self.on_okbutton_clicked)
|
||||
cancelbutton = self.xml.get_widget('cancel_button')
|
||||
cancelbutton.connect('clicked', self.on_cancelbutton_clicked)
|
||||
|
||||
self.xml.signal_autoconnect(self)
|
||||
self.window.show_all()
|
||||
|
||||
self.check = bool(checkbuttontext)
|
||||
checkbutton = self.xml.get_widget('save_passphrase_checkbutton')
|
||||
if self.check:
|
||||
checkbutton.set_label(checkbuttontext)
|
||||
else:
|
||||
checkbutton.hide()
|
||||
|
||||
def on_okbutton_clicked(self, widget):
|
||||
passph = self.passphrase_entry.get_text().decode('utf-8')
|
||||
|
||||
if self.check:
|
||||
checked = self.xml.get_widget('save_passphrase_checkbutton').\
|
||||
get_active()
|
||||
else:
|
||||
checked = False
|
||||
|
||||
self.ok = True
|
||||
|
||||
self.window.destroy()
|
||||
|
||||
self.ok_handler(passph, checked)
|
||||
|
||||
def on_cancelbutton_clicked(self, widget):
|
||||
self.window.destroy()
|
||||
|
||||
def on_passphrase_dialog_destroy(self, widget):
|
||||
if self.cancel_handler and not self.ok:
|
||||
self.cancel_handler()
|
||||
|
||||
class ChooseGPGKeyDialog:
|
||||
'''Class for GPG key dialog'''
|
||||
def __init__(self, title_text, prompt_text, secret_keys, selected = None):
|
||||
|
|
Loading…
Reference in New Issue