Brian Hanley wrote:
Hi,
Has anyone tried to wrap GTK+ in C++ without using GTKmm?
Yes, I have.
That is, making calls to GTK’s C-language API from C++ objects?This CVS link contains the object code you are interested in, in <gfc/glib/object.[cc, hh]>
If so, has anyone documented the paradigms/techniques/gotchas,
or published sample code?
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/gfc/gfccore
This CVS link contains the GTK GUI code http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/gfc/gfcui
Specifically, how does one manage the lifespan of interdependentThe correct way is to let GTK manage the life span of your C++ object. When GTK notifys you that the wrapped C object has been destroyed you call delete on its C++ wrapper. Have a look at the G::Object constuctor and the G::Object::destroy_notify function in <gfc/glib/object.[cc, hh]>.
widgets and C++ objects? Is it feasible to have both event-driven
GTK callbacks which reference C++ objects and externally-driven
calls to the C++ objects which reference these same widgets?
How does one manage the lifespan of such objects and widgets?
It's not possible to answer your questions in just a few lines because the answers are not simple. You should find what your looking for though at the CVS links above. If you have any questions about my code, just ask me. I hope you have a good reason for wanting to write your own C++ wrapper for GTK+ because I can assure you, it will take a lot of committent and a lot of hours, and a lot hours, and a lot hours...For example, an instance "obj" of class "MyWrapper" contains a pointer to a widget "widg", and the address of "obj" has been passed as a user-data argument to a GTK signal handler for "widg".
How might one manage the lifespans of "obj" and "widg" given that someone could both (i) call "delete" on "obj", and (ii) call "gtk_widget_destroy" on "widg"?
Is it just a bad idea to try to mix event-driven code with external triggers?
Regards, Jeff. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list