Thursday 5 February 2009

Trouble with gtkrc

Creating a Metacity window decoration was pretty straightforward. I have what I want. A smooth gray window title that dims when the window looses focus. When focused, it has a gradient look imitating a round vertical curve.

Here comes the catch.

Items in the window are controled by a file ~/.themes/mytheme/gtk-2.0/gtkrc. This file controls everything drawn inside the window -- buttons, menus, scrollbars - you name it.

Here is a basic gtkrc file:

###############################################################################
# default color scheme
###############################################################################
gtk_color_scheme = "fg_color:#202020\nbg_color:#D7D7D7\nbase_color:#FFFFFF\ntext_color:#202020\nselected_bg_color:#696986\nselected_fg_color:#FFFFFF\ntooltip_bg_color:#FCF6DE\ntooltip_fg_color:#202020\n"

###############################################################################
# default style
###############################################################################
style "default"
{
##################
# Color assignment
##################

fg[NORMAL] = @fg_color # Metacity and mouseover, Most text
fg[PRELIGHT] = @fg_color # Text when mouseover
fg[ACTIVE] = @fg_color # Text when mouseclicking button, Tabs, Active window list
fg[SELECTED] = @selected_fg_color # Metacity X when window selected
fg[INSENSITIVE] = darker(@bg_color) # Insensitive Text (in menus)

bg[NORMAL] = @bg_color # Normal Background, inactive Metacity bar, buttons
bg[PRELIGHT] = @bg_color # Mouseover buttons
bg[ACTIVE] = @bg_color # Mouseclicking, Tabs, active window list
bg[SELECTED] = @selected_bg_color # Metacity Bar
bg[INSENSITIVE] = @bg_color # Insensitive buttons

base[NORMAL] = @base_color # Background, most
base[PRELIGHT] = @base_color # Mouseover menu
base[ACTIVE] = @selected_bg_color # Menu active item in inactive window
base[SELECTED] = @selected_bg_color # Menu active item in active window
base[INSENSITIVE] = @bg_color # Background, insensitive

text[NORMAL] = @text_color # Text in window
text[PRELIGHT] = @text_color # Text on Mouseover
text[ACTIVE] = @selected_fg_color # Active text in inactive window
text[SELECTED] = @selected_fg_color # Active text in active window
text[INSENSITIVE] = @bg_color # Insensitive text

xthickness = 3
ythickness = 3

}
class "GtkWidget" style "default"

style "window" = "default"
{
bg[NORMAL] = shade(0.87,@bg_color)
}
class "GtkWindow" style "window"

style "menubar" = "default"
{
GtkMenuBar :: shadow-type = GTK_SHADOW_NONE
GtkToolbar :: shadow-type = GTK_SHADOW_NONE
bg[NORMAL] = shade(0.87,@bg_color)
}
class "GtkMenuBar" style "menubar"
class "GtkToolbar" style "menubar"

style "tooltip"
{
fg[NORMAL] = @tooltip_fg_color # required in order to set the gnome default colors right
bg[NORMAL] = @tooltip_bg_color
}
widget "gtk-tooltip*" style "tooltip"
Two problems with it:

1. It does not load when selected by the Appearance System panel.
2. (and this currently worries me more) I cannot lighten the window background when the window looses its focus.

I would like to change the color of the window interior when the window is in the background. This would allow for the window to visually vanish in the background.

Any hints?

No comments: