Last active
July 10, 2017 00:03
-
-
Save robertsanseries/e7371e4f42ce468d9a4e2abc30fa63b9 to your computer and use it in GitHub Desktop.
Example of Gtk.EntryCompletion with vala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Application : Gtk.Window { | |
public Application () { | |
this.title = "My Gtk.EntryCompletion"; | |
this.window_position = Gtk.WindowPosition.CENTER; | |
this.destroy.connect (Gtk.main_quit); | |
this.set_default_size (500, 300); | |
Gtk.Entry entry = new Gtk.Entry (); | |
this.add (entry); | |
Gtk.EntryCompletion completion = new Gtk.EntryCompletion (); | |
entry.set_completion (completion); | |
Gtk.ListStore list_store = new Gtk.ListStore (1, typeof (string)); | |
completion.set_model (list_store); | |
completion.set_text_column (0); | |
Gtk.TreeIter iter; | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Burgenland"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Carinthia"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Lower Austria"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Upper Austria"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Salzburg"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Styria"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Tyrol"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Vorarlberg"); | |
list_store.append (out iter); | |
list_store.set (iter, 0, "Vienna"); | |
} | |
public static int main (string[] args) { | |
Gtk.init (ref args); | |
Application app = new Application (); | |
app.show_all (); | |
Gtk.main (); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment