Blame platform-demos/C/samples/grid.vala
|
Packit |
1470ea |
public class MyWindow : Gtk.ApplicationWindow {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Gtk.Widget progress_bar;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
internal MyWindow (MyApplication app) {
|
|
Packit |
1470ea |
Object (application: app, title: "Grid Example");
|
|
Packit |
1470ea |
var grid = new Gtk.Grid();
|
|
Packit |
1470ea |
progress_bar = new Gtk.ProgressBar ();
|
|
Packit |
1470ea |
progress_bar.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var button = new Gtk.Button.with_label ("Button");
|
|
Packit |
1470ea |
button.clicked.connect (on_button_click);
|
|
Packit |
1470ea |
button.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
this.add(grid);
|
|
Packit |
1470ea |
grid.attach(button, 0, 1, 1, 1);
|
|
Packit |
1470ea |
grid.attach_next_to (progress_bar, button, Gtk.PositionType.BOTTOM, 1, 1);
|
|
Packit |
1470ea |
grid.show ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
void on_button_click (Gtk.Button button) {
|
|
Packit |
1470ea |
(progress_bar as Gtk.ProgressBar).pulse ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public class MyApplication : Gtk.Application {
|
|
Packit |
1470ea |
protected override void activate () {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
new MyWindow (this).show ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
internal MyApplication () {
|
|
Packit |
1470ea |
Object (application_id: "org.example.MyApplication");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public int main (string[] args) {
|
|
Packit |
1470ea |
return new MyApplication ().run (args);
|
|
Packit |
1470ea |
}
|