Fix our custom styles under KDE and for people using gtk-chtheme
commit232290aad4be81cd67a309e5f28f867ad69a3fd4
authorColomban Wendling <ban@herbesfolles.org>
Fri, 15 Mar 2013 14:54:00 +0000 (15 15:54 +0100)
committerColomban Wendling <ban@herbesfolles.org>
Sat, 16 Mar 2013 15:19:20 +0000 (16 16:19 +0100)
tree7474668b79956d1f0daea7603a6c09f9f736397e
parent0cf495a6db90b068c2ec77404e863eef097fea66
Fix our custom styles under KDE and for people using gtk-chtheme

We have a custom RC file defining various styles we need, and we want
the user to be able to override them (e.g. if they want -- or need --
other colors).  Fair enough, one would simply call gtk_rc_parse() with
the appropriate filename.  However, the styling rules applies in the
order they are loaded, then if we load our styles after GTK has loaded
the user's ones we'd override them.

There are 2 solutions to fix this:
1) set our styles' priority to something with lower than "user"
   (actually "theme" priority because rules precedence are first
   calculated depending on the priority no matter of how precise the
   rules is, so we need to override the theme).
2) prepend our custom style to GTK's list while keeping priority to
   user (which is the default), so it gets loaded before real user's
   ones and so gets overridden by them.

One would normally go for 1 because it's ways simpler and requires less
code: you just have to add the priorities to your styles, which is a
matter of adding a few ":theme" in the RC file.  However, KDE being a
bitch it doesn't set the gtk-theme-name but rather directly includes
the style to use in a user gtkrc file, which makes the theme have
"user" priority, hence overriding our styles.  So, we cannot set
priorities in the RC file if we want to support running under KDE,
which pretty much leave us with no choice but to go with solution 2,
which unfortunately requires writing ugly code since GTK don't have a
gtk_rc_prepend_default_file() function.  Thank you very much KDE.

Though, as a side benefit it also makes the code work with people using
gtk-chtheme, which also found it funny to include the theme in the user
RC file.
data/geany.gtkrc
src/main.c
src/ui_utils.c