#!/usr/bin/vala --pkg gtk+-2.0
// -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*-

public int main (string[] args)
{
  Gtk.init(ref args);

  // Set up model

  var s = new Gtk.ListStore(1, typeof(string));
  Gtk.TreeIter iter;
  int i = 0;
  s.insert_with_values(out iter, i++, 0, "test0");
  s.insert_with_values(out iter, i++, 0, "test1");
  s.insert_with_values(out iter, i++, 0, "test2");
  s.insert_with_values(out iter, i++, 0, "test3");
  s.insert_with_values(out iter, i++, 0, "test4");
  s.insert_with_values(out iter, i++, 0, "test5");
  s.insert_with_values(out iter, i++, 0, "test6");
  s.insert_with_values(out iter, i++, 0, "test7");
  s.insert_with_values(out iter, i++, 0, "test8");
  s.insert_with_values(out iter, i++, 0, "test9");
  s.insert_with_values(out iter, i++, 0, "test10");

  var c = new Gtk.EntryCompletion();
  c.model = s;
  c.text_column = 0;
  c.match_selected.connect(() => {print("Match selected!\n"); return false;});

  // Set up window

  var t = new Gtk.Entry();
  t.set_completion(c);

  var w = new Gtk.Window(Gtk.WindowType.TOPLEVEL);
  w.modal = true;

  w.add(t);
  w.show_all();
  w.delete_event.connect(() => {Gtk.main_quit(); return false;});

  Gtk.main();
  return 0;
}
