-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathentrycompletion.vala
59 lines (48 loc) · 1.45 KB
/
entrycompletion.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Coupled with an Entry, the EntryCompletion object provides matching of text
* to a list of entries, allowing the user to select a value.
*
* Compile using:
* valac entrycompletion.vala --pkg gtk+-3.0
*
* Author: Andrew Steele
*/
using Gtk;
public class EntryExample : Window
{
private Gtk.ListStore liststore;
private Entry entry;
private EntryCompletion entrycompletion;
public EntryExample()
{
this.title = "Entry";
this.destroy.connect(Gtk.main_quit);
entry = new Entry();
this.add(entry);
liststore = new Gtk.ListStore(1, typeof(string));
Gtk.TreeIter iter;
liststore.append(out iter);
liststore.set(iter, 0, "Oklahoma");
liststore.append(out iter);
liststore.set(iter, 0, "California");
liststore.append(out iter);
liststore.set(iter, 0, "Texas");
liststore.append(out iter);
liststore.set(iter, 0, "Connecticut");
liststore.append(out iter);
liststore.set(iter, 0, "Arizona");
entrycompletion = new EntryCompletion();
entrycompletion.set_model(liststore);
entrycompletion.set_text_column(0);
entrycompletion.set_popup_completion(true);
entry.set_completion(entrycompletion);
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new EntryExample();
window.show_all();
Gtk.main();
return 0;
}
}