#include <gtk/gtk.h>

/* Creates a tree model containing the completions */
GtkTreeModel *
create_simple_completion_model (void)
{
  GtkListStore *store;
  GtkTreeIter iter;
  
  store = gtk_list_store_new (1, G_TYPE_STRING);

  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 0, "a\303\246x", -1);
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 0, "a\303\246y", -1);
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 0, "a\303\246z", -1);
 
  return GTK_TREE_MODEL (store);
}

int 
main (int argc, char *argv[])
{
  GtkWidget *entry, *window;
  GtkEntryCompletion *completion;
  GtkTreeModel *completion_model;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "delete_event", gtk_main_quit, NULL);

  /* Create our first entry */
  entry = gtk_entry_new ();
  
  /* Create the completion object */
  completion = gtk_entry_completion_new ();

  /* Assign the completion to the entry */
  gtk_entry_set_completion (GTK_ENTRY (entry), completion);
  g_object_unref (completion);

  /* Create a tree model and use it as the completion model */
  completion_model = create_simple_completion_model ();
  gtk_entry_completion_set_model (completion, completion_model);
  g_object_unref (completion_model);
  
  /* Use model column 0 as the text column */
  gtk_entry_completion_set_text_column (completion, 0);

  gtk_container_add (GTK_CONTAINER (window), entry);

  gtk_widget_show_all (GTK_WIDGET (window));

  gtk_main ();

  return 0;
}
