Writing Liferea Plugins Tutorial Part 2

Let's continue the plugin tutorial. The last installement was on how plugins work and how to create the boilerplate for a new plugin. Now let's look into how to access Liferea UI elements and how to modify them.

Accessing UI elements

Using the plugin boilerplate for a Liferea.ShellActivatable (a plugin that activates once the Liferea shell, which as an object comprises the entire main window UI, has been setup) we get a member variable named "shell"
    shell = GObject.property (type=Liferea.Shell)
which can be used to look up GTK objects by name using
    shell.lookup(<some name>)
Some interesting names to look up are:
Name Description
mainwindowThe main GtkWindow
leftpaneThe vertical pane containing the feed list
rightpaneThe vertical pane containing the rest
feedlistThe feed list GtkTreeView
itemlistThe item list GtkTreeView
browsertabsThe tabs notebook of the item view
statusbarThe main window status bar
This list not being exhaustive you can grep the code for more uses
rgrep liferea_shell_lookup src/
in general when you want to modify existing UI elements or add extra elements to the UI above list should be a good start.

Example: Modifying the feed list

Here is a simple example to hide the 2nd column of the feed list GtkTreeView. To do this we use the "shell" member to look up the "feedlist" GtkTreeView and ask it for the 2nd column which we then hide:
from gi.repository import GObject, Peas, PeasGtk, Gtk, Liferea, Gdk

class NrColumnHidePlugin (GObject.Object, Liferea.ShellActivatable): __gtype_name__ = 'NrColumnHidePlugin'

object = GObject.property (type=GObject.Object) shell = GObject.property (type=Liferea.Shell)

def do_activate (self): treeview = self.shell.lookup ("feedlist") column = Gtk.TreeView.get_column (treeview, 1) Gtk.TreeViewColumn.set_visible (column, 0);

def do_deactivate (self): return
This is all done on activate, nothing needs to be done on deactivation.