changeset 1350:32ccda01a2be frontends_multi_profiles

frontends (primitivus): fixes MUC nicks completion
author souliane <souliane@mailoo.org>
date Wed, 04 Mar 2015 14:04:03 +0100
parents 273b044fde6d
children ec43552f5f8b
files frontends/src/primitivus/primitivus
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Wed Mar 04 14:17:38 2015 +0100
+++ b/frontends/src/primitivus/primitivus	Wed Mar 04 14:04:03 2015 +0100
@@ -69,25 +69,27 @@
     def _nick_completion(self, text, completion_data):
         """Completion method which complete pseudo in group chat
         for params, see AdvancedEdit"""
-        contact = self.host.contact_list.getContact() ###Based on the fact that there is currently only one contact selectable at once
-        if contact:
-            chat = self.host.chat_wins[contact]
-            if chat.type != "group":
-                return text
-            space = text.rfind(" ")
-            start = text[space+1:]
-            nicks = list(chat.occupants)
+        nicks = []
+        for profile, clist in self.host.contact_lists.iteritems():
+            for contact in clist.getContacts():
+                chat = self.host.widgets.getWidget(quick_chat.QuickChat, contact, profile)
+                if chat.type != C.CHAT_GROUP:
+                    continue
+                space = text.rfind(" ")
+                start = text[space + 1:]
+                nicks.extend(list(chat.occupants))
+        if nicks:
             nicks.sort()
             try:
-                start_idx=nicks.index(completion_data['last_nick'])+1
+                start_idx = nicks.index(completion_data['last_nick']) + 1
                 if start_idx == len(nicks):
                     start_idx = 0
-            except (KeyError,ValueError):
+            except (KeyError, ValueError):
                 start_idx = 0
-            for idx in range(start_idx,len(nicks)) + range(0,start_idx):
+            for idx in range(start_idx, len(nicks)) + range(0, start_idx):
                 if nicks[idx].lower().startswith(start.lower()):
                     completion_data['last_nick'] = nicks[idx]
-                    return text[:space+1] + nicks[idx] + (': ' if space < 0 else '')
+                    return text[:space + 1] + nicks[idx] + (': ' if space < 0 else '')
         return text
 
     def onTextEntered(self, editBar):