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

namespace GLib {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class BytesIcon : GLib.Object, GLib.IIcon, GLib.ILoadableIcon {

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_bytes_icon_new(IntPtr bytes);
		static d_g_bytes_icon_new g_bytes_icon_new = FuncLoader.LoadFunction<d_g_bytes_icon_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_bytes_icon_new"));

		public BytesIcon (GLib.Bytes bytes) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (BytesIcon)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				names.Add ("bytes");
				vals.Add (new GLib.Value (bytes));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			Raw = g_bytes_icon_new(bytes == null ? IntPtr.Zero : bytes.Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_bytes_icon_get_bytes(IntPtr raw);
		static d_g_bytes_icon_get_bytes g_bytes_icon_get_bytes = FuncLoader.LoadFunction<d_g_bytes_icon_get_bytes>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_bytes_icon_get_bytes"));

		[GLib.Property ("bytes")]
		public GLib.Bytes Bytes {
			get  {
				IntPtr raw_ret = g_bytes_icon_get_bytes(Handle);
				GLib.Bytes ret = new GLib.Bytes(raw_ret);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_bytes_icon_get_type();
		static d_g_bytes_icon_get_type g_bytes_icon_get_type = FuncLoader.LoadFunction<d_g_bytes_icon_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_bytes_icon_get_type"));

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_icon_equal(IntPtr raw, IntPtr icon2);
		static d_g_icon_equal g_icon_equal = FuncLoader.LoadFunction<d_g_icon_equal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_icon_equal"));

		public bool Equal(GLib.IIcon icon2) {
			bool raw_ret = g_icon_equal(Handle, icon2 == null ? IntPtr.Zero : ((icon2 is GLib.Object) ? (icon2 as GLib.Object).Handle : (icon2 as GLib.IconAdapter).Handle));
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_icon_serialize(IntPtr raw);
		static d_g_icon_serialize g_icon_serialize = FuncLoader.LoadFunction<d_g_icon_serialize>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_icon_serialize"));

		public GLib.Variant Serialize() {
			IntPtr raw_ret = g_icon_serialize(Handle);
			GLib.Variant ret = new GLib.Variant(raw_ret);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_icon_to_string(IntPtr raw);
		static d_g_icon_to_string g_icon_to_string = FuncLoader.LoadFunction<d_g_icon_to_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_icon_to_string"));

		public override string ToString() {
			IntPtr raw_ret = g_icon_to_string(Handle);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_loadable_icon_load(IntPtr raw, int size, IntPtr type, IntPtr cancellable, out IntPtr error);
		static d_g_loadable_icon_load g_loadable_icon_load = FuncLoader.LoadFunction<d_g_loadable_icon_load>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_loadable_icon_load"));

		public GLib.InputStream Load(int size, string type, GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_loadable_icon_load(Handle, size, GLib.Marshaller.StringToPtrGStrdup(type), cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			GLib.InputStream ret = GLib.Object.GetObject(raw_ret) as GLib.InputStream;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_loadable_icon_load_async(IntPtr raw, int size, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_loadable_icon_load_async g_loadable_icon_load_async = FuncLoader.LoadFunction<d_g_loadable_icon_load_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_loadable_icon_load_async"));

		public void LoadAsync(int size, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_loadable_icon_load_async(Handle, size, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_loadable_icon_load_finish(IntPtr raw, IntPtr res, IntPtr type, out IntPtr error);
		static d_g_loadable_icon_load_finish g_loadable_icon_load_finish = FuncLoader.LoadFunction<d_g_loadable_icon_load_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_loadable_icon_load_finish"));

		public GLib.InputStream LoadFinish(GLib.IAsyncResult res, string type) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_loadable_icon_load_finish(Handle, res == null ? IntPtr.Zero : ((res is GLib.Object) ? (res as GLib.Object).Handle : (res as GLib.AsyncResultAdapter).Handle), GLib.Marshaller.StringToPtrGStrdup(type), out error);
			GLib.InputStream ret = GLib.Object.GetObject(raw_ret) as GLib.InputStream;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

#endregion
	}
}
