Ticket #3497: show_only_active_contacts.patch

File show_only_active_contacts.patch, 3.8 KB (added by Danie Roux, 2 years ago)
  • data/glade/roster_window.glade

    diff --git a/data/glade/roster_window.glade b/data/glade/roster_window.glade
    index 625a713..d6b4c64 100644
    a b  
    215215                      </widget> 
    216216                    </child> 
    217217                    <child> 
     218                      <widget class="GtkCheckMenuItem" id="show_only_active_contacts"> 
     219                        <property name="visible">True</property> 
     220                        <property name="label" translatable="yes">_Show Only Active Contacts</property> 
     221                        <property name="use_underline">True</property> 
     222                        <property name="active">False</property> 
     223                        <signal name="activate" handler="on_show_only_active_contacts_activate"/> 
     224                        <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/> 
     225                      </widget> 
     226                    </child> 
     227 
     228                    <child> 
    218229                      <widget class="GtkCheckMenuItem" id="show_transports_menuitem"> 
    219230                        <property name="visible">True</property> 
    220231                        <property name="label" translatable="yes">Show Trans_ports</property> 
  • src/common/config.py

    diff --git a/src/common/config.py b/src/common/config.py
    index 7f51d40..2e75d80 100644
    a b  
    5858                'use_notif_daemon': [ opt_bool, True , _('Use D-Bus and Notification-Daemon to show notifications') ], 
    5959                'ignore_unknown_contacts': [ opt_bool, False ], 
    6060                'showoffline': [ opt_bool, False ], 
     61                'show_only_chat_and_online': [ opt_bool, False ], 
    6162                'show_transports_group': [ opt_bool, True ], 
    6263                'autoaway': [ opt_bool, True ], 
    6364                'autoawaytime': [ opt_int, 5, _('Time in minutes, after which your status changes to away.') ], 
  • src/common/contacts.py

    diff --git a/src/common/contacts.py b/src/common/contacts.py
    index 524b076..8714c81 100644
    a b  
    7070                        return self.contact_name 
    7171                return self.jid.split('@')[0] 
    7272 
    73         def is_hidden_from_roster(self): 
     73        def is_hidden_from_roster(self, show_only_chat_and_online=False): 
    7474                '''if contact should not be visible in roster''' 
     75                if show_only_chat_and_online and (self.show not in ('chat', 'online')): 
     76                        return True 
    7577                # XEP-0162: http://www.xmpp.org/extensions/xep-0162.html 
    7678                if self.is_transport(): 
    7779                        return False 
  • src/roster_window.py

    diff --git a/src/roster_window.py b/src/roster_window.py
    index 35f9e82..e0b7cee 100644
    a b  
    260260                If add_children is True, we also add all children, even if they were not 
    261261                already drawn''' 
    262262                showOffline = gajim.config.get('showoffline') 
     263                showOnlyChatAndOnline = gajim.config.get('show_only_chat_and_online') 
    263264                model = self.tree.get_model() 
    264                 contact = gajim.contacts.get_first_contact_from_jid(account, jid) 
     265                contact = gajim.contacts.get_contact_with_highest_priority(account, jid) 
    265266                nb_events = gajim.events.get_nb_roster_events(account, contact.jid) 
    266267                # count events from all resources 
    267268                for contact_ in gajim.contacts.get_contacts(account, jid): 
     
    286287                        return 
    287288 
    288289                # XEP-0162 
    289                 hide = contact.is_hidden_from_roster() 
     290                hide = contact.is_hidden_from_roster(showOnlyChatAndOnline) 
    290291                if hide and contact.sub != 'from': 
    291292                        return 
    292293                observer = contact.is_observer() 
     
    45204521                gajim.config.set('showoffline', not gajim.config.get('showoffline')) 
    45214522                self.draw_roster() 
    45224523 
     4524 
     4525        def on_show_only_active_contacts_activate(self, widget): 
     4526                gajim.config.set('show_only_chat_and_online', not gajim.config.get('show_only_chat_and_online')) 
     4527                self.draw_roster() 
     4528 
    45234529        def set_renderer_color(self, renderer, style, set_background = True): 
    45244530                '''set style for treeview cell, using PRELIGHT system color''' 
    45254531                if set_background: