|
Packit |
1470ea |
public class MyWindow : Gtk.ApplicationWindow {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Gtk.Statusbar statusbar;
|
|
Packit |
1470ea |
uint context_id;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
internal MyWindow (MyApplication app) {
|
|
Packit |
1470ea |
Object (application: app, title: "Statusbar Example");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
statusbar = new Gtk.Statusbar ();
|
|
Packit |
1470ea |
context_id = statusbar.get_context_id ("example");
|
|
Packit |
1470ea |
statusbar.push (context_id, "Waiting for you to do something...");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
//set the default size of the window
|
|
Packit |
1470ea |
this.set_default_size (200, 100);
|
|
Packit |
1470ea |
var grid = new Gtk.Grid ();
|
|
Packit |
1470ea |
var label = new Gtk.Label ("Press any key or ");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
grid.attach (label, 0, 0, 1, 1);
|
|
Packit |
1470ea |
label.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var button = new Gtk.Button.with_label ("click me.");
|
|
Packit |
1470ea |
grid.attach_next_to (button, label, Gtk.PositionType.RIGHT, 1, 1);
|
|
Packit |
1470ea |
button.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
grid.attach (statusbar, 0, 1, 2, 1);
|
|
Packit |
1470ea |
statusbar.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
grid.set_column_spacing (5);
|
|
Packit |
1470ea |
grid.set_column_homogeneous (true);
|
|
Packit |
1470ea |
grid.set_row_homogeneous (true);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
this.add (grid);
|
|
Packit |
1470ea |
grid.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
button.clicked.connect(button_clicked_cb);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Since the key-press-event is a signal received by the window, we don't need to connect
|
|
Packit |
1470ea |
the window to a callback function. We can just override key_press_event. */
|
|
Packit |
1470ea |
protected override bool key_press_event (Gdk.EventKey event) {
|
|
Packit |
1470ea |
statusbar.push (context_id, Gdk.keyval_name(event.keyval) + " key was pressed.");
|
|
Packit |
1470ea |
return true;
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
void button_clicked_cb (Gtk.Button button) {
|
|
Packit |
1470ea |
statusbar.push (context_id, "You clicked the button.");
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public class MyApplication : Gtk.Application {
|
|
Packit |
1470ea |
protected override void activate () {
|
|
Packit |
1470ea |
new MyWindow (this).show ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
internal MyApplication () {
|
|
Packit |
1470ea |
Object (application_id: "org.example.status");
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public int main (string[] args) {
|
|
Packit |
1470ea |
return new MyApplication ().run (args);
|
|
Packit |
1470ea |
}
|