// Gtk.Toolbar.custom - Gtk Toolbar class customizations
//
// Author: Mike Kestner <mkestner@novell.com> 
//
// Copyright (C) 2005 Novell, Inc.
//
// This code is inserted after the automatically generated code.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General 
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

		[DllImport("libgobject-2.0-0.dll")]
		static extern void g_object_weak_ref (IntPtr raw, WeakNotify cb, IntPtr data);

		delegate void WeakNotify (IntPtr handle, IntPtr obj);

		static void ReleaseDelegateCB (IntPtr handle, IntPtr obj)
		{
			GCHandle gch = (GCHandle) handle;
			gch.Free ();
		}

		static WeakNotify on_weak_notify;
		static WeakNotify OnWeakNotify {
			get {
				if (on_weak_notify == null)
					on_weak_notify = new WeakNotify (ReleaseDelegateCB);
				return on_weak_notify;
			}
		}

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern IntPtr gtk_toolbar_append_element (IntPtr raw, int type, IntPtr widget, IntPtr text, IntPtr tooltip_text, IntPtr tooltip_private_text, IntPtr icon, GtkSharp.SignalFuncNative cb, IntPtr user_data);

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget AppendElement (Gtk.ToolbarChildType type, Gtk.Widget widget, string text, string tooltip_text, string tooltip_private_text, Gtk.Widget icon, Gtk.SignalFunc cb) 
		{
			GtkSharp.SignalFuncWrapper cb_wrapper = new GtkSharp.SignalFuncWrapper (cb);
			IntPtr ntext = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr ntiptext = GLib.Marshaller.StringToPtrGStrdup (tooltip_text);
			IntPtr ntipprivtext = GLib.Marshaller.StringToPtrGStrdup (tooltip_private_text);
			IntPtr raw_ret = gtk_toolbar_append_element (Handle, (int) type, widget == null ? IntPtr.Zero : widget.Handle, ntext, ntiptext, ntipprivtext, icon == null ? IntPtr.Zero : icon.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (ntext);
			GLib.Marshaller.Free (ntiptext);
			GLib.Marshaller.Free (ntipprivtext);
			Gtk.Widget ret;
			if (raw_ret == IntPtr.Zero)
				ret = null;
			else {
				ret = (Gtk.Widget) GLib.Object.GetObject (raw_ret);
				g_object_weak_ref (raw_ret, OnWeakNotify, (IntPtr) GCHandle.Alloc (cb_wrapper));
			}
			return ret;
		}

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern IntPtr gtk_toolbar_insert_element (IntPtr raw, int type, IntPtr widget, IntPtr text, IntPtr tooltip_text, IntPtr tooltip_private_text, IntPtr icon, GtkSharp.SignalFuncNative cb, IntPtr user_data, int position);

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget InsertElement (Gtk.ToolbarChildType type, Gtk.Widget widget, string text, string tooltip_text, string tooltip_private_text, Gtk.Widget icon, Gtk.SignalFunc cb, IntPtr user_data, int position) 
		{
			GtkSharp.SignalFuncWrapper cb_wrapper = new GtkSharp.SignalFuncWrapper (cb);
			IntPtr ntext = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr ntiptext = GLib.Marshaller.StringToPtrGStrdup (tooltip_text);
			IntPtr ntipprivtext = GLib.Marshaller.StringToPtrGStrdup (tooltip_private_text);
			IntPtr raw_ret = gtk_toolbar_insert_element (Handle, (int) type, widget == null ? IntPtr.Zero : widget.Handle, ntext, ntiptext, ntipprivtext, icon == null ? IntPtr.Zero : icon.Handle, cb_wrapper.NativeDelegate, user_data, position);
			GLib.Marshaller.Free (ntext);
			GLib.Marshaller.Free (ntiptext);
			GLib.Marshaller.Free (ntipprivtext);
			Gtk.Widget ret;
			if (raw_ret == IntPtr.Zero)
				ret = null;
			else {
				ret = (Gtk.Widget) GLib.Object.GetObject (raw_ret);
				g_object_weak_ref (raw_ret, OnWeakNotify, (IntPtr) GCHandle.Alloc (cb_wrapper));
			}

			return ret;
		}

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern IntPtr gtk_toolbar_prepend_element (IntPtr raw, int type, IntPtr widget, IntPtr text, IntPtr tooltip_text, IntPtr tooltip_private_text, IntPtr icon, GtkSharp.SignalFuncNative cb, IntPtr user_data);

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget PrependElement (Gtk.ToolbarChildType type, Gtk.Widget widget, string text, string tooltip_text, string tooltip_private_text, Gtk.Widget icon, Gtk.SignalFunc cb) 
		{
			GtkSharp.SignalFuncWrapper cb_wrapper = new GtkSharp.SignalFuncWrapper (cb);
			IntPtr ntext = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr ntiptext = GLib.Marshaller.StringToPtrGStrdup (tooltip_text);
			IntPtr ntipprivtext = GLib.Marshaller.StringToPtrGStrdup (tooltip_private_text);
			IntPtr raw_ret = gtk_toolbar_prepend_element (Handle, (int) type, widget == null ? IntPtr.Zero : widget.Handle, ntext, ntiptext, ntipprivtext, icon == null ? IntPtr.Zero : icon.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (ntext);
			GLib.Marshaller.Free (ntiptext);
			GLib.Marshaller.Free (ntipprivtext);
			Gtk.Widget ret;
			if (raw_ret == IntPtr.Zero)
				ret = null;
			else {
				ret = (Gtk.Widget) GLib.Object.GetObject (raw_ret);
				g_object_weak_ref (raw_ret, OnWeakNotify, (IntPtr) GCHandle.Alloc (cb_wrapper));
			}
			return ret;
		}

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern IntPtr gtk_toolbar_append_item (IntPtr raw, IntPtr text, IntPtr tooltip_text, IntPtr tooltip_private_text, IntPtr icon, GtkSharp.SignalFuncNative cb, IntPtr user_data);

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget AppendItem (string text, string tooltip_text, string tooltip_private_text, Gtk.Widget icon, Gtk.SignalFunc cb) 
		{
			GtkSharp.SignalFuncWrapper cb_wrapper = new GtkSharp.SignalFuncWrapper (cb);
			IntPtr ntext = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr ntiptext = GLib.Marshaller.StringToPtrGStrdup (tooltip_text);
			IntPtr ntipprivtext = GLib.Marshaller.StringToPtrGStrdup (tooltip_private_text);
			IntPtr raw_ret = gtk_toolbar_append_item (Handle, ntext, ntiptext, ntipprivtext, icon == null ? IntPtr.Zero : icon.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (ntext);
			GLib.Marshaller.Free (ntiptext);
			GLib.Marshaller.Free (ntipprivtext);
			Gtk.Widget ret;
			if (raw_ret == IntPtr.Zero)
				ret = null;
			else {
				ret = (Gtk.Widget) GLib.Object.GetObject(raw_ret);
				g_object_weak_ref (raw_ret, OnWeakNotify, (IntPtr) GCHandle.Alloc (cb_wrapper));
			}
			return ret;
		}

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern IntPtr gtk_toolbar_insert_item (IntPtr raw, IntPtr text, IntPtr tooltip_text, IntPtr tooltip_private_text, IntPtr icon, GtkSharp.SignalFuncNative cb, IntPtr user_data, int position);

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget InsertItem (string text, string tooltip_text, string tooltip_private_text, Gtk.Widget icon, Gtk.SignalFunc cb, IntPtr user_data, int position) 
		{
			GtkSharp.SignalFuncWrapper cb_wrapper = new GtkSharp.SignalFuncWrapper (cb);
			IntPtr ntext = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr ntiptext = GLib.Marshaller.StringToPtrGStrdup (tooltip_text);
			IntPtr ntipprivtext = GLib.Marshaller.StringToPtrGStrdup (tooltip_private_text);
			IntPtr raw_ret = gtk_toolbar_insert_item (Handle, ntext, ntiptext, ntipprivtext, icon == null ? IntPtr.Zero : icon.Handle, cb_wrapper.NativeDelegate, user_data, position);
			GLib.Marshaller.Free (ntext);
			GLib.Marshaller.Free (ntiptext);
			GLib.Marshaller.Free (ntipprivtext);
			Gtk.Widget ret;
			if (raw_ret == IntPtr.Zero)
				ret = null;
			else {
				ret = (Gtk.Widget) GLib.Object.GetObject(raw_ret);
				g_object_weak_ref (raw_ret, OnWeakNotify, (IntPtr) GCHandle.Alloc (cb_wrapper));
			}
			return ret;
		}

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern IntPtr gtk_toolbar_prepend_item (IntPtr raw, IntPtr text, IntPtr tooltip_text, IntPtr tooltip_private_text, IntPtr icon, GtkSharp.SignalFuncNative cb, IntPtr user_data);

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget PrependItem (string text, string tooltip_text, string tooltip_private_text, Gtk.Widget icon, Gtk.SignalFunc cb) 
		{
			GtkSharp.SignalFuncWrapper cb_wrapper = new GtkSharp.SignalFuncWrapper (cb);
			IntPtr ntext = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr ntiptext = GLib.Marshaller.StringToPtrGStrdup (tooltip_text);
			IntPtr ntipprivtext = GLib.Marshaller.StringToPtrGStrdup (tooltip_private_text);
			IntPtr raw_ret = gtk_toolbar_prepend_item (Handle, ntext, ntiptext, ntipprivtext, icon == null ? IntPtr.Zero : icon.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
			GLib.Marshaller.Free (ntext);
			GLib.Marshaller.Free (ntiptext);
			GLib.Marshaller.Free (ntipprivtext);
			Gtk.Widget ret;
			if (raw_ret == IntPtr.Zero)
				ret = null;
			else {
				ret = (Gtk.Widget) GLib.Object.GetObject(raw_ret);
				g_object_weak_ref (raw_ret, OnWeakNotify, (IntPtr) GCHandle.Alloc (cb_wrapper));
			}
			return ret;
		}

		[DllImport("libgtk-win32-2.0-0.dll")]
		static extern IntPtr gtk_toolbar_insert_stock (IntPtr raw, IntPtr stock_id, IntPtr tooltip_text, IntPtr tooltip_private_text, GtkSharp.SignalFuncNative cb, IntPtr user_data, int position);

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget InsertStock (string stock_id, string tooltip_text, string tooltip_private_text, Gtk.SignalFunc cb, int position) 
		{
			return InsertStock (stock_id, tooltip_text, tooltip_private_text, cb, IntPtr.Zero, position);
		}

		[Obsolete ("Replaced by ToolItem API")]
		public Gtk.Widget InsertStock (string stock_id, string tooltip_text, string tooltip_private_text, Gtk.SignalFunc cb, IntPtr user_data, int position) 
		{
			GtkSharp.SignalFuncWrapper cb_wrapper = new GtkSharp.SignalFuncWrapper (cb);
			IntPtr nstock = GLib.Marshaller.StringToPtrGStrdup (stock_id);
			IntPtr ntiptext = GLib.Marshaller.StringToPtrGStrdup (tooltip_text);
			IntPtr ntipprivtext = GLib.Marshaller.StringToPtrGStrdup (tooltip_private_text);
			IntPtr raw_ret = gtk_toolbar_insert_stock (Handle, nstock, ntiptext, ntipprivtext, cb_wrapper.NativeDelegate, user_data, position);
			GLib.Marshaller.Free (nstock);
			GLib.Marshaller.Free (ntiptext);
			GLib.Marshaller.Free (ntipprivtext);
			Gtk.Widget ret;
			if (raw_ret == IntPtr.Zero)
				ret = null;
			else {
				ret = (Gtk.Widget) GLib.Object.GetObject (raw_ret);
				g_object_weak_ref (raw_ret, OnWeakNotify, (IntPtr) GCHandle.Alloc (cb_wrapper));
			}
			return ret;
		}