Writing a plugin for GNOME To Do – Introduction

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:

gtd
The extensible elements of GNOME To Do

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!


2 responses to “Writing a plugin for GNOME To Do – Introduction”

  1. rantadi Avatar
    rantadi

    Hello and greetings from Germany. I´ve Gnome-Todo 3.20.2 installed on Fedora24. Actually Todo doesn´t show up the Caldav Task Lists from Evolution. With Todo 3.18 all was fine. Is that a Fedora/Evolution Bug or a Todo Bug?

  2. I am looking forward to more posts about plugins!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.