moved completion definition in a function
get_completion_liststore in gtkgui_helpers
This commit is contained in:
parent
37a65bd72e
commit
8f239a4be0
|
@ -997,20 +997,10 @@ class NewChatDialog(InputDialog):
|
||||||
title = _('Start Chat')
|
title = _('Start Chat')
|
||||||
prompt_text = _('Fill in the jid, or nick of the contact you would like\nto send a chat message to:')
|
prompt_text = _('Fill in the jid, or nick of the contact you would like\nto send a chat message to:')
|
||||||
InputDialog.__init__(self, title, prompt_text, is_modal = False)
|
InputDialog.__init__(self, title, prompt_text, is_modal = False)
|
||||||
# create the completion model for input_entry
|
|
||||||
completion = gtk.EntryCompletion()
|
|
||||||
liststore = gtk.ListStore(gtk.gdk.Pixbuf, str)
|
|
||||||
|
|
||||||
render_pixbuf = gtk.CellRendererPixbuf()
|
|
||||||
completion.pack_start(render_pixbuf, expand = False)
|
|
||||||
completion.add_attribute(render_pixbuf, 'pixbuf', 0)
|
|
||||||
|
|
||||||
render_text = gtk.CellRendererText()
|
|
||||||
completion.pack_start(render_text, expand = True)
|
|
||||||
completion.add_attribute(render_text, 'text', 1)
|
|
||||||
completion.set_property('text_column', 1)
|
|
||||||
# add all contacts to the model
|
|
||||||
self.completion_dict = {}
|
self.completion_dict = {}
|
||||||
|
liststore = gtkgui_helpers.get_completion_liststore(self.input_entry)
|
||||||
|
# add all contacts to the model
|
||||||
for jid in gajim.contacts.get_jid_list(account):
|
for jid in gajim.contacts.get_jid_list(account):
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
self.completion_dict[jid] = contact
|
self.completion_dict[jid] = contact
|
||||||
|
@ -1027,9 +1017,6 @@ class NewChatDialog(InputDialog):
|
||||||
img = gajim.interface.roster.jabber_state_images['16'][contact.show]
|
img = gajim.interface.roster.jabber_state_images['16'][contact.show]
|
||||||
liststore.append((img.get_pixbuf(), jid))
|
liststore.append((img.get_pixbuf(), jid))
|
||||||
|
|
||||||
completion.set_model(liststore)
|
|
||||||
self.input_entry.set_completion(completion)
|
|
||||||
|
|
||||||
self.ok_handler = self.new_chat_response
|
self.ok_handler = self.new_chat_response
|
||||||
okbutton = self.xml.get_widget('okbutton')
|
okbutton = self.xml.get_widget('okbutton')
|
||||||
okbutton.connect('clicked', self.on_okbutton_clicked)
|
okbutton.connect('clicked', self.on_okbutton_clicked)
|
||||||
|
|
|
@ -50,6 +50,25 @@ def get_glade(file_name, root = None):
|
||||||
file_path = os.path.join(GLADE_DIR, file_name)
|
file_path = os.path.join(GLADE_DIR, file_name)
|
||||||
return gtk.glade.XML(file_path, root=root, domain=i18n.APP)
|
return gtk.glade.XML(file_path, root=root, domain=i18n.APP)
|
||||||
|
|
||||||
|
def get_completion_liststore(entry):
|
||||||
|
''' create a completion model for entry widget
|
||||||
|
completion list consists of (Pixbuf, Text) rows'''
|
||||||
|
completion = gtk.EntryCompletion()
|
||||||
|
liststore = gtk.ListStore(gtk.gdk.Pixbuf, str)
|
||||||
|
|
||||||
|
render_pixbuf = gtk.CellRendererPixbuf()
|
||||||
|
completion.pack_start(render_pixbuf, expand = False)
|
||||||
|
completion.add_attribute(render_pixbuf, 'pixbuf', 0)
|
||||||
|
|
||||||
|
render_text = gtk.CellRendererText()
|
||||||
|
completion.pack_start(render_text, expand = True)
|
||||||
|
completion.add_attribute(render_text, 'text', 1)
|
||||||
|
completion.set_property('text_column', 1)
|
||||||
|
completion.set_model(liststore)
|
||||||
|
entry.set_completion(completion)
|
||||||
|
return liststore
|
||||||
|
|
||||||
|
|
||||||
def popup_emoticons_under_button(menu, button, parent_win):
|
def popup_emoticons_under_button(menu, button, parent_win):
|
||||||
''' pops emoticons menu under button, which is in parent_win'''
|
''' pops emoticons menu under button, which is in parent_win'''
|
||||||
window_x1, window_y1 = parent_win.get_origin()
|
window_x1, window_y1 = parent_win.get_origin()
|
||||||
|
|
Loading…
Reference in New Issue