moved completion dict creation in helpers.py
This commit is contained in:
parent
70aad19405
commit
b145e59b41
2 changed files with 24 additions and 27 deletions
|
@ -179,6 +179,25 @@ def convert_bytes(string):
|
||||||
suffix = _('%s B')
|
suffix = _('%s B')
|
||||||
return suffix % unicode(bytes)
|
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):
|
def get_uf_show(show, use_mnemonic = False):
|
||||||
'''returns a userfriendly string for dnd/xa/chat
|
'''returns a userfriendly string for dnd/xa/chat
|
||||||
and makes all strings translatable
|
and makes all strings translatable
|
||||||
|
|
|
@ -1000,18 +1000,8 @@ class NewChatDialog(InputDialog):
|
||||||
|
|
||||||
self.completion_dict = {}
|
self.completion_dict = {}
|
||||||
liststore = gtkgui_helpers.get_completion_liststore(self.input_entry)
|
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
|
# 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():
|
for jid in self.completion_dict.keys():
|
||||||
contact = self.completion_dict[jid]
|
contact = self.completion_dict[jid]
|
||||||
img = gajim.interface.roster.jabber_state_images['16'][contact.show]
|
img = gajim.interface.roster.jabber_state_images['16'][contact.show]
|
||||||
|
@ -1252,29 +1242,17 @@ class SingleMessageWindow:
|
||||||
self.subject = ''
|
self.subject = ''
|
||||||
self.subject_entry.set_text(self.subject)
|
self.subject_entry.set_text(self.subject)
|
||||||
|
|
||||||
self.completion_dict = {}
|
|
||||||
if to == '':
|
if to == '':
|
||||||
liststore = gtkgui_helpers.get_completion_liststore(self.to_entry)
|
liststore = gtkgui_helpers.get_completion_liststore(self.to_entry)
|
||||||
# add all contacts to the model
|
self.completion_dict = helpers.get_contact_dict_for_account(account)
|
||||||
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():
|
for jid in self.completion_dict.keys():
|
||||||
contact = self.completion_dict[jid]
|
contact = self.completion_dict[jid]
|
||||||
img = gajim.interface.roster.jabber_state_images['16'][
|
img = gajim.interface.roster.jabber_state_images['16'][
|
||||||
contact.show]
|
contact.show]
|
||||||
liststore.append((img.get_pixbuf(), jid))
|
liststore.append((img.get_pixbuf(), jid))
|
||||||
|
else:
|
||||||
|
self.completion_dict = {}
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
|
|
||||||
if gajim.config.get('saveposition'):
|
if gajim.config.get('saveposition'):
|
||||||
|
|
Loading…
Add table
Reference in a new issue