On 8/7/07, Dave Howorth <[EMAIL PROTECTED]> wrote: > Jim George wrote: > > It may not be exactly what you want, but gtk_entry_set_completion might > > help. > > It looks interesting. I've found the page in the reference manual and it > says lots of things that sound intriguing but I'm having trouble > grasping exactly what a GtkEntryCompletion can do :( Are there any > tutorials or examples to help me understand what it's capable of? > > Cheers, Dave
Here's a quick example: ... GtkTreeIter iter; GtkListStore *model = gtk_list_store_new(1, G_TYPE_STRING); for (ctr = 0; ctr < NUM_ENTRIES; ctr++) { gtk_list_store_append (model, &iter); /* Assume that 'entries' contains NUM_ENTRIES char *s */ gtk_list_store_set (model, &iter, 0, entries[ctr], -1); } gtk_entry_set_text(entry_widget, default_text); GtkEntryCompletion *entry_comp = gtk_entry_completion_new(); gtk_entry_set_completion(entry_widget, entry_comp); /* We can unref the completion object since the entry holds a ref anyway */ g_object_unref(entry_comp); gtk_entry_completion_set_model(entry_comp, GTK_TREE_MODEL(model)); /* Now when the widget is destroyed, model is automatically freed */ g_object_unref(model); /* All the entries are in column 0 */ gtk_entry_completion_set_text_column(entry_comp, 0); ... I use this when asking the user for a remote host name. I store a list of most-recently-used hosts, which populates the completion list. When the user types in a host name, if the first few characters match, a list pops up with all the remaining matches. Unfortunately, unlike a combo box, there's no way for the user to force this list to be shown (feature request?) In your case though (with 0.5e6 entries), this may actually be A Good Thing. -Jim _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list