[Mono-list] Using P/Invoke
Aaron Bockover
aaron.lists@aaronbock.net
Fri, 08 Apr 2005 10:10:09 -0400
Nevermind! I was going crazy, but apparently it helps to spell the name
of the function you wish to import. What I meant to say was
"gimp_pick_button_new". This code works fine now, with that change. Now
to figure out how to connect to signals.
--Aaron
On Fri, 2005-04-08 at 09:40 -0400, Aaron Bockover wrote:
> Hello, one area I haven't had much practice in with Mono is P/Invoke. I
> am trying to import a function from libgimp, so I can use a custom GTK
> widget in the library.
>
> Here is what I've tried:
>
> using System;
> using System.Runtime.InteropServices;
> using Gtk;
> using GLib;
>
> public class GimpColorButton : Button
> {
> [DllImport("/usr/lib/libgimpwidgets-2.0")]
> static extern IntPtr gimp_color_button_new();
>
> public GimpColorButton() : base(IntPtr.Zero)
> {
> base.Raw = gimp_color_button_new();
> }
>
> ~GimpColorButton()
> {
> Dispose();
> }
> }
>
> ...
>
> Widget colorButton = new GimpColorButton();
>
> As for the actual Gimp Library, I think maybe multiple libraries have to
> be loaded (libgimpcolor, libgimpui, etc.) So maybe I should write a
> wrapper C library that links in all the Gimp libraries, and then import
> that library into the C#? Regardless of the C library in question, is
> the C# above on the right track?
>
> Thanks!
>
> --Aaron Bockover
>
>
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>