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

namespace Gtk {

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

#region Autogenerated code
	public partial class ToolButton : Gtk.ToolItem, Gtk.IActionable {

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_tool_button_new(IntPtr icon_widget, IntPtr label);
		static d_gtk_tool_button_new gtk_tool_button_new = FuncLoader.LoadFunction<d_gtk_tool_button_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_new"));

		public ToolButton (Gtk.Widget icon_widget, string label) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (ToolButton)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				if (icon_widget != null) {
					names.Add ("icon_widget");
					vals.Add (new GLib.Value (icon_widget));
				}
				names.Add ("label");
				vals.Add (new GLib.Value (label));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			IntPtr native_label = GLib.Marshaller.StringToPtrGStrdup (label);
			Raw = gtk_tool_button_new(icon_widget == null ? IntPtr.Zero : icon_widget.Handle, native_label);
			GLib.Marshaller.Free (native_label);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_tool_button_new_from_stock(IntPtr stock_id);
		static d_gtk_tool_button_new_from_stock gtk_tool_button_new_from_stock = FuncLoader.LoadFunction<d_gtk_tool_button_new_from_stock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_new_from_stock"));

		[Obsolete]
		public ToolButton (string stock_id) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (ToolButton)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				names.Add ("stock_id");
				vals.Add (new GLib.Value (stock_id));
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			IntPtr native_stock_id = GLib.Marshaller.StringToPtrGStrdup (stock_id);
			Raw = gtk_tool_button_new_from_stock(native_stock_id);
			GLib.Marshaller.Free (native_stock_id);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tool_button_set_label(IntPtr raw, IntPtr label);
		static d_gtk_tool_button_set_label gtk_tool_button_set_label = FuncLoader.LoadFunction<d_gtk_tool_button_set_label>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_set_label"));

