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

Kjell Ahlstedt via gtkmm-list <[email protected]>
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
On 6/13/19 2:41 PM, Daniel Boles via gtkmm-list wrote:
> > for posterity, it looks like someone else has had the same questions 
> but didn't get much further:
>
> That user was also using wrap_register() to have code called when 
> glibmm wraps the C instances. I know next to nothing about that - but 
> I wonder if it's at all possible that it could be used with 
> builder->get_objects() in order to ensure everything gets wrapped, and 
> custom code in the registered wrap_new() function to apply the derived 
> properties? However, it seems that user didn't get that to work, if I 
> understood correctly.
>
I've made a similar test. It failed.

I started with gtkmm-documentation/examples/book/builder/derived and 
replaced the GtkButton with
   class MyButton : public Gtk::Button
with a few custom properties. I used Glib::Property for those 
properties. In the .ui file:
   <object class="gtkmm__CustomObject_MyButton" id="quit_button">

MyButton has
   MyButton(GtkButton* castitem);
   static Glib::ObjectBase* wrap_new(GObject* object);
and I call
Glib::wrap_register(g_type_from_name("gtkmm__CustomObject_MyButton"), 
&MyButton::wrap_new);
after having created a dummy MyButton instance to have the class init 
function called.

The only problem is that the custom property values, specified in the 
.ui file, are not stored anywhere. Glib::Property stores custom property 
values in the C++ code, but GtkBuilder creates a C instance of MyButton 
and tries to store the property values before Gtk::Builder::get_widget() 
has created the C++ wrapper. Glib::custom_set_property_callback() in 
glibmm/property.cc discards the values.

Conclusion: It's not possible to combine Glib::Property with Gtk::Builder.

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.