After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 775261 - Make DhLanguage a GObject subclass
Make DhLanguage a GObject subclass
Status: RESOLVED FIXED
Product: devhelp
Classification: Applications
Component: General
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: devhelp-maint
devhelp-maint
Depends on:
Blocks:
 
 
Reported: 2016-11-28 17:14 UTC by Corentin Noël
Modified: 2017-01-11 12:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Corentin Noël 2016-11-28 17:14:18 UTC
It's better for the introspection
Comment 1 Corentin Noël 2016-11-28 17:24:37 UTC
Here is a branch fixing the bug https://git.gnome.org/browse/devhelp/log/?h=wip/tintou/language-gobject
Comment 2 Sébastien Wilmet 2016-11-29 17:27:23 UTC
> (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.
Comment 3 Sébastien Wilmet 2016-11-29 17:28:15 UTC
And deprecate dh_language_free().
Comment 4 Sébastien Wilmet 2016-11-29 20:06:49 UTC
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.
Comment 5 Corentin Noël 2016-12-22 18:11:39 UTC
Right, I've updated the branch with the previous comments, it should now be on-par with the way DhBookManager works.
Comment 6 Sébastien Wilmet 2017-01-09 15:14:09 UTC
(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().
Comment 7 Corentin Noël 2017-01-10 18:55:19 UTC
Branch updated with the requested changes
Comment 8 Sébastien Wilmet 2017-01-11 12:20:01 UTC
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).