forked from gerito1/vala-gtk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stackswitcher.vala
46 lines (35 loc) · 1.03 KB
/
stackswitcher.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
/*
* The StackSwitcher can be added to the Stack to provide a way to change the
* visible child using buttons.
*/
using Gtk;
public class Example : Window
{
public Example()
{
this.title = "StackSwitcher";
this.destroy.connect(Gtk.main_quit);
var grid = new Grid();
this.add(grid);
var stackswitcher = new StackSwitcher();
grid.attach(stackswitcher, 0, 0, 1, 1);
var stack = new Stack();
stack.set_vexpand(true);
stack.set_hexpand(true);
stackswitcher.set_stack(stack);
grid.attach(stack, 0, 1, 1, 1);
var label1 = new Label("Page 1 of Stack");
stack.add_titled(label1, "Page1", "Page 1");
var label2 = new Label("Page 2 of Stack");
stack.add_titled(label2, "Page2", "Page 2");
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new Example();
window.set_default_size(200, 200);
window.show_all();
Gtk.main();
return 0;
}
}