Big changes for me too (or maybe not?)

Nope, this is not yet another boring Gtk+ on Win32 blog post.

Yesterday it did 11 months since I’ve moved to Dublin and since I started working for Sun for my internship. I have to say that the whole experience has changed my life and the way I am both professionally and personally wise (for better mostly).

Move to another country away from your family and friends it’s quite hard, and actually the first few months were quite hard for me, different culture, different food, different weather. I’ve learned to take care of my friends better than I did before, I’ve learn to cook, and most importantly, I’ve learned how important the family is. Something that most times I gave for granted, somehow.

Professionally I’ve learned and I keep learning a lot, not only for the fact that I have more free time than I had back at Spain, but also because I’m working with a whole bunch of smart people.

The Spire at O’Connel Street, Dublin
from Sacred Destinations user at

So here goes the big change, or maybe not so big; I was supposed to come back to Spain the 1st of April as my internship was for one year, however, for some strange reason, Dirk wants me to stay on the team as a full time employee, not only as the open source guy but as an engineer working on our mainstream virtualization project for Sun Ray as well, most probably doing some RelEng work and fixing bugs for now.

So the plan now seems to be that I’m gonna be at Dublin for a few years at least, however, I’m gonna be at Spain from April to July to do a few exams (I still have 4 subjects left to end my bachelors degree though) and stay with my family.

I feel quite lucky for having such opportunity, and I would like to thanks alo for recommending me in the first place, without him this turn in my life wouldn’t be possible. I would also like to thanks to the whole GNOME community (specially the GNOME Hispano guys) for being such a good software development school, during this year I’ve realized how much I’ve learned since my involvement back in 2003 I now realize that I’ve wouldn’t been as valuable for Sun as I am without all the skills I learned inside such a great community.

By the way, our team is hiring developers located or willing to locate at Dublin or Hamburg, check out the two open positions and drop and send me a line with your CV to alberto dot ruiz at sun dot com.

Goodbye zlib, libjpeg, libpng, libtiff we’ll miss you all.

This is the image of the victory, thanks to dom, the pixbuf loader is done:

This is, Gtk-demo on windows, loading png, jpeg and gif data from one single loader. Notice that the pixbuf loader directory has only two loaders, one of them being xpm (not supported by GDI+).

I’ve moved the code to gnome’s subversion, you can browse or grab the latest code now:

$ svn co

It still need some love for managing metadata and make it able to store pixbuf in files.

Dom has been the hero today fixing all the remaining bits, kudos for him!

GDI+ Pixbuf Loader: The art of getting native

One of the biggest problems that I’ve run into during the work of getting a sane building/release process for Gtk+ on windows, is the fact that it has a very Unix tied dependency tree:

  • Gtk+ depends on libjpeg, libpng, libtiff, pango, cairo and Glib.
  • Glib depends on gettext.
  • libtiff depends on libjpeg
  • libjpeg and libpng depends on zlib
  • pango depends on cairo

Now, zlib and libjpeg are specially problematic to build for a Win32 target, and even more problematic if they’re built on a cross compilation environment. So we wrote a few patches to workaround the issue, but the patches are ugly and not suitable for mainstream inclusion at all. So we were kind of screwed.

Until dom and tml had a great idea: why not write a pixbuf loader using the native win32 api to load images?

GDI+ is the imaging API for Windows XP (installable on 2000 and 98/Me), its antecessor, GDI,
would only load jpeg and non transparent png (remember the IE transparency problem? blame old GDI).

Now, GDI+ has some shortcomings, the most important being that it’s not included on MinGW 32, so cross compilation is not an option at a first glance. Another one is that it’s not included on Windows 2000 or below, not a big deal since there is an installation package for 2000 and 98/Me, and Gtk 2.12 is not supporting 98 anymore.

So, what do we do? Dom enlightened me with the wonders of LoadLibrary (dlload) and the work he did with Jordi Mas on GDI+ support for AbiWord. So we can load the functions pointers with their prototypes on runtime by doing LoadLibrary("gdiplus.dll"); take that lack of linking information!!! I borrowed some code from wine (which is LGPL as well) so I could figure out the structs and the function prototypes.

Some msdn research, some help from dom and there we go:

$ git clone

It doesn’t work yet really, all the Win32 api pieces are already there (I get the information and all the ARGB pixels of the images), but for some reason the Gdk.Pixbuf I create is not properly received by the application, I’m gonna need some help from dom or other pixbuf hero to finish it.

The result so far (there is supposed to go a background)

If I get this into a good shape, doing something similar for Mac OS X wouldn’t be a big issue I guess.

If you want to help or just support the cause morally, just hang around #win32 at, where all the cross platform lovers are!

Update: I forgot Cairo and Pango dependencies, oops.

Subclassing in Vala/Gtk+

Mikael you forgot to mention one of the other ways to subclass in C (which actually involves no C coding at all), which is Vala, this would be the equivalent of your Ruby sample:

