guile-user
[Top][All Lists]
Advanced

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

Re: gnome-guile and C types?


From: Maciej Stachowiak
Subject: Re: gnome-guile and C types?
Date: Mon, 15 Oct 2001 11:13:24 -0700
User-agent: Mutt/1.2.5i

On 15Oct2001 12:46PM (-0500), Bill Gribble wrote:
> I'd like to write some custom wrappers for various gnome functions that
> don't have bindings in libguilegnome.  How are the C types mapped onto
> Scheme types, and is there an available API to convert them?  
> 
> For example, let's say I have a C function that returns a GList of
> GtkWidget *.  I know that gnome-guile doesn't deal with GLists, so I
> want to write a C function that explicitly handles the wrapping for this
> case.  In the following example, how would I write convert_c_ptr() so
> that a gnome-guile program written in Scheme could use the returned
> value as expected?
> 
> SCM
> handwritten_foo_glue(void) 
> {
>   GList * l = gtk_foo_func();
>   GList * p;
>   SCM ret = SCM_EOL;
>    
>   for(p=l; p; p=p->next) 
>   {
>     ret = scm_cons(convert_c_ptr(GTK_WIDGET(p->data)), ret);
>   }
>   g_list_free(l);
> 
>   return scm_reverse_x(ret, SCM_EOL);
> } 
>    

The best way to add bindings to guile-gtk/gnome-guile is to use the
code generator, which can automatically generate wrappers from .defs
files. Just write a .defs file for your function. (If the function
isn't already in the standard .defs file, it may be that the code
generator can't handle it for some reason, or it could just be simple
omission).

I suspect guile-gtk also exports the function needed to convert a
GtkWidget * to a Scheme object, but I'm not sure.

 - Maciej




reply via email to

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