Oktober 2006

Gtk+ Theming Woes for Embedded GUIs

In the project I’m working on, we want to have a visual user experience that is guaranteed to blow you away. Eye candy and usability combined. This is about eye candy.

In theory, the Gtk+ theming capabilities are good. In practice, it sucks. I won’t go into complaining about the most underdocumented area of Gtk+, but if you want to attract commercial developers who need to rely on being productive and effective right from the start, then Gtk+ is giving you a lot of headaches.

The usage of X11 and Gtk+ as the GUI foundation for embedded devices is increasing steadily, however the Gtk+ theming possibilities are merely adressing the needs of desktop systems. Of course, I am not the first one realizing that. Nokia decided to fork Gtk+ for their Maemo UI — between you and me, one of their worst decisions as developers really hate having to compile a seperate Gtk+ version for Maemo developing. Consequently, this is a no-no for our project.

The worst thing is that Gtk+ treats widgets (instead of images) as first class entities, that means it will scale your images according to the size request of the widgets, not vice versa. Widgets are scaled according to their layout and the internal widget layout and size — which is defined through hardcoded widget code. If you don’t let images to be stretched, they might be clipped (e.g. in a checkbox) or drawn partly outside the parent widget (e.g. for an arrow).

This scaling facility is nice for desktop systems, but in embedded systems this is a nuisance, because you usually

  1. know your display size in advance and want to have every pixel match the layout given by the designer, and
  2. the display size rarely changes (only few people use their mobile phone applications to display via remote-X).

Another requirement is overlapping widgets. The Gtk+ team canon is „Gtk+ doesn’t support overlapping widgets“. Well, this is really bad. A typical use case is a dashboard kind of user interface which contains the static portions of the UI in form of a bitmap. Since you don’t want to implement all widgets on your own, but reuse the GUI toolkit logic, you need to overlay stock Gtk+ widgets on top of this fixed bitmap / layout.

Gtk+ just can’t do that. Even if you think you are smart — e.g. trying to a set a background pixmap to a GtkVBox or a GtkAlignment, hoping it will shine through the widgets you add to the container — you lose. GtkContainer derived widgets are transparent widgets by definition, they don’t have a GdkWindow and they don’t draw anything on their own. So what now? How about forking Gtk+ now? No no no no… there must be a better way…

I have found one. After three days and nights wrapping my head around Gtk+ code, I managed to write a couple of widgets which support overlapping. I have derived custom widgets from

  • GtkFixed,
  • GtkAlignment,
  • GtkVBox, and
  • GtkHBox

which not only support a background pixmap overlapped by Gtk+ widgets, but also the option to hardcode the size through the style sheet, i.e.

