gtk - Change G_PARAM_CONSTRUCT_ONLY property via inheritance -


i try inherit gobject and, among other things, change value of g_param_construct_only property next child class doesn't have care.

here's example depict this: gtkcombobox has construct property called "has-entry" default value false. in class want change value true, class b doesn't need care.

            gtkcomboboxclass <-- aclass <-- bclass "has-entry"      false            true 

the first naive approach use g_object_set() in a's instance_init function, no avail.

the next idea obtain gparamspec g_object_class_find_property() , change default value g_param_value_set_default() in a's class_init function. suppose change default gtkcomboboxclass derived objects.

the best idea come with: if g_object_class_override_property() creates new gparamspec find , set default value in a's class_init function. documentation doesn't loose word this.

so question: working, , intended, way of accomplishing this, or there better solution?

tried far:

  • g_object_set() in instance init():
    • no warning on start
    • no effect
  • g_object_set() in gobjectclass->constructor():
    • no warning on start
    • no effect
    • warning on exit: invalid cast gtkcellciew gtkentry
  • g_object_set() in gobjectclass->constructed():
    • warning on start: can't set after construction

thanks stefan

if want set property in sub-class, , property construct-only, should use constructed virtual function call g_object_set() instead of init virtual.

properties marked construct-only applied during construction, using default value, unless specified on constructor — i.e. g_object_new(). means setting construct-only property inside init() not suffice, value set after init() has been called. constructed() virtual function, on other hand, called after constructor properties have been applied, it's possible override default value there.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -