* Access a GtkWidget in C from guile?
@ 2000-06-03 15:27 Brett Viren
2000-06-24 15:44 ` Marius Vollmer
0 siblings, 1 reply; 2+ messages in thread
From: Brett Viren @ 2000-06-03 15:27 UTC (permalink / raw)
To: guile-gtk
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Access a GtkWidget in C from guile?
2000-06-03 15:27 Access a GtkWidget in C from guile? Brett Viren
@ 2000-06-24 15:44 ` Marius Vollmer
0 siblings, 0 replies; 2+ messages in thread
From: Marius Vollmer @ 2000-06-24 15:44 UTC (permalink / raw)
To: Brett Viren; +Cc: guile-gtk
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-06-24 15:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-03 15:27 Access a GtkWidget in C from guile? Brett Viren
2000-06-24 15:44 ` Marius Vollmer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).