[Geany-devel] Python plugin API

Mars mfogels at xxxxx
Thu Jun 11 14:00:11 UTC 2009

I started on something similar myself a while back, for Geany 0.16,
but ran out of time.  The code is here:


You can grab a copy of the code using bzr:

  bzr branch lp:~mars/+junk/geany-python-bindings

And if you just want to browse it on the web:


The plan was to write a Python interpreter started from within Geany,
create a Python module wrapping the Geany data structures and
functions, and use PyGTK to interact with the graphical components.
This is a similar approach to the Gedit Python bindings - PyGTK means
you can use Glade for your plugins, which makes plugin development
much faster.

The stuff I got stuck on seemed pretty trivial, because I was using
the branch to learn Python binding generation as well as practicing
some C programming (it's been a few years).  The plugin successfully
starts a Python interpreter inside of Geany, the waf build scripts
work, it can load pure-Python Geany Plugin modules from the disk, etc.
etc.  I started wrapping the GeanyApp object into it's Python
equivalent, but couldn't get the Python class to work.  Someone with
actual experience writing C Extensions could probably tell what's
wrong in a flash.

Of course, the plugin API has changed in 0.17, but this wrapper is so
slim at the moment that any updates should be trivial.  I considered
automatic code generation, but left that for a later pass (geany-lua
does code generation using hand-coded interface files and some code
extraction, and the Gedit Python bindings are entirely generated)  The
new Geany plugin interface definition files should make writing
language plugins *much* easier than before.  Combine that with the
Scintilla IDL files and you are flying.

BTW, there is one big problem with the Geany plugin API as of 0.16:
Plugins (like Python bindings) can't register other plugins - put
another way, a there is no plugin registration API published via the
plugin API.  With the geany plugin registration API being wrapped in
Python, I could easily write pure-Python Geany plugins.  Lacking that,
I had to come up with my own Python plugin registration.

If anyone wants to hack away on the code, please feel free to do so.
I would love to see Python bindings become a reality.  They are the
one missing killer feature in Geany for me.


More information about the Devel mailing list