		[GLib.Property ("label")]
		public string Label {
			get  {
				IntPtr raw_ret = gtk_tool_button_get_label(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gtk_tool_button_set_label(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tool_button_set_use_underline(IntPtr raw, bool use_underline);
		static d_gtk_tool_button_set_use_underline gtk_tool_button_set_use_underline = FuncLoader.LoadFunction<d_gtk_tool_button_set_use_underline>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_set_use_underline"));

		[GLib.Property ("use-underline")]
		public bool UseUnderline {
			get  {
				bool raw_ret = gtk_tool_button_get_use_underline(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				gtk_tool_button_set_use_underline(Handle, value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tool_button_set_label_widget(IntPtr raw, IntPtr label_widget);
		static d_gtk_tool_button_set_label_widget gtk_tool_button_set_label_widget = FuncLoader.LoadFunction<d_gtk_tool_button_set_label_widget>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_set_label_widget"));

		[GLib.Property ("label-widget")]
		public Gtk.Widget LabelWidget {
			get  {
				IntPtr raw_ret = gtk_tool_button_get_label_widget(Handle);
				Gtk.Widget ret = GLib.Object.GetObject(raw_ret) as Gtk.Widget;
				return ret;
			}
			set  {
				gtk_tool_button_set_label_widget(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tool_button_set_stock_id(IntPtr raw, IntPtr stock_id);
		static d_gtk_tool_button_set_stock_id gtk_tool_button_set_stock_id = FuncLoader.LoadFunction<d_gtk_tool_button_set_stock_id>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_set_stock_id"));

		[Obsolete]
		[GLib.Property ("stock-id")]
		public string StockId {
			get  {
				IntPtr raw_ret = gtk_tool_button_get_stock_id(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gtk_tool_button_set_stock_id(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tool_button_set_icon_name(IntPtr raw, IntPtr icon_name);
		static d_gtk_tool_button_set_icon_name gtk_tool_button_set_icon_name = FuncLoader.LoadFunction<d_gtk_tool_button_set_icon_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_set_icon_name"));

		[GLib.Property ("icon-name")]
		public string IconName {
			get  {
				IntPtr raw_ret = gtk_tool_button_get_icon_name(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gtk_tool_button_set_icon_name(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_tool_button_set_icon_widget(IntPtr raw, IntPtr icon_widget);
		static d_gtk_tool_button_set_icon_widget gtk_tool_button_set_icon_widget = FuncLoader.LoadFunction<d_gtk_tool_button_set_icon_widget>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_set_icon_widget"));

		[GLib.Property ("icon-widget")]
		public Gtk.Widget IconWidget {
			get  {
				IntPtr raw_ret = gtk_tool_button_get_icon_widget(Handle);
				Gtk.Widget ret = GLib.Object.GetObject(raw_ret) as Gtk.Widget;
				return ret;
			}
			set  {
				gtk_tool_button_set_icon_widget(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		public int IconSpacing {
			get {
				var val = (int)StyleGetProperty("icon-spacing");
				return val;
			}
		}

		[GLib.Signal("clicked")]
		public event System.EventHandler Clicked {
			add {
				this.AddSignalHandler ("clicked", value);
			}
			remove {
				this.RemoveSignalHandler ("clicked", value);
			}
		}

		static ClickedNativeDelegate Clicked_cb_delegate;
		static ClickedNativeDelegate ClickedVMCallback {
			get {
				if (Clicked_cb_delegate == null)
					Clicked_cb_delegate = new ClickedNativeDelegate (Clicked_cb);
				return Clicked_cb_delegate;
			}
		}

		static void OverrideClicked (GLib.GType gtype)
		{
			OverrideClicked (gtype, ClickedVMCallback);
		}

		static void OverrideClicked (GLib.GType gtype, ClickedNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("clicked"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

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

		static void Clicked_cb (IntPtr inst)
		{
			try {
				ToolButton __obj = GLib.Object.GetObject (inst, false) as ToolButton;
				__obj.OnClicked ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gtk.ToolButton), ConnectionMethod="OverrideClicked")]
		protected virtual void OnClicked ()
		{
			InternalClicked ();
		}

		private void InternalClicked ()
		{
			ClickedNativeDelegate unmanaged = class_abi.BaseOverride<ClickedNativeDelegate>(this.LookupGType(), "clicked");
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("button_type"
							, Gtk.ToolItem.class_abi.Fields
							, (uint) Marshal.SizeOf<GLib.GType>() // button_type
							, null
							, "clicked"
							, (long) Marshal.OffsetOf<GtkToolButton_button_typeAlign>("button_type")
							, 0
							),
						new GLib.AbiField("clicked"
							, -1
							, (uint) sizeof( IntPtr ) // clicked
							, "button_type"
							, "_gtk_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved1
							, "clicked"
							, "_gtk_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved2
							, "_gtk_reserved1"
							, "_gtk_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved3
							, "_gtk_reserved2"
							, "_gtk_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_gtk_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _gtk_reserved4
							, "_gtk_reserved3"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GtkToolButton_button_typeAlign
		{
			sbyte f1;
			private GLib.GType button_type;
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_gtk_tool_button_get_type();
		static d_gtk_tool_button_get_type gtk_tool_button_get_type = FuncLoader.LoadFunction<d_gtk_tool_button_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tool_button_get_type"));

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_actionable_set_action_name(IntPtr raw, IntPtr action_name);
		static d_gtk_actionable_set_action_name gtk_actionable_set_action_name = FuncLoader.LoadFunction<d_gtk_actionable_set_action_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_set_action_name"));

		public string ActionName { 
			get {
				IntPtr raw_ret = gtk_actionable_get_action_name(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
			set {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gtk_actionable_set_action_name(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_actionable_set_action_target_value(IntPtr raw, IntPtr target_value);
		static d_gtk_actionable_set_action_target_value gtk_actionable_set_action_target_value = FuncLoader.LoadFunction<d_gtk_actionable_set_action_target_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_set_action_target_value"));

		public GLib.Variant ActionTargetValue { 
			get {
				IntPtr raw_ret = gtk_actionable_get_action_target_value(Handle);
				GLib.Variant ret = new GLib.Variant(raw_ret);
				return ret;
			}
			set {
				gtk_actionable_set_action_target_value(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_gtk_actionable_set_detailed_action_name(IntPtr raw, IntPtr detailed_action_name);
		static d_gtk_actionable_set_detailed_action_name gtk_actionable_set_detailed_action_name = FuncLoader.LoadFunction<d_gtk_actionable_set_detailed_action_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_actionable_set_detailed_action_name"));

		public string DetailedActionName { 
			set {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gtk_actionable_set_detailed_action_name(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, Gtk.ToolItem.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
