context: // This file was generated by the Gtk# code generator.
  // Any changes made will be lost if regenerated.
  
  namespace Gst.Interfaces {
  
  	using System;
  	using System.Runtime.InteropServices;
  	using System.Reflection;
  
  #region Autogenerated code
  	public partial class ColorBalanceAdapter : GLib.GInterfaceAdapter, Gst.Interfaces.ColorBalance {
  
  		[StructLayout (LayoutKind.Sequential)]
  		struct GstColorBalanceClass {
  			public Gst.Interfaces.ColorBalanceType BalanceType;
  			public ListChannelsNativeDelegate ListChannels;
  			public SetValueNativeDelegate SetValue;
  			public GetValueNativeDelegate GetValue;
  			IntPtr ValueChanged;
  			[MarshalAs (UnmanagedType.ByValArray, SizeConst=4)]
  			public IntPtr[] GstReserved;
  		}
  
  		static GstColorBalanceClass iface;
  
  		static ColorBalanceAdapter ()
  		{
  			GLib.GType.Register (_gtype, typeof(ColorBalanceAdapter));
  			iface.ListChannels = new ListChannelsNativeDelegate (ListChannels_cb);
  			iface.SetValue = new SetValueNativeDelegate (SetValue_cb);
  			iface.GetValue = new GetValueNativeDelegate (GetValue_cb);
  		}
  
  		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
  		delegate IntPtr ListChannelsNativeDelegate (IntPtr inst);
  
  		static IntPtr ListChannels_cb (IntPtr inst)
  		{
  			try {
  				ColorBalanceImplementor __obj = GLib.Object.GetObject (inst, false) as ColorBalanceImplementor;
  				Gst.Interfaces.ColorBalanceChannel[] __result = __obj.ListChannels ();
  				return new GLib.List(__result, typeof (Gst.Interfaces.ColorBalanceChannel), false, false) == null ? IntPtr.Zero : new GLib.List(__result, typeof (Gst.Interfaces.ColorBalanceChannel), false, false).Handle;
  			} catch (Exception e) {
  				GLib.ExceptionManager.RaiseUnhandledException (e, true);
  				// NOTREACHED: above call does not return.
  				throw e;
  			}
  		}
  
  		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
  		delegate void SetValueNativeDelegate (IntPtr inst, IntPtr channel, int value);
  
  		static void SetValue_cb (IntPtr inst, IntPtr channel, int value)
  		{
  			try {
  				ColorBalanceImplementor __obj = GLib.Object.GetObject (inst, false) as ColorBalanceImplementor;
  				__obj.SetValue (GLib.Object.GetObject(channel) as Gst.Interfaces.ColorBalanceChannel, value);
  			} catch (Exception e) {
  				GLib.ExceptionManager.RaiseUnhandledException (e, false);
  			}
  		}
  
  		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
  		delegate int GetValueNativeDelegate (IntPtr inst, IntPtr channel);
  
  		static int GetValue_cb (IntPtr inst, IntPtr channel)
  		{
  			try {
  				ColorBalanceImplementor __obj = GLib.Object.GetObject (inst, false) as ColorBalanceImplementor;
  				int __result = __obj.GetValue (GLib.Object.GetObject(channel) as Gst.Interfaces.ColorBalanceChannel);
  				return __result;
  			} catch (Exception e) {
  				GLib.ExceptionManager.RaiseUnhandledException (e, true);
  				// NOTREACHED: above call does not return.
  				throw e;
  			}
  		}
  
  		static int class_offset = 2 * IntPtr.Size;
  
  		static void Initialize (IntPtr ptr, IntPtr data)
  		{
  			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
  			GstColorBalanceClass native_iface = (GstColorBalanceClass) Marshal.PtrToStructure (ifaceptr, typeof (GstColorBalanceClass));
  			native_iface.ListChannels = iface.ListChannels;
  			native_iface.SetValue = iface.SetValue;
  			native_iface.GetValue = iface.GetValue;
  
  			GCHandle gch = (GCHandle) data;
  			ColorBalanceAdapter adapter = gch.Target as ColorBalanceAdapter;
  
  			ColorBalanceImplementor implementor = adapter.Implementor;
  			if (implementor != null) {
  			  PropertyInfo pi = implementor.GetType().GetProperty ("BalanceType", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy);
  			  if (pi != null && pi.PropertyType == typeof (Gst.Interfaces.ColorBalanceType))
  			    native_iface.BalanceType = (Gst.Interfaces.ColorBalanceType) pi.GetValue (null, null);
  			}
  
  			Marshal.StructureToPtr (native_iface, ifaceptr, false);
  			gch.Free ();
  		}
  
  		GLib.Object implementor;
  
  		public ColorBalanceAdapter ()
  		{
  			InitHandler = new GLib.GInterfaceInitHandler (Initialize);
  		}
  
  		public ColorBalanceAdapter (ColorBalanceImplementor implementor)
  		{
  			if (implementor == null)
  				throw new ArgumentNullException ("implementor");
  			else if (!(implementor is GLib.Object))
  				throw new ArgumentException ("implementor must be a subclass of GLib.Object");
  			this.implementor = implementor as GLib.Object;
  		}
  
  		public ColorBalanceAdapter (IntPtr handle)
  		{
  			if (!_gtype.IsInstance (handle))
  				throw new ArgumentException ("The gobject doesn't implement the GInterface of this adapter", "handle");
  			implementor = GLib.Object.GetObject (handle);
  		}
  
  		[DllImport("libgstinterfaces-0.10.dll", CallingConvention = CallingConvention.Cdecl)]
  		static extern IntPtr gst_color_balance_get_type();
  
  		private static GLib.GType _gtype = new GLib.GType (gst_color_balance_get_type ());
  
  		public override GLib.GType GType {
  			get {
  				return _gtype;
  			}
  		}
  
  		public override IntPtr Handle {
  			get {
  				return implementor.Handle;
  			}
  		}
  
  		public IntPtr OwnedHandle {
  			get {
  				return implementor.OwnedHandle;
  			}
  		}
  
  		public static ColorBalance GetObject (IntPtr handle, bool owned)
  		{
  			GLib.Object obj = GLib.Object.GetObject (handle, owned);
  			return GetObject (obj);
  		}
  
  		public static ColorBalance GetObject (GLib.Object obj)
  		{
  			if (obj == null)
  				return null;
  			else if (obj is ColorBalanceImplementor)
  				return new ColorBalanceAdapter (obj as ColorBalanceImplementor);
  			else if (obj as ColorBalance == null)
  				return new ColorBalanceAdapter (obj.Handle);
  			else
  				return obj as ColorBalance;
  		}
  
  		public ColorBalanceImplementor Implementor {
  			get {
  				return implementor as ColorBalanceImplementor;
  			}
  		}
  
  		[GLib.Signal("value-changed")]
  		public event Gst.Interfaces.ValueChangedHandler ValueChanged {
  			add {
  				GLib.Object.GetObject (Handle).AddSignalHandler ("value-changed", value, typeof (Gst.Interfaces.ValueChangedArgs));
  			}
  			remove {
  				GLib.Object.GetObject (Handle).RemoveSignalHandler ("value-changed", value);
  			}
  		}
  
  		[DllImport("libgstinterfaces-0.10.dll", CallingConvention = CallingConvention.Cdecl)]
  		static extern void gst_color_balance_set_value(IntPtr raw, IntPtr channel, int value);
  
  		public void SetValue(Gst.Interfaces.ColorBalanceChannel channel, int value) {
  			gst_color_balance_set_value(Handle, channel == null ? IntPtr.Zero : channel.Handle, value);
  		}
  
  		[DllImport("libgstinterfaces-0.10.dll", CallingConvention = CallingConvention.Cdecl)]
  		static extern IntPtr gst_color_balance_list_channels(IntPtr raw);
  
  		public Gst.Interfaces.ColorBalanceChannel[] ListChannels() {
  			IntPtr raw_ret = gst_color_balance_list_channels(Handle);
  			Gst.Interfaces.ColorBalanceChannel[] ret = (Gst.Interfaces.ColorBalanceChannel[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof(GLib.List), false, false, typeof(Gst.Interfaces.ColorBalanceChannel));
  			return ret;
  		}
  
  		[DllImport("libgstinterfaces-0.10.dll", CallingConvention = CallingConvention.Cdecl)]
  		static extern int gst_color_balance_get_value(IntPtr raw, IntPtr channel);
  
  		public int GetValue(Gst.Interfaces.ColorBalanceChannel channel) {
  			int raw_ret = gst_color_balance_get_value(Handle, channel == null ? IntPtr.Zero : channel.Handle);
  			int ret = raw_ret;
  			return ret;
  		}
  
  		[DllImport("libgstinterfaces-0.10.dll", CallingConvention = CallingConvention.Cdecl)]
  		static extern int gst_color_balance_get_balance_type(IntPtr raw);
  
  		public Gst.Interfaces.ColorBalanceType BalanceType { 
  			get {
  
gt: 				int raw_ret = gst_color_balance_get_balance_type(Handle);