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 elementsUsing 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:
|mainwindow||The main GtkWindow|
|leftpane||The vertical pane containing the feed list|
|rightpane||The vertical pane containing the rest|
|feedlist||The feed list GtkTreeView|
|itemlist||The item list GtkTreeView|
|browsertabs||The tabs notebook of the item view|
|statusbar||The main window status bar|
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 listHere 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, GdkThis is all done on activate, nothing needs to be done on deactivation.
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