I’m starting a small series of posts describing a general how-to on writing plugins for GNOME To Do. The good news: GNOME To Do has a very small API and it’s very easy to build plugins.
Note: I’ll show examples in Python 3, since this might lower the barrier for contributors and it’s a language that I know (and LibPeas supports). If you don’t know what LibPeas is, click here.
A Brief Explanation
Before jumping into code, let’s talk about the internals. GNOME To Do allows developers to extend it in 3 ways: adding UI elements, adding new panels and implementing new data sources.
A data source is pretty much anything that can feed GNOME To Do with data. For example, Evolution-Data-Server is a data source (the default and omnipresent one). A panel is a view displayed by the main window. See below:
Every plugin has a single entry point: GtdActivatable. Plugins must provide an implementation of this interface. I’ll write more about this interface below.
GtdActivatable
As explained, the entry point of the plugin is GtdActivatable, which will provide the data sources and UI widgets. The definition of this interface can be found here. The following methods should be implemented:
void activate (GtdActivatable *activatable); void deactivate (GtdActivatable *activatable); GList* get_header_widgets (GtdActivatable *activatable); GtkWidget* get_preferences_panel (GtdActivatable *activatable); GList* get_panels (GtdActivatable *activatable); GList* get_providers (GtdActivatable *activatable);
A quick explanation of each one of them:
- activate: called after the plugin is loaded and everything is set up.
- deactivate: called after the plugins is unloaded and all the registered data sources and UI elements are removed.
- get_header_widgets: retrieves a list of widgets, usually buttons, to be added to the headerbar. This can be the hook point for your functionality, for example.
- get_preferences_panel: if your plugin needs further configuration, you can pass the preferences panel through this method.
- get_panels: retrieve the list of panels of the plugin. A dedicated blog post will be written about it in the near future.
- get_providers: retrieves the list of data sources your plugin may provide. GtdProvider is the interface a data source should implement. A dedicated blog post will be written about it in the nearby future.
The next posts will be about the various ways to add functionalities to GNOME To Do. Also, the next posts will demonstrate plugins through examples of various kinds. Stay tuned!
Leave a Reply