diff --git a/ChangeLog b/ChangeLog index bf47ff55e..b956b546a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-01-17 Mike Kestner + + * gtk/Gtk.metadata : hide Stock. + * gtk/Makefile.am : add new file. + * gtk/StockManager.cs : stock item management methods. + 2005-01-14 Dan Winship * glib/Object.cs (ConnectDefaultHandlers): Don't call a signal's diff --git a/doc/en/Gtk/StockManager.xml b/doc/en/Gtk/StockManager.xml index 442aadee0..5cb66f80b 100644 --- a/doc/en/Gtk/StockManager.xml +++ b/doc/en/Gtk/StockManager.xml @@ -37,7 +37,8 @@ freed. an array of - + + @@ -51,5 +52,90 @@ Do not use + + + Method + + System.Void + + + + + + + Obsolete, do not use. + a + a + + + + + + Method + + System.Boolean + + + + + + + Finds a stock item by stock_id. + a + a + a + See also + + + + + Method + + System.Boolean + + + + + + + Finds a stock item by stock_id. + a + a + a + + + + + + Method + + System.Void + + + + + + + Adds a stock item. + a + a + This signature is obsolete, but preserved for backward compatibility. Use the single parameter overload for new code. + + + + + Method + + System.Void + + + + + + Adds a stock item. + a + + + - \ No newline at end of file + diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 34bbe3c7b..27f0928ec 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -52,11 +52,7 @@ 1 1 1 - StockManager - 1 - 1 - 1 - 1 + 1 out out 1 diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 87bc1543c..fbc7398dc 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -20,6 +20,7 @@ sources = \ NodeStore.cs \ NodeView.cs \ RadioActionEntry.cs \ + StockManager.cs \ ThreadNotify.cs \ ToggleActionEntry.cs \ TreeNodeAttribute.cs \ diff --git a/gtk/StockManager.cs b/gtk/StockManager.cs new file mode 100644 index 000000000..169dc9bcb --- /dev/null +++ b/gtk/StockManager.cs @@ -0,0 +1,99 @@ +// StockManager.cs - Gtk.Stock item manager +// +// Authors: Mike Kestner +// +// Copyright (c) 2005 Novell, Inc. +// +// 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. + + +namespace Gtk { + + using System; + using System.Runtime.InteropServices; + + public class StockManager { + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_stock_add_static(ref Gtk.StockItem items, uint n_items); + + [Obsolete ("Use StockManager.Add instead")] + public static void AddStatic(Gtk.StockItem items, uint n_items) + { + gtk_stock_add_static(ref items, n_items); + } + + [StructLayout(LayoutKind.Sequential)] + struct ConstStockItem { + public IntPtr StockId; + public IntPtr Label; + public Gdk.ModifierType Modifier; + public uint Keyval; + public IntPtr TranslationDomain; + + public static explicit operator StockItem (ConstStockItem csi) + { + Gtk.StockItem item = new Gtk.StockItem (); + item.StockId = Marshal.PtrToStringAnsi (csi.StockId); + item.Label = Marshal.PtrToStringAnsi (csi.Label); + item.Modifier = csi.Modifier; + item.Keyval = csi.Keyval; + item.TranslationDomain = Marshal.PtrToStringAnsi (csi.TranslationDomain); + return item; + } + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern bool gtk_stock_lookup (string stock_id, out ConstStockItem item); + + public static bool Lookup (string stock_id, ref Gtk.StockItem item) + { + ConstStockItem const_item; + if (!gtk_stock_lookup (stock_id, out const_item)) + return false; + item = (StockItem) const_item; + return true; + } + + public static bool LookupItem (string stock_id, out Gtk.StockItem item) + { + item = StockItem.Zero; + return Lookup (stock_id, ref item); + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_stock_add(ref Gtk.StockItem item, uint n_items); + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_stock_add(Gtk.StockItem[] items, uint n_items); + + [Obsolete ("Use the StockItem or StockItem[] overload instead.")] + public static void Add (Gtk.StockItem items, uint n_items) + { + gtk_stock_add(ref items, n_items); + } + + public static void Add (Gtk.StockItem item) + { + gtk_stock_add (ref item, 1); + } + + public static void Add (Gtk.StockItem[] items) + { + gtk_stock_add (items, (uint) items.Length); + } + + } +}