Changeset 10138

Show
Ignore:
Timestamp:
08/06/08 22:34:36 (4 months ago)
Author:
asterix
Message:

make EditGroups? and ChangePassword? dialogs asynchronous. see #4147

Location:
trunk/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/config.py

    r10101 r10138  
    18811881 
    18821882        def on_change_password_button1_clicked(self, widget): 
     1883                def on_changed(new_password): 
     1884                        if new_password is not None: 
     1885                                gajim.connections[self.current_account].change_password( 
     1886                                        new_password) 
     1887                                if self.xml.get_widget('save_password_checkbutton1').get_active(): 
     1888                                        self.xml.get_widget('password_entry1').set_text(new_password) 
     1889 
    18831890                try: 
    1884                         dialog = dialogs.ChangePasswordDialog(self.current_account) 
     1891                        dialog = dialogs.ChangePasswordDialog(self.current_account, on_changed) 
    18851892                except GajimGeneralException: 
    18861893                        # if we showed ErrorDialog, there will not be dialog instance 
    18871894                        return 
    1888  
    1889                 new_password = dialog.run() 
    1890                 if new_password != -1: 
    1891                         gajim.connections[self.current_account].change_password(new_password) 
    1892                         if self.xml.get_widget('save_password_checkbutton1').get_active(): 
    1893                                 self.xml.get_widget('password_entry1').set_text(new_password) 
    18941895 
    18951896        def on_autoconnect_checkbutton_toggled(self, widget): 
  • trunk/src/dialogs.py

    r10131 r10138  
    8282                self.init_list() 
    8383 
    84         def run(self): 
    8584                self.dialog.show_all() 
    8685                if self.changes_made: 
     
    19801979 
    19811980class ChangePasswordDialog: 
    1982         def __init__(self, account): 
     1981        def __init__(self, account, on_response): 
    19831982                # 'account' can be None if we are about to create our first one 
    19841983                if not account or gajim.connections[account].connected < 2: 
     
    19871986                        raise GajimGeneralException, 'You are not connected to the server' 
    19881987                self.account = account 
     1988                self.on_response = on_response 
    19891989                self.xml = gtkgui_helpers.get_glade('change_password_dialog.glade') 
    19901990                self.dialog = self.xml.get_widget('change_password_dialog') 
    19911991                self.password1_entry = self.xml.get_widget('password1_entry') 
    19921992                self.password2_entry = self.xml.get_widget('password2_entry') 
     1993                self.dialog.connect('response', self.on_dialog_response) 
    19931994 
    19941995                self.dialog.show_all() 
    19951996 
    1996         def run(self): 
    1997                 '''Wait for OK button to be pressed and return new password''' 
    1998                 end = False 
    1999                 while not end: 
    2000                         rep = self.dialog.run() 
    2001                         if rep == gtk.RESPONSE_OK: 
    2002                                 password1 = self.password1_entry.get_text().decode('utf-8') 
    2003                                 if not password1: 
    2004                                         ErrorDialog(_('Invalid password'), 
    2005                                                         _('You must enter a password.')) 
    2006                                         continue 
    2007                                 password2 = self.password2_entry.get_text().decode('utf-8') 
    2008                                 if password1 != password2: 
    2009                                         ErrorDialog(_('Passwords do not match'), 
    2010                                                         _('The passwords typed in both fields must be identical.')) 
    2011                                         continue 
    2012                                 message = password1 
    2013                         else: 
    2014                                 message = -1 
    2015                         end = True 
    2016                 self.dialog.destroy() 
    2017                 return message 
    2018  
     1997        def on_dialog_response(self, dialog, response): 
     1998                if response != gtk.RESPONSE_OK: 
     1999                        dialog.destroy() 
     2000                        self.on_response(None) 
     2001                        return 
     2002                password1 = self.password1_entry.get_text().decode('utf-8') 
     2003                if not password1: 
     2004                        ErrorDialog(_('Invalid password'), _('You must enter a password.')) 
     2005                        return 
     2006                password2 = self.password2_entry.get_text().decode('utf-8') 
     2007                if password1 != password2: 
     2008                        ErrorDialog(_('Passwords do not match'), 
     2009                                _('The passwords typed in both fields must be identical.')) 
     2010                        return 
     2011                dialog.destroy() 
     2012                self.on_response(password1) 
    20192013 
    20202014class PopupNotificationWindow: 
  • trunk/src/roster_window.py

    r10137 r10138  
    27282728 
    27292729        def on_remove_group_item_activated(self, widget, group, account): 
    2730                 dlg = dialogs.ConfirmationDialogCheck(_('Remove Group'), 
     2730                dialogs.ConfirmationDialogCheck(_('Remove Group'), 
    27312731                        _('Do you want to remove group %s from the roster?' % group), 
    2732                         _('Remove also all contacts in this group from your roster')) 
    2733                 dlg.set_default_response(gtk.BUTTONS_OK_CANCEL) 
    2734                 response = dlg.run() 
    2735                 if response == gtk.RESPONSE_OK: 
     2732                        _('Remove also all contacts in this group from your roster'), 
     2733                        on_response_ok=on_ok) 
     2734                def on_ok(checked): 
    27362735                        for contact in gajim.contacts.get_contacts_from_group(account, group): 
    2737                                 if not dlg.is_checked(): 
     2736                                if not checked: 
    27382737                                        self.remove_contact_from_groups(contact.jid,account, [group]) 
    27392738                                else: 
     
    28212820 
    28222821        def on_edit_groups(self, widget, list_): 
    2823                 dlg = dialogs.EditGroupsDialog(list_) 
    2824                 dlg.run() 
     2822                dialogs.EditGroupsDialog(list_) 
    28252823 
    28262824        def on_history(self, widget, contact, account):