This is the mail archive of the guile-gtk@sourceware.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: Access a GtkWidget in C from guile?


Brett Viren <bviren@superk.physics.sunysb.edu> writes:

>  - Now comes the problem:  In scheme I need to do something like:
> 
> 	(use-modules (my app)
> 		     (gnome gnome)
> 		     (gtk gtk)
> 		     (gtk gdk))
> 	;; ...
> 
> 	(let ((window (gtk-window-new 'toplevel))
> 	      (mad (init-my-app-data some args)))
> 	  (gtk-container-add window (give-me-a-canvas mad))
> 	...)
> 
> Where `(give-me-a-canvas mad)' needs to return a guile-ified version
> of my C-land GnomeCanvas.

The easiest would be to write a C function

    #include <guile-gtk.h>

    SCM
    give_me_a_canvas (SCM scm_mad)
    {
      my_app_data *mad = GET_STRUCT_FROM_SMOB (scm_mad);
      return sgtk_wrap_gtkobj (mad->canvas);
    }

and export it to Scheme.  Note `sgtk_wrap_gtkobj' which is probably
the interesting thing here.

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