it is not possible to launch a dialog.run() in a timeout function, so here is a workaround to do the same thing
This commit is contained in:
parent
4ab3c89742
commit
d474d149f7
|
@ -217,23 +217,50 @@ class passphrase_Window:
|
|||
"""Class for Passphrase Window"""
|
||||
def run(self):
|
||||
"""Wait for Ok button to be pressed and return passphrase"""
|
||||
win = self.xml.get_widget("Passphrase")
|
||||
rep = win.run()
|
||||
rep = self.win.run()
|
||||
if rep == gtk.RESPONSE_OK:
|
||||
msg = self.entry.get_text()
|
||||
else:
|
||||
msg = -1
|
||||
win.destroy()
|
||||
self.win.destroy()
|
||||
return msg
|
||||
|
||||
def on_key_pressed(self, widget, event):
|
||||
if event.keyval == gtk.keysyms.Return:
|
||||
self.xml.get_widget("Passphrase").response(gtk.RESPONSE_OK)
|
||||
if self.autoconnect:
|
||||
self.on_ok_clicked(widget)
|
||||
else:
|
||||
self.win.response(gtk.RESPONSE_OK)
|
||||
|
||||
def __init__(self, txt):
|
||||
def on_ok_clicked(self, widget):
|
||||
if self.autoconnect:
|
||||
self.msg = self.entry.get_text()
|
||||
gtk.main_quit()
|
||||
|
||||
def on_cancel_clicked(self, widget):
|
||||
if self.autoconnect:
|
||||
gtk.main_quit()
|
||||
|
||||
def get_pass(self):
|
||||
self.autoconnect = 0
|
||||
self.win.destroy()
|
||||
return self.msg
|
||||
|
||||
def delete_event(self, widget=None):
|
||||
"""close window"""
|
||||
if self.autoconnect:
|
||||
gtk.main_quit()
|
||||
|
||||
def __init__(self, txt, autoconnect=0):
|
||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Passphrase', APP)
|
||||
self.win = self.xml.get_widget("Passphrase")
|
||||
self.entry = self.xml.get_widget("entry")
|
||||
self.msg = -1
|
||||
self.autoconnect = autoconnect
|
||||
self.xml.get_widget("label").set_text(txt)
|
||||
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
||||
self.xml.signal_connect('on_ok_clicked', self.on_ok_clicked)
|
||||
self.xml.signal_connect('on_cancel_clicked', self.on_cancel_clicked)
|
||||
self.xml.signal_connect('on_Passphrase_key_press_event', \
|
||||
self.on_key_pressed)
|
||||
|
||||
|
|
|
@ -8766,6 +8766,7 @@ when NOT online</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="destroy" handler="gtk_widget_destroy" last_modification_time="Wed, 01 Dec 2004 23:47:26 GMT"/>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox4">
|
||||
|
@ -8788,6 +8789,7 @@ when NOT online</property>
|
|||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-6</property>
|
||||
<signal name="clicked" handler="on_cancel_clicked" last_modification_time="Wed, 01 Dec 2004 23:03:26 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
|
@ -8802,6 +8804,7 @@ when NOT online</property>
|
|||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-5</property>
|
||||
<signal name="clicked" handler="on_ok_clicked" last_modification_time="Wed, 01 Dec 2004 22:45:10 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
|
|
@ -1357,14 +1357,18 @@ class roster_Window:
|
|||
self.remove_user(u, account)
|
||||
del self.contacts[account][u.jid]
|
||||
|
||||
def send_status(self, account, status, txt):
|
||||
def send_status(self, account, status, txt, autoconnect=0):
|
||||
if status != 'offline':
|
||||
save_pass = 0
|
||||
if self.plugin.accounts[account].has_key("savepass"):
|
||||
save_pass = self.plugin.accounts[account]["savepass"]
|
||||
if not save_pass and not self.plugin.connected[account]:
|
||||
passphrase = ''
|
||||
w = passphrase_Window('Enter your password for your account %s' % account)
|
||||
w = passphrase_Window('Enter your password for your account %s' % account, autoconnect)
|
||||
if autoconnect:
|
||||
gtk.main()
|
||||
passphrase = w.get_pass()
|
||||
else:
|
||||
passphrase = w.run()
|
||||
if passphrase == -1:
|
||||
return
|
||||
|
@ -1382,7 +1386,11 @@ class roster_Window:
|
|||
passphrase = self.plugin.accounts[account]['gpgpass']
|
||||
else:
|
||||
passphrase = ''
|
||||
w = passphrase_Window('Enter your passphrase for your the GPG key of your account %s' % account)
|
||||
w = passphrase_Window('Enter your passphrase for your the GPG key of your account %s' % account, autoconnect)
|
||||
if autoconnect:
|
||||
gtk.main()
|
||||
passphrase = w.get_pass()
|
||||
else:
|
||||
passphrase = w.run()
|
||||
if passphrase == -1:
|
||||
passphrase = ''
|
||||
|
@ -2432,7 +2440,7 @@ class plugin:
|
|||
for a in self.accounts.keys():
|
||||
if self.accounts[a].has_key('autoconnect'):
|
||||
if self.accounts[a]['autoconnect']:
|
||||
self.roster.send_status(a, 'online', 'Online')
|
||||
self.roster.send_status(a, 'online', 'Online', 1)
|
||||
return 0
|
||||
|
||||
def __init__(self, quIN, quOUT):
|
||||
|
@ -2513,7 +2521,6 @@ class plugin:
|
|||
self.roster = roster_Window(self)
|
||||
gtk.timeout_add(100, self.read_queue)
|
||||
gtk.timeout_add(100, self.read_sleepy)
|
||||
gtk.timeout_add(100, self.autoconnect)
|
||||
self.sleeper = common.sleepy.Sleepy( \
|
||||
self.config['autoawaytime']*60, \
|
||||
self.config['autoxatime']*60)
|
||||
|
@ -2530,6 +2537,7 @@ class plugin:
|
|||
else:
|
||||
self.systray = systrayDummy()
|
||||
gtk.gdk.threads_enter()
|
||||
self.autoconnect()
|
||||
gtk.main()
|
||||
gtk.gdk.threads_leave()
|
||||
|
||||
|
|
Loading…
Reference in New Issue