This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: adding widgets to guile-gtk


julian.gosnell@nomura.co.uk writes:

> With a bit of hacking I can get the library compiled, the bindings
> in guile done, and the whole lot loaded into a running image, and
> call one of the 'C' functions which returns a widget !

Great!  Does it do dynamic linking of the module?
 
> i.e. :
> 
> guile> (use-modules (toolkits jgwm))
> guile> (jgwm-root-new 46)
> #<JgwmRoot 87d90>
> guile> (jgwm-client-new 46)
> #<JgwmClient 11d260>
> 
> I'm happy about that but the problems are :
> 
> I am using my own library prefix - jgwm. Unfortunately
> build-guile-gtk does the following :
> 
> 1. puts a call to sgtk_init_jgwm_defs in my guile-jgwm.c file with no
>  corresponding extern declaration (the function is in jgwm-glue.c

build-guile-gtk does only create jgwm-glue.c.  You have
complete control over how your init function is called by editing the
`init-func' option in jgwm.defs.guile.

The file guile-jgwm.c is written by you and you yourself put the call
to the init-func there, right?

It is indeed the case the build-guile-gtk does not create a header
file for the things in jgwm-glue.c.  I deemed it not to be necessary
and avoiding a header file reduces the complexity of the system.  Err,
I think.

The missing prototype should not be a problem since it would be

    void sgtk_init_jgwm_defs (void);

There are no silent return value or argument conversions going on that
would need a prototype.
 
> 2. puts a call to sgtk_register_type_infos(type_infos) in this
> function without defining the argument or the function

sgtk_register_type_infos is defined in guile-gtk.h which should be
included in jgwm-glue.c.  build-guile-gtk should automatically insert
an approporiate include directive.

The argument type_infos should also be defined in jgwm-glue.c, in any
case, even if you are not defining any types in the defs file (but you
do, at least JgwmRoot and JgwmClient, writing a window manager, eh?)

Something strange must be going on that I can't really diagnose from
here.  Maybe you could tar up the files and make them available for
download somewhere?

> 3 By adding the extern and commenting out the function call I can get the
>  library built

Calling is sgtk_register_type_infos is important, of course.

> but when I try to use gtk fn-ality after using my module I get
>  the following : 
> 
> guile> (use-modules (toolkits jgwm))
> guile> gtk-window-new
> ERROR: In expression gtk-window-new:
> ERROR: Unbound variable: gtk-window-new
> ABORT: (misc-error)
> Type "(backtrace)" to get more information.

Yep, you have to 

    (use-modules (toolkits jgwm) (toolkits gtk))

when you want to access *both* jgwm and gtk.
 
> It seems that none of the gtk module stuff is registered - although
> it has been loaded and something was called to generate all the
> messages at the beginning.

I can't say more without seeing your actual code, I'm afraid.