Class Interface

Hello everyone.

When I use a G_DECLARE_INTERFACE interface, do all classes that use G_DEFINE_TYPE_WITH_CODE necessarily have to implement all the signals and methods of the interface?

The only requirement for interface implementations is that they must override all properties defined by an interface in their own class initialization.

Signal handlers and virtual functions may not be overridden by an implementation of an interface—assuming that the interface itself allows it. An interface can have optional virtual functions, and have code in place to provide a default implementation; and it can have required virtual functions, that implementations must override. The documentation of the interface should make these requirements clear for implementors.

1 Like

Do you know some links related to the topic to refer me? Thank you for the explanation.

The GObject tutorial has a whole section on interfaces.

Thank you my friend.

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