guile-gtk-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: making a SCM from a GObject *


From: gregory benison
Subject: Re: making a SCM from a GObject *
Date: Tue, 10 May 2005 19:53:13 -0400
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Peter Gavin wrote:

Ok, so, I'm a bit new to guile, but I've been playing around w/ trying
to embed guile in my app, and one thing I've been wanting to do is
create a GObject subtype in C and pass it to some scheme code

I am a bit new to guile-gnome as well. I am also interested in doing what you are trying to do. I think this is likely to be a common desire among people trying out guile-gnome.

I
couldn't find any docs concerning this, and google gave me no hits,
I have had success using this method:
1) Create a .defs file which describes your gobject - based header file. It describes all of your functions and custom types. Look in the guile-gnome distribution in the 'defs' directory for examples. You can use the 'h2defs.py' program (found in the guile-gnome distribution) to generate this file automatically from your headers, if you have followed normal conventions in writing your headers. 2) Process your .defs file to automatically create C-to-guile glue code for your gobject types. Look at any "*-spec.scm" file in the guile-gnome distribution to see how this works. 3) Compile the resulting C file into a shared library. Load it from a scheme interpreter, and your gobject type will be available to use from scheme.

( guile-gnome experts: is this the right approach?? )

I admit that the above method looks intimidating at first but it really does work, and it allows you to use your C code from scheme with very little extra coding. If you use the above method, you can use your gobjects seamlessly in scheme (subclassing from them, connecting signals to them, etc.)
I would be interested in writing some additional documentation for this...
in my opinion the guile-gtk and guile-gnome teams have made a really great programming environment here, and new users could benefit from some additional documentation, especially regarding C/guile interoperability issues.

get back an error when I use it:
<gtype> #<gtype GObject> already has a GOOPS class, use gtype->class
Am I using the wrong function, or using it in the wrong way?
I don't understand this approach very well, but I suspect it is not what you want.

Greg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]