Friday, February 26, 2010

Linking notes and email messages

A few days ago, I've cobbled together a note-taking solution for my email messages. It's very unixy, consisting of a fair number of different parts working together: Claws Mail with the Python plugin and two of the shipped example scripts on the one side, Tomboy with the Claws Mail addin and the Reminder addin on the other side.

Starting with a message selection in Claws Mail,

a click on the "Create Tomboy Note" menu item of the Python example script results in this dialog popping up (I know that this dialog is ultra-ugly, but hey, it's a quick&dirty easy-code example script, nothing more)

which in turn creates this Tomboy note

The Tomboy reminder plugin will take care to remind me about this next monday by raising the note.

To make the round-trip complete, there's a second example script that raises all Tomboy notes that link to a selected message.

Okay, admittedly not the end-user friendliest setup, but it suits my needs pretty well. And it shows the benefits of scripting language interfaces for glueing components together -- it didn't take long to write the scripts to make this work, even though the plugins and addins have not especially been designed for it.

Monday, January 18, 2010

The Tomboy and the Git

Tomboy's taming of the beast turned out to be a very useful feature for my daily note keeping. But emails are not the only pieces of information that I often find associated with tasks. Another recurring source that I want to reference are commits in source code management systems. So, if Tomboy can play nicely with my MUA, why shouldn't it play nicely with my source code repository browser as well?

Unfortunately, there's no drag-and-drop target for git repository viewers defined. Most viewers just don't let you drag from the commit list into another application. So, I tried to contact the guys from gitk, giggle, and gitg in the hope to define such a dnd target. The guys from gitg seemed to be the only ones interested in that functionality (good thing that gitg is currently my favorite browser anyways), and it didn't take long until they added the required features.

With that in place, it was easy to write a Tomboy addin that handles dropping of git references into a note analogous to dropping email messages: By creating a link with a nice icon and a meaningful text which when clicked opens the git repository viewer and selects the respective commit.

I like these little helpers. They have a good work/gain ratio.

Sunday, January 17, 2010

Extending and Automating Claws Mail - the sneaky way

The recent release of Claws Mail 3.7.4 has also seen a much more powerful version of the Python plugin. It is now possible to write scripts that are executed automatically on startup, shutdown, or opening of a compose window. It's also now possible to write scripts that work on an already opened compose window. The user interface got better as well (e.g. it's now possible to trigger scripts via toolbar buttons).

However, what the latest release still lacks, is documentation and examples. After all, features that are not documented don't exist. This is supposed to get better in the next release. I've started adding a few example scripts to the source distribution that show possible solutions to questions that have been raised on the user's mailing list lately. Most of these should already work with the released version of the plugin, with the exception of the startup script that show's how to add new menu items for custom actions into the main window (the examples being a menu item to mark a thread as read, and to add a menu item to create and show the Python plugin's API documentation on-the-fly - isn't introspection cool?).

Anyways, if anybody scripted something cool with the plugin, please consider sending the (well commented) script to me. I'd be happy to consider it for inclusion in the distributed examples.

Monday, December 14, 2009

Nautilus Split View and Upstream

Check out that screenshot about the current state of splitting a Nautilus window:

The exciting thing is that this is not a screenshot of my split-view branch, but of Gnome git master.

So after successfully using the split view branch for Nautilus for several months, and (mostly thanks to the PPA) getting some feedback from others, I finally requested a review for it. Turned out that I had a good timing, because with the upcomming Gnome Shell, a debate is currently going on anyways about the future role of Nautilus. With a possible switch away from being a desktop shell and towards more typical file management tasks, split-view fits better into the picture as it used to.

I am very happy that Alex Larsson picked up the task to review and clean up the branch. Even more so as he recently commited a reviewed version to Gnome git master, which can be seen in above screenshot.

The UI is not yet final, and there are a few issues still to be worked out, but I really like the route that it's going. So, if all goes well, there won't be any Nautilus packages for Lucid in my PPA..

Wednesday, December 2, 2009

The Tomboy and the Beast

To a large degree, Open Source is about scratching personal itches. The results are oftentimes small scripts, tools or plugins, rather than ending up as big projects of their own. Even if only little time is invested, the result can sometimes make a difference in terms of working efficiency. And picking low-hanging fruits surely is fun!

I'm using Claws Mail as MUA and Tomboy to organise my ideas and workflow. Both are truly excellent in their areas. However, an email is oftentimes connected to an idea, or a task, so I want to connect emails and notes somehow. Unfortunately, Claws Mail and Tomboy don't play well together.

When dragging emails from Claws Mail and dropping them into a Tomboy note, this is what you get:

Of course, the temporary files are cleaned up again after Claws Mail is closed, so the links are not only clumsy and non-descriptive, but also non-persistent and therefore totally useless in a note.

No more! I wrote a little addin for Tomboy that provides Claws Mail integration, so when loaded, email drag'n'drop results in this:

When clicking the link, the email is opened in Claws Mail again.

Code is on GitHub. I still couldn't find enough motivation to write the autofoo for it, so for now, a small hand-cooked Makefile has to do. Be sure to read the README file. I am not a fan of binary releases, but if anybody is interested in the dll, drop me a line. Also note that it currently only works with Claws Mail from CVS.

First impression of the Tomboy addin interface was very positive. It makes writing small addins easy, even for those unfamiliar with the general codebase. Well, even more in this case, as Tomboy ships with an Evolution addin which does the same thing for Evolution, and was an obvious source of inspiration.. Isn't Open Source great?

Saturday, September 19, 2009

Chronically Underrated: Undo

In the past years, software designers have done a lot of research not only of what a good user interface is supposed to look like, but also how it is supposed to behave. A key component (that to this day a lot of software still gets wrong) is to not bother users with dialogs, especially not those nasty modal ones, but to just do the right thing. Of course, the program can't always know what the right thing is supposed to be, so to accomodate for mistakes, the application should still shoot ahead, but offer an easy way to undo those actions again. The beautiful article "Never Use a Warning When you Mean Undo" by Aza Raskin should be a must-read for all UI developers.

Actually, this not only applies to graphical user interfaces, and clicking away dialog boxes, but also to command line interfaces. I've recently aliased rm with gvfs-trash on a few machines (including my own) for precisely that reason. Unfortunately, this alias does not work completely, but I am still hoping that I can habituate to its limitations.

Unfortunately, Claws Mail is a sinner in that respect, too. On the plus side, it makes it hard to actually loose work (so it's not guilty of Aza's worst software sin). However, in many cases it prevents data loss by distracting the user (by popping up dialog boxes), and makes it hard to revert an accidental operation (like digging up messages in the trash), so it is guilty of Aza's second and third worst software sins. Also, Claws Mail sadly doesn't come with Undo/Redo capabilities at all (well, apart from text entry in the compose window editor).

Some years ago, probably around 2004, I was looking around for a general purpose undo/redo stack that offered GObject integration for a pet project of mine. I was very disappointed to not find anything back then, so I rolled my own. It's a small class that offers undo/redo stacks (optionally with a limited stack size). Stack entries can be grouped, groups can be nested. Everything can have a description. As an optional viewer, I had a simple gtk+ widget to display undo/redo stack entry descriptions in a list (or tree, in case of groups), acting as the view in a MVC pattern. Anyways, in the end, I got distracted from the pet project, and never published it.

So, I thought I could break out the undo class from that old project, clean it up, streamline it a bit, and replace deprecated GObject/gtk+ stuff with shiny new technoligy. While doing that, I was looking around again at available undo frameworks, and was a little surprised to find one for Qt and another one for GObject, both of which I would assume to be older than my class (GUndo's ChangeLog dates back to late 2005, but some copyright headers speak of 1999). I wonder why I haven't found them earlier.. The funny thing is that both are kind of similar to what I did. Especially GUndo is (API-wise) crazily close to what I came up with (but of course, I still like mine better!). I guess there is only a limited amount of reasonable solutions to the undo/redo problem.

We'll see if it's feasible to hook up Claws Mail with an undo stack. It's usually hard to put undo capabilities into a program that hasn't been designed for that from the start. But maybe it'll be possible to put at least a few error-prone actions (like getting back a message that was falsely moved into the trash) in.

Thursday, August 6, 2009

Claws Mail got bitten by a Snake!

I've been successfully using the Perl plugin for Claws Mail for a long time now. It hasn't seen many updates lately, but that's because I am mostly happy with it for my personal needs.

However, filters for Claws Mail is one of the few remaining areas where I'm still a Perl user. I have the feeling that my mental capabilities are insufficient for memorizing the dozens (hundreds?) of operators, magic variables etc., especially after a while of absense from the language. "There is more than one way to do it" is fine, but with age, I tend to prefer "There is a single (obvious) way to do it" as a motto. So, for all of my scripting purposes, I found a new home at the Python people. Please, no discussion which one is "better", for whatever definition of "better". Both are nice languages, and I guess people just have to figure out which one suits their individual work flow better.

So, lately, I had to embed a Python interpreter in some C code, and, as often when learning about new technologies, I though this might be a fun add-on to Claws Mail. Don't worry, I am not trying to bloat Claws Mail with every single interpreter out there -- although that might actually be a fun experience.

So I cooked up a small Python plugin for Claws Mail, which adds an interactive Python console to Claws Mail (stolen and adapted from gtkparasite - which is a great project). It's also possible to execute scripts from the menu, for further automation. The interface to Claws Mail is still limited, and only includes calling menu items for now.

(Planet readers: A short demo screencast is here).

Code is on GitHub.

PS: Yes, I know that the name Python actually refers to a commedy group, not to the animal. But I don't care.

Update: The plugin source moved to Claws Mail CVS. It also gained on a new trick on the way -- automated composing of mail messages. See the README file for an example.