Setting custom Glib::Property values in Gtk::Builder .ui XML

Short of having to write an underlying class in C, is there any way to have custom derived widgets with custom Glib::Property, and set those custom properties through a Gtk::Builder .ui?

Presuming the answer is no, because the properties are only registered with GType when the instance is constructed - not when the class is constructed, which GtkBuilder won't do anyway if it's C++ - is there any way this could possibly work in future, or discussion I can read?

Basically, I'd like to move a tonne of code that does widget packing and property-setting out of .cpp files into .ui files, but it doesn't really seem worth doing if the added properties of my custom widgets would all need set/get through .cpp files still. I'd like to move everything that could be expressed statically/declaratively to .ui files, or nothing. I don't think moving only the base Widget bits to .ui but having to keep the rest in .cpp is better overall, but worse.

So far I can derive a subclass of e.g. Gtk::Button, add whatever Glib::Property, and see/change its value in the GTK Inspector. Even this isn't very well documented; it doesn't seem to be included in the main gtkmm doc book at all, for instance, so we might want to fix that.

Anyway, this registers properties per-instance when the C++ constructor is called, so GtkBuilder doesn't actually apply the values of custom properties, and the GTK Inspector gives warnings about invalid property IDs when you try to check/change customer properties in a .ui

I'm guessing this has been discussed and just can't be done, but I'd just like to check anyway.

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