[Xfce4-commits] <xfce4-vala:xfce-4.6> Update test programs with Vala 0.10

Mike Massonnet noreply at xfce.org
Sun Oct 31 09:02:04 CET 2010


Updating branch refs/heads/xfce-4.6
         to 8a20bbb705a49874c4089e9c40f0de282913da25 (commit)
       from 142e8592d2964d8a929a11c5f938bd21f9cb96ca (commit)

commit 8a20bbb705a49874c4089e9c40f0de282913da25
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sun Oct 31 08:35:26 2010 +0100

    Update test programs with Vala 0.10
    
    GLib.Value can be boxed/unboxed by assignation/casting.
    For example:
    
      Value var = 1;
      printf("%d\n", (int)var);
    
    GLib.Object.get/set_data uses generics:
    
      widget.set_data("text", value);
      text = widget.get_data<string> ("text");

 tests/libxfce4menu-0.1.vala |    3 +--
 tests/libxfconf-0.vala      |   16 +++++++---------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/tests/libxfce4menu-0.1.vala b/tests/libxfce4menu-0.1.vala
index e6fcf0d..686937b 100644
--- a/tests/libxfce4menu-0.1.vala
+++ b/tests/libxfce4menu-0.1.vala
@@ -22,7 +22,6 @@ public class ButtonMenu : Gtk.Button {
 			root_menu = Xfce.Menu.get_root ();
 		} catch (Error ex) {
 			error ("Unable to build a root menu");
-			return;
 		}
 
 		/* Create the gtk menu */
@@ -48,7 +47,7 @@ public class ButtonMenu : Gtk.Button {
 				mi = new Gtk.MenuItem.with_label (item.get_name ());
 				mi.set_data ("command", item.get_command());
 				mi.activate.connect ((mi) => {
-						debug ("execute `%s'", (string)mi.get_data ("command"));
+						debug ("execute `%s'", mi.get_data<string> ("command"));
 						});
 			}
 			else if (item is Xfce.MenuSeparator) {
diff --git a/tests/libxfconf-0.vala b/tests/libxfconf-0.vala
index 0b0d39a..6a859ea 100644
--- a/tests/libxfconf-0.vala
+++ b/tests/libxfconf-0.vala
@@ -8,7 +8,7 @@ public class LibxfconfTests : Object {
 		get; set;
 	}
 
-	LibxfconfTests () {
+	public LibxfconfTests () {
 		channel = new Xfconf.Channel ("test-vala-bindings");
 	}
 
@@ -37,23 +37,21 @@ public class LibxfconfTests : Object {
 		}
 
 		/* Set/get a Value */
-		Value prop_val = Value (typeof(int));
-		prop_val.set_int (5);
+		Value prop_val = 5;
 		channel.set_property ("/property", prop_val);
 		prop_val.reset ();
 		channel.get_property ("/property", prop_val);
-		print ("property: %d\n", prop_val.get_int ());
+		print ("property: %d\n", (int)prop_val);
 	}
 
 	public void test_arrays () {
 		/* Set an array */
-		Value val_int = Value (typeof(int));
-		Value val_string = Value (typeof(string));
-		val_int.set_int (5);
-		val_string.set_string ("cinq");
-		channel.set_array ("/array", typeof(int), ref val_int, typeof(string), ref val_string);
+		int val_int = 5;
+		string val_string = "cinq";
+		channel.set_array ("/array", typeof(int), &val_int, typeof(string), val_string);
 
 		/* Get an array */
+// FIXME
 		int val2_int;
 		string val2_string;
 		channel.get_array ("/array", typeof(int), out val2_int, typeof(string), out val2_string);



More information about the Xfce4-commits mailing list