[Gtk-sharp-list] GLib.Value fix

Radek Doulík rodo@ximian.com
18 Nov 2002 00:24:03 +0100


--=-KXFcdv4vg4gu2jfdeuVl
Content-Type: text/plain
Content-Transfer-Encoding: 7bit


Hi,

attached patch fixes GLib.Value from GLib.Object constructor, it
preserves objects GType now (like Gdk.Pixbuf) instead of remembering it
as GLib.Object.

Could I commit?

Cheers
Radek

--=-KXFcdv4vg4gu2jfdeuVl
Content-Disposition: attachment; filename=glib_value_fix.patch
Content-Type: text/x-patch; name=glib_value_fix.patch; charset=ISO-8859-2
Content-Transfer-Encoding: 7bit

Index: ChangeLog
===================================================================
RCS file: /cvs/public/gtk-sharp/ChangeLog,v
retrieving revision 1.261
diff -u -p -r1.261 ChangeLog
--- ChangeLog	17 Nov 2002 21:17:12 -0000	1.261
+++ ChangeLog	17 Nov 2002 21:24:39 -0000
@@ -1,3 +1,10 @@
+2002-11-17  Radek Doulik  <rodo@ximian.com>
+
+	* glib/Value.cs: cast Typefundamentals.* to uint (GType is
+	unsigned int), fix Value (GLib.Object) - use new GetGType method
+
+	* glib/Object.cs: new GetGType method, returns _obj GType
+
 2002-11-17  Daniel Morgan <danmorg@sc.rr.com>
 
 	* pango/Scale.cs: added file containing constants
Index: glib/Object.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/glib/Object.cs,v
retrieving revision 1.36
diff -u -p -r1.36 Object.cs
--- glib/Object.cs	10 Nov 2002 10:09:05 -0000	1.36
+++ glib/Object.cs	17 Nov 2002 21:24:39 -0000
@@ -193,10 +193,25 @@ namespace GLib {
 		[DllImport("libgtksharpglue.so")]
 		private static extern uint gtksharp_get_type_id (IntPtr obj);
 
-		public static int GType {
+		public static uint GType {
 			get {
 				return 0;
 			}
+		}
+
+		/// <summary>
+		///	GetGType Method
+		/// </summary>
+		///
+		/// <remarks>
+		///	Returns the GType of this object.
+		/// </remarks>
+
+		public uint GetGType () {
+			if (_obj == IntPtr.Zero)
+				return (uint) TypeFundamentals.TypeInvalid;
+			else
+				return gtksharp_get_type_id (_obj);
 		}
 
 		/// <summary>
Index: glib/Value.cs
===================================================================
RCS file: /cvs/public/gtk-sharp/glib/Value.cs,v
retrieving revision 1.19
diff -u -p -r1.19 Value.cs
--- glib/Value.cs	27 Oct 2002 02:30:50 -0000	1.19
+++ glib/Value.cs	17 Nov 2002 21:24:39 -0000
@@ -38,7 +38,7 @@ namespace GLib {
 		// import the glue function to allocate values on heap
 
 		[DllImport("gtksharpglue")]
-		static extern IntPtr gtksharp_value_create(TypeFundamentals type);
+		static extern IntPtr gtksharp_value_create(uint type);
 
 		[DllImport("gtksharpglue")]
 		static extern IntPtr gtksharp_value_create_from_property(IntPtr obj, string name);
@@ -61,7 +61,7 @@ namespace GLib {
 		/// </remarks>
 
 		public Value () {
-			_val = gtksharp_value_create (TypeFundamentals.TypeInvalid);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypeInvalid);
 		}
 
 		/// <summary>
@@ -92,7 +92,7 @@ namespace GLib {
 
 		public Value (bool val)
 		{
-			_val = gtksharp_value_create(TypeFundamentals.TypeBoolean);
+			_val = gtksharp_value_create((uint) TypeFundamentals.TypeBoolean);
 			g_value_set_boolean (_val, val);
 		}
 
@@ -109,7 +109,7 @@ namespace GLib {
 
 		public Value (GLib.Boxed val)
 		{
-			_val = gtksharp_value_create(TypeFundamentals.TypeBoxed);
+			_val = gtksharp_value_create((uint) TypeFundamentals.TypeBoxed);
 			//g_value_set_boxed (_val, val.Handle);
 		}
 
@@ -121,7 +121,7 @@ namespace GLib {
 
 		public Value (GLib.Opaque val)
 		{
-			_val = gtksharp_value_create(TypeFundamentals.TypeBoxed);
+			_val = gtksharp_value_create((uint) TypeFundamentals.TypeBoxed);
 			g_value_set_boxed (_val, val.Handle);
 		}
 
@@ -138,7 +138,7 @@ namespace GLib {
 
 		public Value (double val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypeDouble);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypeDouble);
 			g_value_set_double (_val, val);
 		}
 
@@ -155,7 +155,7 @@ namespace GLib {
 
 		public Value (float val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypeFloat);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypeFloat);
 			g_value_set_float (_val, val);
 		}
 
@@ -172,7 +172,7 @@ namespace GLib {
 
 		public Value (int val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypeInt);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypeInt);
 			g_value_set_int (_val, val);
 		}
 
@@ -189,7 +189,7 @@ namespace GLib {
 
 		public Value (GLib.Object val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypeObject);
+			_val = gtksharp_value_create (val.GetGType ());
 			g_value_set_object (_val, val.Handle);
 		}
 
@@ -206,7 +206,7 @@ namespace GLib {
 
 		public Value (IntPtr val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypePointer);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypePointer);
 			g_value_set_pointer (_val, val); 
 		}
 
@@ -223,7 +223,7 @@ namespace GLib {
 
 		public Value (string val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypeString);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypeString);
 			g_value_set_string (_val, val); 
 		}
 
@@ -240,7 +240,7 @@ namespace GLib {
 
 		public Value (uint val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypeUInt);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypeUInt);
 			g_value_set_uint (_val, val); 
 		}
 
@@ -254,7 +254,7 @@ namespace GLib {
 
 		public Value (ushort val)
 		{
-			_val = gtksharp_value_create (TypeFundamentals.TypeUInt);
+			_val = gtksharp_value_create ((uint) TypeFundamentals.TypeUInt);
 			g_value_set_uint (_val, val); 
 		}
 

--=-KXFcdv4vg4gu2jfdeuVl--