Re: GtkActionEntry doesn't allow closures?





On 5/26/07, Jason Hickey <jyh cs caltech edu> wrote:
I am developing a GTK+ binding for OMake (http://omake.metaprl.org).
OMake has a functional language, so it has closures, etc.

Pardon me if I am daft, but,
    - One cannot simply pass a GClosure where a GCallback is expected
(!?).

GTK+ is usually nice--each signal can be paired with data, making it
easy to form closures.

Am I missing something, or is it not possible to deal with closures
in GtkActionEntry?

struct _GtkActionEntry
{
   const gchar *name;
   const gchar *stock_id;
   const gchar *label;
   const gchar *accelerator;
   const gchar *tooltip;
   GCallback callback;    /* Ummm, what about closures? */
};

I believe this post belongs on gtk-list, but one possible solution to your problem is to have your wrapper pass a custom C callback and to replace the user-data with your closure. Then your callback can just invoke that closure.

I looked at the GTK+ binding I wrote for R and found that I just reimplemented the convenience functions that take a GtkActionEntry as a parameter. I am not sure why I did that, but that's another alternative. That way your code handles connecting the callback to a signal, so you can use a closure.

Michael


BTW, thank you for GTK+, "thou art god" as Heinlein might say.

Jason

--
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257



_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]