Thursday 5 September 2013

Monodevelop 4.0 and dark themes

Monodevelop 4.0 (or "Xamarin Studio" if you're one of the blessed Mac or Windows users) was released a fair while back with great fanfare as the new, awesome major re-designed version of Monodevelop. I think it's fair to say that I wasn't impressed.

Aside from the ever-present nightmare of building the damn thing (turns out you need to already have a version of monodevelop installed or the new version spews out a ton of errors when you build it), the folks behind Monodevelop managed to produce an IDE that was utterly unusable for me. Why? Because it only partially followed the system themes. Following themes is a really nice feature - it makes the application fit in with your working environment nicely and (if you're me) allows you to run it with a nice, dark look that doesn't give you a headache by lunchtime. I find the standard black text on glaring white background to be a great way to increase painkiller sales at my local shop.

Totally ignoring themes would be annoying, but hey, I can live with it. At least you can still get on and work, right?

Monodevelop 4 does neither.

Monodevelop 4 applies some of the colours to some of its interface. Which leads to the joy of trying to read light grey text (following my system theme) on a light grey background (ignoring my system theme). Some of the fancy new components that Xamarin have created to bling up the interface have partially hard-coded colour schemes. It's inexcusable, really; an inexplicable error to put in a supposedly polished, high(ish)-profile release. I can only assume that nobody ever thought to check what happened when you applied dark themes.

Maybe Xamarin have fixed it in later releases. Maybe not. I don't know, and I don't really care, because everything after 4.0 relies on having access to mono > 2.10.8.1 - and since Ubuntu (the platform I'm working on) hasn't had an update to mono in repos for the last three centuries or something I'd have to build mono to use it - but everything I work on needs to be capable of running on the version in repos. Yes, I could run parallel monos on my desktop, but just to fix a colour scheme? Really?

Personally I think it's totally understandable that those who use Mono/Monodevelop on Linux are beginning to feel like Xamarin has hung us out to dry. But that's an argument for another day. The point of this post is: You can hack the monodevelop sources to make your dark theme work enough to use 4.0. This isn't a fix as such; if you change the theme, you'll need to hack the sources again and recompile. I don't know my way around the monodevelop sources well enough to properly fix it (plus it's not my job to spend the time learning my way around and, fuck it, they don't see linux support as worthwhile, I don't see why I should spend my time fixing their shoddy engineering).

The Hack

To make Monodevelop usable with your dark theme (I use Nodoka-Midnight) you'll need to modify a few of the source files. The motherlode of hard-coded colours is in src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs. I've used rather a blunderbuss approach, and some of the following changes may not strictly be necessary; feel free to apply them one by one and see which steps can be skipped:
  • Swap over the values of BaseForegroundColor and BaseBackgroundColor (lines 33 and 34)
  • Darken ThinSplitterColour (I set it to 31,31,31)
  • Darken the TabBarBackgroundColor (I used 2e2d2d)
  • Darken the BreadcrumbGradientStartColor (I used 484444)
  • Darken all the DockTabBar... colours (I used variants on 45d / 255d, 44d / 255d, 44d / 255d and halved the numerators for the ...Shadow... colours)
  • Similarly darken PadBackground, DockFrameBackground and BrowserPadBackground
That should get most of the interface at least usable. There's also a tab strip sitting under the main edit window in the default debugging layout which is almost impossible to read without changing its background colour, so in src/core/MonoDevelop.Ide/MonoDevelop.Components/Tabstrip.cs, line 40 darken BackgroundGradientStart to something like 45d / 255d, 44d / 255d, 44d / 255d

Now make & make install monodevelop and you should be able to use it with a dark system theme without half of the interface being illegible.

As I said, this is NOT a fix. It's a horrible hack. Monodevelop shouldn't be using hardwired colours at all - or it shouldn't be applying colours from the system theme at all. The way it's implemented is a textbook case of a half-baked feature being worse than none at all.