Audacious CSS Desktop Programming

Take a look at this video, here I show an awesome new technology for using Clutter/Gtk with Cascading Style Sheets.


Audacious Video

You can test this out for yourself with Ubuntu 12.04 (Beta) using the following:

sudo apt-get install gir1.2-gtk-3.0 gir1.2-clutter-1.0 gir1.2-gtkclutter-1.0 gir1.2-gconf-2.0
bzr branch lp:csslavie
cd csslavie
./netbook-launcher.py

Note: default clutter/cogl has a bug which prevents the background’s opacity setting, so you won’t get as cool an effect. But a fixed version of those libraries should be available eventually.

Please comment below what you think.

Hot-Swapping Languages Batman!

One of the requirements for this community greeter (login screen for community center machines) is the ability to switch languages. Normally to switch a language you would unload the greeter and relaunch it with a LANG environment variable and your new language would fall into place from gettext.

But I wanted more. First, what languages are installed on the computer? For this I used python-pybabel and gettext, these two tools working together allow me to both get all the installed languages, limit them to just those I have translations for and show the translated name for the language (see screenshot below).

I decided that what I wanted to do was to hot-swap the text in the widgets. Since I’m using gtkme extensions, I could achieve this by creating a TranslatableWindow class. It’s job is simply to go through the window container at load time and note down all the translatable strings from labels and tooltips:

class TranslatableWindow(gtkme.Window):
“””Provides functions for translating the window on the fly”””
def __init__(self, *args, **kwargs):
Window.__init__(self, *args, **kwargs)
self.labels = []
self.tips = []
self.store_translations(self.window)

def store_translations(self, widget):
“””Go through all widgets and store the translatable elements”””
for child in widget.get_children():
if isinstance(child, Gtk.Container):
self.store_translations(child)
if isinstance(child, Gtk.Label):
self.labels.append( (child, child.get_label()) )
if child.get_has_tooltip():
self.tips.append( (child, child.get_tooltip_text()) )

def translate_to(self, lang):
“””Loop through everything and translate on the fly”””
lang = TEXTS[lang]
for (child, text) in self.labels:
child.set_label(lang.gettext(text))
for (child, text) in self.tips:
child.set_tooltip_markup(lang.gettext(text))
logging.debug(“Performed translation to %s” % lang)

Once I had translatable windows, I could tell my application class to go through each window and translate it if it was translatable:

def translate_to(self, lang):
“””Translate all windows to target language”””
for window in self._loaded.values():
if isinstance(window, TranslatableWindow):
logging.debug(“I18n window %s to %s” % (window.name, lang))
window.translate_to(lang)

Obviously because I’m not modifying the environment, when I log you on I need to update your language settings. I actually only show major language varieties and only ask about minor languages at registration time or when you change your setting:

If you’re even more curious, you can check out the code here: Launchpad Code or look at the translations here.

Genetic Wallpapers Now Available to Test!

In my previous videos I showed off some scripts which modified some svg files and made the desktop background shift and move randomly and with determination towards pre-set patterns.

In this video I show you how to install the new packages for testing and how you can make your own:

View Video on Blip

Your thoughts? have you ested my new packages and do they work for you?

Ever Wondered WTF Gnome vs Ubuntu?

This post will either go one of two ways, either people will get more irritated or it will shed some light on why seemingly rational people keep on doing seemingly irrational things.

From near as best I can tell, we look like this:

Your agreement may vary, post below (politely) if you do or don’t agree with my graphic.

Why Gnome? Why.

I have a love/hate relationship with gnome. I use it, I develop for it and at the same time I dislike the way the gnome project produces functional libraires.

Take for example librsvg, an awesome library for turning svg files into pngs for display and for making thumbnails. For some unintelligent reason installing or compiling librsvg requires gtk and thus also requires avahi and hicolor-icon-theme, xrandr and libcups2. Does making a png out of an svg require us to send icons to a rotated screen connected to a networked discovered printer? No? Then why do I need all this stuff?

The problem as I see it is that librsvg should be split out more into it’s none-gtk library parts and it’s pixbuf/gdk parts. Making it a useful library to a wider audience from servers to other desktop systems. Larger audiences mean more attention and more attention means more bug fixes.

The gnome project historically I think didn’t have much of a culture of serving a wider ecosystem and saw gaps and filled those gaps with gnome-only libs. It pains me to say but as a programmer I’m disappointed by the lack of foresight even though I understand resources were always tight. A “do everything with gtk deps” culture produces inflexible libs with rare logical separation between layers and fewer opportunities to share with the wider community because of it.

I’ve always hoped that the FDO culture of sharing APIs and working towards standard consensus would help the culture along and promote a culture of making libs for everyone.

Does anyone know of any alternatives to librsvg that produce good results? imagemagik failed to meet standards as it doesn’t support most of the filter effects, but I don’t know of many others.

just my 2 cents, what are your thoughts?

Whoa! Where’s it going?

After good healthy interest in yesterday’s video I decided to post the code in a repository (GPLv3 and CC-BY-SA) and as a second act to deliver Mark Shuttleworth’s feature request which I show off in the new video:

View Video on Blip

This is particularly cool since it means desktops will converge and look the same at certain dates as well as diverge and look different at all other times. What are your thoughts?