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]

Access a GtkWidget in C from guile?


Hello,

From guile, I want to access a GnomeCanvas which has been created in
(non guile-gtk) C code.

To explain, here are some details:

 - I have a C structure which holds my app's data, including a pointer
to a GnomeCanvas widget.  As a simplified example:

	typedef struct _my_app_data {
		int blah;
		GnomeCanvas *canvas;
	} my_app_data;

 - I have a function which allocates memory and sets up things,
including the canvas and various GnomeCanvasItems:

	my_app_data *init_my_app_data ();

 - I wrap `my_app_data' as a guile SMOB and also package any functions
which operate on `my_app_data' into a dynamically linked lib
(following Guile's data-rep.info as well as ``Dynamic Linking and
Compiled Code Modules'' in the guile-ref info page).  This lib is at
`my/libapp.so' in my GUILE_LOAD_PATH.  One of the functions I wrapped
is `init_my_app_data'.  So, after I do:

	(use-modules (my app))

in guile then I can see the function `init-my-app-data' which is the
scheme equiv to `init_my_app_data'.  

 - 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.

Any pointers (pun intended) would be appreciated.

Thanks,
-Brett.

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