What benefits does it have to inherit GObject?

Hi,
I’m developing a project which uses GLib and C-based inheritance/OOP (it’s Midnight Commander’s fork). Basically, all TUI elements have a type Widget as the first member, some other inherit this way such element further, etc.

I wonder what benefits could it give to add GObject as the first member of Widget struct? Ie. to inherit it and thus to make all widgets a GObject? I have briefly read something about properties and signals, however I would like to shed some light on what a GObject really is, by asking about immediate side effects of just inheriting it?

1 Like

Hej,

inheriting from GObject gives you a multitude of advantages. The Vala wiki has a pretty good comparison between the different types of classes (Full GObject, only GType, compact (basically C structs)): Projects/Vala/Manual/Classes - GNOME Wiki!

1 Like

Thanks, the web page is helpful, as it directly shades light on the meritum – understanding GObject.

I wonder what initialization and boilerplate code a fully implemented GObject requires. I’d expect some significant requirements here, e.g.: signals and closures seem to require a little verbose code. I thus have another question: are there any GObject features that can be used without initialization or with just a small amount of it?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.