style "mydashboard" {
bg_pixmap[NORMAL] = "dashboard.png"
GtkFixedOverlay::size-request = { 0, 480, 0, 120 }
GtkFixedOverlay::cargo-border = { 40, 380, 10, 80 }
widget "*.mydashboard-widget" style "mydashboard"

It’s not perfect, because for some cases it still involves hardcoding inside the application, but it’s a huge step forward for dashboard-style embedded user interfaces. These classes have been created for my current client, but will be open sourced soon — together with the complete project as well.

Read more →

Back from Trolltech DevDays’06

The two days event run by Trolltech in the Hilton Park Hotel in Munich was fully loaded with

  • a sophisticated technical program,
  • interesting partner exhibits, and
  • really good food (excluding the Trolltech cookies, which only looked cute)!

Add two nice giveaways (a Trolltech branded backpack which is really usefully designed + a Trolltech shirt) and a lot of friendly Trolls and you have an event that was really worth to attend.

For me, the most impressing issues were:

  1. Qt for WinCE in 2008
  2. Advanced Item Views
  3. Thread Support in Qt
  4. Styling Qt Widgets using Style-Sheets
  5. QGraphicsView

1. Matthias Ettrich announced that Trolltech is working on Qt for Windows CE and that it’s supposed to be out in 2008. This is an important step that may have serious impact to Embedded Linux. Basically, it means we have roughly one more year left to shape our platforms. By 2008, Windows CE will be a much stronger competitor than it ever was.

2. Thanks to the new Interview framework — which is slightly based on the Model-View-Controller design pattern — a lot of new possibilities for presenting and manipulating data in QListViews arise. You are using classes derived from QAbstractItemModel to interface with your data model and you are using classes derived from QItemDelegate to do custom painting per item or derived from QAbstractItemView to control the layout or even the complete viewport. The possibilities are endless and starting by now you can (finally) resuse data models and data views seperatly — which is a great thing.

3. Qt 4.2 contains a revamped version of Multithreading support. The most useful fact is that there are per-thread event loops now. This makes signalling between threads much more easy, e.g. signals are thread-safe nowadays, because slots are no longer called from the context of the emitting thread. This is one great feature that users probably won’t recognize, but it allows for reduced latency and more simple (hence less error-prone) algorithms.

4. Customizing the Qt look previously needed deriving a custom class from QStyle which implements drawing the widgets. In Qt 4.2 Trolltech seperated the widget look description from actual code by using a description language similar to CSS which is parsed on-the-fly when widgets are drawn. This enables designers styling your application, not coders. It blows away Gtk+ RC files. Interestingly, it’s quite similar to what Enlightenment’s Edje can do — I guess both used CSS as inspiration.

5. The canvas is back! And it will blow you away. Visualizing complex data has never been so easy and powerful. I can’t wait to write the first application using QGraphicsView.

The ones of you who know me from the Opie project are probably wondering why I didn’t say anything about the GreenPhone yet. Uhm, well, … I don’t feel very excited about that. It’s good to have an „open“ (it’s still not clear whether the libraries will be open source) Qtopia platform, but it comes two years late, the „SDK“ is a joke (they really should hire someone with OpenEmbedded experience) and I’m afraid the community has moved on to X11 (that is: kdrive) and Gtk+.
I’m looking forward to be on board for the DevDays’06 and want to express my gratitude to Trolltech which made it possible for me (and a lot of other open source developers) to attend this conference – thanks!

Read more →

Back from OEDEM’06

The three days in Berlin were fun while begin efficient and productive at the same time. I guess most of it boils down to the small amount of participants. If you are less than 10 people, you can discuss informal without the need of a moderator-operated discussion protocol. This made it an event that I really enjoyed.

OEDEM'06 Participants

From left to right:

  • Richard ‚RP‘ Purdie (O-Hand)
  • Thomas Frydrych (O-Hand)
  • Marcin ‚Hrw‘ Juszkiewicz (HaeRWu)
  • Michael ‚Mickey‘ Lauer (Vanille-Media)
  • Koen Kooi
  • Florian Boor (Kernelconcepts)
  • Holger ‚Zecke‘ Freyther

Missing in the picture are Henning ‚Woglinde‘ Heinold and Rolf ‚Laibsch‘ Leggewie.OEDEM’07 is scheduled to take place in Poland early summer next year. If you want to sponsor this event, contact us.

Read more →

Installing Mandriva 2007 on a Thinkpad X60s

My recently acquired Thinkpad X60s just arrived a couple of days ago and naturally the first thing I had to do was to install my Linux-Distribution of Choice to get a nice mobile development workstation. Getting there wasn’t that easy and since there are already documentations for installing other Linux Distributions, I just thought I briefly share my findings with you.

Installation Procedure:

  1. The preinstalled operating system is Windows XP. To make room for the Linux OS, you have to shrink the Windows NTFS partition. I did that using PartitionMagic 8.0 from within Windows. I shrinked the partition to be 30G which left me with 40G for Linux.
  2. Prepare a medium with an installer. If you have a docking station with an optical drive, this is easy. I didn’t, hence I had to prepare a bootable USB drive. I created a FAT16 partition on the USB drive, dd’ed images/all.img from the Mandriva Installer DVD onto the partition and set it to active (bootable) using fdisk from a Linux machine.
  3. Boot from the Installer medium. On the Thinkpad X60s, you have to press F12 during boot to chose the boot drive. I did that and then the Mandriva installer started.
  4. If you — like me — have no docking station and no optical drive, then you need to come up with another storage source for the installation packages. I put the Mandriva Installation DVD into my Windows machine and launched the WarFTPd ftp daemon to serve it. If you have enough space on your USB drive, just copy the i586 directory over to it as well.
  5. Unfortunately the Mandriva Installation image does not recognize either the internal LAN nor the internal WLAN adapter of the Thinkpad X60s. Fortunately, I had a cheapo USB-Ethernet adapter laying around which was recognized. You won’t need this if you have enough space to put the i586 directory onto your USB hard drive.
  6. The actual installation procedure went pretty straightforward. Be sure to chose manual partitioning otherwise you’ll ruin your Windows installation. Partition your drive so that /dev/sda5 will contain your Linux root file system (I chose ext3fs), /dev/sda6 should contain the swap space. Sometimes the installer seems to stall for a couple of minutes, but don’t be worried, it will eventually continue.
  7. If you want to preserve the special ThinkPad Bootloader, then you should choose to install the Grub Bootloader into /dev/sda5, not into the MBR (Master Boot Record).
  8. After rebooting, boot into Windows again and grab the latest version of Grub4Dos. This way you can boot Linux from the Windows (special Thinkpad version) Bootloader.

Things that didn’t work out of the box:

  1. Ethernet
  2. Wireless LAN
  3. Sound
  4. SD/MMC Card Reader

Post-Installation Hints:

  1. Kernel 2.6.17 contains a bug in the e1000 driver that prevents the network card being correctly initialized when you don’t have a cable w/ a working link plugged in. This can be fixed by recompiling the kernel with a patch.
  2. The ipw3945 driver needs manually installing the firmware microcode and the ipw3945 daemon. You can get both from http://www.bughost.org/ipw3945/.
  3. Install alsaconf and go through the menu-based configuration. The X60s contains the AD1981HP as part of the Intel ICH7 chipset.
  4. It’s a RICOH card reader which needs the module sdhci a recent kernel (>= 2.6.17rc1). Open /etc/modprobe.preload and add this line. After rebooting (or manually modprobe’ing) the SD should be found as /dev/mmcblk0.

[to be continued]

Read more →