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 thoughts on “Gtk+ work on windows”

  1. 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.

  2. 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.

  3. 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.

  4. 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 🙂

  5. 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?

    1. 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.

  6. 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.

  7. 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=0x3546040, 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=0x0,
    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

    1. 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;

  8. 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!

      1. 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.

  9. >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.

  10. 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).

    1. 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).

  11. 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.

  12. 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.

  13. 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.

  14. 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.

    1. 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.

  15. 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.

  16. 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.

  17. 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!

  18. 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.

  19. Hi! I just have a question… Where can I find information about the patch for cairo?? Like LNR, I have the same problem… but I don’t know how to fix it! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *