Python bindings for the Geany plugin API.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs docs: update docs for the proxy plugin changes Feb 24, 2016
geany Backport most changes from Geany-Plugins fork Feb 17, 2017
m4
plugins
src
.gitignore Backport most changes from Geany-Plugins fork Feb 17, 2017
COPYING Remove redundant license blurb comment from some code and add a COPYI… Sep 9, 2011
Makefile.am Add a demo plugin to build system. Aug 2, 2011
README.markdown docs: update docs for the proxy plugin changes Feb 24, 2016
README.win32 Add note about PATH environment variable Aug 20, 2012
autogen.sh Cleanup the build system Aug 1, 2011
configure.ac Backport most changes from Geany-Plugins fork Feb 17, 2017
geanypy.nsi Add GLib logging support with python wrapper functions Sep 14, 2014
makefile.win32 makefile.win32: correct installation dir for plugins Feb 24, 2016
win32env.mk Switch to NSIS instead of 7zip SFX exe Aug 20, 2012

README.markdown

GeanyPy

Write Geany plugins in Python!

Please note: since GeanyPy is under heavy development, the API it exposes may change quite drastically. If you start using GeanyPy to write plugins, drop me a line and I'll do my best to not break your code.

Update: There's now some documentation available, visit http://codebrainz.github.com/geanypy to read it.

How it works

In the src/ directory is a normal Geany plugin (plugin.c) which loads the Python interpreter. It then loads some C Python modules (dialogs.c, documents.c, etc.) that interface with Geany's C API. After that, it loads the geany Python module which is just glue/sugar-coating to make the C module more "Pythonic".

To write a plugin, inherit from the geany.Plugin class and implmenent the required members (see geany/plugin.py documentation comments). Then put the plugin in a searched plugin path. Currently two locations are search for plugins. The first is PREFIX/lib/geany and the recommended location is under your personal Geany directory (usually ~/.config/geany/plugins). To load or unload plugins, use Geany's regular Plugin Manager. Python plugins appear there once GeanyPy is activated.

When the Python Console plugin is enabled, it will add a new tab to the notebook in the message window area that contains an interactive Python shell with the geany module pre-imported. You can tinker around with API with this console, for example:

import geany # called automatically in the built-in interactive shell

doc = geany.document.open("/some/file/here")

print(doc.file_name)
print(doc.file_type.display_name)

geany.dialogs.show_msgbox("Hello World")

geany.main_widgets.window.set_title("Hello Window")

def on_document_open(doc):
    print("Document '%s' was opened" % doc.file_name)

geany.signals.connect('document-open', on_document_open)

Dependencies

To build GeanyPy you need the following dependencies:

  • Python 2.6+ and development files (I don't think Python 3 will work).
  • Geany 0.21+ and development files (from SVN)
  • PyGTK 2.0 and development files

On Debian/Ubuntu, the (non-Geany) dependencies can be installed like this:

$ apt-get install python python-dev python-gtk2 python-gtk2-dev

See Geany's documentation/website for information on compiling it from the Subversion or Git repositories.

Installation

First you need to know where Geany is installed:

$ GEANY_PREFIX=`pkg-config --variable=prefix geany`

The you can install as normal:

$ ./autogen.sh
$ ./configure --prefix=$GEANY_PREFIX
$ make
# make install

You should be able to force a specific version of Python to be used, by using the PYTHON_VERSION environment variable, but I've only tested with 2.6.6 so far. I imagine 2.7 series will also work fine.

Running on Windows

See README.win32 for more information.