add completion for single message dialog

This commit is contained in:
Dimitur Kirov 2006-05-08 22:06:42 +00:00
parent c159894cc4
commit afdfdc05ce
1 changed files with 25 additions and 0 deletions

View File

@ -1252,6 +1252,29 @@ 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
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))
self.xml.signal_autoconnect(self)
if gajim.config.get('saveposition'):
@ -1357,6 +1380,8 @@ class SingleMessageWindow:
_('Please make sure you are connected with "%s".' % self.account))
return
to_whom_jid = self.to_entry.get_text().decode('utf-8')
if self.completion_dict.has_key(to_whom_jid):
to_whom_jid = self.completion_dict[to_whom_jid].jid
subject = self.subject_entry.get_text().decode('utf-8')
begin, end = self.message_tv_buffer.get_bounds()
message = self.message_tv_buffer.get_text(begin, end).decode('utf-8')