Murray Cumming schrieb: > Yes, but I think that's how we create the underlying C GObject even when > we use a C++ constructor. It will need some thought/investigation to > figure out how to best solve this. ok, attached are my humble efforts to figure this out. I used your MyWidget as a pattern for a Gtk::DrawingArea-derived one, on one hand because that's what many of my own Widgets are derived from, on the other hand because you have visual feedback in glade as soon as it works ;-) simpledraw.{cc,h} just implement the widget as you'd usually do (with the addition of the gobject-c'tor. simpledraw_glade.cc is the glue for glade and libglade, and simpledraw_postcreate() does the trick of calling simpledraw_wrap_new() when a GObject is created inside the user interface builder. I had to use "int" instead of "GladeCreateReason" in simpledraw_postcreate() because i couldn't get rid of the compiler errors when including libgladeui/glade.h ... will eventually look into this again. simpledraw.xml is a sample catalog for this widget that shows the usage of simpledraw_init() and simpledraw_postcreate() inside the catalog. simpledraw_gladetest.cc and simpledraw_ctortest.cc prove you can use the widget from libglade and also directly use it's c'tors. for glade3 first-timers who would like to try this one: assuming you compiled glade-3 with --prefix=/usr: extract and compile simpledraw, copy libsimpledraw.so to /usr/lib/glade3/modules/ copy simpledraw.xml to /usr/share/glade3/catalogs/ fire up glade, there should be a section called "Gtk::Widgets" and a "Simple Draw" widget in the Palette Window. Create a new window and drop a SimpleDraw inside it, you should see a red and blue rectangle. call the test programs like this: LD_LIBRARY_PATH=. ./simpledraw_gladetest LD_LIBRARY_PATH=. ./simpledraw_ctortest will now investigate on how to add properties ;-) .... -- o -- Oliver Nittka ESEM Grünau GmbH & Co. KG Dornierstraße 6, 88677 Markdorf/Germany phone: +49 7544 9583-25, fax: +49 7544 9583-60
Attachment:
simpledraw.tar.gz
Description: GNU Zip compressed data