So what’s the problem?

Ubuntu 11.10 (and maybe earlier versions as well) have a default theme called “Ambiance”. This theme controls the colors of window borders and other such things. One of the things it controls is the background color of tooltips (those little things that hover over something when you mouse over it). In the Ambiance theme that background is black with a light foreground color for the text.

The problem with this is that Eclipse 3.7.1 (and maybe earlier versions) deals with colors in an odd way. Firstly control of the theme inside eclipse is controlled on a per-language or per-plugin basis (it’s a bit more complicated then this). I’m using the “Dynamic Languages Toolkit - Ruby Development Tools” Eclipse plugin for Ruby development. This plugin picks it’s own for the foreground text (black) and by default uses the system default background color (black when using the Ubuntu Unity Ambiance theme). This results in black on black text in tooltips inside Eclipse. Some interesting aspects of this :

  • The Ruby Eclipse plugin has settings supposedly allowing you to change the tooltip background color, called “Source Hover Background” from the default setting of “System Default” to a user specified color within Eclipse. The broken thing about this is the following
    • If you set a user defined Source Hover Background in Eclipse under the “Ruby”… “Editor”… “Appearance color options” preference page
    • That setting will work and effect the background color of a tooltip the first time you mouse over something
    • Once that happens, your preference is wiped back to “System Default” and all subsequent tooltips will display black on black
      • I even tried making the preference files unwritable to prevent my preference from being overwritten. This resulted in the tooltip being the correct color the first time mousing over something each time I ran Eclipse, but then it would immediately revert to black on black.
  • There is a bug on this over on the Eclipse bug site which is marked as “RESOLVED FIXED” which it clearly is not.
  • There is an faq item regarding this problem on the Eclipse wiki
  • There is a section that talks about this on the Ubuntu help page for Eclipse

After trying many of the various suggestions out there on the internet to fix this, I found one solution which worked.

The solution involves taking the “Ambiance” theme that comes with Ubuntu 11.10, copying it to your home directory, and modifying it to change the tooltip background color.

Here’s how to do it

Copy the Ambiance theme

mkdir ~/.themes
rsync -a /usr/share/Ambiance ~/.themes/Ambiance-fixed-tooltip-bg-color

Patch your copy of Ambiance

cd ~/.themes
patch -p0 <<EOF
diff -ur Ambiance-fixed-tooltip-bg-color/gtk-2.0/gtkrc /usr/share/themes/Ambiance/gtk-2.0/gtkrc
--- Ambiance-fixed-tooltip-bg-color/gtk-2.0/gtkrc	2011-12-12 16:27:36.000000000 -0800
+++ /usr/share/themes/Ambiance/gtk-2.0/gtkrc	2011-09-20 09:02:50.000000000 -0700
@@ -1,4 +1,4 @@
-gtk-color-scheme = "base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#000000\nselected_bg_color:#f07746\nselected_fg_color:#FFFFFF\ntext_color:#3C3C3C\nbg_color:#F2F1F0\ntooltip_bg_color:#e6e6fa\nlink_color:#DD4814"
+gtk-color-scheme = "base_color:#ffffff\nfg_color:#4c4c4c\ntooltip_fg_color:#ffffff\nselected_bg_color:#f07746\nselected_fg_color:#FFFFFF\ntext_color:#3C3C3C\nbg_color:#F2F1F0\ntooltip_bg_color:#000000\nlink_color:#DD4814"
 
 gtk-icon-sizes = "panel-menu=22,22:gtk-button=16,16"
 
diff -ur Ambiance-fixed-tooltip-bg-color/gtk-3.0/gtk.css /usr/share/themes/Ambiance/gtk-3.0/gtk.css
--- Ambiance-fixed-tooltip-bg-color/gtk-3.0/gtk.css	2011-12-12 16:28:40.000000000 -0800
+++ /usr/share/themes/Ambiance/gtk-3.0/gtk.css	2011-09-20 09:02:50.000000000 -0700
@@ -5,8 +5,8 @@
 @define-color text_color #3C3C3C;
 @define-color selected_bg_color #f07746;
 @define-color selected_fg_color #ffffff;
