Changeset 9846 for trunk/src/gajim.py

Show
Ignore:
Timestamp:
06/27/08 01:36:58 (5 months ago)
Author:
bct
Message:

first pass at stripping out the one-tab-per-session code

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gajim.py

    r9845 r9846  
    539539                                return 
    540540 
    541                 for ctrl in self.msg_win_mgr.get_chat_controls(jid_from, account): 
    542                         if ctrl.type_id == message_control.TYPE_GC: 
    543                                 ctrl.print_conversation('Error %s: %s' % (array[2], array[1])) 
     541                ctrl = self.msg_win_mgr.get_control(jid_from, account) 
     542                if ctrl and ctrl.type_id == message_control.TYPE_GC: 
     543                        ctrl.print_conversation('Error %s: %s' % (array[2], array[1])) 
    544544 
    545545        def handle_event_con_type(self, account, con_type): 
     
    662662                                # don't have to open a new tab if a new session comes in 
    663663 
    664                                 for ctrl in self.msg_win_mgr.get_chat_controls(jid, account): 
     664                                ctrl = self.msg_win_mgr.get_control(jid, account) 
     665                                if ctrl: 
    665666                                        ctrl.set_session(None) 
    666667 
     
    813814                                nick = jids[1] 
    814815 
    815                                 ctrl = None 
    816816                                if session: 
    817817                                        ctrl = session.control 
    818  
    819                                 if not ctrl: 
    820                                         ctrls = self.msg_win_mgr.get_chat_controls(full_jid_with_resource, account) 
    821                                         if ctrls: 
    822                                                 ctrl = ctrls[0] 
     818                                else: 
     819                                        ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account) 
    823820 
    824821                                if not ctrl: 
     
    11251122                        self.roster.draw_contact(room_jid, account) 
    11261123 
    1127                 # print status in chat windows and update status/GPG image 
    1128                 for ctrl in self.msg_win_mgr.get_chat_controls(fjid, account): 
     1124                # print status in chat window and update status/GPG image 
     1125                ctrl = self.msg_win_mgr.get_control(fjid, account) 
     1126                if ctrl: 
    11291127                        statusCode = array[9] 
    11301128                        if '303' in statusCode: 
     
    18181816 
    18191817        def handle_event_ping_sent(self, account, contact): 
    1820                 for ctrl in self.msg_win_mgr.get_chat_controls(contact.jid, account): 
    1821                         ctrl.print_conversation(_('Ping?'), 'status') 
    1822                 for ctrl in self.msg_win_mgr.get_chat_controls(contact.get_full_jid(), account): 
    1823                         ctrl.print_conversation(_('Ping?'), 'status') 
     1818                for jid in [contact.jid, contact.get_full_jid()]: 
     1819                        ctrl = self.msg_win_mgr.get_control(jid, account) 
     1820                        if ctrl: 
     1821                                ctrl.print_conversation(_('Ping?'), 'status') 
    18241822 
    18251823        def handle_event_ping_reply(self, account, data): 
    18261824                contact = data[0] 
    18271825                seconds = data[1] 
    1828                 for ctrl in self.msg_win_mgr.get_chat_controls(contact.jid, account): 
    1829                         ctrl.print_conversation(_('Pong! (%s s.)') % seconds, 'status') 
    1830                 for ctrl in self.msg_win_mgr.get_chat_controls(contact.get_full_jid(), account): 
    1831                         ctrl.print_conversation(_('Pong! (%s s.)') % seconds, 'status') 
     1826 
     1827                for jid in [contact.jid, contact.get_full_jid()]: 
     1828                        ctrl = self.msg_win_mgr.get_control(jid, account) 
     1829                        if ctrl: 
     1830                                ctrl.print_conversation(_('Pong! (%s s.)') % seconds, 'status') 
    18321831 
    18331832        def handle_event_ping_error(self, account, contact): 
    1834                 for ctrl in self.msg_win_mgr.get_chat_controls(contact.jid, account): 
    1835                         ctrl.print_conversation(_('Error.'), 'status') 
    1836                 for ctrl in self.msg_win_mgr.get_chat_controls(contact.get_full_jid(), account): 
    1837                         ctrl.print_conversation(_('Error.'), 'status') 
     1833                for jid in [contact.jid, contact.get_full_jid()]: 
     1834                        ctrl = self.msg_win_mgr.get_control(jid, account) 
     1835                        if ctrl: 
     1836                                ctrl.print_conversation(_('Error.'), 'status') 
    18381837 
    18391838        def handle_event_search_form(self, account, data): 
     
    21272126                                ctrl = session.control 
    21282127                        elif type_ == '': 
    2129                                 ctrls = self.msg_win_mgr.get_chat_controls(fjid, account) 
    2130  
    2131                                 if ctrls: 
    2132                                         ctrl = ctrls[0] 
     2128                                ctrl = self.msg_win_mgr.get_control(fjid, account) 
    21332129 
    21342130                        if not ctrl: 
     
    25792575                                resource=resource) 
    25802576 
    2581                 ctrls = self.msg_win_mgr.get_chat_controls(fjid, account) 
    2582                 if ctrls: 
    2583                         ctrl = ctrls[0] 
    2584                 else: 
     2577                ctrl = self.msg_win_mgr.get_control(fjid, account) 
     2578 
     2579                if not ctrl: 
    25852580                        ctrl = self.new_chat(contact, account, 
    25862581                                resource=resource)