Software we’d like to see, part six million: the Swamp

This arose from an IRC conversation which I was tangentially involved in, and I wanted to write down my thoughts while I ate my lunch. I am not a HCI person, so take it all with a pinch of salt. Also, all this has been said a thousand times before.


1. You know what? I am tired of arguments about filechoosers. Nobody can get the things right and make everyone happy, and I think the reason for that is actually they assume you’re thinking about a small set of separate files where the set members don’t change very often, and which live in a hierarchy. That’s a bit like how programmers think of source code, which is probably why, but it’s not how most people think of documents. (Heck, I think it’s not how programmers think of most documents.) If you look at the documents directory or the desktop of most people, you’ll find a huge flat heap of files. You know we already have tools to deal with this sort of thing, but they only work for certain kinds of file (F-Spot lets you organise your thousands of photos by date and tags rather than by requiring you use hierarchical directories and filenames).

2. Yes, I know about Beagle. I still have to make up names for my documents and put them in a hierarchy.

3. Colin Walters mentioned in the IRC discussion that we could just make “File | Save” write stuff straight out to ~/Documents or whatever and not make people deal with having to slot it into a hierarchy at all. I would love this. Maybe turn it on in gconf or with an environment variable that could be set at login for certain users.

4. The trouble with this very good idea, of course, is that they then have to be able to find it again. So we let them search on metadata (yes, including <buzzword>tags</buzzword>) when they want to re-open the file. (Effectively that’s what they’re doing when they choose a filename like “email from Joe” so they they can find it again.) We have three kinds of metadata, though the difference should not be apparent to the user: there’s information gathered from the file like the height and width of an image (and some files formats can store arbitrary metadata internally), and there’s similar information which can be edited by the user and written back in, and then there’s information which must be stored externally to the actual file.

5. Where we actually store the data and metadata doesn’t matter. Ext2, maybe, with separate GKeyFiles for the metadata. Or maybe in a big SQLite database. I don’t mind, really. Maybe give people the option. Don’t ask users on installation or they’ll run a mile.

6. Using separate files raises the problem that all third-party solutions to the 8+3 character filename limit on MS-DOS had: you would always lose the data if you copied the file away. For this reason I’d rather not reuse an existing ~/Documents-type directory. Maybe call it ~/.swamp or something (I like the idea of a files floating around in the swamp and occasionally bubbling to the surface). Using one big file with tools to copy files in or out saves us that problem, of course.

7. Those of you thinking very fast will say, “If people don’t give a filename when they choose Save, then Save and Save As are the same thing, and that means there is no way to branch development of a document”. You are right, but you said the magic word, “branch”. Once user documents live in a controlled environment, there is no reason not to apply simple version control, which VMS has had since basically forever. Imagine how useful that would be! In fact, why are we requiring users to name files like programmers and not also automatically giving them the programmers’ advantage of putting their files under some distributed VCS?

This is just a thought-experiment, really.

I’ve had a number of people say they can’t comment on my GNOME blog; try clicking the number of comments and seeing whether that works. If it doesn’t, email me (tthurman at gnome). [Update: Might be working better now.]

Let me know when you make other posts about the subject (as I said on IRC, this is long on ranting and short on original content) and I’ll link them here. Or you could just pingback, of course.

planet as message board

alex-weej: I would like metacity and libwnck to share the window menu code. If Compiz is doing it already, hurrah. If you know more, more hurrah.

bkor: I am quite willing to release 2.21.21, but I don’t know what you want in it. There is no 2.21 branch because there are never branches named after odd-numbered versions. I am quite happy to make special branch, though, but from where? And what should go in after the branch? Or do you just want a copy of current trunk, or of the 2.23 branchpoint, with the numbers changed? And if so, why?

Session management and metacity (nargery)

Metacity has a directory ~/.metacity which it uses to store session state. When you log out of GNOME, Metacity stores away a bunch of data about the windows of session-managed applications so that when they start up again it can attempt to restore them. (For example, if you were running Epiphany maximised when you logged out, you probably want it to come up maximised when you log back in.) This is how it’s been done since the early days.

