-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlabel.vala
55 lines (45 loc) · 1.44 KB
/
label.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
/*
* The Label is commonly used for basic purposes such as displaying short
* amounts of text. It does however provide a number of extra features allowing
* the display of complex text layouts.
*
* Compile using:
* valac label.vala --pkg gtk+-3.0
*
* Author: Andrew Steele
*/
using Gtk;
public class Example : Window
{
public Example()
{
this.title = "Label";
this.destroy.connect(Gtk.main_quit);
var vbox = new Box(Gtk.Orientation.VERTICAL, 5);
vbox.set_spacing(5);
this.add(vbox);
var label1 = new Label("This is a single-line example.");
vbox.add(label1);
var label2 = new Label("This is a multiple\nline\nexample using new line breaks.");
vbox.add(label2);
var hbox = new Box(Gtk.Orientation.HORIZONTAL, 5);
hbox.set_spacing(5);
vbox.add(hbox);
var label3 = new Label(null);
label3.set_justify(Gtk.Justification.RIGHT);
label3.set_label("This is an\nexample label\nright justified.");
hbox.add(label3);
var label4 = new Label(null);
label4.set_justify(Gtk.Justification.CENTER);
label4.set_markup("This is a\ncenter aligned\n label with <b>markup</b>.");
hbox.pack_end(label4, true, true, 0);
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new Example();
window.show_all();
Gtk.main();
return 0;
}
}