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/10/19 6:50 PM, Kjell Ahlstedt wrote:
> On 6/10/19 10:39 AM, Daniel Boles via gtkmm-list wrote:
>> A related question here is: How can we ensure the derived type is 
>> registered with GObject before GtkBuilder would need it? Will a 
>> simple g_type_ensure( g_type_from_name("gtkmm__Custom_Whatever") ) 
>> work? I imagine not, as the GObject class won't exist until C++ 
>> constructs the first instance, right? Then it would seem we must 
>> instead create a dummy C++ instance (and ensure it isn't optimised 
>> out) before trying anything that would require GObject to know about 
>> it...
>>
> I think you're right. The only way to have a custom widget's type 
> registered in the GType system is to create an instance. All the 
> ordinary gtkmm types are registered with calls to the static 
> get_type() methods. That's done in wrap_init(). But there is no 
> corresponding method to call for custom types.
Now that I've thought a second time, I wonder if it's really necessary 
to use Glib::ExtraClassInit, and install the custom properties in the 
class init func. Glib::Property<> installs properties with a call to 
g_object_class_install_property(), but it's not done in the class init 
func. Does it matter if it's done later, as long as it's done before 
GtkBuilder reads the .ui file? I mean, if you anyway have to create an 
instance of the custom widget in order to get the class registered in 
the GType system.
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.