diff options
author | mathieui <mathieui@mathieui.net> | 2012-08-01 01:36:18 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-08-01 01:36:18 +0200 |
commit | c890fefbc40377fd63f1d69011ed12a863e11043 (patch) | |
tree | 9de5cb6d023d64fa52d6f07154b3c18352c9e4ef | |
parent | 47c593ddaf80b95ba48c826d8c2a7e9d95067cbc (diff) | |
download | poezio-c890fefbc40377fd63f1d69011ed12a863e11043.tar.gz poezio-c890fefbc40377fd63f1d69011ed12a863e11043.tar.bz2 poezio-c890fefbc40377fd63f1d69011ed12a863e11043.tar.xz poezio-c890fefbc40377fd63f1d69011ed12a863e11043.zip |
Add an "online" contact sorting method
- put the online contacts at the beginning of the list
- allows, e.g. jid_reverse_online_reverse, to put offline contacts at
the start of the group, in alphabetical order
-rw-r--r-- | data/default_config.cfg | 1 | ||||
-rw-r--r-- | doc/en/configure.txt | 5 | ||||
-rw-r--r-- | src/roster.py | 5 |
3 files changed, 9 insertions, 2 deletions
diff --git a/data/default_config.cfg b/data/default_config.cfg index f75ae14b..76e02d57 100644 --- a/data/default_config.cfg +++ b/data/default_config.cfg @@ -231,6 +231,7 @@ roster_show_offline = false # - show: sort by show (available/away/xa/…) # - name: sort by roster name (if no name, then the bare jid is used) # - resource: sort by resource number +# - online: sort by online presence (online or not) # You can arrange them however you like, and you have to separate them with # underscores "_". Keep in mind that if there are more than 3 or 4 your sorting # is most likely inefficient. diff --git a/doc/en/configure.txt b/doc/en/configure.txt index fc854dba..8331d2ea 100644 --- a/doc/en/configure.txt +++ b/doc/en/configure.txt @@ -289,8 +289,9 @@ section of this documentation. * reverse: reverse the current sorting * jid: sort by JID (alphabetical order) * show: sort by show (available/away/xa/…) - * name: Sort by roster name (if no name, then the bare jid is used) - * resource: Sort by resource number + * name: sort by roster name (if no name, then the bare jid is used) + * resource: sort by resource number + * online: sort by online presence (online or not) Those methods can be arranged however you like, and they have to be separated by underscores ("_"). If there are more than 3 or 4 chained diff --git a/src/roster.py b/src/roster.py index c7717ea8..c5f89218 100644 --- a/src/roster.py +++ b/src/roster.py @@ -255,11 +255,16 @@ def sort_resource_nb(contact): def sort_name(contact): return contact.name.lower() or contact.bare_jid +def sort_online(contact): + result = sort_show(contact) + return 0 if result < 5 else 1 + SORTING_METHODS = { 'jid': sort_jid, 'show': sort_show, 'resource': sort_resource_nb, 'name': sort_name, + 'online': sort_online, } class RosterGroup(object): |