Readon Shaw
Readon Shaw

Reputation: 439

How to override property in vala?

When I inherit from GTK widget, I want to override inherited property, so that the normal operation will not be affected. However I could not find any material or tutorials describing it.

Upvotes: 0

Views: 246

Answers (1)

Jens Mühlenhoff
Jens Mühlenhoff

Reputation: 14873

Since properties are inherited from parent classes, you normally don't have to do anything for them to continue to work.

I assume you want to somehow modify the getters / setters. If not, please clarify your question.

  • If you can modify the parent class:

Just create explicit virtual getter and/or setter methods that have (at least) protected visibility level.

With implicit getters and setters valac will create methods for you, but they won't be virtual.

You can then use normal method overriding and base class calling semantics to adjust the parents property.

  • If you can not modify the parent class:

One thing you can still do is to register a handler for the notify signal to react on the setter being called.

Or you may be in luck and the parent class comes with some facility to modify its behaviour.

Upvotes: 1

Related Questions