It has been pointed out in GNOME bug 518596 that using ~/.metacity for this purpose is contrary to the freedesktop specifications. This would mean that everyone’s home directory was slightly less cluttered. bkor and others are suggesting making this a Gnome Goal across the whole system.

The question then arises whether session state is a “config” or a “cache” file within the meaning of that specification. Window placement is “non-essential” and to some extent temporary, so perhaps it’s “cache”. On the other hand, it’s not information that can be regenerated with greater effort and is stored to save the trouble, and it is used in configuration, so perhaps it’s “config”. I am writing this post to ask you your opinions on the matter and to lazyweb for prior art.

If we do decide it’s cache, it’s possible we could avoid searching ~/.metacity if the file isn’t in ~/.cache/metacity. That’s good, because that step would stay with us for ever, and I doubt most people keep useful session management files around for more than a few months.

the snow, the rain, and the nasal bleed

Friday began with snow. Lots of snow. Nobody was willing to run the risk of driving me into work, so I stayed home and (as is usually the case if I get the chance to stay home) got a lot of work done.

Other than that, on Friday we went to the diner and ate some food. Then we went to buy Rio some shoes, and on the way we found a scarlet towel that Rio said she liked. The shop person said, “I have a towel like that at home. You’ll never guess what I like to put in it.” I said “What?” and bit my tongue to stop myself saying “Yourself naked?”, since although it seemed the obvious answer it was presumably not what was meant. (The answer was actually kitchen supplies in an entirely red and black kitchen.)

I also wrote a poem in a trochaic form I don’t usually use.

Welcome to the adult world!
Feel a clumsy failing fool.
Living is a tricky game,
Harder than they tell at school.

Every day beyond your means:
Hide it from the public view.
All around must never guess
What it is they’re hiding too.

Conquer bedrooms, conquer boardrooms,
Build your mountain to the sky.
Have a resume to die for:
When you get it, then you die.

Yet the children play in dirt,
Heedless of a pointless star:
“Never ask us what we’ll be:
Know that we already are”.

Conversation at the dinner table on Saturday:
Rio (eating the last of a tub of tin roof ice-cream): My ice-cream is crumby. I mean, I don’t think it’s crummy like it’s no good, it’s crumby like it has peanut crumbs in it.
Marn: But your ice-cream is also cool. I don’t mean like, whoah, it’s awesome, I mean cool like you got it out of the freezer.
Rio: That’s true.
Marn: And your ice-cream is also sweet. I don’t mean like sweet, like, SCHWEEET, I mean sweet like it contains sugar.
Rio: I don’t get it.
Fin: You didn’t grow up in the eighties.

I have also been refactoring Metacity’s parsing of gconf options, and it has been very satisfying to regularise the code. Other Metacity bugs I’m working on : GNOME bug 460018 and GNOME bug 509530. Moreover, I have been playing with launchpad; Gnusto is now known to launchpad and known to ohloh. I may add other such things later.

Conversation at the dinner table on Sunday:
Fin: So we’ll try to alternate beef and chicken.
Me: But we’re having pizza on Wednesday.
Alex: What are pepperonis, anyway? Is that cow meat?
Me: No, I think pig meat.
Alex: Wow, does that mean Jewish people can’t eat pepperoni pizzas?
Rio: I think they have to eat them because they have a rule that says they mustn’t.
Fin: That’s Discordianism, love, not Judaism.
Rio: Oh, yeah, like how they have to eat hot dog buns on a Friday.

Today Rio and I went to Alex’s church. Rio has a bit of a cold and was sniffling through the sermon, and a kindly Mother’s Union-type person (or whatever the RCs have instead) sitting behind us offered her a tissue. Shortly after the acclamation Rio attempted to kneel, slipped off the kneeler and hit her face on the pew in front. She bled copiously all over her clothes and hands. The Mother’s Union woman asked whether she was all right and handed us the whole packet! I asked Rio if she was okay to walk and she nodded, so we scrambled out of the building, down the stairs, past some Girl Scouts who appeared out of nowhere to shout “Girl Scout Cookies!” at us– we shouted “Nosebleed!” back at them. I think they were the boss monster– and we ran back to our house. Fin cleaned Rio up and soaked her clothes and I found her an icepack. She curled up and recuperated by watching every rerun of MythBusters she could find.

