Show
Ignore:
Timestamp:
07/19/08 19:36:21 (5 months ago)
Author:
steve-e
Message:

Improved groupchat minimization:

  • partly rewrote join_room because it was hard to read
  • Correctly handle invites from anonymous rooms. Fixes #4057
  • Use HIG dialog for invitation requests
  • Fix bug where minimized groupchats where hidden after a reconnect
  • Removed some duplicated code
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/roster_window.py

    r9945 r9960  
    706706                                self._remove_entity(contact, account) 
    707707 
    708  
    709708                        if backend: 
    710709                                # Remove contact before redrawing, otherwise the old 
     
    731730                ''' 
    732731                contact = gajim.contacts.get_contact_with_highest_priority(account, jid) 
     732                # Do not show gc if we are disconnected and minimize it 
     733                if gajim.account_is_connected(account): 
     734                        show = 'online' 
     735                else:  
     736                        show = 'offline' 
     737                        status = '' 
     738 
    733739                if contact is None: 
    734                         # Do not show gc if we are disconnected and minimize it 
    735                         if gajim.account_is_connected(account): 
    736                                 show = 'online' 
    737                         else:  
    738                                 show = 'offline' 
    739                                 status = '' 
     740                        # New groupchat 
    740741                        contact = gajim.contacts.create_contact(jid=jid, name=jid, 
    741742                                groups=[_('Groupchats')], show=show, status=status, sub='none') 
    742743                        gajim.contacts.add_contact(account, contact) 
     744                        gc_control = gajim.interface.msg_win_mgr.get_gc_control(jid, account) 
     745                        if gc_control: 
     746                                # there is a window that we can minimize 
     747                                gajim.interface.minimized_controls[account][jid] = gc_control 
    743748                        self.add_contact(jid, account) 
    744749                else: 
    745                         contact.show = 'online' 
     750                        contact.show = show 
     751                        contact.status = status 
    746752                        self.draw_completely_and_show_if_needed(jid, account) 
     753 
    747754                return contact 
    748755 
     
    752759                contact = gajim.contacts.get_contact_with_highest_priority(account, jid) 
    753760                if contact.is_groupchat(): 
     761                        if jid in gajim.interface.minimized_controls[account]: 
     762                                gajim.interface.minimized_controls[account][jid] 
    754763                        self.remove_contact(jid, account, force=True, backend=True) 
    755764                        return True 
     
    962971 
    963972                # gets number of unread gc marked messages 
    964                 if jid in gajim.interface.minimized_controls[account]: 
     973                if jid in gajim.interface.minimized_controls[account] and \ 
     974                gajim.interface.minimized_controls[account][jid]: 
    965975                        nb_unread = len(gajim.events.get_events(account, jid, 
    966976                                ['printed_marked_gc_msg'])) 
     
    15821592                return False 
    15831593 
    1584         def auto_join_bookmarks(self, account): 
    1585                 '''autojoin bookmarks that have 'auto join' on for this account''' 
    1586                 for bm in gajim.connections[account].bookmarks: 
    1587                         if bm['autojoin'] in ('1', 'true'): 
    1588                                 jid = bm['jid'] 
    1589                                 if not gajim.gc_connected[account].has_key(jid) or\ 
    1590                                         not gajim.gc_connected[account][jid]: 
    1591                                         # we are not already connected 
    1592                                         minimize = bm['minimize'] in ('1', 'true') 
    1593                                         gajim.interface.join_gc_room(account, jid, bm['nick'], 
    1594                                         bm['password'], minimize = minimize) 
    1595  
    15961594        def on_event_removed(self, event_list): 
    15971595                '''Remove contacts on last events removed. 
     
    26522650        def on_disconnect(self, widget, jid, account): 
    26532651                '''When disconnect menuitem is activated: disconect from room''' 
    2654                 ctrl = gajim.interface.minimized_controls[account][jid] 
    2655                 del gajim.interface.minimized_controls[account][jid] 
    2656                 ctrl.shutdown() 
     2652                if jid in gajim.interface.minimized_controls[account]: 
     2653                        ctrl = gajim.interface.minimized_controls[account][jid] 
     2654                        ctrl.shutdown() 
    26572655                self.remove_groupchat(jid, account) 
    26582656 
     
    27232721        def on_groupchat_maximized(self, widget, jid, account): 
    27242722                '''When a groupchat is maximised''' 
     2723                if not jid in gajim.interface.minimized_controls[account]: 
     2724                        return 
    27252725                ctrl = gajim.interface.minimized_controls[account][jid] 
    27262726                mw = gajim.interface.msg_win_mgr.get_window(ctrl.contact.jid, 
     
    27322732                mw.new_tab(ctrl) 
    27332733                mw.set_active_tab(ctrl) 
    2734                 del gajim.interface.minimized_controls[account][jid] 
    2735  
     2734                 
    27362735                self.remove_groupchat(jid, account) 
    27372736 
     
    32413240                jid = model[path][C_JID].decode('utf-8') 
    32423241                resource = None 
    3243                 contact = None 
     3242                contact = gajim.contacts.get_first_contact_from_jid(account, jid) 
    32443243                titer = model.get_iter(path) 
    32453244                if type_ in ('group', 'account'): 
     
    32483247                        else: 
    32493248                                self.tree.expand_row(path, False) 
    3250                 elif jid in gajim.interface.minimized_controls[account]: 
    3251                         self.on_groupchat_maximized(None, jid, account) 
     3249                elif contact.is_groupchat(): 
     3250                        first_ev = gajim.events.get_first_event(account, jid) 
     3251                        if first_ev and self.open_event(account, jid, first_ev): 
     3252                                # We are invited to a GC 
     3253                                # open event cares about connecting to it 
     3254                                self.remove_groupchat(jid, account) 
     3255                        else: 
     3256                                self.on_groupchat_maximized(None, jid, account) 
    32523257                else: 
    32533258                        first_ev = gajim.events.get_first_event(account, jid)