File: button.vala

package info (click to toggle)
gnome-devel-docs 3.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 46,300 kB
  • ctags: 630
  • sloc: xml: 2,321; ansic: 2,040; python: 1,807; makefile: 747; sh: 504; cpp: 131
file content (42 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download | duplicates (5)
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
/* A window in the application */
public class MyWindow : Gtk.ApplicationWindow {

	/* The constructor of the window */
	internal MyWindow (MyApplication app) {
		Object (application: app, title: "GNOME Button");

		var button = new Gtk.Button.with_label ("Click Me");
		button.clicked.connect (this.reverse_label);
		button.show ();

		this.window_position = Gtk.WindowPosition.CENTER;
		this.set_default_size (250,50);
		this.add (button);
	}

	/* The callback function connected to the
	 * 'clicked' signal of the button.
	 */
	void reverse_label (Gtk.Button button) {
		button.label = button.label.reverse ();
	}
}

/* This is the application. */
public class MyApplication : Gtk.Application {

	/* This is the constructor */
	internal MyApplication () {
		Object (application_id: "org.example.MyApplication");
	}

	/* Override the activate signal of GLib.Application */
	protected override void activate () {
		new MyWindow (this).show ();
	}
}

/* main creates and runs the application */
public int main (string[] args) {
	return new MyApplication ().run (args);
}