GNOME Bugzilla – Bug 586366
Allow dynamic module type registration (g_type_module_register_type)
Last modified: 2010-03-26 09:53:39 UTC
We need to allow classes to use g_type_module_register_type(): http://library.gnome.org/devel/gobject/unstable/GTypeModule.html#g-type-module-register-type instead of g_type_register_static(), currently used in Glib::Class::register_derived_type(), called from the derived SomeWidget_Class::init() functions. The custom type-registration function would then be called by a plugin entry point, such as the entry point, void hd_plugin_module_load(HDPluginModule* plugin); for a Hildon Desktop Widget. Maybe we could add an optional _DYNAMIC_REGISTRATION() gmmproc macro that would _add_ a SomeWidget::register_dynamic_type(GTypeModule* module) that could be called from the entry point function, and we could check for that previous registration in our regular SomeWidget_Class::init() functions to avoid a second (static) type registration.
Created attachment 137000 [details] [review] glibmm_dynamic_gype.patch An untested patch to implement this: 2009-06-19 Murray Cumming <murrayc@murrayc.com> Allow dynamic GType registration, using g_type_module_register_type(). * glib/glibmm/class.[h|cc]: Added a register_derived_type() overload that takes an extra GTypeModule* parameter, and which calls g_type_module_register_type() instead of g_type_register_static(). * tools/m4/class_gobject.m4: * tools/m4/class_gtkobject.m4: * tools/m4/class_shared.m4: Added a _DYNAMIC_GTYPE_REGISTRATION macro to be used in the class in the hg file, to add a *_Class::init(GTypeModule) method, and a get_type(GTypeModule*) method that calls it.
I committed this, to get some testing.