Your mountains so lofty

There has been quite a bit of discussion on the GNOME wiki about how CSS themes could be improved. I would very much like your feedback too.  (The section numbers are taken from the Cowbell documentation.)

Also, I am not sure whether to add optional CSS theming support into standard Metacity and then split it out into libcowbell so it can be easily used by other WMs, or to do the libcowbell split first. It’s probably simpler the second way, but the first brings more immediate and obvious results.

I wrote a poem the other day:

April in Paris

The sea lies solid under ice,
The blizzard seldom stops;
The glögi’s running freely
In friendly coffee-shops;
The trams still run and life goes on
And still I can’t remember
Why no-one ever calls a song
“Helsinki in November”.

(It’s actually far more like this in December, so maybe I should make that the month; but then you’d all know that I was employing poetic licence. February even more, but then it wouldn’t rhyme.)

I went to St Nicholas’s yesterday, where everyone was very friendly as usual, and they held a minute’s silence for Remembrance Sunday. It seems that a lot of people are posting “what my grandfather did in the war” stories, so here are the exploits of my own grandfather, Bob Thurman.

I have expanded my old triolets blog into a site called triolets.org. Here’s another I recently wrote for Fin:
To sleep next to you
when the weather is cold
is trusted and true.
To sleep next to you
is decades from new
yet it never grows old
to sleep next to you
when the weather is cold.

On the plane over here, and occasionally in the evenings, I played around with automatic translation into Shavian. We’ve had some problems using Launchpad for translation, so I experimented with doing things upstream the old-fashioned way. Though the translation is automatic, it needs to be hand-checked; otherwise, things like XML elements get translated. But it’s a quick and simple thing to do, and I’ve checked quite a few of them already. I know some of the people reading this are interested in Shavian, so if you want to join in, please do. Once we get GNOME in Shavian, we will of course automatically have GNOME in Deseret, Unifon and Tengwar. I imagine having everything marked up in a phonemic alphabet might actually be useful for screen readers, too.

CSS on window borders experimental layout language

cowbellI’m happy to announce the first experimental version of Metacity with support for CSS window borders (“Cowbell”). This work was largely supported by Collabora Ltd.

You can:

This diagram should explain everything, perhaps.

I would especially like to hear from:

  • theme artists, to let me know whether it’s adequately powerful;
  • anyone else interested in hacking on this with me;
  • the GTK client-side decoration people, so that we can harmonise the way we represent things;
  • people who know a lot about CSS and can offer insights into the suitability of the way we represent things;
  • people who know a lot about the Dublin Core and can offer insights into whether our metadata system uses it appropriately;
  • maintainers of other window managers (especially Mutter), so we can talk about including CSS support in other window managers;
  • everyone else, to suggest which of the directions for future development are most interesting.

I think it may perhaps be helpful to set up a Cowbell mailing list, so that we can compare notes on implementations. For example, I haven’t written down anywhere how to place an image to the right of the title, which is commonly needed (you use border-image).

Photo © Craft*ology, cc-by-nc.

Wednesday in brief

Cowbell, Shavian and a sonnet

I haven’t posted for a while.  Here are four things:

  1. Collabora have been supporting the CSS-on-window-borders project recently by letting me work on it during work hours.  Here is a status update.
  2. Recent updates to shavian.org.uk include a gentle Shavian tutorial and translations of all the recent XKCDs into Shavian.
  3. Many years ago, I wrote a sonnet for use on a server’s custom 404 page:

    So many years have passed since first you sought
    the lands beyond the edges of the sky,
    so many moons reflected in your eye,
    (familiar newness, fear of leaving port),
    since first you sought, and failed, and learned to fall,
    (first hope, then cynicism, silent dread,
    the countless stars, still counting overhead
    the seconds to your final voyage of all…)
    and last, in glory gold and red around
    your greatest search, your final quest to know!
    yet… ashes drift, the embers cease to glow,
    and darkened life in frozen death is drowned;
    and ashes on the swell are seen no more.
    The silence surges. Error 404.

    It’s been spreading itself around, mostly without my permission, so I’m releasing it under a Creative Commons licence.  Fly free, little sonnet!  Please feel free to copy it onto your own sites, and if you would, let me know you’ve done so.

  4. I need to write more of the Maemo tutorials.  They will be coming soon.  Sorry; things have been busy.

