tags:

views:

24

answers:

2

Hi,

I've started working with GTK+ and Vala and am having a hard time finding documentation on creating custom buttons (totally new looking buttons). In fact now that I think about it, every GTK+ application has that distinct look that gives away that it's a GTK+ app. Is it difficult to create a totally new look for my application if I decide to use GTK+?

Thanks,

Sam

A: 

You can use the GTK2_RC_FILES environment variable to assign a special theme to (only) your application.

For example, you can create a batch starter (Windows) like so:

set GTK2_RC_FILES=%GTK_HOME%\share\themes\slickness-black\gtk-2.0\gtkrc
launch.exe

Or in Linux (haven't tried that one):

env GTK2_RC_FILES=/usr/share/themes/slickness-black/gtk-2.0/gtkrc ./launch

Hint: Don't trust in GTK_HOME to be set, rather use the absolute path of the GTK+ installation. If you install a special theme with your application, it might be possible to use a relative path (relative to the installation path of your app). Then you should make sure that the theme is supported by one of the most common theme engines because usually not all of them are installed (especially on Windows, where GTK installers are a mess).

AndiDog
A: 

It's made difficult on purpose, because "that distinct GTK look" is the whole point. GTK applications generally place a lot of value on usability, accessibility, and user experience. You, the application programmer, should concentrate on the content of your application, and let the user choose a theme they like. If you make custom buttons, then they might be too narrow to fit the translated labels for a user using your application in another language. Or maybe your custom buttons look really horrible on someone's preferred window background color.

ptomato