GNOME Bugzilla – Bug 775261
Make DhLanguage a GObject subclass
Last modified: 2017-01-11 12:20:01 UTC
It's better for the introspection
Here is a branch fixing the bug https://git.gnome.org/browse/devhelp/log/?h=wip/tintou/language-gobject
> (GDestroyNotify)g_object_unref No need to cast g_object_unref to GDestroyNotfiy, it's already the good function type. Use G_DEFINE_TYPE_WITH_PRIVATE, not G_DEFINE_TYPE. Please don't define DH_LANGUAGE_GET_PRIVATE, it's not really a standard way to get the private data. Call dh_language_get_instance_private() in the functions that need to access the Private struct. Don't remove the dh_language_free() function, it's a library. If possible, we need to keep backward-compatibility. And here it is possible, just call g_object_unref() in dh_language_free(). For a GObject class, we usually don't add 'const' for the self param in public functions. So it's better to remove the 'const' in all functions listed in the header. That's a small API incompatibility, but not a major one. And I don't think DhLanguage is used a lot outside of Devhelp itslef. Please space out more the code, add blank lines: - after variable declarations. - before/after g_returns.
And deprecate dh_language_free().
Actually since there are now so many ways to create a GObject (which is not a good thing IMHO), the best is to be consistent with other GObjects in Devhelp. DhApp is a good example after a quick glance. And it seems that other GObjects in Devhelp follows the same style.
Right, I've updated the branch with the previous comments, it should now be on-par with the way DhBookManager works.
(In reply to Sébastien Wilmet from comment #2) > Please space out more the code, add blank lines: > - after variable declarations. > - before/after g_returns. This still applies, in dh_language_finalize(), dh_language_class_init(), dh_language_init(). When deprecating a function, you need to add G_DEPRECATED_FOR or G_DEPRECATED in the header, to have a compilation warning when using the function. G_DEPRECATED_FOR is better when there is a direct replacement. In class_init, you normally don't need to call g_type_class_add_private().
Branch updated with the requested changes
I've improved/fixed the coding style (it was easier to do it myself than explaining everything, you should read a book like Code Complete or something). There is still this warning to fix: <unknown>:: Warning: Devhelp: (Signal)open-link: argument flags: Unresolved type: 'DhOpenLinkFlags' (open a separate bug to fix that).