unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Questions about guile-gtk
@ 2002-10-16 11:48 tomas
  2002-10-19 14:07 ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: tomas @ 2002-10-16 11:48 UTC (permalink / raw)


Hi, experts

(yeah, Marius, I fear that's especially you ;-)

while trying to come up with bindings for the GtkCanvas widget
(see my other posting), I came across several questions. Maybe
someone can shec a bit of light on me.

  - I use the function  sgtk_build_args(), which, as I understand,
    tries to convert an SCM keyword list into a GtkArg array to
    set the properties of a Gtk object.
    The third argument to it is a `protector', I don't understand
    exactly its use (but it's usually passed the object, which is
    annoying if it's the object just being created ;-)
    What I'm supposed to do with this?

  - I can't draw a line. The problem is that one of the parameters
    needed is a GtkCanvasPoints* (which is not a regular Gtk object,
    but just a C structure). Does the guile-gtk conversion mechanism
    provide a way to cope with that, or have I to do something
    by hand here?

  - How do I handle C functions with in/out parameters, that is,
    pointers, like:
    
      gtk_canvas_get_scroll_region(GtcCanvas c,
                        double *x1, double *y1, 
                        double *x2, double *y2) 

    Again: is there something in guile-gtk to cope with it and didn't
    I see it, or is it ``roll your own''?

Besides, I think another discussion is in order: is it worth extending
the binding mechanism of guile-gtk (I actually like it), or should we
move towards a more general approach (g-wrap or swig)?

In the mid-term I think it's important to have an ``official'' bindings
generator tool, just to attract good bindings...

Thanks for any input
-- tomas


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Questions about guile-gtk
  2002-10-16 11:48 Questions about guile-gtk tomas
@ 2002-10-19 14:07 ` Marius Vollmer
  2002-10-19 14:21   ` Marius Vollmer
  2002-10-21 10:41   ` tomas
  0 siblings, 2 replies; 4+ messages in thread
From: Marius Vollmer @ 2002-10-19 14:07 UTC (permalink / raw)
  Cc: guile-user

tomas@fabula.de writes:

>   - I use the function  sgtk_build_args(), which, as I understand,
>     tries to convert an SCM keyword list into a GtkArg array to
>     set the properties of a Gtk object.
>     The third argument to it is a `protector', I don't understand
>     exactly its use (but it's usually passed the object, which is
>     annoying if it's the object just being created ;-)
>     What I'm supposed to do with this?

The 'protector' is used to combine the mark/sweep collector of Guile
with the refcounting collector of Gtk+.  Here is a shortish
explanation:

/* GtkObjects.

   GtkObjects are wrapped with a smob.  The smob of a GtkObject is
   called its proxy.  The proxy and its GtkObject are strongly
   connected; that is, the GtkObject will stay around as long as the
   proxy is referenced from Scheme, and the proxy will not be
   collected as long as the GtkObject is used from outside of Scheme.

   The lifetime of GtkObjects is controlled by a reference count,
   while Scheme objects are managed by a tracing garbage collector
   (mark/sweep).  These two techniques are made to cooperate like
   this: the pointer from the proxy to the GtkObject is reflected in
   the reference count of the GtkObject.  All proxies are kept in a
   list and those that point to GtkObjects with a reference count
   greater than the number of `internal' references are marked during
   the marking phase of the tracing collector.  An internal reference
   is one that goes from a GtkObject with a proxy to another GtkObject
   with a proxy.  We can only find a subset of the true internal
   references (because Gtk does not yet cooperate), but this should be
   good enough.

   By using this combination of tracing and reference counting it is
   possible to break the cycle that is formed by the proxy pointing to
   the GtkObject and the GtkObject pointing back.  It is
   straightforward to extend this to other kind of cycles that might
   occur.  For example, when connecting a Scheme procedure as a signal
   handler, the procedure is very likely to have the GtkObject that it
   is connected to in its environment.  This cycle can be broken by
   including the procedure in the set of Scheme objects that get
   marked when we are tracing GtkObjects with a reference count
   greater than the number of internal references.

   Therefore, each proxy contains a list of `protects' that are marked
   when the proxy itself is marked.  In addition to this, there is
   also a global list of `protects' that is used for Scheme objects
   that are somewhere in Gtk land but not clearly associated with a
   particular GtkObject (like timeout callbacks).

  */

Does this help?  Not specifying a protector will not put the SCM
objects on the global list.  This is not optimal, but it is still safe
in the sense that they might be freed too late, but not too early.

>   - How do I handle C functions with in/out parameters, that is,
>     pointers, like:
>     
>       gtk_canvas_get_scroll_region(GtcCanvas c,
>                         double *x1, double *y1, 
>                         double *x2, double *y2) 
> 
>     Again: is there something in guile-gtk to cope with it and didn't
>     I see it, or is it ``roll your own''?

There is a section in the README named "Composite Types and
`call-by-reference'".

> In the mid-term I think it's important to have an ``official'' bindings
> generator tool, just to attract good bindings...

Yes!

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Questions about guile-gtk
  2002-10-19 14:07 ` Marius Vollmer
@ 2002-10-19 14:21   ` Marius Vollmer
  2002-10-21 10:41   ` tomas
  1 sibling, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2002-10-19 14:21 UTC (permalink / raw)
  Cc: guile-user

Marius Vollmer <mvo@zagadka.ping.de> writes:

> Not specifying a protector will not put the SCM objects on the
> global list.

Sorry: Not specifying a protector _will_ put the SCM objects on the
global list.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Questions about guile-gtk
  2002-10-19 14:07 ` Marius Vollmer
  2002-10-19 14:21   ` Marius Vollmer
@ 2002-10-21 10:41   ` tomas
  1 sibling, 0 replies; 4+ messages in thread
From: tomas @ 2002-10-21 10:41 UTC (permalink / raw)
  Cc: tomas, guile-user

On Sat, Oct 19, 2002 at 04:07:32PM +0200, Marius Vollmer wrote:
> tomas@fabula.de writes:
> 
[question about protect]

> The 'protector' is used to combine the mark/sweep collector of Guile
> with the refcounting collector of Gtk+.  Here is a shortish
> explanation:

[...]

Great explanation, thanks.

[...]

> There is a section in the README named "Composite Types and
> `call-by-reference'".

I must have been blind, as so often.

Thanks for your patience

-- tomas


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-10-21 10:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-16 11:48 Questions about guile-gtk tomas
2002-10-19 14:07 ` Marius Vollmer
2002-10-19 14:21   ` Marius Vollmer
2002-10-21 10:41   ` tomas

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