vala-tests r11 - trunk/tests/examples
- From: malureau svn gnome org
- To: svn-commits-list gnome org
- Subject: vala-tests r11 - trunk/tests/examples
- Date: Fri, 17 Oct 2008 22:47:16 +0000 (UTC)
Author: malureau
Date: Fri Oct 17 22:47:15 2008
New Revision: 11
URL: http://svn.gnome.org/viewvc/vala-tests?rev=11&view=rev
Log:
More tests from live.gnome.org/Vala
Added:
trunk/tests/examples/gconf.test
- copied, changed from r10, /trunk/tests/examples/cairo.test
trunk/tests/examples/gconf.vala
trunk/tests/examples/glade.test
- copied, changed from r10, /trunk/tests/examples/cairo.test
trunk/tests/examples/glade.vala
trunk/tests/examples/gladesample.glade
trunk/tests/examples/gnome-desktop-and-menu.test
- copied, changed from r10, /trunk/tests/examples/advanced.test
trunk/tests/examples/gnome-desktop-and-menu.vala
trunk/tests/examples/gstreamer-square-beep.test
- copied, changed from r10, /trunk/tests/examples/cairo.test
trunk/tests/examples/gstreamer-square-beep.vala
trunk/tests/examples/gstreamer-video.test
- copied, changed from r10, /trunk/tests/examples/cairo.test
trunk/tests/examples/gstreamer-video.vala
trunk/tests/examples/gtk-builder-sample.test
- copied, changed from r10, /trunk/tests/examples/cairo.test
trunk/tests/examples/gtk-builder-sample.vala
trunk/tests/examples/gtk-sample.test
- copied, changed from r10, /trunk/tests/examples/cairo.test
trunk/tests/examples/gtk-sample.vala
trunk/tests/examples/main_window.ui
Modified:
trunk/tests/examples/advanced.test
trunk/tests/examples/async-gio.test
trunk/tests/examples/basic.test
trunk/tests/examples/bluez-dbus-sample.test
trunk/tests/examples/cairo.test
trunk/tests/examples/dbus-sample.test
trunk/tests/examples/dbus-server-sample.test
trunk/tests/examples/egg-clock.test
trunk/tests/examples/list.test
trunk/tests/examples/properties-construction.test
trunk/tests/examples/properties.test
trunk/tests/examples/string.test
trunk/tests/examples/string.vala
trunk/tests/examples/update.sh
Modified: trunk/tests/examples/advanced.test
==============================================================================
--- trunk/tests/examples/advanced.test (original)
+++ trunk/tests/examples/advanced.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/async-gio.test
==============================================================================
--- trunk/tests/examples/async-gio.test (original)
+++ trunk/tests/examples/async-gio.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg gio-2.0 -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gtk+-2.0 --pkg gio-2.0 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/basic.test
==============================================================================
--- trunk/tests/examples/basic.test (original)
+++ trunk/tests/examples/basic.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/bluez-dbus-sample.test
==============================================================================
--- trunk/tests/examples/bluez-dbus-sample.test (original)
+++ trunk/tests/examples/bluez-dbus-sample.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg dbus-glib-1 -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg dbus-glib-1 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/cairo.test
==============================================================================
--- trunk/tests/examples/cairo.test (original)
+++ trunk/tests/examples/cairo.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/dbus-sample.test
==============================================================================
--- trunk/tests/examples/dbus-sample.test (original)
+++ trunk/tests/examples/dbus-sample.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg dbus-glib-1 -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg dbus-glib-1 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/dbus-server-sample.test
==============================================================================
--- trunk/tests/examples/dbus-server-sample.test (original)
+++ trunk/tests/examples/dbus-server-sample.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg dbus-glib-1 -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg dbus-glib-1 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/egg-clock.test
==============================================================================
--- trunk/tests/examples/egg-clock.test (original)
+++ trunk/tests/examples/egg-clock.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Copied: trunk/tests/examples/gconf.test (from r10, /trunk/tests/examples/cairo.test)
==============================================================================
--- /trunk/tests/examples/cairo.test (original)
+++ trunk/tests/examples/gconf.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gconf-2.0 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/gconf.vala
==============================================================================
--- (empty file)
+++ trunk/tests/examples/gconf.vala Fri Oct 17 22:47:15 2008
@@ -0,0 +1,131 @@
+/*
+ * vala-gconf.vala
+ * Various operations with GConf: Getting, Setting, Unsetting and Notifying
+ */
+
+using GLib;
+using GConf;
+
+public static GConf.Client gc;
+
+// Stupid function which just sets a boolean key to true
+bool set_key (string key)
+{
+ bool success;
+ // For the Client API see
+ // http://www.vala-project.org/doc/references/gconf-2.0.vapi/GConf/Client.htm
+ success = gc.set_bool(key, true);
+ // The set_* functions return a boolean to indicate whether the operation
+ // was successful
+ return success;
+}
+
+bool get_key (string key)
+{
+ return gc.get_bool(key);
+}
+
+// A callback which gets called everytime a defined keys change
+void gconf_cb (GConf.Client gc, uint cxnid, GConf.Entry entry)
+{
+ // For the Entry API see
+ // http://www.vala-project.org/doc/references/gconf-2.0.vapi/GConf/Entry.htm
+ string key = entry.key;
+ // For the Value API see
+ // http://www.vala-project.org/doc/references/gconf-2.0.vapi/GConf/Value.htm
+ // We have to set the "weak" keyword, because the reference on that
+ // Value object isn't counted
+ weak GConf.Value gconf_value = entry.get_value();
+ // We silently assume, that this Value contains a bool, we should check it
+ // first
+ bool new_value = gconf_value.get_bool();
+
+ stdout.printf("Callback called with Entry %s, new value: %s\n",
+ key,
+ new_value?"True":"False"
+ );
+}
+
+
+int main ()
+{
+ // You don't create a GConf.Client with "new GConf.Client();" but rather
+ // this way:
+ gc = GConf.Client.get_default();
+
+ // A root directory to work in
+ string root = "/apps/myapp";
+
+ // Set and retrieve a boolean key, see API for more information on how to
+ // retrieve other types
+ string key = root + "foo/baz"; // Sub directories are created automatically
+ set_key(key);
+
+ bool result = true;
+ result = get_key(key);
+ stdout.printf("Result is %s\n", result?"True":"False");
+
+
+
+ // Getting a list of keys in a directory
+
+ // first, create a few more entries
+ set_key(root+"/baz"); set_key(root+"/baz"); set_key(root+"/qux");
+
+ // You might also want to have a look at the GConf documentation:
+ // http://library.gnome.org/devel/gconf/2.23/gconf-GConfClient.html#gconf-client-all-entries
+ // For a strange reason we have to define the type of the lists entries
+ // ourselves.
+ weak GLib.SList<GConf.Entry> entrylist = gc.all_entries(root);
+ stdout.printf("Entrylist has %u items\n", entrylist.length() );
+ foreach (weak GConf.Entry entry in entrylist) {
+ // You must define entry to be weak until bug 549061 is resolved
+ stdout.printf("Key: %s Value: %s\n",
+ entry.key,
+ entry.get_value().get_bool()?"True":"False"
+ );
+ }
+
+
+
+
+ // Getting a list of subdirectories in a directory
+ // first, create a few more directories
+ set_key(root+"/bar/baz"); set_key(root+"/baz/baz"); set_key(root+"/qux/baz");
+ // You might also want to have a look at the GConf documentation:
+ // http://library.gnome.org/devel/gconf/2.23/gconf-GConfClient.html#gconf-client-all-dirs
+ // For a strange reason we have to define the type of the lists entries
+ // ourselves.
+ weak GLib.SList<string> dirlist = gc.all_dirs(root);
+ stdout.printf("Dirlist has %u items\n", dirlist.length() );
+ foreach (string dir in dirlist) {
+ stdout.printf("Dir: %s\n", dir);
+ }
+
+
+
+
+ // Now installing the callback function which gets called everytime
+ // the key changes
+ string listeningdir = "/apps/myapp/foo";
+ //gc.add_dir(listeningdir, GConf.ClientPreloadType.ONELEVEL);
+ stdout.printf("Listening on %s\n", listeningdir);
+ string listeningkey = "/apps/myapp/foo/baz";
+ //gc.notify_add(listeningkey, gconf_cb, null);
+ stdout.printf("Having ourselves notified on %s\n", listeningkey);
+
+ GLib.MainLoop main = new GLib.MainLoop(null,false);
+ main.run();
+ // You may now run gconf-editor and change the value for @listeningkey
+ // Or comment main.run() to remove the key
+
+
+ // This operation unsets values from keys. If a key is unset or a directory
+ // doesn't have subkeys anymore, they get deleted. They might be visible
+ // with gconf-editor until GConf has collected its garbage though.
+ // There is just one valid flag in GConf.UnsetFlags according to
+ // http://www.vala-project.org/doc/references/gconf-2.0.vapi/GConf/UnsetFlags.htm
+ gc.recursive_unset("/apps/myapp", GConf.UnsetFlags.NAMES);
+
+ return 0;
+}
\ No newline at end of file
Copied: trunk/tests/examples/glade.test (from r10, /trunk/tests/examples/cairo.test)
==============================================================================
--- /trunk/tests/examples/cairo.test (original)
+++ trunk/tests/examples/glade.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gtk+-2.0 --pkg libglade-2.0 --pkg gmodule-2.0 -o $TESTNAME $SRCDIR/$TESTNAME.vala -X "-Wl,--export-dynamic" $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/glade.vala
==============================================================================
--- (empty file)
+++ trunk/tests/examples/glade.vala Fri Oct 17 22:47:15 2008
@@ -0,0 +1,46 @@
+/* Glade in Vala sample code */
+
+using GLib;
+using Gtk;
+using Glade;
+
+public class GladeSample : Gtk.Object {
+
+ private Glade.XML xml;
+
+ construct {
+ this.xml = new Glade.XML ("gladesample.glade", null, null);
+ this.xml.signal_autoconnect_full (connect_signals);
+ }
+
+ [CCode (instance_pos = -1)]
+ public void on_bHelloWorld_clicked (Gtk.Widget widget) {
+ stdout.printf ("Hello World!\n");
+ }
+
+ [CCode (instance_pos = -1)]
+ public void on_win_destroy (Gtk.Widget widget) {
+ Gtk.main_quit ();
+ }
+
+ [InstanceLast]
+ public void connect_signals (string handler_name, GLib.Object object, string signal_name, string? signal_data, GLib.Object? connect_object, bool after) {
+ Module module = Module.open (null, ModuleFlags.BIND_LAZY);
+ void* sym;
+
+ if (!module.symbol (handler_name, out sym)) {
+ stdout.printf ("Symbol not found!\n");
+ } else {
+ GLib.Signal.connect(object, signal_name, (GLib.Callback) sym, this);
+ }
+ }
+
+ public static int main (string[] args) {
+ Gtk.init (ref args);
+
+ var sample = new GladeSample ();
+
+ Gtk.main ();
+ return 0;
+ }
+}
\ No newline at end of file
Added: trunk/tests/examples/gladesample.glade
==============================================================================
--- (empty file)
+++ trunk/tests/examples/gladesample.glade Fri Oct 17 22:47:15 2008
@@ -0,0 +1,37 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkWindow" id="win">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Vala Glade Example</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <signal name="destroy" handler="glade_sample_on_win_destroy" last_modification_time="Sat, 13 Oct 2007 15:25:26 GMT"/>
+
+ <child>
+ <widget class="GtkButton" id="bHelloWorld">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Hello World!</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="glade_sample_on_bHelloWorld_clicked" last_modification_time="Sat, 13 Oct 2007 15:14:45 GMT"/>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
Copied: trunk/tests/examples/gnome-desktop-and-menu.test (from r10, /trunk/tests/examples/advanced.test)
==============================================================================
--- /trunk/tests/examples/advanced.test (original)
+++ trunk/tests/examples/gnome-desktop-and-menu.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gnome-desktop-2.0 --pkg libgnome-menu -o $TESTNAME $SRCDIR/$TESTNAME.vala -X "-DGMENU_I_KNOW_THIS_IS_UNSTABLE" $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/gnome-desktop-and-menu.vala
==============================================================================
--- (empty file)
+++ trunk/tests/examples/gnome-desktop-and-menu.vala Fri Oct 17 22:47:15 2008
@@ -0,0 +1,79 @@
+/* GnomeDesktop and GMenu in Vala sample code */
+
+using GLib;
+
+public class GnomeDesktopAndGMenuExample : GLib.Object {
+
+ private List<GMenu.TreeDirectory> getMainDirectories () {
+ var tree = GMenu.Tree.lookup ("applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED);
+ var root = tree.get_root_directory ();
+
+ var mainDirectoryEntries = new List<GMenu.TreeDirectory> ();
+
+ foreach (GMenu.TreeItem item in root.get_contents()) {
+ if (item.get_type() == GMenu.TreeItemType.DIRECTORY) {
+ mainDirectoryEntries.append((GMenu.TreeDirectory) item);
+ }
+ }
+ return mainDirectoryEntries;
+ }
+
+ private List<GMenu.TreeEntry> getEntriesFlat (GMenu.TreeDirectory directory ) {
+ var entries = new List<GMenu.TreeEntry> ();
+
+ foreach (GMenu.TreeItem item in directory.get_contents ()) {
+ switch (item.get_type ()) {
+ case GMenu.TreeItemType.DIRECTORY:
+ entries.concat (getEntriesFlat ((GMenu.TreeDirectory) item));
+ break;
+ case GMenu.TreeItemType.ENTRY:
+ entries.append ((GMenu.TreeEntry) item);
+ break;
+ }
+ }
+ return entries;
+ }
+
+ private Gnome.DesktopItem getDesktopItemForMenuEntry (GMenu.TreeEntry entry) throws GLib.Error {
+ return new Gnome.DesktopItem.from_file (entry.get_desktop_file_path (), Gnome.DesktopItemLoadFlags.ONLY_IF_EXISTS);
+ }
+
+ private void launch (Gnome.DesktopItem item) {
+ try {
+ item.launch (new List<string> (), Gnome.DesktopItemLaunchFlags.ONLY_ONE);
+ } catch (Error error) {
+ stdout.printf ("Error: %s\n", error.message);
+ }
+ }
+
+ static int main (string[] args) {
+ GnomeVFS.init ();
+ var desktopAndMenu = new GnomeDesktopAndGMenuExample ();
+
+ stdout.printf ("\nGet all main directories:\n");
+ var directories = desktopAndMenu.getMainDirectories ();
+ foreach (GMenu.TreeDirectory directory in directories) {
+ stdout.printf ("%s\n", directory.get_name ());
+ }
+
+ stdout.printf ("\nGet all entries/directories for the first directory:\n");
+ var entries = desktopAndMenu.getEntriesFlat (directories.nth_data(0));
+ foreach (GMenu.TreeEntry entry in entries) {
+ stdout.printf ("%s\n", entry.get_name ());
+ }
+
+ stdout.printf ("\nGet desktop item for first menu entry and display Name, Generic name, Description and Icon name:\n");
+ try {
+ var item = desktopAndMenu.getDesktopItemForMenuEntry (entries.nth_data (0));
+ stdout.printf ("Name: %s\n", item.get_string(Gnome.DESKTOP_ITEM_NAME));
+ stdout.printf ("GenericName: %s\n", item.get_string(Gnome.DESKTOP_ITEM_GENERIC_NAME));
+ stdout.printf ("Comment: %s\n", item.get_string(Gnome.DESKTOP_ITEM_COMMENT));
+ stdout.printf ("Exec: %s\n", item.get_string(Gnome.DESKTOP_ITEM_EXEC));
+ stdout.printf ("Icon: %s\n", item.get_string(Gnome.DESKTOP_ITEM_ICON));
+ } catch (GLib.Error e) {
+ stdout.printf ("Failed to get desktop iten.");
+ }
+
+ return 0;
+ }
+}
\ No newline at end of file
Copied: trunk/tests/examples/gstreamer-square-beep.test (from r10, /trunk/tests/examples/cairo.test)
==============================================================================
--- /trunk/tests/examples/cairo.test (original)
+++ trunk/tests/examples/gstreamer-square-beep.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gstreamer-0.10 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/gstreamer-square-beep.vala
==============================================================================
--- (empty file)
+++ trunk/tests/examples/gstreamer-square-beep.vala Fri Oct 17 22:47:15 2008
@@ -0,0 +1,39 @@
+/* GStreamer in Vala sample code */
+
+using GLib;
+using Gst;
+
+public void main (string[] args) {
+ MainLoop loop;
+ Element src;
+ Element sink;
+ Pipeline pipeline;
+
+ // Creating a GLib main loop with a default context
+ loop = new MainLoop (null, false);
+
+ // Initializing GStreamer
+ Gst.init (ref args);
+
+ // Creating pipeline and elements
+ // NOTE: The return type of the pipeline construction method is Element,
+ // not Pipeline, so we have to cast
+ pipeline = (Pipeline) new Pipeline ("test");
+ src = ElementFactory.make ("audiotestsrc", "my_src");
+ sink = ElementFactory.make ("autoaudiosink", "my_sink");
+
+ // Adding elements to pipeline
+ pipeline.add_many (src, sink);
+
+ // Linking source to sink
+ src.link (sink);
+
+ // Setting waveform to square
+ src.set ("wave", 1);
+
+ // Set pipeline state to PLAYING
+ pipeline.set_state (State.PLAYING);
+
+ // Start GLib mainloop
+ loop.run ();
+}
\ No newline at end of file
Copied: trunk/tests/examples/gstreamer-video.test (from r10, /trunk/tests/examples/cairo.test)
==============================================================================
--- /trunk/tests/examples/cairo.test (original)
+++ trunk/tests/examples/gstreamer-video.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gtk+-2.0 --pkg gstreamer-0.10 --pkg gdk-x11-2.0 --pkg gstreamer-interfaces-0.10 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/gstreamer-video.vala
==============================================================================
--- (empty file)
+++ trunk/tests/examples/gstreamer-video.vala Fri Oct 17 22:47:15 2008
@@ -0,0 +1,68 @@
+using GLib;
+using Gtk;
+using Gst;
+
+public class VideoSample : Window {
+
+ private DrawingArea drawing_area;
+ private Pipeline pipeline;
+ private Element src;
+ private Element sink;
+
+ construct {
+ create_widgets ();
+ setup_gst_pipeline ();
+ }
+
+ private void create_widgets () {
+ var vbox = new VBox (false, 0);
+ this.drawing_area = new DrawingArea ();
+ this.drawing_area.set_size_request (300, 150);
+ vbox.pack_start (this.drawing_area, true, true, 0);
+
+ var play_button = new Button.from_stock (STOCK_MEDIA_PLAY);
+ play_button.clicked += on_play;
+ var stop_button = new Button.from_stock (STOCK_MEDIA_STOP);
+ stop_button.clicked += on_stop;
+ var quit_button = new Button.from_stock (STOCK_QUIT);
+ quit_button.clicked += Gtk.main_quit;
+
+ var bb = new HButtonBox ();
+ bb.add (play_button);
+ bb.add (stop_button);
+ bb.add (quit_button);
+ vbox.pack_start (bb, false, true, 0);
+
+ add (vbox);
+ }
+
+ private void setup_gst_pipeline () {
+ this.pipeline = (Pipeline) new Pipeline ("mypipeline");
+ this.src = ElementFactory.make ("videotestsrc", "video");
+ this.sink = ElementFactory.make ("xvimagesink", "sink");
+ this.pipeline.add_many (this.src, this.sink);
+ this.src.link (this.sink);
+ }
+
+ private void on_play () {
+ ((XOverlay) this.sink).set_xwindow_id (
+ Gdk.x11_drawable_get_xid (this.drawing_area.window));
+ this.pipeline.set_state (State.PLAYING);
+ }
+
+ private void on_stop () {
+ this.pipeline.set_state (State.READY);
+ }
+
+ public static int main (string[] args) {
+ Gst.init (ref args);
+ Gtk.init (ref args);
+
+ var sample = new VideoSample ();
+ sample.show_all ();
+
+ Gtk.main ();
+
+ return 0;
+ }
+}
\ No newline at end of file
Copied: trunk/tests/examples/gtk-builder-sample.test (from r10, /trunk/tests/examples/cairo.test)
==============================================================================
--- /trunk/tests/examples/cairo.test (original)
+++ trunk/tests/examples/gtk-builder-sample.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gtk+-2.0 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/gtk-builder-sample.vala
==============================================================================
--- (empty file)
+++ trunk/tests/examples/gtk-builder-sample.vala Fri Oct 17 22:47:15 2008
@@ -0,0 +1,62 @@
+/* GtkTreeView and GtkBuilder in Vala sample code */
+
+using GLib;
+using Gtk;
+
+public class BuilderExample : Gtk.Builder {
+
+ string uifile = "main_window.ui";
+
+ public bool create_widgets () {
+ try {
+ add_from_file (uifile);
+ Gtk.Widget window = (Gtk.Widget) get_object ("window");
+ setup_treeview ((Gtk.TreeView) get_object ("treeview1"));
+ window.show_all ();
+ window.destroy += Gtk.main_quit;
+ } catch (GLib.Error err) {
+ var msg = new Gtk.MessageDialog (
+ null, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CANCEL,
+ "Failed to load UI\n" + err.message);
+ msg.run();
+
+ return false;
+ }
+ return true;
+ }
+
+ public void setup_treeview (Gtk.TreeView view) {
+
+ /* use liststore to hold accountname, accounttype, balance and color attribute */
+ /* for more info how gtkTreeview works take a look in the GTK API */
+
+ var listmodel = new Gtk.ListStore(4, typeof(string), typeof(string), typeof(string), typeof(string));
+ view.set_model(listmodel);
+
+ view.insert_column_with_attributes (-1, "Account Name", new Gtk.CellRendererText(), "text", 0, null);
+ view.insert_column_with_attributes (-1, "Type", new Gtk.CellRendererText(), "text", 1, null);
+
+ var cell = new Gtk.CellRendererText ();
+ cell.set ("foreground_set", true, null);
+ view.insert_column_with_attributes (-1, "Balance", cell, "text", 2, "foreground", 3, null);
+
+ Gtk.TreeIter iter;
+ listmodel.append (out iter);
+ listmodel.set (iter, 0, "My Visacard", 1, "card", 2, "102,10", 3, "red", -1);
+
+ listmodel.append (out iter);
+ listmodel.set (iter, 0, "My Mastercard", 1, "card", 2, "10,20", 3, "red", -1);
+ }
+
+ public static int main (string[] args) {
+ Gtk.init (ref args);
+
+ var mainapp = new BuilderExample ();
+ if (mainapp.create_widgets ()) {
+ Gtk.main ();
+ }
+
+ return 0;
+ }
+}
+
Copied: trunk/tests/examples/gtk-sample.test (from r10, /trunk/tests/examples/cairo.test)
==============================================================================
--- /trunk/tests/examples/cairo.test (original)
+++ trunk/tests/examples/gtk-sample.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC --pkg gtk+-2.0 --pkg cairo -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC --pkg gtk+-2.0 -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x0" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/gtk-sample.vala
==============================================================================
--- (empty file)
+++ trunk/tests/examples/gtk-sample.vala Fri Oct 17 22:47:15 2008
@@ -0,0 +1,33 @@
+/* GTK+ in Vala sample code */
+
+using GLib;
+using Gtk;
+
+public class GtkSample : Gtk.Window {
+
+ construct {
+ this.title = "Sample Window";
+ this.create_widgets ();
+ }
+
+ public void create_widgets () {
+ this.destroy += Gtk.main_quit;
+
+ var button = new Button.with_label ("Hello World");
+ button.clicked += btn => {
+ title = btn.label;
+ };
+
+ add (button);
+ }
+
+ static int main (string[] args) {
+ Gtk.init (ref args);
+
+ var sample = new GtkSample ();
+ sample.show_all ();
+
+ Gtk.main ();
+ return 0;
+ }
+}
\ No newline at end of file
Modified: trunk/tests/examples/list.test
==============================================================================
--- trunk/tests/examples/list.test (original)
+++ trunk/tests/examples/list.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Added: trunk/tests/examples/main_window.ui
==============================================================================
--- (empty file)
+++ trunk/tests/examples/main_window.ui Fri Oct 17 22:47:15 2008
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!--Generated with glade3 3.4.0 on Wed Jan 23 13:09:17 2008 -->
+<interface>
+ <object class="GtkWindow" id="window">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="title" translatable="yes">Main Window</property>
+ <property name="default_width">100</property>
+ <property name="default_height">200</property>
+ <child>
+ <object class="GtkTreeView" id="treeview1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="headers_clickable">True</property>
+ </object>
+ </child>
+ </object>
+</interface>
Modified: trunk/tests/examples/properties-construction.test
==============================================================================
--- trunk/tests/examples/properties-construction.test (original)
+++ trunk/tests/examples/properties-construction.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/properties.test
==============================================================================
--- trunk/tests/examples/properties.test (original)
+++ trunk/tests/examples/properties.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/string.test
==============================================================================
--- trunk/tests/examples/string.test (original)
+++ trunk/tests/examples/string.test Fri Oct 17 22:47:15 2008
@@ -19,12 +19,12 @@
TESTNAME=`basename $0 .test`
-$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala
+$VALAC -o $TESTNAME $SRCDIR/$TESTNAME.vala $VALAFLAGS
if [ "x1" = "x1" -o "x$INTERACT" = "x1" ] ; then
- ./$TESTNAME
+ ./$TESTNAME
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
Modified: trunk/tests/examples/string.vala
==============================================================================
--- trunk/tests/examples/string.vala (original)
+++ trunk/tests/examples/string.vala Fri Oct 17 22:47:15 2008
@@ -68,7 +68,7 @@
// String dimensions
- string dessert = "crÃme brÃlÃe";
+ string dessert = "CrÃme brÃlÃe";
print ("The string '%s' is %ld characters long and is stored in %ld bytes\n",
dessert, dessert.len (), dessert.size ());
Modified: trunk/tests/examples/update.sh
==============================================================================
--- trunk/tests/examples/update.sh (original)
+++ trunk/tests/examples/update.sh Fri Oct 17 22:47:15 2008
@@ -6,7 +6,18 @@
dbus-sample
dbus-server-sample
egg-clock
+gconf
+glade
+gstreamer-square-beep
+gstreamer-video
+gtk-sample
+gtk-builder-sample
"
+
+deprecated="
+glade
+"
+
set -e
while true ; do
@@ -20,14 +31,26 @@
for file in *.vala ; do
+test=`basename $file .vala`
+
# hackish
PACKAGES=
grep "Gtk\." $file >/dev/null && PACKAGES="$PACKAGES --pkg gtk+-2.0"
grep -i " gio" $file >/dev/null && PACKAGES="$PACKAGES --pkg gio-2.0"
grep "DBus\." $file >/dev/null && PACKAGES="$PACKAGES --pkg dbus-glib-1"
grep -i "cairo" $file >/dev/null && PACKAGES="$PACKAGES --pkg cairo"
-
-test=`basename $file .vala`
+grep "GConf\." $file >/dev/null && PACKAGES="$PACKAGES --pkg gconf-2.0"
+grep "Glade\." $file >/dev/null && PACKAGES="$PACKAGES --pkg libglade-2.0"
+grep "Module\." $file >/dev/null && PACKAGES="$PACKAGES --pkg gmodule-2.0"
+grep "Gnome\.Desktop" $file >/dev/null && PACKAGES="$PACKAGES --pkg gnome-desktop-2.0"
+grep "GMenu\." $file >/dev/null && PACKAGES="$PACKAGES --pkg libgnome-menu"
+grep "Gst\." $file >/dev/null && PACKAGES="$PACKAGES --pkg gstreamer-0.10"
+grep "Gdk\.x11" $file >/dev/null && PACKAGES="$PACKAGES --pkg gdk-x11-2.0"
+grep "XOverlay" $file >/dev/null && PACKAGES="$PACKAGES --pkg gstreamer-interfaces-0.10"
+
+VALAFLAGS=
+[ "$test" = "glade" ] && VALAFLAGS='-X "-Wl,--export-dynamic"'
+[ "$test" = "gnome-desktop-and-menu" ] && VALAFLAGS='-X "-DGMENU_I_KNOW_THIS_IS_UNSTABLE"'
RUN=1
for nr in $interactive ; do
@@ -56,20 +79,20 @@
TESTNAME=\`basename \$0 .test\`
-\$VALAC $PACKAGES -o \$TESTNAME \$SRCDIR/\$TESTNAME.vala
+\$VALAC $PACKAGES -o \$TESTNAME \$SRCDIR/\$TESTNAME.vala $VALAFLAGS \$VALAFLAGS
if [ "x$RUN" = "x1" -o "x\$INTERACT" = "x1" ] ; then
- ./\$TESTNAME
+ ./\$TESTNAME $@
else
echo ""
- echo "WARNING: This vala test is interactive and will not be run (try --interactive)"
+ echo "*** WARNING: This vala test is interactive and will not be run (try --interact) ***"
fi
EOF
chmod +x $test.test
-[ "$check" = "1" ] && echo "Running $test..." && ./$test.test $interact
+[ "$check" = "1" ] && echo "Running $test..." && ./$test.test $interact $@
rm -f $test
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]