From dc9046526c4a14ac910d0bd2ef0706f316facb2f Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 4 Aug 2005 18:03:21 +0000 Subject: [PATCH] * gtk/TargetList.custom: add an operator for casting to TargetEntry[], so you can use methods like TargetList.AddTextTargets() in situations where you need a TargetEntry[] rather than a TargetList. * gtk/glue/targetlist.c: glue for that svn path=/trunk/gtk-sharp/; revision=48006 --- ChangeLog | 9 ++++++++ doc/en/Gtk/TargetList.xml | 39 +++++++++++++++++++++++++--------- gtk/TargetList.custom | 14 +++++++++++++ gtk/glue/Makefile.am | 1 + gtk/glue/targetlist.c | 44 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 10 deletions(-) create mode 100644 gtk/glue/targetlist.c diff --git a/ChangeLog b/ChangeLog index 2784c7ec2..836807dbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-08-04 Dan Winship + + * gtk/TargetList.custom: add an operator for casting to + TargetEntry[], so you can use methods like + TargetList.AddTextTargets() in situations where you need a + TargetEntry[] rather than a TargetList. + + * gtk/glue/targetlist.c: glue for that + 2005-08-04 Mike Kestner * generator/Ctor.cs : call Finish and HandleException for static ctor diff --git a/doc/en/Gtk/TargetList.xml b/doc/en/Gtk/TargetList.xml index a44d81ee3..a260a3eea 100644 --- a/doc/en/Gtk/TargetList.xml +++ b/doc/en/Gtk/TargetList.xml @@ -185,9 +185,10 @@ - To be added - a - To be added + Adds the target types for URIs to the target list + application-defined ID for these target types + Appends the URI targets supported by to the target list. All targets are + added with the same . @@ -202,10 +203,11 @@ - To be added - a - a - To be added + Adds the target types for images to the target list + application-defined ID for these target types + if , only add the target types for which Gtk knows how to convert a to the format. + Appends the image targets supported by to the target list. All targets are + added with the same . @@ -219,11 +221,28 @@ - To be added - a - To be added + Adds the target types for text to the target list + application-defined ID for these target types + Appends the text targets supported by to the target list. All targets are + added with the same . + + + Method + + Gtk.TargetEntry[] + + + + + + A . + Converts a to an array of . + An equivalent array of . + + + diff --git a/gtk/TargetList.custom b/gtk/TargetList.custom index ed5ae45e6..fc831426b 100644 --- a/gtk/TargetList.custom +++ b/gtk/TargetList.custom @@ -34,3 +34,17 @@ public void Remove(string target) { 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; + } diff --git a/gtk/glue/Makefile.am b/gtk/glue/Makefile.am index 156b0580d..c6e63d165 100644 --- a/gtk/glue/Makefile.am +++ b/gtk/glue/Makefile.am @@ -10,6 +10,7 @@ libgtksharpglue_2_la_SOURCES = \ object.c \ selectiondata.c \ style.c \ + targetlist.c \ vmglueheaders.h \ widget.c diff --git a/gtk/glue/targetlist.c b/gtk/glue/targetlist.c new file mode 100644 index 000000000..9a7300618 --- /dev/null +++ b/gtk/glue/targetlist.c @@ -0,0 +1,44 @@ +/* + * 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; + } +}