summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-02-14 00:33:29 +0100
committermathieui <mathieui@mathieui.net>2012-02-14 00:33:29 +0100
commit560390793d29728ea96e1a547424a28098dcb610 (patch)
treee73b2d04717f6f2f1efd04b48515a3cedcd17966 /src/core.py
parentaf110581290d28b86f991dc48ced55c085852225 (diff)
downloadpoezio-560390793d29728ea96e1a547424a28098dcb610.tar.gz
poezio-560390793d29728ea96e1a547424a28098dcb610.tar.bz2
poezio-560390793d29728ea96e1a547424a28098dcb610.tar.xz
poezio-560390793d29728ea96e1a547424a28098dcb610.zip
Add 'joined' tab state, and rewrite the function handling the priorities
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py39
1 files changed, 10 insertions, 29 deletions
diff --git a/src/core.py b/src/core.py
index 95ad22af..dfea7dd3 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1085,35 +1085,16 @@ class Core(object):
def go_to_important_room(self):
"""
- Go to the next room with activity, in this order:
- - A personal conversation with a new message
- - A Muc with an highlight
- - A Muc with any new message
- """
- for tab in self.tabs:
- if tab.state == 'attention':
- self.command_win('%s' % tab.nb)
- return
- for tab in self.tabs:
- if tab.state == 'private':
- self.command_win('%s' % tab.nb)
- return
- for tab in self.tabs:
- if tab.state == 'highlight':
- self.command_win('%s' % tab.nb)
- return
- for tab in self.tabs:
- if tab.state == 'message':
- self.command_win('%s' % tab.nb)
- return
- for tab in self.tabs:
- if tab.state == 'disconnected':
- self.command_win('%s' % tab.nb)
- return
- for tab in self.tabs:
- if isinstance(tab, tabs.ChatTab) and not tab.input.is_empty():
- self.command_win('%s' % tab.nb)
- return
+ Go to the next room with activity, in the order defined in the
+ dict tabs.STATE_PRIORITY
+ """
+ priority = tabs.STATE_PRIORITY
+ sorted_tabs = sorted(self.tabs, key=lambda tab: priority[tab.state],
+ reverse=True)
+ tab = sorted_tabs.pop(0) if sorted_tabs else None
+ if priority[tab.state] < 0 or not tab:
+ return
+ self.command_win('%s' % tab.nb)
def rotate_rooms_right(self, args=None):
"""