Link soup:

You can’t stop the waves, but you can learn to surf

Rio and Alex and I went to St Gabriel’s. The man who had served as the organist and choirmaster there for nineteen years died very suddenly the other week, and the place is still feeling shocked. Mother Donna Jean preached a rather interesting sermon on the parallels between the story of Abraham’s call and the story of Nicodemus. I asked her about other Johannine uses of the metaphor of night to represent the lack of understanding and she joked that I should be preaching next week; I said that was possibly the scariest thing anyone had said for a while. I was a little frustrated that the last hymn was one I didn’t know but the score for Cwm Rhondda was staring at me from the next page. (I am not responsible for that video.)

Later I finished writing a program to compile Metacity Journal entries: in other words, it goes around and finds bug activity, checkins of code and translations, mentions on blogs, and so on, and makes a blog post out of them. Here is the first output. I will be publishing the code, of course, but it will need a bit of tidying.

Later we all went for a walk in the park. Riordon stopped and said “I’ve got something in my shoe”, and when she took it off, balancing on one foot on the towpath, and shook it, out fell a US quarter, a US nickel, and a British 5p. I told her that she must have swept her hearth particularly well, according to the old rhyme. She said that she had actually been cleaning the floor in her room, but that she had been keeping shoes downstairs, and the good folk were hardly going to be able both to see her floor and examine her footwear.

After that we came home and I closed a ton of Metacity bugs.

“When I get a little money I buy books…” I have been wanting for a long time to read three particular books to Rio that I loved as a kid. They are: The Turbulent Term of Tyke Tyler by Gene Kemp, Nothing to be Afraid Of by Jan Mark, and I Like This Poem, which is an anthology edited by Kaye Webb. Amazon in the US doesn’t know TTTOTT, though it has the other two second-hand, which I don’t mind at all and indeed prefer in a lot of ways. Tonight I thought I’d order all three from Amazon in the UK; I was quite pleased to find that most of them were available for prices as low as a penny in some cases until I saw that shipping would be £20 to me in the US and £8 even to my parents in Hertfordshire. I think this must be the result of reasoning in a weak currency, because $20 to ship three books, or $40 overseas, seems rather excessive to me. Is that really what postage costs, and do any of you have advice or even an old copy of TTTOTT that you can send me in return for postage, gratitude, other trinkets, love, bug fixes, sonnets written praising you…? Update: My sister Mandy tells me that the book is called “Tyke Tiler” in the US, for obscure reasons, and it may therefore be findable after all.

Software we’d like to see: I have always been in slight awe of IMAP. It does everything POP3 does, everything SMTP does (and a lot better)[1], everything NNTP does, and it does its own useful things as well. You even could use it, if you were monomaniac enough, for a ton of other things, including as a replacement for FTP, or as an RPC transport. If some Emperor of the Internet was to decree tomorrow that henceforth nobody was to use POP3, even the people who only want what POP3 does could run IMAP and just only allow or only use its “recent” mode. Really, I think there are two things that puzzle me about it:

  • Why anyone is still using POP3, and more so, why they are still using SMTP.
  • Why everything-but-the-wire-protocol of IMAP is still travelling over a custom protocol and not REST. It seems to me as though it would mean we could reuse existing and well-tested code, it would mean you’d get all the existing bonuses of the HTTP protocol like its ubiquity and gateway support and so on, and the IMAP protocol is very REST-like already: it would be a pretty simple one-to-one mapping.

I haven’t seen anyone seriously suggest this, although Google showed me a thought-experiment as a teaching aid. If I was still working for an email provider I would suggest it, but I’m not.

[1] Ryan Lovett has pointed out that IMAP specifically doesn’t allow for sending mail, and he’s right: I misread the RFC and thought I saw something that wasn’t there. I’m sorry. I do think it should be included into a system such as the one I discuss above: something which allowed access to a group of messages/files over HTTP in the style of WebDAV (although possibly simpler), so that you could read and write and sort them into folders, and then also have a way to send them and to search for ones with flags like “recent”, would be a hugely useful grand unified protocol.

I fixed the “partlock” bug in Joule, which annoyed a small number of people a whole lot. Also, I thought you might be interested to see the usage of the cupid script:

The community was quite quiet this year compared to last, I think. I would show you the world map for just the script if I could figure out how to generate it. I can only seem to get Google Analytics to show maps for the whole site.

(Very brief) link soup:

(I apologise for those of you reading this on blogo/tthurman who think it clashes; I’m trying to make it look like and so far I’ve only got as far as playing with the CSS.)

Valentine’s and after

Valentine’s day was actually quite quiet for the most part. Our company gave us a bag of sweets, mostly those little love-heart ones which say things on them like EMAIL ME and YOU’RE THE BEST and CLOSE MY BUG((Not an actual example, sadly. Maybe we could make some GNOME sweets for next year.)), and chocolate hearts with mottos inside. My team lead was told “Be your own Valentine!” which sounds like a polite way of saying something else.

When we got home, Fin had made an amazing meal for all of us, each with our favourite thing to eat. Some of them had tomatoes and things cut into heart shapes. It must have taken ages.

I also discovered a not terribly obvious problem with GMail. I wrote a script which would tell you who had left you Valentine’s messages on LiveJournal, and it worked by turning on email notification, sending each LJ comment received to a GMail account, and every hour having a cronjob which read the account using IMAP, indexed them all in a Postgres database, and then having a cgi which could display search results. That was all very well, but on Valentine’s day itself, something inside GMail decided that the account was being used for IMAP in some kind of inappropriate way, and shut it down wth the error Lockdown in Sector 4! I disabled the cronjob, but it meant that some people didn’t see their valentine messages for another day or so.

On Friday it was pretty quiet again. I wrote a triolet.

Lines Written on the 15th of February

Today’s just a day
That’s not Valentine.
No roses, no wine.
Today’s just a day
I still want to say
I’m glad that you’re mine.
Today’s just a day
That’s not Valentine.

I also spent far too long trying to remember the visibility rules in GNOME bug 509165.

Link soup:

When Wednesday was quiet

I had a doctor’s appointment on Tuesday; I told Fin and Alex about it on the Monday and asked them to drop me off there. On Tuesday they went to see this cat that I mentioned earlier, and came to pick me up afterwards, and as I also mentioned we decided to go out to eat. I’d thought that meant after the appointment, and I was so sleepy I fell right asleep. When I woke up, we were coming up to the restaurant, and I was faced with the dilemma of whether to say, “But we’re missing my appointment” (and go back, have missed the appointment anyway, and have ruined the meal), or to keep quiet for now. I decided to keep quiet. Either way I’d have to pay for the missed appointment.

The next day I phoned the doctor to reschedule and they were very apologetic: they said, “Oh, we were trying to contact you: the doctor was off sick yesterday. We’ll phone in a refill for you.”

I didn’t go to see the cat after all on Wednesday, because she behaves nothing like our cat did and doesn’t respond to her name, and people were afraid I’d give a false positive because I miss our cat so.

I spent much of the evening writing about GMarkup instead of fixing bugs.

I also had a very interesting email, which I might tell you all about later.

This morning, the company has given us all bags of love heart sweets and teddy bears. Thank you to the people who left comments for me on valentinr and places like that! If anyone sent one of those mutual things where you have to send another of the same kind in order to see them– well, I didn’t send any like that, so I won’t see them.

Fin, Alex: I am going to get you trees. But it is too cold to plant trees, so later in the year I will get them.

Link soup:

XML, GMarkup, and all that jazz

xmlchick.jpgI was asked to talk about how to use GMarkup. This is a brief introduction; there are many people more qualified to talk about it than I am. These are my opinions and not those of the project or my employer. If you want to suggest a change or report a mistake, suggest away.

Firstly, why you shouldn’t use GMarkup.
Don’t use GMarkup if all you want is to store a simple list of settings. Instead, either use gconf, or if what you want is a file on disk, use GKeyFile, which lets you write things like:

film=Better Than Chocolate
poem=Jenny kiss'd me when we met

in the style of .ini files. These are much more user-friendly.

Don’t use GMarkup if you want to parse actual arbitrary XML files. Instead, use libxml, which is beautiful and wonderful and fast and accurate. GMarkup is made to be easy to use.

Do use GMarkup if you want a reasonably complicated way to store files on disk, in a new format you’re making up.

Why GMarkup files are not XML.
XML is big and scary and complicated and spiky. People pretend it is simple. It isn’t. GMarkup files differ in many ways from XML, which makes them easier to use but also less flexible. Here are some ways in which a file can be XML but not GMarkup:

  • There is no character code but Unicode, and UTF-8 is its encoding. GMarkup does not attempt to screw around with UTF-16, ASCII, ISO646, or, heaven help us, EBCDIC. That way madness lies.
  • There are five predefined entities: &amp; for &, &lt; for <, &gt; for >, &quot; for ", and &apos; for '. You cannot define any new ones, but you can use character references (giving the code point explicitly, like &#9731; or &#X2603; for a snowman, ☃).
  • Processing instructions (including doctypes and comments) aren’t specially treated, and there is no validation.

There are also a few subtle ways in which a file can be parsable by GMarkup but not be valid XML. However, these are officially invalid GMarkup even though they work fine, if you can follow that. Many people don’t care, but they should.

Okay, so how do we get going?
There are two ways people deal with XML: either as a tree, or as a series of events. GMarkup always sees them as a series of events. There are five kinds of event which can happen:

  • The start of an element
  • The end of an element
  • Some text (inside an element)
  • Some other stuff (processing instructions, mainly, including comments and doctypes)
  • An error

Let’s imagine we have this file, called simple.xml:

  <animal noise="roar">lion</animal>
  <animal noise="sniffle">bunny</animal>
  <animal noise="lol">cat</animal>

This will be seen by the parser as a series of events, as follows:

  • Start of “zoo”.
  • Start of “animal”, with a “noise” attribute of “roar”.
  • The text “lion”.
  • End of “animal”.
  • Start of “animal”, with a “noise” attribute of “sniffle”.
  • The text “bunny”.
  • End of “animal”.
  • Start of “animal”, with a “noise” attribute of “lol”.
  • The text “cat”.
  • End of “animal”.
  • Start of “keeper”.
  • End of “keeper”.
  • End of “zoo”.

(Actually there’ll be some extra text which is just whitespace, but let’s ignore that for now.)

There are two kinds of objects to deal with.
One is a GMarkupParser: it lists what to do in each of the five cases given above. In each case we give a function which knows how to handle opening elements, or closing elements, or whatever. If we don’t care about that case, we can say NULL. The signatures needed for each of these functions are given in the API documentation.

The second kind of object is a GMarkupParseContext. You construct this, feed it text, which it will parse, and then eventually destroy it. It would be nice if there was a function which would just read in a file and deal with it, but there isn’t. Fortunately, we have g_file_get_contents(), which is almost as good, if we can assume there’s memory available to store the whole file at once.

So let’s say we want to print the animals’ noises from the file above.

  1. Decide which kinds of events we need to know about. We need to know when elements open so that we can pick up the animal noise, and when text comes past giving the animal name, so we can print it. It would be possible to free the noise when we need to get the next noise, but it would be easier to free it when we see </animal>, so let’s do it like that. Processing instructions and errors we can ignore for the sake of example.
  2. Write functions to handle each one.
  3. Write a GMarkupParser listing the name of each function.
  4. Write something to load the file into memory and parse it.

Here’s some less-than-beautiful example code to do that.

#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

gchar *current_animal_noise = NULL;

/* The handler functions. */