-@define-color tooltip_bg_color #e6e6fa;
-@define-color tooltip_fg_color #000000;
+@define-color tooltip_bg_color #000000;
+@define-color tooltip_fg_color #ffffff;
 
 /* misc colors used by gtk+ */
 @define-color info_fg_color rgb (181, 171, 156);
diff -ur Ambiance-fixed-tooltip-bg-color/gtk-3.0/settings.ini /usr/share/themes/Ambiance/gtk-3.0/settings.ini
--- Ambiance-fixed-tooltip-bg-color/gtk-3.0/settings.ini	2011-12-12 16:28:11.000000000 -0800
+++ /usr/share/themes/Ambiance/gtk-3.0/settings.ini	2011-09-20 09:02:50.000000000 -0700
@@ -1,3 +1,3 @@
 [Settings]
-gtk-color-scheme = "base_color:#ffffff\nbg_color:#f2f1f0\ntooltip_bg_color:#e6e6fa\nselected_bg_color:#f07746\ntext_color:#3C3C3C\nfg_color:#4c4c4c\ntooltip_fg_color:#000000\nselected_fg_color:#ffffff\nlink_color:#DD4814\nbg_color_dark:#3c3b37\nfg_color_dark:#dfdbd2"
+gtk-color-scheme = "base_color:#ffffff\nbg_color:#f2f1f0\ntooltip_bg_color:#000000\nselected_bg_color:#f07746\ntext_color:#3C3C3C\nfg_color:#4c4c4c\ntooltip_fg_color:#ffffff\nselected_fg_color:#ffffff\nlink_color:#DD4814\nbg_color_dark:#3c3b37\nfg_color_dark:#dfdbd2"
 gtk-auto-mnemonics = 1
diff -ur Ambiance-fixed-tooltip-bg-color/index.theme /usr/share/themes/Ambiance/index.theme
--- Ambiance-fixed-tooltip-bg-color/index.theme	2011-12-16 12:40:45.396183669 -0800
+++ /usr/share/themes/Ambiance/index.theme	2011-09-20 09:02:50.000000000 -0700
@@ -1,12 +1,12 @@
 [Desktop Entry]
 Type=X-GNOME-Metatheme
-Name=Ambiance-fixed-tooltip-bg-color
-Comment=Ubuntu theme with tooltip-bg fixed
+Name=Ambiance
+Comment=Ubuntu Ambiance theme
 Encoding=UTF-8
 
 [X-GNOME-Metatheme]
-GtkTheme=Ambiance-fixed-tooltip-bg-color
-MetacityTheme=Ambiance-fixed-tooltip-bg-color
+GtkTheme=Ambiance
+MetacityTheme=Ambiance
 IconTheme=ubuntu-mono-dark
 CursorTheme=DMZ-White
 ButtonLayout=close,minimize,maximize:
diff -ur Ambiance-fixed-tooltip-bg-color/metacity-1/metacity-theme-1.xml /usr/share/themes/Ambiance/metacity-1/metacity-theme-1.xml
--- Ambiance-fixed-tooltip-bg-color/metacity-1/metacity-theme-1.xml	2011-12-16 13:20:35.132190765 -0800
+++ /usr/share/themes/Ambiance/metacity-1/metacity-theme-1.xml	2011-09-20 09:02:50.000000000 -0700
@@ -2,7 +2,7 @@
 
 <metacity_theme>
 <info>
-  <name>Ambiance-fixed-tooltip-bg-color</name>
+  <name>Ambiance</name>
   <author>Kenneth Wimer, James Schriver, Andrea Cimitan</author>
   <copyright>Canonical Ltd.</copyright>
   <date>June, 2011</date>
EOF

Change your Ubuntu theme to the new one

This can be done by installing the “gnome-tweak-tool” because the “Appearance” interface in Ubuntu 11.10 doesn’t show you all of the Themes. Install it by running :

sudo apt-get install gnome-tweak-tool

Once installed you can find it in the Unity dock under the name “Advanced Settings”. This means that it isn’t called Gnome Tweak Tool, it’s listed as “Advanced Settings”

Once running go to the “Themes” section of the “Advanced Settings” tool and change your “Window Theme” from “Ambiance” to Ambiance-fixed-tooltip-bg-color”