using GLib;
using Gtk;
class OpenFileDialog : FileChooserDialog {
public static string CWD = null;
construct {
set_title ("Open file");
set_action (FileChooserAction.OPEN);
add_button (STOCK_CANCEL, ResponseType.CANCEL);
add_button (STOCK_OPEN, ResponseType.OK);
set_default_response (ResponseType.OK);
response += on_response;
if (CWD != null)
set_current_folder (CWD);
private void on_response (Dialog diag, ResponseType resp) {
if (resp == ResponseType.OK)
set_current_folder (CWD);
public static void main (string[] args) {
Gtk.init(ref args);
for (int i = 0; i<2; i++) {
var ofd = new OpenFileDialog ();
if ( == ResponseType.OK)
stdout.printf("filename = " + ofd.get_filename ());

Download: subclass.vala
Compile, run and ejoy:

$ valac --pkg gtk+-2.0 subclass.vala -o subclass
$ ./subclass 

Update: pinky has figured out a bug in the code which is now fixed in the example and the file above. Thanks pinky! Good catch!

Ignorance is not happiness at all

After the moral injection and the union of the Win32 team in #win32 at, some more progress have been made already.

I finally got to successfully cross compile Gtk+ with MinGW and all its dependencies (zlib, gettext, libjpeg, libtiff…) using jhbuild. It took me a while to figure out all of the glitches, but I finally come up with a set of modulesets and patches.

It turns out that jpeg and zlib configure/makefile scripts are very tied to the expected unix behavior, and wasn’t very flexible, which make them very hard to build in a jhbuild fashion (automated and configurable). So I’ve been building them statically without noticing it, I finally found a patch for libjpeg from MinGW ports that I used, and had to hardcode the zlib Makefile to make it work.

So I’ve been wasting like a year due to the frustration on not getting this to work due to a sparse knowledge on how dynamic and static linking differences (and the lack of proper messages from autohell). Is there any good documentation to get a good picture about the different kind of linking procedures that exists? I’m still quite confused with .la, .a… and the like.

I’m now storing the modulesets and the patches in a bzr branch within the buildows project at launchpad so I can keep a better track of the changes and we have now a centralized place for the jhbuildrc and the modulesets. If you want to contribute more modulesets (GStreamer, Clutter, WebKit…)  Drop me a line!

Now, If you want to try out this, follow the instructions at the cross compiling wiki page and the brand new Win32 Gtk+ team wiki page.

You just basically has to get jhbuild, place your sample.jhbuildrc in your home directory as .jhbuildrc, and run bin/jhbuild build, you’ll get your windows binaries on ~/gtk-target/. Testers and patchers are welcome!

My personal “Hacker of the year” awards for 2007

Something that I’ve been thinking to do since Christmas is to post here a list of hackers that I personally think that have done a great work. This is a very, absolutely, subjective list in no particular order of people that have brought technologies that I’ve found interesting and exciting for the GNOME project in particular.

Johan Dahlin

For his work on Gtk+, specially GtkBuilder, I’m looking forward to see Glade unleashing all its capabilities. Thanks Johan!

Alexander Larsson

This guy has done an amazing work in very little time, killing gnome-vfs and bringing a brand new beautiful IO API for GNOME is not an easy task. Kudos for Alex!

Jurg Billeter

He has done an stunning work bringin Vala to an usable state and working on instrospection, this project is bringing a pretty promising future to binding generation as well. On the other hand I think that he’s a great maintainer, very responsive and helpful.

Richard Hult

Gtk+ natively on Mac OS X done… do I need to say anything else?

Richard Hughes

He’s bringing sanity to the packaging area on the desktop through PackageKit, he has brought the project to life in very little time, and on the other hand he had the ability to grow a pretty big and healthy community around the project while doing regular blog posts.

Mathew Allum & Co.

This one goes for the guys at OpenedHand working for Clutter as well. They’re bringing a beautifully designed API for fancy effects that it’s going to enable lots of bling on the free desktops. Go go go!

Alp Toker

Alp is getting Gtk+ and the web even closer with his work on WebKit, I cannot wait until that widget gets stable enough to see it on the mainstream projects. Go Alp, go!

Andreas Nilsson

It might not be code, but this guy is a real hacker! Bringing integrated icons and artwork with a Tango touch!

The whole GNOME community

This one goes for the community as a whole! Cheers everyone! Let’s rock even more on 2008!

Pachi is my homeboy!

Long time no blog, I’ve been pretty busy lately due to some important changes on my life, more on that on some other post.

Anyway, I would like to thank Pachi to do that call for action on the Win32 side.

The answer of the people to that call has been actually pretty productive, so far we’ve got:

  • All the Gtk+ Win32 heroes on #win32, having johan and tor actively helping on the cause is gonna be a great boost.
  • A new wikipage on l.g.o to keep track of the goals, issues, tools and people.
  • A new project, buildows, started by asabil. This is an integration between jhbuild and WiX, the opensource microsoft installer generator.

Johan is getting closer to make WiX work with mono and wine, that would allow us to setup a buildbot that would generate the installers under Linux. It seems to me that we’re pretty close to get to an easy reproduceble and automated way to get builds and .msi installers.

Please, test our tools!

So, kudos to pachi, tor, johan, asabil and the rest of Gtk+/Win32 rock stars!