Fix #2294 (fix /w priority)
Now each different match has a different priority. It might need some tuning to have the desired result.
This commit is contained in:
parent
6c046fe161
commit
6a5423d5f5
2 changed files with 17 additions and 5 deletions
|
@ -1652,10 +1652,16 @@ class Core(object):
|
|||
return
|
||||
self.current_tab_nb = nb
|
||||
else:
|
||||
matchs = []
|
||||
for tab in self.tabs:
|
||||
for name in tab.matching_names():
|
||||
if nb in name:
|
||||
if nb.lower() in name[1].lower():
|
||||
matchs.append((name[0], tab))
|
||||
self.current_tab_nb = tab.nb
|
||||
if not matchs:
|
||||
return
|
||||
tab = min(matchs, key=lambda m: m[0])[1]
|
||||
self.current_tab_nb = tab.nb
|
||||
old_tab.on_lose_focus()
|
||||
self.current_tab().on_gain_focus()
|
||||
self.refresh_window()
|
||||
|
|
14
src/tabs.py
14
src/tabs.py
|
@ -1825,7 +1825,7 @@ class MucTab(ChatTab):
|
|||
return False
|
||||
|
||||
def matching_names(self):
|
||||
return [safeJID(self.get_name()).user]
|
||||
return [(1, safeJID(self.get_name()).user), (3, self.get_name())]
|
||||
|
||||
class PrivateTab(ChatTab):
|
||||
"""
|
||||
|
@ -2115,7 +2115,7 @@ class PrivateTab(ChatTab):
|
|||
self.add_message(txt=reason, typ=2)
|
||||
|
||||
def matching_names(self):
|
||||
return [safeJID(self.get_name()).resource]
|
||||
return [(3, safeJID(self.get_name()).resource), (4, self.get_name())]
|
||||
|
||||
class RosterInfoTab(Tab):
|
||||
"""
|
||||
|
@ -3342,10 +3342,13 @@ class ConversationTab(ChatTab):
|
|||
self.send_chat_state('gone')
|
||||
|
||||
def matching_names(self):
|
||||
res = []
|
||||
jid = safeJID(self.get_name())
|
||||
res.append((2, jid.bare))
|
||||
res.append((1, jid.user))
|
||||
contact = roster[self.get_name()]
|
||||
res = [contact.bare_jid if contact else safeJID(self.get_name()).bare]
|
||||
if contact and contact.name:
|
||||
res.append(contact.name)
|
||||
res.append((0, contact.name))
|
||||
return res
|
||||
|
||||
class DynamicConversationTab(ConversationTab):
|
||||
|
@ -3602,6 +3605,9 @@ class MucListTab(Tab):
|
|||
self.listview.refresh()
|
||||
self.core.doupdate()
|
||||
|
||||
def matching_names(self):
|
||||
return [(2, self.name)]
|
||||
|
||||
class XMLTab(Tab):
|
||||
def __init__(self):
|
||||
Tab.__init__(self)
|
||||
|
|
Loading…
Reference in a new issue