Implementing a GTK+ custom widget

The next step is to implement a custom widget, which is not extending from a currently existing widget, but rather creates a widget from scratch. We will need to do this if we really can't find any similar widgets from GTK+ standard widgets, which can do what we require from the widget that we want to implement.

We can only do this with Vala; unfortunately, as the version of Seed used during the writing of this book can't handle the overriding of a function properly when called from within a class.

Our example does not really reflect the real life situation just discussed because you can easily search a widget which can be readily used, instead of implementing it from scratch. However, the example is provided to simply show the effort involved and how to do it.

Imagine that we need a widget which fulfills the following requirements: