// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Gst {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class PresetAdapter : GLib.GInterfaceAdapter, Gst.IPreset {

		[StructLayout (LayoutKind.Sequential)]
		struct GstPresetInterface {
			public GetPresetNamesNativeDelegate GetPresetNames;
			public GetPropertyNamesNativeDelegate GetPropertyNames;
			public LoadPresetNativeDelegate LoadPreset;
			public SavePresetNativeDelegate SavePreset;
			public RenamePresetNativeDelegate RenamePreset;
			public DeletePresetNativeDelegate DeletePreset;
			public SetMetaNativeDelegate SetMeta;
			public GetMetaNativeDelegate GetMeta;
			[MarshalAs (UnmanagedType.ByValArray, SizeConst=4)]
			private IntPtr[] _gstGstReserved;
		}

		static GstPresetInterface iface;

		static PresetAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (PresetAdapter));
			iface.GetPresetNames = new GetPresetNamesNativeDelegate (GetPresetNames_cb);
			iface.GetPropertyNames = new GetPropertyNamesNativeDelegate (GetPropertyNames_cb);
			iface.LoadPreset = new LoadPresetNativeDelegate (LoadPreset_cb);
			iface.SavePreset = new SavePresetNativeDelegate (SavePreset_cb);
			iface.RenamePreset = new RenamePresetNativeDelegate (RenamePreset_cb);
			iface.DeletePreset = new DeletePresetNativeDelegate (DeletePreset_cb);
			iface.SetMeta = new SetMetaNativeDelegate (SetMeta_cb);
			iface.GetMeta = new GetMetaNativeDelegate (GetMeta_cb);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetPresetNamesNativeDelegate (IntPtr inst);

		static IntPtr GetPresetNames_cb (IntPtr inst)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				string[] __result;
				__result = __obj.PresetNames;
				return GLib.Marshaller.StringArrayToNullTermStrvPointer (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetPropertyNamesNativeDelegate (IntPtr inst);

		static IntPtr GetPropertyNames_cb (IntPtr inst)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				string[] __result;
				__result = __obj.PropertyNames;
				return GLib.Marshaller.StringArrayToNullTermStrvPointer (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool LoadPresetNativeDelegate (IntPtr inst, IntPtr name);

		static bool LoadPreset_cb (IntPtr inst, IntPtr name)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				bool __result;
				__result = __obj.LoadPreset (GLib.Marshaller.Utf8PtrToString (name));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SavePresetNativeDelegate (IntPtr inst, IntPtr name);

		static bool SavePreset_cb (IntPtr inst, IntPtr name)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				bool __result;
				__result = __obj.SavePreset (GLib.Marshaller.Utf8PtrToString (name));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool RenamePresetNativeDelegate (IntPtr inst, IntPtr old_name, IntPtr new_name);

		static bool RenamePreset_cb (IntPtr inst, IntPtr old_name, IntPtr new_name)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				bool __result;
				__result = __obj.RenamePreset (GLib.Marshaller.Utf8PtrToString (old_name), GLib.Marshaller.Utf8PtrToString (new_name));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool DeletePresetNativeDelegate (IntPtr inst, IntPtr name);

		static bool DeletePreset_cb (IntPtr inst, IntPtr name)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				bool __result;
				__result = __obj.DeletePreset (GLib.Marshaller.Utf8PtrToString (name));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetMetaNativeDelegate (IntPtr inst, IntPtr name, IntPtr tag, IntPtr value);

		static bool SetMeta_cb (IntPtr inst, IntPtr name, IntPtr tag, IntPtr value)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				bool __result;
				__result = __obj.SetMeta (GLib.Marshaller.Utf8PtrToString (name), GLib.Marshaller.Utf8PtrToString (tag), GLib.Marshaller.Utf8PtrToString (value));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool GetMetaNativeDelegate (IntPtr inst, IntPtr name, IntPtr tag, out IntPtr value);

		static bool GetMeta_cb (IntPtr inst, IntPtr name, IntPtr tag, out IntPtr value)
		{
			try {
				IPresetImplementor __obj = GLib.Object.GetObject (inst, false) as IPresetImplementor;
				bool __result;
				string myvalue;
				__result = __obj.GetMeta (GLib.Marshaller.Utf8PtrToString (name), GLib.Marshaller.Utf8PtrToString (tag), out myvalue);
				value = GLib.Marshaller.StringToPtrGStrdup(myvalue);
				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);
			GstPresetInterface native_iface = (GstPresetInterface) Marshal.PtrToStructure (ifaceptr, typeof (GstPresetInterface));
			native_iface.GetPresetNames = iface.GetPresetNames;
			native_iface.GetPropertyNames = iface.GetPropertyNames;
			native_iface.LoadPreset = iface.LoadPreset;
			native_iface.SavePreset = iface.SavePreset;
			native_iface.RenamePreset = iface.RenamePreset;
			native_iface.DeletePreset = iface.DeletePreset;
			native_iface.SetMeta = iface.SetMeta;
			native_iface.GetMeta = iface.GetMeta;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

		public PresetAdapter ()
		{
			InitHandler = new GLib.GInterfaceInitHandler (Initialize);
		}

		public PresetAdapter (IPresetImplementor 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 PresetAdapter (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("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_preset_get_type();

		private static GLib.GType _gtype = new GLib.GType (gst_preset_get_type ());

		public static GLib.GType GType {
			get {
				return _gtype;
			}
		}

		public override GLib.GType GInterfaceGType {
			get {
				return _gtype;
			}
		}

		public override IntPtr Handle {
			get {
				return implementor.Handle;
			}
		}

		public IntPtr OwnedHandle {
			get {
				return implementor.OwnedHandle;
			}
		}

		public static IPreset GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static IPreset GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IPresetImplementor)
				return new PresetAdapter (obj as IPresetImplementor);
			else if (obj as IPreset == null)
				return new PresetAdapter (obj.Handle);
			else
				return obj as IPreset;
		}

		public IPresetImplementor Implementor {
			get {
				return implementor as IPresetImplementor;
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_preset_get_app_dir();

		public static string AppDir { 
			get {
				IntPtr raw_ret = gst_preset_get_app_dir();
				string ret = GLib.Marshaller.FilenamePtrToString (raw_ret);
				return ret;
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_set_app_dir(IntPtr app_dir);

		public static bool SetAppDir(string app_dir) {
			IntPtr native_app_dir = GLib.Marshaller.StringToFilenamePtr (app_dir);
			bool raw_ret = gst_preset_set_app_dir(native_app_dir);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_app_dir);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_delete_preset(IntPtr raw, IntPtr name);

		public bool DeletePreset(string name) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			bool raw_ret = gst_preset_delete_preset(Handle, native_name);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_name);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_get_meta(IntPtr raw, IntPtr name, IntPtr tag, out IntPtr value);

		public bool GetMeta(string name, string tag, out string value) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			IntPtr native_tag = GLib.Marshaller.StringToPtrGStrdup (tag);
			IntPtr native_value;
			bool raw_ret = gst_preset_get_meta(Handle, native_name, native_tag, out native_value);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_name);
			GLib.Marshaller.Free (native_tag);
			value = GLib.Marshaller.PtrToStringGFree(native_value);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_preset_get_preset_names(IntPtr raw);

		public string[] PresetNames { 
			get {
				IntPtr raw_ret = gst_preset_get_preset_names(Handle);
				string[] ret = GLib.Marshaller.NullTermPtrToStringArray (raw_ret, true);
				return ret;
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_preset_get_property_names(IntPtr raw);

		public string[] PropertyNames { 
			get {
				IntPtr raw_ret = gst_preset_get_property_names(Handle);
				string[] ret = GLib.Marshaller.NullTermPtrToStringArray (raw_ret, true);
				return ret;
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_is_editable(IntPtr raw);

		public bool IsEditable { 
			get {
				bool raw_ret = gst_preset_is_editable(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_load_preset(IntPtr raw, IntPtr name);

		public bool LoadPreset(string name) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			bool raw_ret = gst_preset_load_preset(Handle, native_name);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_name);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_rename_preset(IntPtr raw, IntPtr old_name, IntPtr new_name);

		public bool RenamePreset(string old_name, string new_name) {
			IntPtr native_old_name = GLib.Marshaller.StringToPtrGStrdup (old_name);
			IntPtr native_new_name = GLib.Marshaller.StringToPtrGStrdup (new_name);
			bool raw_ret = gst_preset_rename_preset(Handle, native_old_name, native_new_name);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_old_name);
			GLib.Marshaller.Free (native_new_name);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_save_preset(IntPtr raw, IntPtr name);

		public bool SavePreset(string name) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			bool raw_ret = gst_preset_save_preset(Handle, native_name);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_name);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_preset_set_meta(IntPtr raw, IntPtr name, IntPtr tag, IntPtr value);

		public bool SetMeta(string name, string tag, string value) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			IntPtr native_tag = GLib.Marshaller.StringToPtrGStrdup (tag);
			IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
			bool raw_ret = gst_preset_set_meta(Handle, native_name, native_tag, native_value);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_name);
			GLib.Marshaller.Free (native_tag);
			GLib.Marshaller.Free (native_value);
			return ret;
		}

		public bool SetMeta(string name, string tag) {
			return SetMeta (name, tag, null);
		}

#endregion
	}
}