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

namespace GLib {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class SeekableAdapter : GLib.GInterfaceAdapter, GLib.ISeekable {

		GLib.Object implementor;

		public SeekableAdapter (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);
		}

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

		private static GLib.GType _gtype = new GLib.GType (g_seekable_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 ISeekable GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static ISeekable GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj as ISeekable == null)
				return new SeekableAdapter (obj.Handle);
			else
				return obj as ISeekable;
		}

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

		public bool CanSeek { 
			get {
				bool raw_ret = g_seekable_can_seek(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

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

		public bool CanTruncate() {
			bool raw_ret = g_seekable_can_truncate(Handle);
			bool ret = raw_ret;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_seekable_seek(IntPtr raw, long offset, int type, IntPtr cancellable, out IntPtr error);
		static d_g_seekable_seek g_seekable_seek = FuncLoader.LoadFunction<d_g_seekable_seek>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_seekable_seek"));

		public bool Seek(long offset, GLib.SeekType type, GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_seekable_seek(Handle, offset, (int) type, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

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

		public long Position { 
			get {
				long raw_ret = g_seekable_tell(Handle);
				long ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_seekable_truncate(IntPtr raw, long offset, IntPtr cancellable, out IntPtr error);
		static d_g_seekable_truncate g_seekable_truncate = FuncLoader.LoadFunction<d_g_seekable_truncate>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_seekable_truncate"));

		public bool Truncate(long offset, GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_seekable_truncate(Handle, offset, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

#endregion
	}
}
