Author: dkirov
Date: 2006-05-08 23:59:09 +0200 (Mon, 08 May 2006)
New Revision: 6300
Modified:
trunk/src/dialogs.py
trunk/src/gtkgui_helpers.py
Log:
moved completion definition in a function
get_completion_liststore in gtkgui_helpers
Modified: trunk/src/dialogs.py
===================================================================
--- trunk/src/dialogs.py 2006-05-08 21:34:57 UTC (rev 6299)
+++ trunk/src/dialogs.py 2006-05-08 21:59:09 UTC (rev 6300)
@@ -997,20 +997,10 @@
title = _('Start Chat')
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)
- # 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 = {}
+ liststore = gtkgui_helpers.get_completion_liststore(self.input_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
@@ -1027,9 +1017,6 @@
img = gajim.interface.roster.jabber_state_images['16'][contact.show]
liststore.append((img.get_pixbuf(), jid))
- completion.set_model(liststore)
- self.input_entry.set_completion(completion)
-
self.ok_handler = self.new_chat_response
okbutton = self.xml.get_widget('okbutton')
okbutton.connect('clicked', self.on_okbutton_clicked)
Modified: trunk/src/gtkgui_helpers.py
===================================================================
--- trunk/src/gtkgui_helpers.py 2006-05-08 21:34:57 UTC (rev 6299)
+++ trunk/src/gtkgui_helpers.py 2006-05-08 21:59:09 UTC (rev 6300)
@@ -50,6 +50,25 @@
file_path = os.path.join(GLADE_DIR, file_name)
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):
''' pops emoticons menu under button, which is in parent_win'''
window_x1, window_y1 = parent_win.get_origin()