new show_only_active_contact option. Fixes #3497

This commit is contained in:
Yann Leboulanger 2009-01-30 07:53:26 +00:00
parent 405f2d11b3
commit 5e2c8da594
3 changed files with 46 additions and 4 deletions

View File

@ -214,6 +214,15 @@
<accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/> <accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkCheckMenuItem" id="show_only_active_contacts_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">Show Only _Active Contacts</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_show_only_active_contacts_menuitem_activate"/>
<accelerator key="Y" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child> <child>
<widget class="GtkCheckMenuItem" id="show_transports_menuitem"> <widget class="GtkCheckMenuItem" id="show_transports_menuitem">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -81,6 +81,7 @@ class Config:
'autopopupaway': [ opt_bool, False ], 'autopopupaway': [ opt_bool, False ],
'use_notif_daemon': [ opt_bool, True , _('Use D-Bus and Notification-Daemon to show notifications') ], 'use_notif_daemon': [ opt_bool, True , _('Use D-Bus and Notification-Daemon to show notifications') ],
'showoffline': [ opt_bool, False ], 'showoffline': [ opt_bool, False ],
'show_only_chat_and_online': [ opt_bool, False, _('Show only online and free for chat contacts in roster.')],
'show_transports_group': [ opt_bool, True ], 'show_transports_group': [ opt_bool, True ],
'autoaway': [ opt_bool, True ], 'autoaway': [ opt_bool, True ],
'autoawaytime': [ opt_int, 5, _('Time in minutes, after which your status changes to away.') ], 'autoawaytime': [ opt_int, 5, _('Time in minutes, after which your status changes to away.') ],

View File

@ -1441,6 +1441,9 @@ class RosterWindow:
if contact.jid in gajim.to_be_removed[account]: if contact.jid in gajim.to_be_removed[account]:
return True return True
return False return False
if gajim.config.get('show_only_chat_and_online') and contact.show in (
'away', 'xa', 'busy'):
return False
return True return True
def _visible_func(self, model, titer): def _visible_func(self, model, titer):
@ -1500,12 +1503,14 @@ class RosterWindow:
for data in nearby_family: for data in nearby_family:
jid = data['jid'] jid = data['jid']
account = data['account'] account = data['account']
contact = gajim.contacts.get_first_contact_from_jid(account, jid) contact = gajim.contacts.get_contact_with_highest_priority(
account, jid)
if contact and self.contact_is_visible(contact, account): if contact and self.contact_is_visible(contact, account):
return True return True
return False return False
else: else:
contact = gajim.contacts.get_first_contact_from_jid(account, jid) contact = gajim.contacts.get_contact_with_highest_priority(account,
jid)
return self.contact_is_visible(contact, account) return self.contact_is_visible(contact, account)
if type_ == 'agent': if type_ == 'agent':
return gajim.config.get('show_transports_group') and \ return gajim.config.get('show_transports_group') and \
@ -3674,11 +3679,29 @@ class RosterWindow:
redraw the treeview''' redraw the treeview'''
gajim.config.set('showoffline', not gajim.config.get('showoffline')) gajim.config.set('showoffline', not gajim.config.get('showoffline'))
self.refilter_shown_roster_items() self.refilter_shown_roster_items()
w = self.xml.get_widget('show_only_active_contacts_menuitem')
if gajim.config.get('showoffline'): if gajim.config.get('showoffline'):
# We need to filter twice to show groups with no contacts inside # We need to filter twice to show groups with no contacts inside
# in the correct expand state # in the correct expand state
self.refilter_shown_roster_items() self.refilter_shown_roster_items()
w.set_sensitive(False)
else:
w.set_sensitive(True)
def on_show_only_active_contacts_menuitem_activate(self, widget):
'''when show only active contact option is changed:
redraw the treeview'''
gajim.config.set('show_only_chat_and_online', not gajim.config.get(
'show_only_chat_and_online'))
self.refilter_shown_roster_items()
w = self.xml.get_widget('show_offline_contacts_menuitem')
if gajim.config.get('show_only_chat_and_online'):
# We need to filter twice to show groups with no contacts inside
# in the correct expand state
self.refilter_shown_roster_items()
w.set_sensitive(False)
else:
w.set_sensitive(True)
def on_view_menu_activate(self, widget): def on_view_menu_activate(self, widget):
# Hide the show roster menu if we are not in the right windowing mode. # Hide the show roster menu if we are not in the right windowing mode.
@ -6240,8 +6263,17 @@ class RosterWindow:
self.previous_status_combobox_active = number_of_menuitem self.previous_status_combobox_active = number_of_menuitem
showOffline = gajim.config.get('showoffline') showOffline = gajim.config.get('showoffline')
self.xml.get_widget('show_offline_contacts_menuitem').set_active( showOnlyChatAndOnline = gajim.config.get('show_only_chat_and_online')
showOffline)
w = self.xml.get_widget('show_offline_contacts_menuitem')
w.set_active(showOffline)
if showOnlyChatAndOnline:
w.set_sensitive(False)
w = self.xml.get_widget('show_only_active_contacts_menuitem')
w.set_active(showOnlyChatAndOnline)
if showOffline:
w.set_sensitive(False)
show_transports_group = gajim.config.get('show_transports_group') show_transports_group = gajim.config.get('show_transports_group')
self.xml.get_widget('show_transports_menuitem').set_active( self.xml.get_widget('show_transports_menuitem').set_active(