Gtk+ work on windows

The last few weeks I have been working on the Gtk+ win32 port. Since the client side windows work landed in Gtk+ 2.18 the Windows port has been a bit broken, but now I finally sat down and fixed the remaining issues. So, the newly released Gtk+ 2.24.8 is now officially the best ever Gtk+ 2.x release on windows.

Then I forward ported all the work to the current Gtk 3 tree. It was mostly trivial, but one thing that changed a lot in Gtk3 is theming. The old windows theme was mostly a custom themeing engine, but in Gtk+ 3 we want to use engines less in favour of CSS. So, I had to completely redo the windows theme using CSS.

I added a few CSS extensions that access the win32 theming APIs, so you can get theme backgrounds, theme colors and theme sizes. Then the rest is just traditional CSS to bind the things together.

Here is an image of the current state:

Widget Factory on Windows

There are clearly still some issues that need fixing, but it works impressively well for just being some CSS. Check it out.

55 Responses to “Gtk+ work on windows”

  1. MiKom says:

    Is it possible that we will have official win32 runtime builds on gtk.org anytime soon?

  2. Leif Gruenwoldt says:

    Very glad to see GTK getting revived love on Windows. I’d love to have my favourite Gnome apps on working well on Windows; epiphany, rhythmbox, evince, etc. Though I wonder how many hard dependencies these apps are getting that make GTK the least of the porting concerns.

  3. alexl says:

    Dieter is working on a binary release. It will be announced any day now.

  4. z says:

    many thanks!

  5. Bertrand says:

    Thank you so much for your work !
    This is going to be a big help for our Windows port of Banshee.

  6. [...] заявлению разработчиков из всех выпусков Gtk+ 2.x версия Gtk+ 2.24.8 [...]

  7. I am now testing the GTK 2.24.8 for Windows as found here:
    http://www.gtk.org/download/win32.php

    As far as I could see the distribution on this page is missing libxml2 dependency. Additionally intl.dll is provided, but when the compiled program is started, it does not start because it requires libintl-8.dll.

    Perhaps it would be good to have an proper installers (runtime and development) similar to ones available here:
    http://sourceforge.net/userapps/mediawiki/alex-sh/index.php?title=Main_Page

    Thank you for your work.

  8. I’m glad that GTK 2.24.8 solved most of the issues I had with GTK on Windows.
    If only this one would be solved soon :-)
    https://bugzilla.gnome.org/show_bug.cgi?id=607544

  9. Luis Matos says:

    First of all, thank you for your effort working on a windows port.
    It is very important for opensource applications to be cross platform, but there is also space for gtk use in the windows environment.
    I would like to ask if there is a place where we could download binaries to test.

    Thanks.

  10. [...] заявлению разработчиков из всех выпусков Gtk+ 2.x версия Gtk+ 2.24.8 [...]

    [WORDPRESS HASHCASH] The comment’s server IP (77.120.119.154) doesn’t match the comment’s URL host IP (77.120.119.155) and so is spam.

  11. Sam Thursfield says:

    Amazing work!

  12. Kris says:

    Is it possible to theme GTK3 with CSS on Windows to make a custom look for one application? :)

  13. Stu says:

    This is very cool; one thing I’ve noticed for donkeys years but not repported is that gtk apps in windows often have white text on menus when it should be black in windows (on the highlighted item IIRC).

    Great work, can’t wait to see it in all my fave gtk apps on windows :)

  14. [...] Via | Alexander Larsson [...]

    [WORDPRESS HASHCASH] The comment’s server IP (62.149.141.144) doesn’t match the comment’s URL host IP (62.149.140.145) and so is spam.

  15. Tobias says:

    I have two questions:
    1. Why are there the old Icons and not the Tango Icons?
    2. Is it possible to change the look of the filedialogs with css?

  16. Tobias says:

    And a third question:
    Is it possible to help this the theming as a not Programmer?

  17. [...] nel blog di Alexander Larsson, ho letto un interessantissimo post riguardo il porting delle GTK+ 3 su Windows; l’argomento [...]

    [WORDPRESS HASHCASH] The comment’s server IP (72.233.13.152) doesn’t match the comment’s URL host IP (74.200.243.251) and so is spam.

  18. me says:

    Does DPI scaling work well in windows 7?

  19. [...] зaявлeнию рaзрaбoтчикoв из вceх выпуcкoв Gtk+ 2.x вeрcия Gtk+ 2.24.8 [...]

    [WORDPRESS HASHCASH] The comment’s actual post text did not contain your blog url (http://blogs.gnome.org/alexl/2011/11/25/gtk-work-on-windows) and so is spam.

  20. alexl says:

    Kris: For sure you can use CSS to create a custom app look with gtk on *any* platform.

  21. alexl says:

    Tobias:
    1: I just didn’t have any icon theme installed, you can chose whichever you want.
    2: You can do some custom tweaking of the CSS that changes the fileselector only, but you can’t change it however you want, just how its rendered.
    3: You have to know CSS, and have some level of knowledge in how Gtk+ work and the win32 theming APIs, but you don’t really need to be a programmer, no.

  22. alexl says:

    Not sure exactly what you refer to by DPI scaling, but we don’t do anything special with respect to DPI on windows.

  23. me says:

    The On/Off switches are still so VERY UNINTUITIVE. No real switch here is left-right, and I always wonder if it’s on on the left or off.
    And in particular: in order to turn it ON, I have to drag the slider ONTO OFF?

    I remember when GNOME was still about usability, and not about “oooh, pretty buttons. With drag effects!”

    [WORDPRESS HASHCASH] The poster sent us ’0 which is not a hashcash value.

  24. Yevgen Muntyan says:

    Gtk crashes on a server 2008R2 machine to which I connect using remote desktop: _gdk_pixmap_new returns NULL because ‘depth’ parameter is 16. Any idea?

    #0 _gdk_pixmap_new (drawable=0x354a010, width=48, height=48, depth=16)
    at /home/muntyan/projects/gtk-win-build/debug/source/gtk+-2.24.8/gdk/win32/g
    dkpixmap-win32.c:184
    #1 0x6c356567 in gdk_pixmap_new (drawable=0x354a010, width=48, height=48,
    depth=16)
    at /home/muntyan/projects/gtk-win-build/debug/source/gtk+-2.24.8/gdk/gdkpixm
    ap.c:249
    #2 0x6c356131 in gdk_pixbuf_render_pixmap_and_mask_for_colormap (
    pixbuf=0x354d548, colormap=0×3546040, pixmap_return=0x550d19c,
    mask_return=0x550d1a0, alpha_threshold=128)
    at /home/muntyan/projects/gtk-win-build/debug/source/gtk+-2.24.8/gdk/gdkpixb
    uf-render.c:305
    #3 0x013ebaf1 in get_pixmap_and_mask (window=0x354a220, parent_info=0×0,
    is_default_list=1, icon_list=0x5507a20, pmap_return=0x550d19c,
    mask_return=0x550d1a0)
    at /home/muntyan/projects/gtk-win-build/debug/source/gtk+-2.24.8/gtk/gtkwind
    ow.c:3186
    #4 0x013ebefb in gtk_window_realize_icon (window=0x35e0020)
    at /home/muntyan/projects/gtk-win-build/debug/source/gtk+-2.24.8/gtk/gtkwind
    ow.c:3322
    #5 0x013ee29d in gtk_window_realize (widget=0x35e0020)
    at /home/muntyan/projects/gtk-win-build/debug/source/gtk+-2.24.8/gtk/gtkwind
    ow.c:4907

  25. alexl says:

    Yevgen: Can you try something like:
    --- a/gdk/win32/gdkpixmap-win32.c
    +++ b/gdk/win32/gdkpixmap-win32.c
    @@ -175,6 +175,7 @@ _gdk_pixmap_new (GdkDrawable *drawable,
    format = CAIRO_FORMAT_A8;
    break;

    + case 16:
    case 24:
    case 32:
    format = CAIRO_FORMAT_RGB24;

  26. Yevgen Muntyan says:

    Returning CAIRO_FORMAT_RGB24 for depth=16 does fix the crash. It’s not perfect, button icons are missing (no log messages about those). I am also using the same build of gtk on a windows 7 with a real display, where it works pretty well; so it seems that only remote desktop is broken. Should I open a bug? (I’d rather not.) Thanks!

  27. alexl says:

    Yevgen: The underlying issue is that cairo doesn’t support rendering to 16bit native win32 surfaces.

    I opened a bug at:
    https://bugzilla.gnome.org/show_bug.cgi?id=665013

  28. alexl says:

    Yevgen:

    If you want you could try to have gdk return a cairo_image_surface based pixmap for 16 bit. This will be kinda busted as you can’t e.g use such a pixmap with win32 calls that expect a real dibsection, like setting a cursor, but it might work well enough for pure gdk rendering.

    I don’t have remote rendering set up, so i can’t really test this stuff.

  29. me says:

    >Not sure exactly what you refer to by DPI scaling, but we don’t do anything special with respect to DPI on windows.

    I don’t know exactly myself, but if in application doesn’t react in proper wat to non standard dpi in Windows 7, then windows will just scale it by interpolation leading to blurriness.

  30. [...] Izstrādātāji apgalvo, ka Gtk+ 2.24.8 ir viskvalitatīvākais Windows atbalsts, kāds vien līdz šim bijis nodrošināts GTK ietvaros. Binārās pakotnes pieejamas gtk.org vietnē. [...]

    [WORDPRESS HASHCASH] The comment’s server IP (89.111.20.253) doesn’t match the comment’s URL host IP (89.111.20.42) and so is spam.

  31. shevy says:

    YES!!

    FINALLY CSS SUPPORT!

    CSS makes customizing really easy.

  32. [...] Izstrādātāji apgalvo, ka Gtk+ 2.24.8 ir viskvalitatīvākais Windows atbalsts, kāds vien līdz šim bijis nodrošināts GTK ietvaros. Binārās pakotnes pieejamas gtk.org vietnē. [...]

    [WORDPRESS HASHCASH] The comment’s actual post text did not contain your blog url (http://blogs.gnome.org/alexl/2011/11/25/gtk-work-on-windows) and so is spam.

  33. LRN says:

    Did you merge that into master? When?
    I’ve tried gtk+-3.3.4, after some coercing it compiled, but the apps look horrible (like, half of the things are not drawn).

  34. alexl says:

    LRN:
    There were some theme fixes after 3.3.4, but it should not be that bad before those.
    Got a screenshot?
    What Windows version did you use? (I’ve just tested win7 with the theming stuff so far).

  35. Hope to see a Windows Installer on the web-site soon. It’s about time! Looking forward to making classy GTK 3 Apps, hope it works fine with Vala though, or else I’ll have to write all the C Boiler-plate code again.

  36. LRN says:

    intermediate_hacker, AFAIU, you need working gobject-introspection to be able to use Vala, and last time i checked, gobject-introspection didn’t work well on W32.

  37. LRN says:

    Partially fixed the problem. After taking a look at http://optionexplicit.be/projects/gnome-windows/GTK+3/ , i’ve discovered that you’re using a patched version of cairo. After i’ve applied the same patches to my build, lots of problems have disappeared.

    Non-themed (or should i say “classic”?) look is still b0rked though, but i guess you’ve just never paid any attention to it.

  38. Yeah. You need the cairo fix. I’ve been trying to get them into a release, but no luck so far. As for classic theme, yeah that is just not done yet. I think we need an alternative css file for it.

  39. Hi Alex:

    Just a question: is hard to create a backend for GTK? I need to use GTK with DirectFB, but the original backend was drop in 3.0 because it was broken since GTK 2.18. Where can I find info about how to create it?

    Thanks.

  40. alexl says:

    Sergio: There isn’t a lot of information about writing such backends, because its something that happens very rarely. You need to read the code for the existing backends basically.

  41. Heromyth says:

    Thanks for your hard works.
    Here a bug I found:
    The content in Tabpage will disappear when switching between Tabpages.

    To test it:
    Run gtk-demo.exe, click [Source] tabpage, and then [Info], now the content in [Info] disappeared.

  42. Perry Werneck says:

    Cool!! Is it available for download or you´re build it directly from git?

    [WORDPRESS HASHCASH] The poster sent us ’0 which is not a hashcash value.

  43. Any chance to get GTK+ 2.24.9 build soon, not that this version has been released?

  44. estecb says:

    I found a bug, when you keep resizing the window over and over again the ram consumption keeps growing, and the application crashes once you reach 70MB or so.
    If you use the microsoft theme, the ram consumption grows much faster and the more widgets in the window the more faster it grows. Maybe it is a bug in the theme engine or gtk+ itself. Also it may be just related to ram consumption, it would be weird though.
    And I know most people wont keep resizing the window, but I found the same behavior in other escenaries.

    Thanks!

  45. estecb says:

    I must add, it seems to only happen if you have multiple tabs (notebooks) with many widgets on it (or a treeview). And with the MS-Window theme.

  46. Jochem Liem says:

    Many thanks for all your work on this!

  47. estecb says:

    Funny thing, it only happens when you set the tabs position at the bottom (notebook.set_tab_pos(gtk.POS_BOTTOM)) .