void start_element (GMarkupParseContext *context,
    const gchar         *element_name,
    const gchar        **attribute_names,
    const gchar        **attribute_values,
    gpointer             user_data,
    GError             **error) {

  const gchar **name_cursor = attribute_names;
  const gchar **value_cursor = attribute_values;

  while (*name_cursor) {
    if (strcmp (*name_cursor, "noise") == 0)
      current_animal_noise = g_strdup (*value_cursor);


void text(GMarkupParseContext *context,
    const gchar         *text,
    gsize                text_len,
    gpointer             user_data,
    GError             **error)
  /* Note that "text" is not a regular C string: it is
   * not null-terminated. This is the reason for the
   * unusual %*s format below.
  if (current_animal_noise)
    printf("I am a %*s and I go %s. Can you do it?\n",
        text_len, text, current_animal_noise);

void end_element (GMarkupParseContext *context,
    const gchar         *element_name,
    gpointer             user_data,
    GError             **error)
  if (current_animal_noise)
      g_free (current_animal_noise);
      current_animal_noise = NULL;

/* The list of what handler does what. */
static GMarkupParser parser = {

/* Code to grab the file into memory and parse it. */
int main() {
  char *text;
  gsize length;
  GMarkupParseContext *context = g_markup_parse_context_new (

  /* seriously crummy error checking */

  if (g_file_get_contents ("simple.xml", &text, &length, NULL) == FALSE) {
    printf("Couldn't load XML\n");

  if (g_markup_parse_context_parse (context, text, length, NULL) == FALSE) {
    printf("Parse failed\n");

  g_markup_parse_context_free (context);
/* EOF */

Save that as simple.c. If you have the GNOME libraries properly installed, then typing

gcc simple.c $(pkg-config glib-2.0 --cflags --libs) -o simple

will compile the program, and running it with ./simple will give you

I am a lion and I go roar. Can you do it?
I am a bunny and I go sniffle. Can you do it?
I am a cat and I go lol. Can you do it?

I think that was enough to whet your appetite, but there’s a whole lot more to know. You can read more here. If you want to see a real-life example, Metacity uses exactly this sort of arrangement for its theme files. (Later: Julien Puydt shares memories of how schema handling in gconf was written using GMarkup.) Any questions?

Photo: Day-old chick, GFDL, from here, by Fir0002, modified by Dcoetzee, Editor at Large, and tthurman.


I have had a moderately successful day. I branched metacity for 2.22. (I wish I could write more about work here; it feels silly not writing about the thing I spend most of my time doing.) I made a list of things which need dealing with now we’ve branched, and as a diversion fixed up some map SVGs for Wikipedia (and another project). Someone came around with bagels.

Fin phoned and told me the SPCA had come by and told them they’d found a cat who looked just like our cat Zarate, who ran away shortly before Kirsten came to visit; Fin and Alex and Rio went to see, but the new cat (let’s say her name is Zaratbee) didn’t respond to her name or the feeding song, despite being about the right size and shape and colour. Fin thought it was her; Alex didn’t. I will go along tomorrow and see.

It snowed a lot. I was told I gave the best hugs. I came home and it snowed a lot and Fin in her awesomeness said “Why not let’s go to Los Aztecas?” So we did and the food was even better than it usually is, and almost nobody was there because of the snow. We talked about politics, and came home. I worked on some simple breadboard electronics on the dining-room table with Rio before she went to bed; she wrote up the findings in her lab notebook, which has a picture of Strawberry Shortcake on the front. Did I mention she has dyed her hair grape-soda purple? It really suits her.

I learned, or re-learned, about the __import__ statement in Python for a project I’m doing with the Metacity Journal (more will be revealed later). I asked jdub to move my public planet feed to and I will automagically duplicate all content to LJ and blogo. I have not decided what I will do about comments. I also need to put some time into copying the stylesheets and formatting from to

Ande: I have started work on the river story. It is progressing nicely.

Things I wanted to share (because they were an interesting read):

Now I will make more tea and then go and get out of these clothes and sit in bed and fix bugs, which I can do because Alex has fixed wireless networking, so hallelujah, say I.

an update

Sharon came over and made us lasagne as a belated birthday tea for me.

I have done a good amount of hacking; it was fun and got stuff done. Yay.

Later, we went to the park and walked by the river, and Riordon and I discussed high-voltage electricity transmission.

Metacity’s translation into Welsh has not been touched in almost two years. It is a shame. If one of you Welsh speakers who reads this would like to give it a shot (there are about 500 phrases, mostly short, about 80% of them already filled in, and most of them guessed by the computer from the others and you only have to make minor adjustments), I will show you how to do so and you will have your name all over the credits. If not, I am happy to try to do the work myself, but I would like it if someone would check my work since I’m hardly confident in my own fluency.

Oh, and I learned how to say “fish and chips” in Welsh. It’s “sgod a sglod”. Makes sense.

I think this does not sound like a very exciting entry. Sorry :(