diff --git a/ChangeLog b/ChangeLog index a7b7c2bb1..6f0c2ed69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-04-05 Christian Hoff + + * gtk/Target.custom: custom implementation of TableNewFromList. + * gtk/TargetList.custom: use Target.TableNewFromList method + to convert the TargetList to a TargetEntry array. + * gtk/glue/targetlist.c: deleted. + 2009-03-28 Christian Hoff * gtk/TextBuffer.custom: Use the right overload of Marshal.Copy diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 432db6578..ab4c92391 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -109,6 +109,7 @@ 1 1 1 + 1 1 out out diff --git a/gtk/Makefile.am b/gtk/Makefile.am index d3f420d57..766adc747 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -108,6 +108,7 @@ customs = \ StockItem.custom \ Style.custom \ Table.custom \ + Target.custom \ TargetEntry.custom \ TargetList.custom \ TargetPair.custom \ diff --git a/gtk/Target.custom b/gtk/Target.custom new file mode 100644 index 000000000..6f71dd9f4 --- /dev/null +++ b/gtk/Target.custom @@ -0,0 +1,36 @@ +// Gtk.Target.custom - Gtk.Target class customizations +// +// Author: Christian Hoff +// +// Copyright (c) 2009 Christian Hoff +// +// 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("libgtk-win32-2.0-0.dll")] + static extern IntPtr gtk_target_table_new_from_list(IntPtr list, out int n_targets); + + public static Gtk.TargetEntry[] TableNewFromList(Gtk.TargetList list) { + int n_targets; + IntPtr array_ptr = gtk_target_table_new_from_list (list.Handle, out n_targets); + + Gtk.TargetEntry[] ret = new Gtk.TargetEntry [n_targets]; + int unmanaged_struct_size = Marshal.SizeOf (typeof (Gtk.TargetEntry)); + for (int i = 0; i < n_targets; i++) { + ret [i] = Gtk.TargetEntry.New (new IntPtr (array_ptr.ToInt64 () + i * unmanaged_struct_size)); + } + return ret; + } diff --git a/gtk/TargetList.custom b/gtk/TargetList.custom index fc831426b..af875c326 100644 --- a/gtk/TargetList.custom +++ b/gtk/TargetList.custom @@ -35,16 +35,7 @@ Remove(Gdk.Atom.Intern (target, false)); } - [DllImport("gtksharpglue-2")] - static extern int gtksharp_target_list_length (IntPtr list); - - [DllImport("gtksharpglue-2")] - static extern void gtksharp_target_list_to_entry_array (IntPtr list, [In, Out] TargetEntry[] entries); - public static explicit operator TargetEntry[] (TargetList list) { - int length = gtksharp_target_list_length (list.Handle); - TargetEntry[] entries = new TargetEntry[length]; - gtksharp_target_list_to_entry_array (list.Handle, entries); - return entries; + return Target.TableNewFromList (list); } diff --git a/gtk/glue/Makefile.am b/gtk/glue/Makefile.am index c6bfa7a05..29b243695 100644 --- a/gtk/glue/Makefile.am +++ b/gtk/glue/Makefile.am @@ -9,7 +9,6 @@ libgtksharpglue_2_la_SOURCES = \ selectiondata.c \ statusicon.c \ style.c \ - targetlist.c \ vmglueheaders.h \ widget.c diff --git a/gtk/glue/targetlist.c b/gtk/glue/targetlist.c deleted file mode 100644 index 9a7300618..000000000 --- a/gtk/glue/targetlist.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Utilities for GtkTargetList - * - * 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. - */ - -#include - -/* forward declarations */ -int gtksharp_target_list_length (GtkTargetList *list); -void gtksharp_target_list_to_entry_array (GtkTargetList *list, GtkTargetEntry *entries); -/* */ - -int -gtksharp_target_list_length (GtkTargetList *list) -{ - return g_list_length (list->list); -} - -void -gtksharp_target_list_to_entry_array (GtkTargetList *list, GtkTargetEntry *entries) -{ - GList *l; - int i; - - for (l = list->list, i = 0; l; l = l->next, i++) { - GtkTargetPair *pair = (GtkTargetPair *)l->data; - entries[i].target = gdk_atom_name (pair->target); - entries[i].flags = pair->flags; - entries[i].info = pair->info; - } -}