diff options
author | mathieui <mathieui@mathieui.net> | 2013-02-03 23:31:27 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2013-02-03 23:55:13 +0100 |
commit | 27d85a0961f7aad312538213f68862e2db09726b (patch) | |
tree | 2cc8a1cf8bf61d09d1d21b6a20e2ac2dab4931a0 /src/contact.py | |
parent | a76b016f953b9a3e670d7c186403fa059ecb1d0a (diff) | |
download | poezio-27d85a0961f7aad312538213f68862e2db09726b.tar.gz poezio-27d85a0961f7aad312538213f68862e2db09726b.tar.bz2 poezio-27d85a0961f7aad312538213f68862e2db09726b.tar.xz poezio-27d85a0961f7aad312538213f68862e2db09726b.zip |
Fix the folding of contacts in multiple groups
(add a defaultdict to keep the folded state in each group)
Diffstat (limited to 'src/contact.py')
-rw-r--r-- | src/contact.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/contact.py b/src/contact.py index 62092057..d235fae2 100644 --- a/src/contact.py +++ b/src/contact.py @@ -15,6 +15,7 @@ log = logging.getLogger(__name__) from sleekxmpp import JID from common import safeJID +from collections import defaultdict class Resource(object): """ @@ -63,7 +64,7 @@ class Contact(object): item: a SleekXMPP RosterItem pointing to that contact """ self.__item = item - self.folded = True # Folded by default + self.folded_states = defaultdict(lambda: True) @property def groups(self): @@ -165,11 +166,17 @@ class Contact(object): return resources[-1] return None - def toggle_folded(self): + def folded(self, group_name='none'): + """ + Return the Folded state of a contact for this group + """ + return self.folded_states[group_name] + + def toggle_folded(self, group='none'): """ Fold if it's unfolded, and vice versa """ - self.folded = not self.folded + self.folded_states[group] = not self.folded_states[group] def __repr__(self): ret = '<Contact: %s' % self.bare_jid |