Guest User

gtk-hello.vala - gnome-shell CPU usage example

a guest
Jan 5th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 0.93 KB | None | 0 0
  1. // gtk-hello.vala:
  2. // valac --pkg gtk+-3.0 gtk-hello.vala
  3. using Gtk;
  4.  
  5. class HelloWindow : Gtk.Window {
  6.     public HelloWindow() {
  7.         this.title = "First GTK+ Program";
  8.         this.border_width = 10;
  9.         this.window_position = WindowPosition.CENTER;
  10.         this.set_default_size (350, 70);
  11.        
  12.         var button = new Button.with_label ("Click me!");
  13.         button.clicked.connect (() => {
  14.             button.label = "Thank you";
  15.         });
  16.  
  17.         this.add (button);
  18.        
  19.         this.add_tick_callback(() => {
  20.             DateTime now = new DateTime.now(new TimeZone.utc());
  21.             //print(now.format("%T - Redrawing\n"));
  22.             this.queue_draw();
  23.             return true;
  24.         });
  25.     }
  26.    
  27.     public override bool draw(Cairo.Context cr) {
  28.         return base.draw(cr);
  29.     }
  30. }
  31.  
  32. int main (string[] args) {
  33.     Gtk.init (ref args);
  34.  
  35.     var window = new HelloWindow ();
  36.     window.destroy.connect (Gtk.main_quit);
  37.     window.show_all ();
  38.  
  39.     Gtk.main ();
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment