/* Using cairo with the posix profile -- pancake<nopcode.org> */ /* valac --profile=posix --pkg cairo --pkg posix cairotest.vala */ using Cairo; using Posix; const int WH = 320; private void drawstuff (Context?
Window $win using=Gtk:WebKit default-width=800 default-height=600 destroy=Gtk.main_quit { VBox { HBox !expand { Button label="<-" !expand clicked=webview.go_back; Button label="->" !expand clicked=webview.go_forward; Entry $url text="http://google.es" activate=open; Button label="GO!" !expand clicked=open; } ScrolledWindow { WebKit:WebView $webview; } } -{ void open() { if (url.text.index_of ("://") != -1) webview.open (url.text);
/* http://lolcathost.org/b/libmemcached.vapi */ /* valac --pkg libmemcached --vapidir .
$ chmod +x hello.gtkon $ ./hello.gtkon
#!/usr/bin/env gtkaml Window $Test using=Gtk { VBox { Label $msg label="Do it for fun"; Button !expand label="CLICK ME" clicked={ if (msg.label == "byebye") Gtk.main_quit (); msg.label = "byebye"; }; } gtkaml:preconstruct { -{ print ("Hello GtkON World!\n"); resize (400, 300); position = WindowPosition.CENTER; }- } -{gtkaml::gtk::main}- }
/* valac --pkg gtk+-2.0 --pkg x11 --pkg gdk-x11-2.0 --pkg gee-1.0 keybinding-manager.vala */ /** * This class is in charge to grab keybindings on the X11 display * and filter X11-events and passing on such events to the registed * handler methods. * * @author Oliver Sauder <os@esite.ch> */ public class KeybindingManager : GLib.Object { /** * list of binded keybindings */ private Gee.List<Keybinding> bindings = new Gee.ArrayList<Keybinding>(); /** * locked modifiers used to grab all keys whatever lock key * is pressed. */
[indent = 4] /* * compilation: * valac --pkg gtk+-2.0 --pkg gmodule-2.0 sample.gs * Of course you need a sample.ui file containing at least two buttons, and their * clicked signals connected to the functions on_button1_clicked * and on_button2_clicked */ uses Gtk [CCode (cname = "G_MODULE_EXPORT on_button1_clicked")] def on_button1_clicked (source : Button) source.label = "Thank you!" [CCode (cname = "G_MODULE_EXPORT on_button2_clicked")] def on_button2_clicked (source : Button) source.label = "Thanks!" init Gtk.init (ref args); try
/* from http://www.openismus.com/documents/clutter_tutorial/0.8/docs/tutorial/html/sec-full-example.html */ Window $ClutterExamples.MainWindow using=Gtk using:gc=GtkClutter using:clutter=Clutter destroy=Gtk.main_quit { VBox { gc:Embed $.embed width_request=800 height_request=600; HBox { Button label=Close clicked=Gtk.main_quit; } } /* configuring the existing stage */ clutter:Stage &embed.get_stage() standalone { color { clutter:Color red=0xB0 green=0xB0 blue=0xB0 alpha=0xff; } clutter:Text x=10 y=10 opacity=0 col
Window using=Gtk name="TreeViewSample" title="Tree View Sample" default-width=250 default-height=100 destroy=Gtk.main_quit { TreeView $.view construct=setup_treeview() { TreeViewColumn title="Account Name" { CellRendererText $.column0 !expand; CellRendererText &column0 attribute="text" column=0; } TreeViewColumn title="Type" { CellRendererText $.column1 !expand; /* $.
Window using=Gtk title="Enter your age" position={WindowPosition.CENTER} destroy=Gtk.main_quit default-width=300 default-height=20 name=SyncSample { HBox spacing=5 { SpinButton $.spin with-range min=0 max=130 step=1 value=35 value-changed={slider.set_value (target.get_value ())}; HScale $.slider with-range min=0 max=130 step=1 value-changed={spin.set_value (target.get_value ())}; } -{ public static int main (string[] args) { G
Window using=Gtk name=GtkHello type={WindowType.TOPLEVEL} title="First GTK+ Program" position={WindowPosition.CENTER} default-width=300 default-height=50 destroy=Gtk.main_quit { Button label="Click me!" clicked={target.label="Thank you"}; -{ static int main (string[] args) { Gtk.init (ref args); var window = new GtkHello (); window.show_all (); Gtk.main (); return 0; } }- }