Ticket #3497: show_only_active_contacts.2.patch

File show_only_active_contacts.2.patch, 4.2 KB (added by Danie Roux <lists+gajim@…>, 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 5408fe1..2d06ca3 100644
    a b  
    6363                'use_notif_daemon': [ opt_bool, True , _('Use D-Bus and Notification-Daemon to show notifications') ], 
    6464                'ignore_unknown_contacts': [ opt_bool, False ], 
    6565                'showoffline': [ opt_bool, False ], 
     66                'show_only_chat_and_online': [ opt_bool, False ], 
    6667                'show_transports_group': [ opt_bool, True ], 
    6768                'autoaway': [ opt_bool, True ], 
    6869                '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 23a798a..d78d4a8 100644
    a b  
    7575                        return self.contact_name 
    7676                return self.jid.split('@')[0] 
    7777 
    78         def is_hidden_from_roster(self): 
     78        def is_hidden_from_roster(self, show_only_chat_and_online=False): 
    7979                '''if contact should not be visible in roster''' 
     80                if show_only_chat_and_online and (self.show not in ('chat', 'online')): 
     81                        return True 
    8082                # XEP-0162: http://www.xmpp.org/extensions/xep-0162.html 
    8183                if self.is_transport(): 
    8284                        return False 
  • src/roster_window.py

    diff --git a/src/roster_window.py b/src/roster_window.py
    index ae3f40e..204786b 100644
    a b  
    265265                If add_children is True, we also add all children, even if they were not 
    266266                already drawn''' 
    267267                showOffline = gajim.config.get('showoffline') 
     268                showOnlyChatAndOnline = gajim.config.get('show_only_chat_and_online') 
    268269                model = self.tree.get_model() 
    269                 contact = gajim.contacts.get_first_contact_from_jid(account, jid) 
     270                contact = gajim.contacts.get_contact_with_highest_priority(account, jid) 
    270271                nb_events = gajim.events.get_nb_roster_events(account, contact.jid) 
    271272                # count events from all resources 
    272273                for contact_ in gajim.contacts.get_contacts(account, jid): 
     
    291292                        return 
    292293 
    293294                # XEP-0162 
    294                 hide = contact.is_hidden_from_roster() 
     295                hide = contact.is_hidden_from_roster(showOnlyChatAndOnline) 
    295296                if hide and contact.sub != 'from': 
    296297                        return 
    297298                observer = contact.is_observer() 
     
    45424543                gajim.config.set('showoffline', not gajim.config.get('showoffline')) 
    45434544                self.draw_roster() 
    45444545 
     4546 
     4547        def on_show_only_active_contacts_activate(self, widget): 
     4548                gajim.config.set('show_only_chat_and_online', not gajim.config.get('show_only_chat_and_online')) 
     4549                self.draw_roster() 
     4550 
    45454551        def set_renderer_color(self, renderer, style, set_background = True): 
    45464552                '''set style for treeview cell, using PRELIGHT system color''' 
    45474553                if set_background: 
     
    52805286                self.xml.get_widget('show_transports_menuitem').set_active( 
    52815287                        show_transports_group) 
    52825288 
     5289                showOnlyChatAndOnline = gajim.config.get('show_only_chat_and_online') 
     5290                self.xml.get_widget('show_only_active_contacts').set_active( 
     5291                        showOnlyChatAndOnline) 
     5292 
    52835293                # columns 
    52845294 
    52855295                # this col has 3 cells: