Languages

Using Cairo with posix profile

0
Your rating: None
Description: 
This example shows how to render vector graphics without depending on GObject. This can be useful in environments where glib/gobject is not yet ported, like game consoles or embedded hardware.
/* 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?

[GtkON] Simple web browser

0
Your rating: None
Description: 
Simple GtkON web browser using webkit.
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);
 

libmemcached example

0
Your rating: None
Description: 
Simple test program using libmemcached to connect to a memcached instance running at 127.0.0.1:11211 (default port)
/* http://lolcathost.org/b/libmemcached.vapi */
/* valac --pkg libmemcached --vapidir .

[GtkON] Hello World that runs in 'script' mode

0
Your rating: None
Description: 
Simple example of a GtkON application that can run in script mode.
$ 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}-
}

Global hotkeys

0
Your rating: None
Description: 
Some sample code to easily bind delegates to a hotkey. Note: At least version 0.11.3 of vala is needed.
/*
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.
     */
 

[Genie] GtkBuilder Example

0
Your rating: None
Description: 
An example of how to load gtkbuilder files on genie, based on the vala sample
[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

[GtkON] Clutter example

4
Your rating: None Average: 4 (1 vote)
/* 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

[GtkON] TreeView liststore sample

4.5
Your rating: None Average: 4.5 (2 votes)
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; /* $.

[GtkON] Slider synchronized with entry text

5
Your rating: None Average: 5 (1 vote)
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

[GtkON] Hello world using GtkON syntax with gtkaml and Gtk api

4.5
Your rating: None Average: 4.5 (2 votes)
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;
                }
        }-
}
Syndicate content