-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbutton.vala
52 lines (42 loc) · 1.06 KB
/
button.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
/*
* The Button widget is commonly found in programs and used to launch processes
* and operations.
*
* Compile using:
* valac button.vala --pkg gtk+-3.0
*
* Author: Andrew Steele
*/
using Gtk;
public class Example : Window
{
private Button button;
public Example()
{
this.title = "Button";
this.destroy.connect(Gtk.main_quit);
var box = new Box(Gtk.Orientation.VERTICAL, 5);
this.add(box);
button = new Button();
button.set_label("Button 1");
button.clicked.connect(on_button_clicked);
box.add(button);
button = new Button();
button.set_label("Button 2");
button.clicked.connect(on_button_clicked);
box.add(button);
}
private void on_button_clicked(Button button)
{
var label = button.get_label();
stdout.printf("%s clicked\n", label);
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new Example();
window.show_all();
Gtk.main();
return 0;
}
}