Artikel getaggt mit jockey

GTK 3.0/GIR application porting: Successes and problems

GNOME 3.0 and Ubuntu Natty are currently undergoing a major architectural shift from GTK 2.0 to 3.0. Part of this is that the previous set of manually maintained language bindings, such as PyGTK, are being deprecated in favor of GObject Introspection, a really cool technology!

For us this means that we have to port all our PyGTK applications from PyGTK 2 to gobject-introspection and GTK 3.0 at the same time. I started with that for my own projects (Apport and Jockey) a few days ago, and along the way encountered a number of problems. They are being fixed (particular thanks to the quick responsiveness of John Palmieri!), so I guess after a few of those iterations, porting should actually become straight forward and solid.

So now I’m proud to announce Apport 1.16 which is now fully working with GTK 3.0 and pygobject-introspection. I just uploaded it to Ubuntu Natty, where it can get some wider testing. I also have a pygi/GTK3.0 branch for Jockey, which is also mostly working now, but it’s blocked on the availability of a GIR for AppIndicator. Once that lands, I’ll release and upload the Jockey as well.

For other people working on porting, these are the bugs and problems I’ve encountered:

  • [pygobject] GtkMessageDialog constructors did not work at all. This was fixed in pygobject 2.27, so it works fine in Natty, but there is little to no chance of making these work in Ubuntu 10.10.
  • [pygobject] Gtk.init_check() crashes (upstream bug). It’s not strictly necessary, though, just avoids crashes (and crash reports) when calling it without a $DISPLAY. I’ll put that back once that gets fixed.
  • [pygobject] You can’t pass unicode objects as method arguments or property values (upstream bug). Method arguments were recently fixed in upstream git head, and I backported it to the Natty package, so these work now. Property values are still outstanding. The workaround for both is to convert unicode values to bytes with .encode('UTF-8') everywhere.
  • [pygobject] is a great help which automates most of the mechanical rewriting work and thus gets you 90% of the porting done automatically. It’s currently missing MessageDialog constants, and is a bit inconvenient to call. I sent two patches upstream (upstream bug) which improve this.
  • [GIR availability] libnotify did not build a GIR yet (upstream bug). This was fixed in upstream git head with some contributions of mine, and I uploaded it to Natty. This works quite well now, although add_action() crashes on passing the callback. This is still to be investigated.
  • [GIR availability] There is no Application Indicator GIR, as already mentioned. Our DX team and Ken VanDine are working on this, so this should get fixed soon.
  • [GTK] Many dialogs now scale in a very ugly manner: Instead of resizing the contents, the dialog just grows huge outer padding. This is due to a change of the default “fill” property, and apparently is not fully understood yet (upstream bug). As a workaround I explicitly added the fill property to the top-level GTKBox in my GTKBuilder .ui files. (Note that this happens in C as well, it’s not a GI specific bug.)
  • [GTK] Building GtkRadioButton groups is currently a bit inconvenient and requires special-casing for the first group member, due to some missing annotations. I sent a patch upstream which fixes that (upstream bug).
  • [GTK] After initial porting, a lot of my dialogs got way too narrow with wrapped labels and text, because GTK 3 changed the behaviour and handling of widget and window sizes. This is intended, not a bug, but it does require some adaptions in the GtkBuilder files and also in the code. The GTK 2 → 3 migration guide has a section about it.

Despite those, I’m impressed how well gobject-introspection already works. It was relatively painless for me to generate a GIR from a libnotify (thanks to the annotations already being mostly correct for building the documentation) and use it from Python. In another couple of months this will be rock solid, and porting our bigger pygtk projects like ubiquity and software-center will hopefully become feasible.

Tags: , , , , , , , , , ,

New Jockey 0.5 Beta 1 release

I just released the first beta release of Jockey 0.5, which fixes a ton of bugs compared to the first Alpha from two weeks ago. Compared to 0.4, it grew quite a lot of new features:

  • Split program into a privileged system D-BUS backend (access controlled by PolicyKit), and unprivileged frontend. This provides a cleaner design, gets rid of ugly distribution specific hacks and makes the program more portable.
  • Add support for detecting printers. Add Driver DB implementation for database lookup. Supports package systems “apt”, “urpmi”, and “yum” right now.
  • New Driver DBs can now added dynamically at run time through a D-BUS call (such as adding an XMLRPC compatible DB on a new server).
  • Upstream OSLib now uses PackageKit’s “pkcon” for query operations, so that distributions which support packagekit do not need to implement their custom functions for it. (Package installation/removal does not use packagekit yet, due to a bug in dbus-glib, but it is planned).
  • Provide a session D-BUS interface so that applications like system-config-printer can call Jockey through an abstract interface for looking for a driver for a particular device. This will search for a driver in all databases, ask the user for confirmation, and install it.
  • Add support for “recommended” driver versions, in case several different versions of a driver are available (which is e. g. the case with the proprietary NVidia driver, or lots of drivers from
  • GTK and KDE user interface got some usability and workflow improvements. They also show the license and support status now:

  • KDE user interface got ported to PyKDE 4:

    • As of today, 0.5 beta 1 was uploaded to Ubuntu Intrepid, too.

      Tags: ,

Python code coverage

Today I was playing with python-coverage, which seems to be the tool of choice for code coverage measurement in Python. Since I am constantly hacking on Jockey’s test suite, I want to strive for perfection and cover everything, so it does sound like something worthwhile.

First I tried to use it like documented:

python /usr/share/python-support/python-coverage/ -x tests/run

which just caused the tests not to run at all, for no immediately obvious reason (it worked fine with real Python modules in apport). However, it gets much nicer once you stop trying to wrap it around the command line call and start to integrate it into the test suite code itself:

import coverage
coverage.exclude('raise NotImplementedError')

[… run all the tests … ]


(which is more or less what I committed).

This will run all the tests, and give me a report about how much code they covered, plus a list of code lines which weren’t touched. For example:

Name                 Stmts   Exec  Cover   Missing
jockey/handlers        248    242    97%   402-405, 420-421, 514

Also, the exclude() interface is much more flexible than putting #pragmas all over the place (which do not seem to really work anyway unfortunately).

Now, off to fixing everything to get 100%. I was surprised how many little bugs I found and fixed while completing the tests. Test suites FTW!!

Tags: , ,

Getting ready for Austin

I’m really looking forward to go to Austin next Saturday, for my first LinuxFoundation collaboration summit. I’m particularly interested in bringing forward the work of the Driver Backport workgroup, where my focus is on delivering drivers to the user.

Tags: ,