using Gtk; public class Toolbar : Window { VBox vbox; ActionGroup actionGroup; UIManager uimanger; public Toolbar() { vbox = new VBox(true, 8); this.add(vbox); this.set_title("Toolbar Example"); this.set_position(WindowPosition.CENTER_ALWAYS); this.destroy.connect(Gtk.main_quit); // create actions for the tool bar buttons Action quitAction = new Action("QuitAction", "Quit", "Exit application", Gtk.STOCK_QUIT); // connect to the action quitAction.activate.connect(HandleQuitAction); // add action to action group actionGroup = new Ac
# Makefile # vala project # # name of your project/program PROGRAM = main_debug # for most cases the following two are the only you'll need to change # add your source files here SRC = main.vala # add your used packges here PKGS = --pkg gtk+-2.0 --pkg gee-1.0 # vala compiler VALAC = valac # compiler options for a debug build VALACOPTS = -g --save-temps # set this as root makefile for Valencia BUILD_ROOT = 1 # the 'all' target build a debug build all: @$(VALAC) $(VALACOPTS) $(SRC) -o $(PROGRAM) $(PKGS) # the 'release' target builds a release build # you mi
/* archive.vala - Example for using the libarchive bindings in Vala.
*
* Copyright (C) 2009 Julian Andres Klode <jak@debian.org>
*
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
* notice and this notice are preserved.//compile with: valac --thread --pkg libsoup-2.4 main.vala -o soup_post using Soup; class rpc_request { private static rpc_request request_instance; private HashTable<string,string> args; private rpc_request() { args=new HashTable<string,string>(str_hash,str_equal); } public static rpc_request get_instance() { if(null==request_instance) { request_instance=new rpc_request(); } return request_instance; } public void add_parameter(string name,string val) { args.insert(name,val); } private string prepare() { Soup.URI myuri=new Soup.URI("http://
/**
* You'll need to grab the attached files and remove the .txt at the end of them in order to use this.
* I put both the vapi and deps file in /usr/share/vala/vapi/ to have them readily available. You can also keep them in your project folder if you want, * but you'll need to update the compile line to reflect that
* the compiled .so and gedit-plugin files go in ~/.gnome2/gedit/plugins/
* Sample makefile is also attached.
*
* Displays a button on the top Gedit panel that displays a color dialog when clicked.using Gst; public class StreamPlayer { private MainLoop loop = new MainLoop (null, false); private void foreach_tag (Gst.TagList list, string tag) { switch (tag) { case "title": string tag_string; list.get_string (tag, out tag_string); stdout.printf ("tag: %s = %s\n", tag, tag_string); break; default: break; } } private bool bus_callback (Gst.Bus bus, Gst.Message message) { switch (message.type) { case MessageType.ERROR: GLib.Error err
using Gee; private class RangeIterator : Object, Iterator<int> { private Range range; private int current; public RangeIterator (Range range) { this.range = range; this.current = range.from; } public bool next () { return this.current <= this.range.to; } public int get () { return this.current++; } } public class Range : Object, Iterable<int> { public int from { get; private set; } public int to { get; private set; } public Range (int from, int to) { assert (from < to);
using Gee; static int main (string[] args) { var map = new HashMap<string, int> (str_hash, str_equal); map.set ("one", 1); map.set ("two", 2); map.set ("three", 3); map["four"] = 4; // same as map.set ("four", 4) map["five"] = 5; foreach (string key in map.get_keys ()) { stdout.printf ("%d\n", map[key]); // same as map.get (key) } return 0; }
using Gee; static int main (string[] args) { var my_set = new HashSet<string> (str_hash, str_equal); my_set.add ("one"); my_set.add ("two"); my_set.add ("three"); my_set.add ("two"); // will not be added because it's a duplicate foreach (string s in my_set) { stdout.printf ("%s\n", s); } return 0; }
using Gee; static int main (string[] args) { var list = new ArrayList<int> (); list.add (1); list.add (2); list.add (5); list.add (4); list.insert (2, 3); list.remove_at (3); foreach (int i in list) { stdout.printf ("%d\n", i); } list[2] = 10; // same as list.set (2, 10) stdout.printf ("%d\n", list[2]); // same as list.get (2) return 0; }