Ubuntu en@Shaw

There has been a small surge of interest in translating (or transliterating) Ubuntu into the Shavian alphabet, possibly by means of the automated transliterator I mentioned a few weeks ago.

A small team has formed; if anyone else would like to join, they will be most welcome.  I’m a bit busy to do a huge amount of the work, but I am providing support and some of my existing transliteration resources.  Also, wiki pages are being worked on.  And discussion, most of it in the alphabet, is continuing on #ubuntu-l10n-en-shaw on freenode. See you there, perhaps.

If this works out, it will be simple to produce Deseret and Tengwar transliterations of Ubuntu as well.  Is anyone interested in those?

In unrelated news, the book I mentioned in my last post now has its own website, where you can read some of the story for yourself.

(Logo mashup by permission.)

Dragons and hawks

A few things which have happened recently:

Writing apps for the N900, part 4– the power of DBus

There is a contents page for all these posts.

Matters arising from last time. Several people have been replying to these posts as if I was the embodiment of the Maemo team. Although I worked on some really interesting parts of the desktop as part of a team from Collabora, I didn’t have anything to do with the package format or anything like that, and I’m writing these posts as an individual (and I welcome corrections). If you want to ask about the rationale behind anything here, there might be people who would know more at talk.maemo.org.

It’s a grand life on the buses. One of the many wonderful things to happen to the free desktop in recent years has been the invention of DBus as the glue to stick it all together; it’s gone a long way towards making Unix not suck.  Maemo sticks together with DBus just as much as GNOME or KDE do, which means we can interact with system services fairly painlessly.  And if we don’t know how to do something, we can always run dbus-monitor, use some other program to do what we wanted to do, and see how it managed.  Then we know what to google for when we’re looking for the official documentation.

Sharing is good. So today we’re going to be adding a “share” button to the app, so that we can tell our friends when we find an interesting link on reddit, and we’re going to be doing it using only a DBus client. Adding the entry to the menu is pretty trivial:

Selector with the 'share' item added

Now, let’s consider how we might want to share things with people:

  • Microblogging (twitter, identi.ca…): yes, definitely. You can very simply post a message to an account on one of these systems using DBus services provided by a library called microfeed. We’ll add an optional dependency on that library, and assume that people who are using it will already have set it up (using Mauku or something similar).
  • Email: certainly. We can interact with the email subsystem using DBus services provided by modest.
  • IM: yes, but… We could do this by putting up a dialogue from the address book, waiting for them to choose a contact, and then sending the message using Telepathy. But that’s not what we want; what we want is to start a conversation: we want to put up the IM window with the link as a sent message and allow the recipient to respond. I don’t know a good way of doing that, but maybe you do.
  • “Sharing services” usually means file hosting services like share.ovi.com, and isn’t really the sort of thing that concerns us here– even if the link’s to an image, you probably don’t want to upload a second copy of the image to your Ovi account.
  • Bluetooth: probably overkill (do people really send URLs over bluetooth? Apparently they do, actually, so maybe we’ll add that later.)

But let’s stick with microblogging and email for now. I’ve created a rather rough version of this idea as a separate file, sharing.c, in case it could be separately useful to someone else. This brings us up to raeddit-06 (diff to raeddit-05, git cloneable, and available from maemo-extras). When the user taps “Share”, this part of the program will put up another selector listing “Email” and as many microblogging services as it can find:

Sharing selector

Let’s say we choose Twitter; then the message gets posted, and we can go and check it in Mauku or the web browser:

Successful tweet

Behold the power of DBus!

Next time we’ll be adding the ability to view images in-process rather than launching the web browser, and we’ll be learning about a rather wonderful innovation called “stackable windows”.

Writing apps for the N900, part 3 — touch selectors

There is a contents page for all these posts.

Matters arising from last time: There’s been some very helpful feedback:

  • Colin Watson pointed out that debhelper 7 makes building debian/rules files far, far simpler. But Jonny Lamb told us that Maemo doesn’t ship with debhelper 7.
  • A Nokian emailed me to point out that in Maemo 5, application icons should be 48×48, and that 26×26 is from Maemo 4. (26×26 will still work, though, as we saw.)
  • Several people pointed out that the “B” in “XB-Maemo-Icon-26stands for “binary”.
  • And someone on Reddit said that “raeddit” is not a particularly wonderful name. This is true, and I’m open to better suggestions. I didn’t want to call it “reddit” without asking the reddit admins!

Today we’re going to introduce another new widget which is specific to Maemo.  The program currently opens the target site when you click a link. Last time, we promised to make it put up a menu of possibilities, instead:

Selectors. This is called a HildonTouchSelector, and it pops up (so to speak) all over the place. It can live inside any window, but it also has its own special kind of dialogue called a HildonPickerDialog.  It’s very like a combo box, but much easier to use with your fingers.

You see that the program behind the selector is blurred out: that’s to show that it’s not available. If you were to tap the blurred area, the selector would close without making any choices, and you would return to the rest of the program. You can also see that the switcher button at top left is not blurred: that’s because the selector is only modal, not system-modal. You can’t interact further with this program until you deal with the selector, but you’re free to switch to another program or start a new one.

What do we actually need? Now, before we dive into coding, let’s think about what we need from any representation of one of the lines in the menus.

  • We will need to ask it for the text to appear in the menu.
  • And it should be able to decline to appear in the menu.  For example, “vote up” should only appear if you’re logged in.
  • We will need to ask it to deploy, if it’s chosen.

How could we best implement that?

  • The fairly elegant way would be a set of singleton classes all implementing a common interface.
  • The very elegant way would be a set of DBus services.  That way, third parties could come along and add new menu options.
  • And perhaps we’ll do it the very elegant way later.  But this is a quick and simple tutorial, so…

We’ll use a set of callbacks.

  • Each callback takes a representation of the post, and a boolean– true if we’re preparing, false if we’re deploying– and returns a char*.
  • If we’re preparing, the char* is the name that will appear in the menu, and should be freed by the caller.
  • But if we’re preparing, the callback may also return NULL, to decline to appear in the menu.
  • If we’re deploying, the callback should always return NULL.
  • We promise not to ask a callback to deploy if it returned NULL in the preparation stage.

A small amount of extra work brings us to raeddit-05 (diff to raeddit-04, git cloneable, and available from maemo-extras).  This contains two callbacks: one to visit the actual site, and one to visit the comments page on reddit.  It looks like this:

Selector with two entries

It’s already much more useful this way, but it’s looking a bit bare with only two entries.  Clearly we can’t put in “vote up” or “vote down” until we allow the user to log in. We could easily put in the ability to buy a shirt, but there seem more important things to do first.

For example, every good mobile application needs a “share” button.  So next time we’ll be looking at how to add an entry which lets us IM or email the link to our friends, or post the link to twitter or identi.ca.

Writing apps for the N900, part 2 — packaging

Here’s a list of all these posts, which I’ll keep updated as I add new ones.

Matters arising from last time. A number of people asked, in the comments here and on Y Combinator, whether the change to using Qt instead of GTK in Maemo 6 will mean that Maemo 5 apps will need to be rewritten. I think it’s understandable that the switch will make people ask this question, but I don’t foresee any problems. If you want to write Qt applications, you can write them now under Maemo 5 and they’ll run; if you write GTK applications now, they will still run under Maemo 6 when it comes out. The GTK libraries won’t stop shipping with Maemo just because Qt becomes the primary toolkit.

Work behind the scenes. Today we’re talking about packaging. The version of raeddit we wrote last time downloads all the data from reddit and then puts up a window. If you’re on a slow connection, this could take several seconds. The Maemo guidelines say programs should put up a window as soon as possible, and indeed if they don’t put one up within a fairly long amount of time, the desktop assumes they’ve stalled and puts up a message to tell the user there was a problem.

