-
Notifications
You must be signed in to change notification settings - Fork 1
/
OtherExampleApp.vala
66 lines (53 loc) · 1.73 KB
/
OtherExampleApp.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
60
61
62
63
64
65
66
//$ valac --pkg gtk4 OtherExampleApp.vala -o OtherExampleApp
/*
int main (string[] argv) {
var app = new Gtk.Application ("com.example.GtkApplication",
GLib.ApplicationFlags.FLAGS_NONE);
app.activate.connect (() => {
// Create a new window
var window = new Gtk.ApplicationWindow (app);
// Create a new button
var button = new Gtk.Button.with_label ("Hello, World!");
// When the button is clicked, close the window
button.clicked.connect (() => {
stdout.printf("btn_clicked!!!\n");
window.close ();
});
window.set_child (button);
window.present ();
});
return app.run (argv);
}
*/
int main (string[] argv) {
var app = new Gtk.Application ("com.example.GtkApplication",
GLib.ApplicationFlags.FLAGS_NONE);
app.activate.connect (() => {
var view = new ApplicationView (app);
var presenter = new ApplicationPresenter (view);
presenter.show ();
});
return app.run (argv);
}
public class ApplicationView : Gtk.ApplicationWindow {
public ApplicationView (Gtk.Application app) {
this.application = app;
this.title = "Hello, World!";
this.set_default_size (400, 200);
var button = new Gtk.Button.with_label ("Hello, World!");
button.clicked.connect (() => {
stdout.printf("btn_clicked!!!\n");
//this.close ();
});
this.set_child (button);
}
}
public class ApplicationPresenter {
private ApplicationView view;
public ApplicationPresenter (ApplicationView view) {
this.view = view;
}
public void show () {
view.present();
}
}