[Gtk-sharp-list] Does exist a C# Wrapper for the GNode struct from GLib?

Dan Winship danw at novell.com
Tue Jan 31 10:34:30 EST 2006

Mario Sánchez wrote:
> My question is... is this true? There's not a wrapper for GNode yet?

It's true. Most of the non-type-system-related data structures from glib
aren't wrapped in GLib#, because it's generally better to try to map
those APIs to use more .NET-ish data types.

> In case of this to be true... How can I wrap a library which contains
> functions using GNodes? Would be a good idea trying to implement a GNode
> C# wrapper by myself or it's a better way to achieve this problem?

There are two pieces to what you have to do: decide how you want to
represent the GNodes in C#, and then tell that to GAPI.

For the first part, it depends on whether or not you need to manipulate
the GNodes from C#, or if you're just going to be treating them as
opaque cookies that you receive from some methods and pass back to
others. If you need to manipulate them, you'll need to create your own
wrapper type for them in C#. Look at the way that GList is wrapped for
some ideas, as well as the generated wrappers for a GLib.Opaque-based
type like Gdk.Cursor. Another possibility would be to try running GAPI
on gnode.h, and seeing what it comes up with. You might need to tweak it
a bit before it's usable.

On the other hand, if you don't need to ever actually use the GNodes
from C#, then you could just map GNode* to IntPtr.

Once you've decided what type to map it to (either your own wrapper
type, or IntPtr), tell GAPI by using a symbols file, as explained at
http://mono-project.com/GAPI#Symbols. (Use "simple" to map to IntPtr, or
"manual" to map to an opaque type.)

-- Dan

More information about the Gtk-sharp-list mailing list