Skip to content
Snippets Groups Projects
Commit b145e59b authored by dkirov's avatar dkirov
Browse files

moved completion dict creation in helpers.py

parent 70aad194
No related branches found
No related tags found
No related merge requests found
......@@ -179,6 +179,25 @@ def convert_bytes(string):
suffix = _('%s B')
return suffix % unicode(bytes)
def get_contact_dict_for_account(account):
''' create a dict of jid, nick -> contact with all contacts of account.
Can be used for completion lists'''
contacts_dict = {}
for jid in gajim.contacts.get_jid_list(account):
contact = gajim.contacts.get_contact_with_highest_priority(account,
jid)
contacts_dict[jid] = contact
name = contact.name
if contacts_dict.has_key(name):
contact1 = contacts_dict[name]
del contacts_dict[name]
contacts_dict['%s (%s)' % (name, contact1.jid)] = contact1
contacts_dict['%s (%s)' % (name, jid)] = contact
else:
contacts_dict[name] = contact
return contacts_dict
def get_uf_show(show, use_mnemonic = False):
'''returns a userfriendly string for dnd/xa/chat
and makes all strings translatable
......
......@@ -1000,18 +1000,8 @@ class NewChatDialog(InputDialog):
self.completion_dict = {}
liststore = gtkgui_helpers.get_completion_liststore(self.input_entry)
self.completion_dict = helpers.get_contact_dict_for_account(account)
# add all contacts to the model
for jid in gajim.contacts.get_jid_list(account):
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
self.completion_dict[jid] = contact
name = contact.name
if self.completion_dict.has_key(name):
contact1 = self.completion_dict[name]
del self.completion_dict[name]
self.completion_dict['%s (%s)' % (name, contact1.jid)] = contact1
self.completion_dict['%s (%s)' % (name, jid)] = contact
else:
self.completion_dict[name] = contact
for jid in self.completion_dict.keys():
contact = self.completion_dict[jid]
img = gajim.interface.roster.jabber_state_images['16'][contact.show]
......@@ -1252,29 +1242,17 @@ class SingleMessageWindow:
self.subject = ''
self.subject_entry.set_text(self.subject)
self.completion_dict = {}
if to == '':
liststore = gtkgui_helpers.get_completion_liststore(self.to_entry)
# add all contacts to the model
for jid in gajim.contacts.get_jid_list(account):
contact = gajim.contacts.get_contact_with_highest_priority(
account, jid)
self.completion_dict[jid] = contact
name = contact.name
if self.completion_dict.has_key(name):
contact1 = self.completion_dict[name]
del self.completion_dict[name]
self.completion_dict['%s (%s)' % (name, contact1.jid)] = \
contact1
self.completion_dict['%s (%s)' % (name, jid)] = contact
else:
self.completion_dict[name] = contact
self.completion_dict = helpers.get_contact_dict_for_account(account)
for jid in self.completion_dict.keys():
contact = self.completion_dict[jid]
img = gajim.interface.roster.jabber_state_images['16'][
contact.show]
liststore.append((img.get_pixbuf(), jid))
else:
self.completion_dict = {}
self.xml.signal_autoconnect(self)
if gajim.config.get('saveposition'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment