Gedit Plugins

Posted on Thu 10 March 2016 in Articles • 4 min read

Late last year, I wrote a post on turning Gedit into a Markdown IDE. At the time, I was in the middle of Nanowrimo and wanted to share how I use Gedit to write and review documents in Markdown.

I noted that Gedit was a powerful text editor that could be extended a number of different ways. In my post, I demonstrated how to use Snippets to add CriticMarkup support and External Tools to create a build system for MultiMarkdown.

That's child's play though compared to what you can do with Gedit plugins.

Gedit plugins can be written in C or Python and as, such, they can do anything thing these languages support. Not only can you extend Gedit's functionality but you can also extend Gedit's UI by calling Gtk, the underlying graphical toolkit on which Gedit is built. In plain English, that means you can create user input forms much like you can with Microsoft Word using VBA macros.

I'll take a step back for a minute and say why I think this is cool.

Plugins let you extend applications that you already use with new functionality. I've already noted that I use Gedit because it's a pretty solid editor. It supports a bunch of languages and syntaxes, has decent spell checking and is pretty fast and responsive. So by using a Plugin, you can leverage off what's already a good editor and give it the functionality you need without having to use a different app.

Plugins are much easier and faster to write than creating a desktop app from scratch. This is particularly useful when you want to create something fairly unique and personal. Case in point: world building. At the risk of exclusion, the only people who want to create new worlds are writers and table-top gamers. There's limited commercial interest in this activity because most people can and do engage in the process with little more than word processor, spreadsheet and their imagination. It's not worth creating an app from scratch because it's not something people will buy.

By extending a text editor, I don't have to buy into a proprietary format or a proprietary filing system. I can continue to use text and use the computer's file manager. This is good: world building and writing doesn't need all the cruft that goes along with more complex applications and complex file formats. That said, there's nothing wrong with giving the process a helping hand.

For while now, I've been using a bunch of home-baked utilities to generate characters, settings and story files. Some of these are the basic tools you get in any Unix-based operating system, while others consist of custom tools that leverage some of the practice's I've seen table-top game/dungeon masters employ. I also make heavy use of templates.

At the moment my toolbox is a bit of a mess. I've got markdown templates, json models, spreadsheets with calculations, and a variety of scripts written in PHP, Python and Bash. It's time to consolidate the mess and as you've no doubt guessed, I'm doing it into a Gedit plugin written in Python.

So why this combination?

Well, as I've already noted I like Gedit. I also like Python - a lot - it's everywhere I care about, easy to use and there's tonne of free code out there I can use. If I write in Python, the code (well, the model code at least) can be adapted to work in other editors such as SublimeText, TextMate and Editorial.

The only problem is that the documentation for writing plugins with PyGtk+ sucks. The tutorials, scant as they are expect you to know PyGtk+ (fair enough) but the PyGtk+ documentation is patchy at best. So I'll document the process here so hopefully others will find it useful.

No, really dude, why aren't you doing this as a HTML5 app? Mobile, first man!

I've wrestled with this for ages. For a long time, I thought about doing a web app, first in PHP and then in some HTML5 framework. That would make it more accessible; I could host it on a website or even package it as a mobile app and shove it on an app store. Truth is though, I'm not interested. I don't like web apps and the level of abstraction they add between users and their files. I also can't be bothered supporting it; this is something that will be built to reflect the way I like to work on what's a pretty niche past time as it is. Besides, building a complete app would require more work and I'd rather spend the time with my kids.

In my next post, I'll write a tutorial on how to create a Gedit tutorial that's a bit more complex than the ones you'll find in the official tutorial.

Share on: Diaspora*TwitterFacebookGoogle+Email