Today, I created my first extension for midori browser. I wanted to have the current time in my statusbar, in way similar to what Statubar Clock does for Firefox.

Extensions for midori must be written in C language. An extension source file must implement a function extensions_init to be loaded. If the source file to be in extensions/ directory, midori build system will be aware of its existence and build it.

A MidoriExtension object must be created in extension_init. A callback must then be connected to it for signal "activate". When extension is activated, this callback will be called with a MidoriApp object as argument. With this object, it's possible to access the underlying windows, tabs, menus, webviews, and other objects extension may need to access. Extension must also connect a callback to deactivate in order to be able to clean up things if user wants to deactivate the extension.

In my extension, I needed to get the statusbar, add a label to it, and set a timeout to update with with current time. Display format can be configured in a config file. There is currently no UI for configuration; I still need to work on it.

You can take a look at a screenshot of midori with Stat'o'clock activated. You can also see the source code of stat'o'clock.

In the end, I think building a simple extension for midori is quite easy and fun if you known a bit of gtk. It will be even better if one day, midori extension can be written in other languages (python, lua, javascript ...). You can learn more by reading the midori extension tutorial.