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

namespace GES {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class Project : GES.Asset {

		public Project (IntPtr raw) : base(raw) {}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr ges_project_new(IntPtr uri);

		public Project (string uri) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Project)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				names.Add ("uri");
				vals.Add (new GLib.Value (uri));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			Raw = ges_project_new(native_uri);
			GLib.Marshaller.Free (native_uri);
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr ges_project_get_uri(IntPtr raw);

		[GLib.Property ("uri")]
		public string Uri {
			get  {
				IntPtr raw_ret = ges_project_get_uri(Handle);
				string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
				return ret;
			}
		}

		[GLib.Signal("asset-removed")]
		public event GES.AssetRemovedHandler AssetRemoved {
			add {
				this.AddSignalHandler ("asset-removed", value, typeof (GES.AssetRemovedArgs));
			}
			remove {
				this.RemoveSignalHandler ("asset-removed", value);
			}
		}

		[GLib.Signal("loaded")]
		public event GES.LoadedHandler Loaded {
			add {
				this.AddSignalHandler ("loaded", value, typeof (GES.LoadedArgs));
			}
			remove {
				this.RemoveSignalHandler ("loaded", value);
			}
		}

		[GLib.Signal("asset-added")]
		public event GES.AssetAddedHandler AssetAdded {
			add {
				this.AddSignalHandler ("asset-added", value, typeof (GES.AssetAddedArgs));
			}
			remove {
				this.RemoveSignalHandler ("asset-added", value);
			}
		}

		[GLib.Signal("asset-loading")]
		public event GES.AssetLoadingHandler AssetLoading {
			add {
				this.AddSignalHandler ("asset-loading", value, typeof (GES.AssetLoadingArgs));
			}
			remove {
				this.RemoveSignalHandler ("asset-loading", value);
			}
		}

		static AssetAddedNativeDelegate AssetAdded_cb_delegate;
		static AssetAddedNativeDelegate AssetAddedVMCallback {
			get {
				if (AssetAdded_cb_delegate == null)
					AssetAdded_cb_delegate = new AssetAddedNativeDelegate (AssetAdded_cb);
				return AssetAdded_cb_delegate;
			}
		}

		static void OverrideAssetAdded (GLib.GType gtype)
		{
			OverrideAssetAdded (gtype, AssetAddedVMCallback);
		}

		static void OverrideAssetAdded (GLib.GType gtype, AssetAddedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("asset_added"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void AssetAddedNativeDelegate (IntPtr inst, IntPtr asset);

		static void AssetAdded_cb (IntPtr inst, IntPtr asset)
		{
			try {
				Project __obj = GLib.Object.GetObject (inst, false) as Project;
				__obj.OnAssetAdded (GLib.Object.GetObject(asset) as GES.Asset);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GES.Project), ConnectionMethod="OverrideAssetAdded")]
		protected virtual void OnAssetAdded (GES.Asset asset)
		{
			InternalAssetAdded (asset);
		}

		private void InternalAssetAdded (GES.Asset asset)
		{
			AssetAddedNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("asset_added"));
				unmanaged = (AssetAddedNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(AssetAddedNativeDelegate));
			}
			if (unmanaged == null) return;

			unmanaged (this.Handle, asset == null ? IntPtr.Zero : asset.Handle);
		}

		static AssetLoadingNativeDelegate AssetLoading_cb_delegate;
		static AssetLoadingNativeDelegate AssetLoadingVMCallback {
			get {
				if (AssetLoading_cb_delegate == null)
					AssetLoading_cb_delegate = new AssetLoadingNativeDelegate (AssetLoading_cb);
				return AssetLoading_cb_delegate;
			}
		}

		static void OverrideAssetLoading (GLib.GType gtype)
		{
			OverrideAssetLoading (gtype, AssetLoadingVMCallback);
		}

		static void OverrideAssetLoading (GLib.GType gtype, AssetLoadingNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("asset_loading"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void AssetLoadingNativeDelegate (IntPtr inst, IntPtr asset);

		static void AssetLoading_cb (IntPtr inst, IntPtr asset)
		{
			try {
				Project __obj = GLib.Object.GetObject (inst, false) as Project;
				__obj.OnAssetLoading (GLib.Object.GetObject(asset) as GES.Asset);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GES.Project), ConnectionMethod="OverrideAssetLoading")]
		protected virtual void OnAssetLoading (GES.Asset asset)
		{
			InternalAssetLoading (asset);
		}

		private void InternalAssetLoading (GES.Asset asset)
		{
			AssetLoadingNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("asset_loading"));
				unmanaged = (AssetLoadingNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(AssetLoadingNativeDelegate));
			}
			if (unmanaged == null) return;

			unmanaged (this.Handle, asset == null ? IntPtr.Zero : asset.Handle);
		}

		static AssetRemovedNativeDelegate AssetRemoved_cb_delegate;
		static AssetRemovedNativeDelegate AssetRemovedVMCallback {
			get {
				if (AssetRemoved_cb_delegate == null)
					AssetRemoved_cb_delegate = new AssetRemovedNativeDelegate (AssetRemoved_cb);
				return AssetRemoved_cb_delegate;
			}
		}

		static void OverrideAssetRemoved (GLib.GType gtype)
		{
			OverrideAssetRemoved (gtype, AssetRemovedVMCallback);
		}

		static void OverrideAssetRemoved (GLib.GType gtype, AssetRemovedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("asset_removed"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void AssetRemovedNativeDelegate (IntPtr inst, IntPtr asset);

		static void AssetRemoved_cb (IntPtr inst, IntPtr asset)
		{
			try {
				Project __obj = GLib.Object.GetObject (inst, false) as Project;
				__obj.OnAssetRemoved (GLib.Object.GetObject(asset) as GES.Asset);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GES.Project), ConnectionMethod="OverrideAssetRemoved")]
		protected virtual void OnAssetRemoved (GES.Asset asset)
		{
			InternalAssetRemoved (asset);
		}

		private void InternalAssetRemoved (GES.Asset asset)
		{
			AssetRemovedNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("asset_removed"));
				unmanaged = (AssetRemovedNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(AssetRemovedNativeDelegate));
			}
			if (unmanaged == null) return;

			unmanaged (this.Handle, asset == null ? IntPtr.Zero : asset.Handle);
		}

		static LoadedNativeDelegate Loaded_cb_delegate;
		static LoadedNativeDelegate LoadedVMCallback {
			get {
				if (Loaded_cb_delegate == null)
					Loaded_cb_delegate = new LoadedNativeDelegate (Loaded_cb);
				return Loaded_cb_delegate;
			}
		}

		static void OverrideLoaded (GLib.GType gtype)
		{
			OverrideLoaded (gtype, LoadedVMCallback);
		}

		static void OverrideLoaded (GLib.GType gtype, LoadedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("loaded"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void LoadedNativeDelegate (IntPtr inst, IntPtr timeline);

		static void Loaded_cb (IntPtr inst, IntPtr timeline)
		{
			try {
				Project __obj = GLib.Object.GetObject (inst, false) as Project;
				__obj.OnLoaded (GLib.Object.GetObject(timeline) as GES.Timeline);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GES.Project), ConnectionMethod="OverrideLoaded")]
		protected virtual void OnLoaded (GES.Timeline timeline)
		{
			InternalLoaded (timeline);
		}

		private void InternalLoaded (GES.Timeline timeline)
		{
			LoadedNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("loaded"));
				unmanaged = (LoadedNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(LoadedNativeDelegate));
			}
			if (unmanaged == null) return;

			unmanaged (this.Handle, timeline == null ? IntPtr.Zero : timeline.Handle);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("asset_added"
							, GES.Asset.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // asset_added
							, null
							, "asset_loading"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("asset_loading"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // asset_loading
							, "asset_added"
							, "asset_removed"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("asset_removed"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // asset_removed
							, "asset_loading"
							, "missing_uri"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("missing_uri"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // missing_uri
							, "asset_removed"
							, "loading_error"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("loading_error"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // loading_error
							, "missing_uri"
							, "loaded"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("loaded"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // loaded
							, "loading_error"
							, "_ges_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_ges_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _ges_reserved
							, "loaded"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr ges_project_get_type();

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = ges_project_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern bool ges_project_add_asset(IntPtr raw, IntPtr asset);

		public bool AddAsset(GES.Asset asset) {
			bool raw_ret = ges_project_add_asset(Handle, asset == null ? IntPtr.Zero : asset.Handle);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern bool ges_project_add_encoding_profile(IntPtr raw, IntPtr profile);

		public bool AddEncodingProfile(Gst.PbUtils.EncodingProfile profile) {
			bool raw_ret = ges_project_add_encoding_profile(Handle, profile == null ? IntPtr.Zero : profile.Handle);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern bool ges_project_create_asset(IntPtr raw, IntPtr id, IntPtr extractable_type);

		public bool CreateAsset(string id, GLib.GType extractable_type) {
			IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
			bool raw_ret = ges_project_create_asset(Handle, native_id, extractable_type.Val);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_id);
			return ret;
		}

		public bool CreateAsset(GLib.GType extractable_type) {
			return CreateAsset (null, extractable_type);
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern unsafe IntPtr ges_project_create_asset_sync(IntPtr raw, IntPtr id, IntPtr extractable_type, out IntPtr error);

		public unsafe GES.Asset CreateAssetSync(string id, GLib.GType extractable_type) {
			IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = ges_project_create_asset_sync(Handle, native_id, extractable_type.Val, out error);
			GES.Asset ret = GLib.Object.GetObject(raw_ret, true) as GES.Asset;
			GLib.Marshaller.Free (native_id);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		public GES.Asset CreateAssetSync(GLib.GType extractable_type) {
			return CreateAssetSync (null, extractable_type);
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr ges_project_get_asset(IntPtr raw, IntPtr id, IntPtr extractable_type);

		public GES.Asset GetAsset(string id, GLib.GType extractable_type) {
			IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id);
			IntPtr raw_ret = ges_project_get_asset(Handle, native_id, extractable_type.Val);
			GES.Asset ret = GLib.Object.GetObject(raw_ret, true) as GES.Asset;
			GLib.Marshaller.Free (native_id);
			return ret;
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr ges_project_get_loading_assets(IntPtr raw);

		public GES.Asset[] LoadingAssets { 
			get {
				IntPtr raw_ret = ges_project_get_loading_assets(Handle);
				GES.Asset[] ret = (GES.Asset[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof(GLib.List), true, true, typeof(GES.Asset));
				return ret;
			}
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr ges_project_list_assets(IntPtr raw, IntPtr filter);

		public GES.Asset[] ListAssets(GLib.GType filter) {
			IntPtr raw_ret = ges_project_list_assets(Handle, filter.Val);
			GES.Asset[] ret = (GES.Asset[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof(GLib.List), true, true, typeof(GES.Asset));
			return ret;
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern unsafe bool ges_project_load(IntPtr raw, IntPtr timeline, out IntPtr error);

		public unsafe bool Load(GES.Timeline timeline) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = ges_project_load(Handle, timeline == null ? IntPtr.Zero : timeline.Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern bool ges_project_remove_asset(IntPtr raw, IntPtr asset);

		public bool RemoveAsset(GES.Asset asset) {
			bool raw_ret = ges_project_remove_asset(Handle, asset == null ? IntPtr.Zero : asset.Handle);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("ges-1.0", CallingConvention = CallingConvention.Cdecl)]
		static extern unsafe bool ges_project_save(IntPtr raw, IntPtr timeline, IntPtr uri, IntPtr formatter_asset, bool overwrite, out IntPtr error);

		public unsafe bool Save(GES.Timeline timeline, string uri, GES.Asset formatter_asset, bool overwrite) {
			IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
			IntPtr error = IntPtr.Zero;
			bool raw_ret = ges_project_save(Handle, timeline == null ? IntPtr.Zero : timeline.Handle, native_uri, formatter_asset == null ? IntPtr.Zero : formatter_asset.Handle, overwrite, out error);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_uri);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		public bool Save(GES.Timeline timeline, string uri, bool overwrite) {
			return Save (timeline, uri, null, overwrite);
		}


		static Project ()
		{
			GtkSharp.GstEditingServices.ObjectManager.Initialize ();
		}

		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, GES.Asset.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // priv
							, null
							, "__ges_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("__ges_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 20 // __ges_reserved
							, "priv"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