So I’ve modified raeddit to put up the window immediately it launches, and to load the data in a separate thread. I was simply going to put up one of those whirly “please wait” symbols in the titlebar, but my ten-year-old user interface consultant told me that percentage-loaded bars are much more helpful. So I made the change to version 04 (diff to version 03), but since it has little to do with writing Maemo apps in particular, I’m not going to go into great detail about it. This also involved a slight change to the reddit client library, so that it could call a callback every so often to update the progress bar. The new version is backward-compatible with the old.

Where to find the files. The files we’re going to talk about are at the link; if you’d like a local copy you can get one with

git clone http://www.gnome.org/~tthurman/pics/maemo/raeddit-04/.git

So, packaging. Packaging under Maemo isn’t much different from packaging under Debian or Ubuntu. I said last time that I wasn’t going to replicate the contents of existing tutorials, and there are plenty of good packaging tutorials out there. But I’ll bend the rule a little in order to tell you what I changed to turn this into a packaged program.

The Makefile. Last time we were compiling by hand, but now we need the package to be capable of building itself. We could use autotools, but we’re trying to keep things really simple. So here’s a simple Makefile that knows how to compile and install the program.

But what do we need to install?

  • The compiled binary itself, into /usr/bin.
  • A desktop file, into /usr/share/applications. This tells the desktop where to find the program, how to launch it, and what the icon is. The moment you drop the file into that directory, through installing the package or otherwise, the desktop will pick it up and add it to the menus. The file is pretty straightforward, but if you want the full details you can read the spec.
  • The reddit alien An icon for the desktop file to refer to. We’ll use the obvious candidate– the reddit alien– and hope the reddit admins don’t mind us borrowing their logo to refer to their site.

The debian/ directory. That’s all very well, but we also need some instructions about how the package should be put together.  These live in the debian/ directory. There are only three you really need to concern yourself with:

  • debian/rules is another Makefile to explain how to package the program. (Now you understand the in-joke with that shirt). I’ve been using the same debian/rules with minor ad hoc tweaks for a while now; you can probably adapt it.
  • debian/changelog needs to say, at the very least, the date, your name, “initial release”, and that this is (say) version 0.01.
  • debian/control is mostly self-explanatory, but there’s one thing you need to know…

Adding an icon to debian/control. If we added the basic package to App Manager, it would appear like this:

Package in the Maemo repository

The blue square means that it doesn’t have an icon. App Manager isn’t going to download and unpack every package just to see whether we’ve included an icon, so we need to include one in debian/control, which will make its way into the package index. However, there’s not as much room, so it needs to be just 26×26. We’ll just show the alien’s head: All we have to do to get it into debian/control is to uuencode it (producing this result) and then put it into debian/control, indented by one space, under the heading XB-Maemo-Icon-26:. (No, I don’t know what the B is for either.)

This makes our entry in App Manager much prettier:
Package in the Maemo repository

Building it. So now all we need to do is to run dpkg-buildpackage on our package, copy it to the phone, and install it. Rather than show how to do that here, I’ll just show you a log of me doing it, since it’s quite a mechanical process.

Firing it up. And now we can load the program from the ordinary menu and run it. I would show you screenshots, but I think screencasts are far more fun. So here’s a quick video on YouTube of raeddit in use. I’ve added the current version of raeddit, such as it is, to maemo-extras, so that you can actually install it with App Manager if you feel so inclined.

One quick plug: if you’d like to see a longer screencast of a more advanced Maemo 5 program, I’m working on a location-aware system to find nearby belltowers hung for English full-circle change ringing. It uses the database from Dove’s Guide. You can see a screencast of the work in progress here.

Next time, when the user clicks a post, instead of going straight to the linked site we’ll figure out how to put up one of these menus:

Example of a Hildon selector

After that, who knows? I added a long list of possibilities to the previous post, so feel free to advocate as to which you’d like to see fixed first.