✈ Prague, ♥ Python
My goal was to get GNOME DVB Daemon’s GUI ported to PyGI and GTK+3. I’m glad to say that I could reach that goal, getting closer to GNOME 3 readiness. Porting wasn’t easy, because it basically requires to do two ports at once, to PyGI and to GTK+3. The good news is that during this process pygi-convert.sh got better, which should make other people’s lives a little bit easier. Needless to say, a lot of bugs got fixed as well.
Here are some tips for those who want to port their applications:
- Use JHBuild to setup an environment with GTK+3 and pygobject.
- Run pygi-convert.sh.
- Read the GTK+ 2.x to GTK+ 3 migration guide.
- Most callbacks now require an additional parameter for user_data
- Unfortunately pygi-convert.sh does just simple replacements and doesn’t know anything about types. This especially becomes a problem for Gtk.Box.pack_start and Gtk.CellLayout.pack_start, where the former takes 4 arguments and the latter 2 arguments. The script assumes pack_start belongs to Gtk.Box, therefore you have to remove the last two arguments for Gtk.CellLayout’s pack_start manually.
- Column types of Gtk.ListStore and Gtk.TreeStore are now stricter, e.g. you can’t add a
longsuch as dbus.UInt32 to a column of type
int. In addition, if you previously had a column of type gobject.TYPE_PYOBJECT but your object is a sub-class of gobject.GObject you have to change the column type to gobject.GObject. What makes it difficult is that you won’t get an exception if the type is wrong, just a critical warning. Try commenting lines out to find the source of an error.
- If you use Gtk.ComboBox with your own model, make sure that you call set_entry_text_column.
- pygi-convert.sh adds a call to gobject.GObject.__init__ in every constructor of a GTK widget sub-class. But in the case of Gtk.Dialog you most likely want to call Gtk.Dialog.__init__, because it accepts keyword arguments as in PyGTK. This might apply to other widgets, where the default constructor has been overridden, too.
- Get rid of Gtk.Alignment and use “halign”, “valign” and “margin” properties on the child widget instead.
- Porting an application takes a lot of trial and error, especially for ListStore and TreeStore. Start by commenting out non-essential parts to avoid getting overwhelmed by errors.
If you are interested in the ported code of GNOME DVB Daemon, it currently lives in a separate branch.
In summary, the hackfest was a great opportunity to port a mid-sized application in a rather short period of time and not forgetting meating my fellow hackers in person and enjoying the Czech cuisine. Which brings me to my next point: I want to thank J5 and Tomeu for organizing the hackfest, the GNOME Foundation for sponsoring my stay in Prague and last but not least Collabora for keeping us hydrated and a tremendously delicious duck.