[Gtk-sharp-list] How the bindings work

Dave Joyner d4ljoyn@yahoo.com
Tue, 5 Aug 2003 02:49:19 -0700 (PDT)


This is my understanding of the process --

The xml and custom files are processed during 'make'
with a program called either codgen.exe or
gapi_codegen.exe (depending on your platform).  This
program is in the generator folder of your gtk-sharp
distribution.

The code generator creates C# code which you will
generally find in the generated/ folder of each
'wrapped' api.  For example, after building gtk#,
navigate to the folder gtk/generated.  There you'll
find the C# source code for the binding.  This folder
will not exist or will be empty until you've done a
build.

Generally speaking, the wrapper classes use PInvoke to
delegate to the native libraries for your platform.

Since the .xml files are generated by a script that
reads the original 'C' source code for a widget, the
.custom files are used to add functionality or
convenience methods to the binding.

For example, here's SetSizeRequest from Widget.cs in
gtk/generated:

[DllImport("libgtk-win32-2.0-0.dll")]
static extern void gtk_widget_set_size_request(IntPtr 
             raw, int width, int height);

/// <summary> SetSizeRequest Method </summary>
/// <remarks> To be completed </remarks>
public void SetSizeRequest(int width, int height) {
gtk_widget_set_size_request(Handle, width, height);
}

In the case of WidthRequest, HeightRequest these
properties are retrieved via g_object_get_property 
in glib/Object.cs if I remember correctly.  

I believe -1 is a perfectly valid value for these
properties -- indicating something like 'let the
container decide'.

Dave Joyner

--- Erik Pukinskis <erik@snowedin.net> wrote:
> Hello all,
> 
> I am trying to get the SizeRequest from a GTK widget
> via gtk-sharp.  It
> doesn't seem to work right now:  WidthRequest and
> HeightRequest seem to
> return -1.  I'd like to try to fix this, but I'll
> need a little
> guidance, as I don't know much about language
> bindings.
> 
> Poking through the source files I am trying to
> figure out where a
> property like WidthRequest is defined, but it only
> seems to be mentioned
> in api/gtk-api.xml and there is no implementation
> there.  Can someone
> give me a brief overview as to how gtk-sharp
> actually works?  
> 
> It seems to me like there is some sort of automatic
> binding
> specification in the XML in the the api/ folder and
> then there are more
> C#ish objects in .custom files in gtk/, gdk/, etc. 
> Is this right?  If
> so, does that mean eventually the goal is to have
> all of the
> functionality of GTK contained in .custom files?  Is
> there anything I
> can read to get a better understanding of how this
> works?
> 
> Thanks for your patience, I'm not an expert, but I
> want to help.
> 
> Erik Pukinskis
> 
> _______________________________________________
> Gtk-sharp-list maillist  - 
> Gtk-sharp-list@lists.ximian.com
>
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com