Changeset 8888

Show
Ignore:
Timestamp:
10/07/07 19:22:47 (14 months ago)
Author:
asterix
Message:

NonModalConfirmationDialog? and ConfirmationDialognow? automaticaly close window on ok or cancel. fixes #3486

Location:
trunk/src
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/config.py

    r8737 r8888  
    16461646                                        break 
    16471647                # Detect if we have opened windows for this account 
    1648                 self.dialog = None 
    1649                 def remove(widget, account): 
    1650                         if self.dialog: 
    1651                                 self.dialog.destroy() 
     1648                def remove(account): 
    16521649                        if gajim.interface.instances[account].has_key('remove_account'): 
    16531650                                gajim.interface.instances[account]['remove_account'].window.\ 
     
    16571654                                        RemoveAccountWindow(account) 
    16581655                if win_opened: 
    1659                         self.dialog = dialogs.ConfirmationDialog( 
     1656                        dialog = dialogs.ConfirmationDialog( 
    16601657                                _('You have opened chat in account %s') % account, 
    16611658                                _('All chat and groupchat windows will be closed. Do you want to ' 
     
    16631660                                on_response_ok = (remove, account)) 
    16641661                else: 
    1665                         remove(widget, account) 
     1662                        remove(account) 
    16661663 
    16671664        def on_rename_button_clicked(self, widget): 
     
    25252522 
    25262523        def on_remove_button_clicked(self, widget): 
    2527                 def remove(widget): 
    2528                         if self.dialog: 
    2529                                 self.dialog.destroy() 
     2524                def remove(): 
    25302525                        if gajim.connections[self.account].connected and \ 
    25312526                        not self.remove_and_unregister_radiobutton.get_active(): 
     
    25502545                                self._on_remove_success(True) 
    25512546 
    2552                 self.dialog = None 
    25532547                if gajim.connections[self.account].connected: 
    2554                         self.dialog = dialogs.ConfirmationDialog( 
     2548                        dialog = dialogs.ConfirmationDialog( 
    25552549                                _('Account "%s" is connected to the server') % self.account, 
    25562550                                _('If you remove it, the connection will be lost.'), 
    25572551                                on_response_ok = remove) 
    25582552                else: 
    2559                         remove(None) 
     2553                        remove() 
    25602554         
    25612555        def _on_remove_success(self, res): 
  • trunk/src/dialogs.py

    r8882 r8888  
    10171017        def __init__(self, pritext, sectext='', on_response_ok = None, 
    10181018        on_response_cancel = None): 
     1019                self.user_response_ok = on_response_ok 
     1020                self.user_response_cancel = on_response_cancel 
    10191021                HigDialog.__init__(self, None,  
    10201022                        gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext, 
    1021                         on_response_ok, on_response_cancel) 
     1023                        self.on_response_ok, self.on_response_cancel) 
    10221024                self.popup() 
     1025 
     1026        def on_response_ok(self, widget): 
     1027                if self.user_response_ok: 
     1028                        if isinstance(self.user_response_ok, tuple): 
     1029                                self.user_response_ok[0](*self.user_response_ok[1:]) 
     1030                        else: 
     1031                                self.user_response_ok() 
     1032                self.destroy() 
     1033 
     1034        def on_response_cancel(self, widget): 
     1035                if self.user_response_cancel: 
     1036                        if isinstance(self.user_response_cancel, tuple): 
     1037                                self.user_response_cancel[0](*self.user_response_ok[1:]) 
     1038                        else: 
     1039                                self.user_response_cancel() 
     1040                self.destroy() 
    10231041 
    10241042class NonModalConfirmationDialog(HigDialog): 
     
    10261044        def __init__(self, pritext, sectext='', on_response_ok = None, 
    10271045        on_response_cancel = None): 
     1046                self.user_response_ok = on_response_ok 
     1047                self.user_response_cancel = on_response_cancel 
    10281048                HigDialog.__init__(self, None,  
    10291049                        gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext, 
    1030                         on_response_ok, on_response_cancel) 
     1050                        self.on_response_ok, self.on_response_cancel) 
    10311051                self.set_modal(False) 
     1052 
     1053        def on_response_ok(self, widget): 
     1054                if self.user_response_ok: 
     1055                        if isinstance(self.user_response_ok, tuple): 
     1056                                self.user_response_ok[0](*self.user_response_ok[1:]) 
     1057                        else: 
     1058                                self.user_response_ok() 
     1059                self.destroy() 
     1060 
     1061        def on_response_cancel(self, widget): 
     1062                if self.user_response_cancel: 
     1063                        if isinstance(self.user_response_cancel, tuple): 
     1064                                self.user_response_cancel[0](*self.user_response_ok[1:]) 
     1065                        else: 
     1066                                self.user_response_cancel() 
     1067                self.destroy() 
    10321068 
    10331069class WarningDialog(HigDialog): 
  • trunk/src/filetransfers_window.py

    r8571 r8888  
    295295                dialog, dialog2 = None, None 
    296296 
    297                 def on_response_ok(widget, account, contact, file_props): 
    298                         dialog.destroy() 
     297                def on_response_ok(account, contact, file_props): 
    299298 
    300299                        def on_ok(widget, account, contact, file_props): 
     
    349348                                on_cancel(widget, account, contact, file_props)) 
    350349 
    351                 def on_response_cancel(widget, account, file_props): 
    352                         dialog.destroy() 
     350                def on_response_cancel(account, file_props): 
    353351                        gajim.connections[account].send_file_rejection(file_props) 
    354352 
  • trunk/src/groupchat_control.py

    r8882 r8888  
    851851        def on_send_file(self, widget, gc_contact): 
    852852                '''sends a file to a contact in the room''' 
    853                 def _on_send_files(widget, gc_c): 
    854                         if widget: 
    855                                 widget.destroy() 
     853                def _on_send_files(gc_c): 
    856854                        gajim.interface.instances['file_transfers'].show_file_send_request( 
    857855                                self.account, gc_c) 
     
    866864                        dialog.popup() 
    867865                else: 
    868                         _on_send_files(None, gc_contact) 
     866                        _on_send_files(gc_contact) 
    869867 
    870868        def draw_contact(self, nick, selected=False, focus=False): 
  • trunk/src/gtkgui_helpers.py

    r8882 r8888  
    751751default_name = ''): 
    752752        def on_ok(widget): 
    753                 def on_ok2(widget, file_path, pixbuf): 
     753                def on_ok2(file_path, pixbuf): 
    754754                        pixbuf.save(file_path, 'jpeg') 
    755                         dialog2.destroy() 
    756755                        dialog.destroy() 
    757756 
     
    807806                                os.remove(file_path) 
    808807                        new_file_path = '.'.join(file_path.split('.')[:-1]) + '.jpeg' 
    809                         dialog2 = dialogs.ConfirmationDialog(_('Extension not supported'), 
     808                        dialogs.ConfirmationDialog(_('Extension not supported'), 
    810809                                _('Image cannot be saved in %(type)s format. Save as %(new_filename)s?') % {'type': type_, 'new_filename': new_file_path}, 
    811810                                on_response_ok = (on_ok2, new_file_path, pixbuf)) 
  • trunk/src/history_manager.py

    r8509 r8888  
    482482                        return 
    483483 
    484                 def on_ok(widget, liststore, list_of_paths): 
     484                def on_ok(liststore, list_of_paths): 
    485485                        # delete all rows from db that match jid_id 
    486                         self.dialog.destroy() 
    487486                        list_of_rowrefs = [] 
    488487                        for path in list_of_paths: # make them treerowrefs (it's needed) 
     
    515514                        'Do you really want to delete logs of the selected contacts?', 
    516515                        paths_len) 
    517                 self.dialog = dialogs.ConfirmationDialog(pri_text, 
     516                dialogs.ConfirmationDialog(pri_text, 
    518517                        _('This is an irreversible operation.'), on_response_ok = (on_ok, 
    519518                        liststore, list_of_paths)) 
     
    524523                        return 
    525524 
    526                 def on_ok(widget, liststore, list_of_paths): 
    527                         self.dialog.destroy() 
     525                def on_ok(liststore, list_of_paths): 
    528526                        # delete rows from db that match log_line_id 
    529527                        list_of_rowrefs = [] 
     
    551549                        'Do you really want to delete the selected message?', 
    552550                        'Do you really want to delete the selected messages?', paths_len) 
    553                 self.dialog = dialogs.ConfirmationDialog(pri_text, 
     551                dialogs.ConfirmationDialog(pri_text, 
    554552                        _('This is an irreversible operation.'), on_response_ok = (on_ok, 
    555553                        liststore, list_of_paths)) 
  • trunk/src/roster_window.py

    r8882 r8888  
    15251525                                return 
    15261526 
    1527                 def remove(widget, list_): 
    1528                         self.dialog.destroy() 
     1527                def remove(list_): 
    15291528                        for (contact, account) in list_: 
    15301529                                full_jid = contact.get_full_jid() 
     
    15581557                        sectext = _('You will no longer be able to send and receive messages ' 
    15591558                                'to contacts from these transports:%s') % jids 
    1560                 self.dialog = dialogs.ConfirmationDialog(pritext, sectext, 
     1559                dialogs.ConfirmationDialog(pritext, sectext, 
    15611560                        on_response_ok = (remove, list_)) 
    15621561 
     
    33463345                                                gajim.events.remove_events(account, contact.jid) 
    33473346                                        self.readd_if_needed(contact, account) 
     3347 
     3348                def on_ok2(list_): 
     3349                        on_ok(False, list_) 
     3350 
    33483351                if len(list_) == 1: 
    33493352                        contact = list_[0][0] 
     
    33523355                                contact.get_shown_name() 
    33533356                        if contact.sub == 'to': 
    3354                                 self.dialog = dialogs.ConfirmationDialog(pritext, 
     3357                                dialogs.ConfirmationDialog(pritext, 
    33553358                                        _('By removing this contact you also remove authorization ' 
    33563359                                        'resulting in him or her always seeing you as offline.'), 
    3357                                         on_response_ok = (on_ok, list_)) 
     3360                                        on_response_ok = (on_ok2, list_)) 
    33583361                        else: 
    3359                                 self.dialog = dialogs.ConfirmationDialogCheck(pritext, 
     3362                                dialogs.ConfirmationDialogCheck(pritext, 
    33603363                                        _('By removing this contact you also by default remove ' 
    33613364                                        'authorization resulting in him or her always seeing you as ' 
     
    33723375                                'authorization resulting in them always seeing you as offline.') % \ 
    33733376                                jids 
    3374                         self.dialog = dialogs.ConfirmationDialog(pritext, sectext, 
     3377                        dialogs.ConfirmationDialog(pritext, sectext, 
    33753378                                on_response_ok = (on_ok, list_)) 
    33763379 
     
    35313534 
    35323535        def change_status(self, widget, account, status): 
    3533                 def change(widget, account, status): 
    3534                         if self.dialog: 
    3535                                 self.dialog.destroy() 
     3536                def change(account, status): 
    35363537                        message = self.get_status_message(status) 
    35373538                        if message is None: 
     
    35403541                        self.send_status(account, status, message) 
    35413542 
    3542                 self.dialog = None 
    35433543                if status == 'invisible' and self.connected_rooms(account): 
    3544                         self.dialog = dialogs.ConfirmationDialog( 
     3544                        dialogs.ConfirmationDialog( 
    35453545                                _('You are participating in one or more group chats'), 
    35463546                                _('Changing your status to invisible will result in disconnection ' 
     
    35483548                                on_response_ok = (change, account, status)) 
    35493549                else: 
    3550                         change(None, account, status) 
     3550                        change(account, status) 
    35513551 
    35523552        def on_send_custom_status(self, widget, contact_list, show, group=None): 
     
    49374937                        uri_splitted = uri.split() # we may have more than one file dropped 
    49384938                        nb_uri = len(uri_splitted) 
    4939                         def _on_send_files(widget, account, jid, uris): 
    4940                                 dialog.destroy() 
     4939                        def _on_send_files(account, jid, uris): 
    49414940                                c = gajim.contacts.get_contact_with_highest_priority(account, jid) 
    49424941                                for uri in uris: 
     
    49534952                                path = helpers.get_file_path_from_dnd_dropped_uri(uri) 
    49544953                                sec_text += '\n' + os.path.basename(path) 
    4955                         dialog = dialogs.NonModalConfirmationDialog(prim_text, sec_text, 
     4954                        dialogs.NonModalConfirmationDialog(prim_text, sec_text, 
    49564955                                on_response_ok = (_on_send_files, account_dest, jid_dest, 
    49574956                                uri_splitted))