entry completion
"Walter C. Pelissero" <[email protected]> Fri, 31 Aug 2007 19:25:58 +0200
| Newsgroups | gmane.lisp.clg.devel |
|---|---|
| Message-ID | <[email protected]> |
Is it just me or entry completions don't work quite right?
I've tried this code but the drop-down I get is tiny and apparently
empty. You can select a completion, but it's more or less a blind
action as you can't read them.
(defun test-completion ()
(let ((window (make-instance 'window))
(entry (make-instance 'entry))
(store (make-instance 'list-store :column-types '(string)))
(completion (make-instance 'entry-completion)))
(dolist (string '("foo" "bar" "foobar"))
(list-store-append store (vector string)))
(setf (entry-completion-text-column completion) 0)
(setf (entry-completion-model completion) store)
(setf (entry-completion entry) completion)
(container-add window entry)
(widget-show-all window)))
I know this is not the most elegant way to write a completed entry but
I wanted it too look as close as possible to the C equivalent (which
works):
#include <gtk/gtk.h>
#include <assert.h>
static void
completion ()
{
GtkWidget *window = gtk_window_new(GTK_WIN_POS_NONE);
GtkEntry *entry = (GtkEntry *) gtk_entry_new();
GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);
GtkEntryCompletion *completion = gtk_entry_completion_new();
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, "foo", -1);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, "bar", -1);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, "foobar", -1);
gtk_entry_completion_set_text_column(completion, 0);
gtk_entry_completion_set_model(completion, (GtkTreeModel *)store);
gtk_entry_set_completion(entry, completion);
gtk_container_add((GtkContainer *)window, (GtkWidget *) entry);
gtk_widget_show_all(window);
}
int
main (int argc, char *argv[])
{
gtk_init(&argc, &argv);
completion();
gtk_main();
}
--
walter pelissero
http://www.pelissero.de
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/