From 86d4828d5de094da1f74c3c93e9e5b278dcb288e Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 20 Dec 2004 19:33:29 +0000 Subject: [PATCH] * gtk/Gtk.metadata: Don't rename GtkStock to StockManager, hide Lookup (so we can customize it) and AddStatic (since it can't work right from managed code), and tweak the params of Add. * gtk/Stock.custom: Implement Lookup() using a special ConstStockItem struct so the p/invoke layer won't try to free static strings. [#70589] svn path=/trunk/gtk-sharp/; revision=37995 --- ChangeLog | 10 ++++++++++ gtk/Gtk.metadata | 5 +++-- gtk/Stock.custom | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 861241949..0f61569c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-12-20 Dan Winship + + * gtk/Gtk.metadata: Don't rename GtkStock to StockManager, hide + Lookup (so we can customize it) and AddStatic (since it can't work + right from managed code), and tweak the params of Add. + + * gtk/Stock.custom: Implement Lookup() using a special + ConstStockItem struct so the p/invoke layer won't try to free + static strings. [#70589] + 2004-12-20 Mike Kestner * generator/Property.cs : generate Interface properties. diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index f2347940b..f29e81109 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -49,9 +49,10 @@ 1 1 1 - StockManager + 1 + 1 1 - ref + 1 out out 1 diff --git a/gtk/Stock.custom b/gtk/Stock.custom index 0d9c3550e..e1db9c3ff 100644 --- a/gtk/Stock.custom +++ b/gtk/Stock.custom @@ -34,3 +34,30 @@ return result; } + [StructLayout(LayoutKind.Sequential)] + struct ConstStockItem { + public IntPtr StockId; + public IntPtr Label; + public Gdk.ModifierType Modifier; + public uint Keyval; + public IntPtr TranslationDomain; + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern bool gtk_stock_lookup (string stock_id, out ConstStockItem item); + + public static Gtk.StockItem Lookup (string stock_id) { + ConstStockItem const_item; + + if (!gtk_stock_lookup (stock_id, out const_item)) + return Gtk.StockItem.Zero; + + Gtk.StockItem item = new Gtk.StockItem (); + item.StockId = Marshal.PtrToStringAnsi (const_item.StockId); + item.Label = Marshal.PtrToStringAnsi (const_item.Label); + item.Modifier = const_item.Modifier; + item.Keyval = const_item.Keyval; + item.TranslationDomain = Marshal.PtrToStringAnsi (const_item.TranslationDomain); + return item; + } +