17 July 2010

Pimp your GTK application

Fact: Visually ugly application will get poor acceptance in Windows world (even with blessed functionality)

PyGTK/GTK applications in windows are commonly distributed with its own version of GTK runtime. Why? cause Windows' user hate bloated dependencies, even when official GTK runtime available for download it's still a bad excuse there even more than one source, the one at sourceforge and other one at gnome's ftp which add more confusion. Eventually every developer start abandoning shared GTK runtime (those that installed in Programs Files\Common Files\GTK or Program Files\GTK). In short, there is no strict convention to follow since GTK ported on Windows.

This situation should bring good chance for developer to pimp their apps indepedently since there is a gtkrc for each apps. The de facto theme is MS-Windows which took windows' native theme. But there is much more! visit http://gnome-look.org/ for user contributed theme or http://art.gnome.org/themes/ for official distribution, some major linux distros also often design their own theme too. If you want to make your own theme visit http://live.gnome.org/GnomeArt/Tutorials/GtkThemes

There are five kind of themes: Controls, Window Borders, Icons, Splash Screens and Login Window actually there is more: Cursors, Sounds, etc (like in Windows). But among them only Controls and Icons that can be used effectively, you can't use window borders since GTK didn't hijack toplevel window. Controls or I would call as GTK's theme engine is the commonly available for windows platform. Remember! after GTK 2.16 MS-Windows theme is broken.

What used to be a global setting for GTK-based application has become per apps setting (etc\gtk-2.0\gtkrc) and there is per user setting file (%USERPROFILE%\.gtkrc-2.0) that if exist will override the previous one by default. Finally there is gtkrc file in each GTK theme (share\theme\[theme-name]\gtk-2.0\gtkrc) which called by any of previous two file, this file defined all about the theme itself.

How to pimp?
First, please refer to GTK's API documentation under 'GTKSettings' properties for complete info.

OK have you download the themes? Now there a problem that you might get when extracting tarball (especially from gnome-look.org) many of them has invalid symlinks (at least for windows case). Even more you should realize whether your archive manager does handle symlinks or not at all. In my experience WinRAR is the one that does, sadly 7zip doesn't yet.

Extract the theme tarball into share\themes folder, you will get a folder which name is the one you should noted and remember. To enable the theme, edit etc\gtk-2.0\gtkrc file and set this line:

gtk-theme-name = "[theme's foldername]"

Save it and try your apps. You also can use GTK2 Theme Selector (GTK2_prefs.exe) application to get a preview on how its looks.

Icon theme, this might has little impact for your apps but still  usable anyway. Extract icons tarball into share\icons folder, there you will also get a folder and note its foldername. To enable icons theme globally thus override built-in stock icons (if available) you need to define this line in etc\gtk-2.0\gtkrc file and put it before gtk-theme-name statement. a.k.a:

gtk-icon-theme-name = "[icon's foldername]"
gtk-icon-sizes = "gtk-dialog=24,24:gtk-button=16,16"
gtk-theme-name = "[theme's foldername]"

Save it and try.

There is a case when you found a match between one GTK theme and another icon theme. In this case you can define 'gtk-icon-theme-name' in 'share\theme\[theme-name]\gtk-2.0\gtkrc' file to make it per theme icon setting.

The Gimp under GTK Leopard theme and MacUltimate_Leopard icon theme

No comments:

Post a Comment