|
LinuxGtkThemeIntegration
Documentation for GTK+ theme authors
linux IntroductionThe GTK+ port of Chromium has a mode where we try to match the user's GTK theme (which can be enabled under Wrench -> Options -> Personal Stuff -> Set to GTK+ theme). The heuristics often don't pick good colors due to a lack of information in the GTK themes. Starting in Chrome 9, we're providing a new way for theme authors to control our GTK+ theming mode. I am not sure of the earliest build these showed up in, but I know 9.0.597 works. Describing the previous heuristicsThe frame heuristics were simple. Query the bg[SELECTED] and bg[INSENSITIVE] colors on the MetaFrames class and darken them slightly. This usually worked OK until the rise of themes that try to make a unified titlebar/menubar look. At roughly that time, it seems that people stopped specifying color information for the MetaFrames class and this has lead to the very orange chrome frame on Maverick. MetaFrames is (was?) a class that was used to communicate frame color data to the window manager around the Hardy days. (It's still defined in most of XFCE's themes). In chrome's implementation, MetaFrames derives from GtkWindow. If you are happy with the defaults that chrome has picked, no action is necessary on the part of the theme author. Introducing ChromeGtkFrameFor cases where you want control of the colors chrome uses, Chrome gives you a number of style properties for injecting colors and other information about how to draw the frame. For example, here's the proposed modifications to Ubuntu's Ambiance: style "chrome-gtk-frame"
{
ChromeGtkFrame::frame-color = @fg_color
ChromeGtkFrame::inactive-frame-color = lighter(@fg_color)
ChromeGtkFrame::frame-gradient-size = 16
ChromeGtkFrame::frame-gradient-color = "#5c5b56"
ChromeGtkFrame::scrollbar-trough-color = @bg_color
ChromeGtkFrame::scrollbar-slider-prelight-color = "#F8F6F2"
ChromeGtkFrame::scrollbar-slider-normal-color = "#E7E0D3"
}
class "ChromeGtkFrame" style "chrome-gtk-frame"Frame color propertiesThese are the frame's main solid color.
Frame gradient propertiesChrome's frame (along with many normal window manager themes) have a slight gradient at the top, before filling the rest of the frame background image with a solid color. For example, the top frame-gradient-size pixels would be a gradient starting from frame-gradient-color at the top to frame-color at the bottom, with the rest of the frame being filled with frame-color.
Scrollbar controlBecause widget rendering is done in a separate, sandboxed process that doesn't have access to the X server or the filesystem, there's no current way to do GTK+ widget rendering. We instead pass WebKit a few colors and let it draw a default scrollbar. We have a very complex fallback where we render the widget and then average colors if this information isn't provided.
Anticipated Q&AWill you patch themes upstream?I am at the very least hoping we can get Radiance and Ambiance patches since we make very poor frame decisions on those themes, and hopefully a few others. How about control over the min/max/close buttons?I actually tried this locally. There's a sort of uncanny valley effect going on; as the frame looks more native, it's more obvious that it isn't behaving like a native frame. (Also my implementation added a startup time hit.) Why use style properties instead of (i.e.) bg[STATE]?There's no way to distinguish between colors set on different classes. Using style properties allows us to be backwards compatible and maintain the heuristics since not everyone is going to modify their themes for chromium (and the heuristics do a reasonable job). Why now?
Any details about MetaFrames and ChromeGtkFrame relationship and history?MetaFrames is a class that was used in metacity to communicate color information to the window manager. During the Hardy Heron days, we slurped up the data and used it as a key part of our heuristics. At least on my Lucid Lynx machine, none of the GNOME GTK+ themes have MetaFrames styling. (As mentioned above, several of the XFCE themes do, though.) Internally to chrome, our ChromeGtkFrame class inherits from MetaFrames (again, which inherits from GtkWindow) so any old themes that style the MetaFrames class are backwards compatible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I've added the following
style "chrome-gtk-frame" { # ChromeGtkFrame::frame-color = @fg_color ChromeGtkFrame::frame-color = "#AAFF00" ChromeGtkFrame::inactive-frame-color = lighter(@fg_color) ChromeGtkFrame::frame-gradient-size = 16 ChromeGtkFrame::frame-gradient-color = "#5c5b56" # ChromeGtkFrame::scrollbar-trough-color = @bg_color ChromeGtkFrame::scrollbar-trough-color = "#DDFF00" ChromeGtkFrame::scrollbar-slider-prelight-color = "#F8F6F2" ChromeGtkFrame::scrollbar-slider-normal-color = "#E7E0D3" } class "ChromeGtkFrame" style "chrome-gtk-frame"into my /usr/share/themes/Ambieance/gtk-2.0/gtkrc (or /usr/share/themes/Ambiance/gtk-2.0/apps/chromium.rc) but it doesn't work for me. What am I doing wrong?
I use Google Chrome 8.0.552.215 and Ubuntu 10.10
It says you need version 9, at least.
Hi, I'm running Chrome version 10.0.648.45 (dev channel) and Ubuntu 10.10 and am running into the same issue with the style changes not seeming to be applied to Chrome
What about buttons, please ? Is it possible they match the GTK theme colors ? How to proceed ? Will be thanks to a own user CSS ? Thank you for your answer !
Chromium for Windows has Aero style controls, Chromium for MacOS X has Aqua controls so why Chromium for Linux doesn't use native GTK+ controls (buttons, check box...) ?
That's because there are many different window decorators in Linux and it's impossible to implement tabs-in-window-title working everywhere, so we are using our own decorations.
I hope that people at FDO will look at this problem.
Isn't it possible to have the inside written using GTK+ directly?