[seed] Fix #637248 - Add support for implicitly converting GObject to GValue



commit b254df57d964317c37ebdeab5f875c8de8d4adf9
Author: Sunil Mohan Adapa <sunil medhas org>
Date:   Tue Nov 8 15:48:08 2011 +0530

    Fix #637248 - Add support for implicitly converting GObject to GValue

 libseed/seed-types.c                |   10 +++++++++-
 tests/javascript/gvalue-argument.js |    4 +++-
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index d3b138c..2d25eb1 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -1314,9 +1314,17 @@ seed_value_to_gvalue (JSContextRef ctx,
 	// TODO: FIXME: This whole undefined type area
 	// needs some heaaavy improvement.
 
+	if (type == 0 && seed_value_is_gobject(ctx, val))
+	  {
+	    GObject *o = seed_value_to_object (ctx, val, exception);
+
+	    g_value_init (ret, G_OBJECT_TYPE(o));
+	    g_value_set_object (ret, o);
+	    return TRUE;
+	  }
 	// Support [GObject.TYPE_INT, 3]
 	// TODO: FIXME: Might crash.
-	if (type == 0 && JSValueIsObject (ctx, val))
+	else if (type == 0 && JSValueIsObject (ctx, val))
 	  {
 	    // TODO: FIXME: Better array test like the cool one on reddit.
 	    guint length = seed_value_to_int (ctx,
diff --git a/tests/javascript/gvalue-argument.js b/tests/javascript/gvalue-argument.js
index 3386b4c..80358d1 100755
--- a/tests/javascript/gvalue-argument.js
+++ b/tests/javascript/gvalue-argument.js
@@ -6,10 +6,12 @@ Gtk.init(Seed.argv);
 
 var s = new Gtk.ListStore();
 
-s.set_column_types(2, [GObject.TYPE_STRING, GObject.TYPE_INT]);
+s.set_column_types(3, [GObject.TYPE_STRING, GObject.TYPE_INT, Gtk.Label.type]);
 
 var ret = {};
 
 s.append(ret);
 s.set_value(ret.iter, 0, "Hi");
 s.set_value(ret.iter, 1, [GObject.TYPE_INT, 10] );
+l = new Gtk.Label.c_new("Hi");
+s.set_value(ret.iter, 2, l);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]