Re: Getting native colors in GTK/GDK?



On Tue, Sep 21, 2010 at 10:58:09PM +1000, Matthew Allen wrote:
So I want to match my GTK app's custom widgets to the current theme in
both Linux and Windows.

The current theme of what?

If you say that the current theme is the current Gtk+ theme then you are
done on *both* Linux and MS Windows.  If you want to match the current
theme of something else (Qt, Win32, ...) the best solution is a
specialised theme engine that attempts to mimic the theme of that
something else.  Some such engines have been written, or attempted
(GTK-Wimp, GTK-Qt theme engine, ...) and according to my experience they
invariably end up showing white text on slightly grey background or
othwerise fail to display things propertly due to some mismatch of
concepts in the different UI toolkits.

I grepped the source code and there is no mention of GetSysColor, and
certainly GTK ignores the current window colors on win32 (at least for
me). It just uses a default grey for window backgrounds etc. I tested
it using a GTK "hello world" build.

The default theme engine, that is included in Gtk+, uses, of course, the
Gtk+ theme.

Interestingly, if I grep the Gtk+ source tree I also find the Wimp theme
engine in modules/engines/ms-windows which uses GetSysColor rather a lot.
So I'm not sure what you grepped...

On Linux is there a way to make GTK read the current theme's colors in
and access them?

Please define what you mean by the current theme on Linux if you don't
mean the current Gtk+ theme.  In any case, the GtkStyle API is the way
to read the current theme's colors.

Regards,

Yeti




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]