Changeset 10158

Show
Ignore:
Timestamp:
08/08/08 19:03:56 (2 months ago)
Author:
asterix
Message:

fix closing a tab

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/message_window.py

    r10157 r10158  
    440440                '''reason is only for gc (offline status message) 
    441441                if force is True, do not ask any confirmation''' 
     442                def close(ctrl): 
     443                        if reason is not None: # We are leaving gc with a status message 
     444                                ctrl.shutdown(reason) 
     445                        else: # We are leaving gc without status message or it's a chat 
     446                                ctrl.shutdown() 
     447                        # Update external state 
     448                        gajim.events.remove_events(ctrl.account, ctrl.get_full_jid, 
     449                                types = ['printed_msg', 'chat', 'gc_msg']) 
     450 
     451                        fjid = ctrl.get_full_jid() 
     452                        jid = gajim.get_jid_without_resource(fjid) 
     453 
     454                        fctrl = self.get_control(fjid, ctrl.account) 
     455                        bctrl = self.get_control(jid, ctrl.account) 
     456                        # keep last_message_time around unless this was our last control with 
     457                        # that jid 
     458                        if not fctrl and not bctrl: 
     459                                del gajim.last_message_time[ctrl.account][fjid] 
     460 
     461                        # Disconnect tab DnD only if GTK version < 2.10 
     462                        if gtk.pygtk_version < (2, 10, 0) or gtk.gtk_version < (2, 10, 0): 
     463                                self.disconnect_tab_dnd(ctrl.widget) 
     464 
     465                        self.notebook.remove_page(self.notebook.page_num(ctrl.widget)) 
     466 
     467                        del self._controls[ctrl.account][fjid] 
     468 
     469                        if len(self._controls[ctrl.account]) == 0: 
     470                                del self._controls[ctrl.account] 
     471 
     472                        self.check_tabs() 
     473                        self.show_title() 
     474 
     475                def on_yes(ctrl): 
     476                        close(ctrl) 
     477 
     478                def on_no(ctrl): 
     479                        if not force: 
     480                                return 
     481                        close(ctrl) 
     482 
     483                def on_minimize(ctrl): 
     484                        if method != self.CLOSE_COMMAND: 
     485                                ctrl.minimize() 
     486                                self.check_tabs() 
     487                                return 
     488                        close(ctrl) 
     489 
    442490                # Shutdown the MessageControl 
    443                 allow_shutdown = ctrl.allow_shutdown(method) 
    444                 if not force and allow_shutdown == 'no': 
    445                         return 
    446                 if allow_shutdown == 'minimize' and method != self.CLOSE_COMMAND: 
    447                         ctrl.minimize() 
    448                         self.check_tabs() 
    449                         return 
    450                 if reason is not None: # We are leaving gc with a status message 
    451                         ctrl.shutdown(reason) 
    452                 else: # We are leaving gc without status message or it's a chat 
    453                         ctrl.shutdown() 
    454  
    455                 # Update external state 
    456                 gajim.events.remove_events(ctrl.account, ctrl.get_full_jid, 
    457                         types = ['printed_msg', 'chat', 'gc_msg']) 
    458  
    459                 fjid = ctrl.get_full_jid() 
    460                 jid = gajim.get_jid_without_resource(fjid) 
    461  
    462                 fctrl = self.get_control(fjid, ctrl.account) 
    463                 bctrl = self.get_control(jid, ctrl.account) 
    464                 # keep last_message_time around unless this was our last control with 
    465                 # that jid 
    466                 if not fctrl and not bctrl: 
    467                         del gajim.last_message_time[ctrl.account][fjid] 
    468  
    469                 # Disconnect tab DnD only if GTK version < 2.10 
    470                 if gtk.pygtk_version < (2, 10, 0) or gtk.gtk_version < (2, 10, 0): 
    471                         self.disconnect_tab_dnd(ctrl.widget) 
    472  
    473                 self.notebook.remove_page(self.notebook.page_num(ctrl.widget)) 
    474  
    475                 del self._controls[ctrl.account][fjid] 
    476  
    477                 if len(self._controls[ctrl.account]) == 0: 
    478                         del self._controls[ctrl.account] 
    479  
    480                 self.check_tabs() 
    481                 self.show_title() 
     491                ctrl.allow_shutdown(method, on_yes, on_no, on_minimize) 
    482492 
    483493        def check_tabs(self):