Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2008-08-07 00:34:36 +0400
committerYann Leboulanger <asterix@lagaule.org>2008-08-07 00:34:36 +0400
commitd5a8f7508041596e1df9fb44841e5eae66d4c39b (patch)
tree2b3462bc2b997efc64d1bc83b7fe2783574ddc0b
parentf5be05a14a8a04fc6664552d68f07d1219a439b2 (diff)
make EditGroups and ChangePassword dialogs asynchronous. see #4147
-rw-r--r--src/config.py15
-rw-r--r--src/dialogs.py44
-rw-r--r--src/roster_window.py14
3 files changed, 33 insertions, 40 deletions
diff --git a/src/config.py b/src/config.py
index cc001fc0c..103d9c6ac 100644
--- a/src/config.py
+++ b/src/config.py
@@ -1880,18 +1880,19 @@ class AccountsWindow:
return
def on_change_password_button1_clicked(self, widget):
+ def on_changed(new_password):
+ if new_password is not None:
+ gajim.connections[self.current_account].change_password(
+ new_password)
+ if self.xml.get_widget('save_password_checkbutton1').get_active():
+ self.xml.get_widget('password_entry1').set_text(new_password)
+
try:
- dialog = dialogs.ChangePasswordDialog(self.current_account)
+ dialog = dialogs.ChangePasswordDialog(self.current_account, on_changed)
except GajimGeneralException:
# if we showed ErrorDialog, there will not be dialog instance
return
- new_password = dialog.run()
- if new_password != -1:
- gajim.connections[self.current_account].change_password(new_password)
- if self.xml.get_widget('save_password_checkbutton1').get_active():
- self.xml.get_widget('password_entry1').set_text(new_password)
-
def on_autoconnect_checkbutton_toggled(self, widget):
if self.ignore_events:
return
diff --git a/src/dialogs.py b/src/dialogs.py
index 932803d8d..ea8139dd7 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -81,7 +81,6 @@ class EditGroupsDialog:
self.xml.signal_autoconnect(self)
self.init_list()
- def run(self):
self.dialog.show_all()
if self.changes_made:
for (contact, account) in self.list_:
@@ -1979,43 +1978,38 @@ class NewChatDialog(InputDialog):
gajim.interface.new_chat_from_jid(self.account, jid)
class ChangePasswordDialog:
- def __init__(self, account):
+ def __init__(self, account, on_response):
# 'account' can be None if we are about to create our first one
if not account or gajim.connections[account].connected < 2:
ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not change your password.'))
raise GajimGeneralException, 'You are not connected to the server'
self.account = account
+ self.on_response = on_response
self.xml = gtkgui_helpers.get_glade('change_password_dialog.glade')
self.dialog = self.xml.get_widget('change_password_dialog')
self.password1_entry = self.xml.get_widget('password1_entry')
self.password2_entry = self.xml.get_widget('password2_entry')
+ self.dialog.connect('response', self.on_dialog_response)
self.dialog.show_all()
- def run(self):
- '''Wait for OK button to be pressed and return new password'''
- end = False
- while not end:
- rep = self.dialog.run()
- if rep == gtk.RESPONSE_OK:
- password1 = self.password1_entry.get_text().decode('utf-8')
- if not password1:
- ErrorDialog(_('Invalid password'),
- _('You must enter a password.'))
- continue
- password2 = self.password2_entry.get_text().decode('utf-8')
- if password1 != password2:
- ErrorDialog(_('Passwords do not match'),
- _('The passwords typed in both fields must be identical.'))
- continue
- message = password1
- else:
- message = -1
- end = True
- self.dialog.destroy()
- return message
-
+ def on_dialog_response(self, dialog, response):
+ if response != gtk.RESPONSE_OK:
+ dialog.destroy()
+ self.on_response(None)
+ return
+ password1 = self.password1_entry.get_text().decode('utf-8')
+ if not password1:
+ ErrorDialog(_('Invalid password'), _('You must enter a password.'))
+ return
+ password2 = self.password2_entry.get_text().decode('utf-8')
+ if password1 != password2:
+ ErrorDialog(_('Passwords do not match'),
+ _('The passwords typed in both fields must be identical.'))
+ return
+ dialog.destroy()
+ self.on_response(password1)
class PopupNotificationWindow:
def __init__(self, event_type, jid, account, msg_type = '',
diff --git a/src/roster_window.py b/src/roster_window.py
index c1a499231..321fb0073 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -2727,14 +2727,13 @@ class RosterWindow:
on_canceled)
def on_remove_group_item_activated(self, widget, group, account):
- dlg = dialogs.ConfirmationDialogCheck(_('Remove Group'),
+ dialogs.ConfirmationDialogCheck(_('Remove Group'),
_('Do you want to remove group %s from the roster?' % group),
- _('Remove also all contacts in this group from your roster'))
- dlg.set_default_response(gtk.BUTTONS_OK_CANCEL)
- response = dlg.run()
- if response == gtk.RESPONSE_OK:
+ _('Remove also all contacts in this group from your roster'),
+ on_response_ok=on_ok)
+ def on_ok(checked):
for contact in gajim.contacts.get_contacts_from_group(account, group):
- if not dlg.is_checked():
+ if not checked:
self.remove_contact_from_groups(contact.jid,account, [group])
else:
gajim.connections[account].unsubscribe(contact.jid)
@@ -2820,8 +2819,7 @@ class RosterWindow:
on_response_clear = on_clear)
def on_edit_groups(self, widget, list_):
- dlg = dialogs.EditGroupsDialog(list_)
- dlg.run()
+ dialogs.EditGroupsDialog(list_)
def on_history(self, widget, contact, account):
'''When history menuitem is activated: call log window'''