primitivus: implement "Show offline contacts" parameter (sync with "DISCONNECTED_HIDE" action key)
This commit is contained in:
parent
176512b013
commit
e554934f31
3 changed files with 18 additions and 6 deletions
|
|
@ -24,7 +24,7 @@ from sat_frontends.quick_frontend.quick_contact_list import QuickContactList
|
|||
from sat_frontends.quick_frontend.quick_utils import unescapePrivate
|
||||
from sat_frontends.tools.jid import JID
|
||||
from sat_frontends.primitivus.status import StatusBar
|
||||
from sat_frontends.primitivus.constants import Const
|
||||
from sat_frontends.primitivus.constants import Const as C
|
||||
from sat_frontends.primitivus.keys import action_key_map as a_key
|
||||
from sat.core import log as logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -41,6 +41,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
self.alert_jid=set()
|
||||
self.show_status = False
|
||||
self.show_disconnected = False
|
||||
self.host.bridge.asyncGetParamA(C.SHOW_OFFLINE_CONTACTS, "General", profile_key=host.profile, callback=self.showOfflineContacts)
|
||||
|
||||
#we now build the widget
|
||||
self.host.status_bar = StatusBar(host)
|
||||
|
|
@ -77,8 +78,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
self.show_status = not self.show_status
|
||||
self.update()
|
||||
elif key == a_key['DISCONNECTED_HIDE']: #user wants to (un)hide disconnected contacts
|
||||
self.show_disconnected = not self.show_disconnected
|
||||
self.update()
|
||||
self.host.bridge.setParam(C.SHOW_OFFLINE_CONTACTS, C.str(not self.show_disconnected), "General", profile_key=self.host.profile)
|
||||
return super(ContactList, self).keypress(size, key)
|
||||
|
||||
def __contains__(self, jid):
|
||||
|
|
@ -100,7 +100,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
# contact group
|
||||
value = widget.getValue()
|
||||
elif isinstance(widget, sat_widgets.SelectableText):
|
||||
if widget.data.startswith(Const.PRIVATE_PREFIX):
|
||||
if widget.data.startswith(C.PRIVATE_PREFIX):
|
||||
# muc private dialog
|
||||
value = widget.getValue()
|
||||
else:
|
||||
|
|
@ -150,7 +150,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
widgets = [] #list of built widgets
|
||||
|
||||
for contact in contacts:
|
||||
if contact.startswith(Const.PRIVATE_PREFIX):
|
||||
if contact.startswith(C.PRIVATE_PREFIX):
|
||||
contact_disp = ('alert' if contact in self.alert_jid else "show_normal", unescapePrivate(contact))
|
||||
show_icon = ''
|
||||
status = ''
|
||||
|
|
@ -165,7 +165,7 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
if (not self.show_disconnected and show == "unavailable"
|
||||
and not contact in self.alert_jid and contact != self.selected):
|
||||
continue
|
||||
show_icon, show_attr = Const.PRESENCE.get(show, ('', 'default'))
|
||||
show_icon, show_attr = C.PRESENCE.get(show, ('', 'default'))
|
||||
contact_disp = ('alert' if contact in self.alert_jid else show_attr, nick or name or jid.node or jid.bare)
|
||||
display = [ show_icon + " " , contact_disp]
|
||||
if self.show_status:
|
||||
|
|
@ -319,3 +319,10 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
#XXX: for the moment, we ignore presence updates for special entities
|
||||
if jid.bare not in self.specials:
|
||||
QuickContactList.updatePresence(self, jid, show, priority, statuses)
|
||||
|
||||
def showOfflineContacts(self, show):
|
||||
show = C.bool(show)
|
||||
if self.show_disconnected == show:
|
||||
return
|
||||
self.show_disconnected = show
|
||||
self.update()
|
||||
|
|
|
|||
|
|
@ -556,6 +556,8 @@ class QuickApp(object):
|
|||
self.profiles[profile]['whoami'] = JID(value)
|
||||
elif (namespace, name) == ("Misc", "Watched"):
|
||||
self.profiles[profile]['watched'] = value.split()
|
||||
elif (namespace, name) == ('General', C.SHOW_OFFLINE_CONTACTS):
|
||||
self.contact_list.showOfflineContacts(C.bool(value))
|
||||
|
||||
def contactDeletedHandler(self, jid, profile):
|
||||
target = JID(jid)
|
||||
|
|
|
|||
|
|
@ -104,3 +104,6 @@ class QuickContactList(object):
|
|||
self.setCache(jid, 'prority', priority)
|
||||
self.setCache(jid, 'statuses', statuses)
|
||||
self.update_jid(jid)
|
||||
|
||||
def showOfflineContacts(self, show):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue