Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gtk-hello.vala:
- // valac --pkg gtk+-3.0 gtk-hello.vala
- using Gtk;
- class HelloWindow : Gtk.Window {
- public HelloWindow() {
- this.title = "First GTK+ Program";
- this.border_width = 10;
- this.window_position = WindowPosition.CENTER;
- this.set_default_size (350, 70);
- var button = new Button.with_label ("Click me!");
- button.clicked.connect (() => {
- button.label = "Thank you";
- });
- this.add (button);
- this.add_tick_callback(() => {
- DateTime now = new DateTime.now(new TimeZone.utc());
- //print(now.format("%T - Redrawing\n"));
- this.queue_draw();
- return true;
- });
- }
- public override bool draw(Cairo.Context cr) {
- return base.draw(cr);
- }
- }
- int main (string[] args) {
- Gtk.init (ref args);
- var window = new HelloWindow ();
- window.destroy.connect (Gtk.main_quit);
- window.show_all ();
- Gtk.main ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment