Skip to content

Add user-defined GUI presets.

Albert Gräf requested to merge aggraef/purr-data:user-css into master

Yesterday, Joseph asked me about user-defined GUI presets, since he wanted to create his own "dark" style. Deriving your own css from existing style files isn't all that difficult if you just want to change the colors, and finding the right subdir in which to put those css files is also quite easy. But then the trouble begins, because Purr currently doesn't look for user-defined css files, and only allows the user to select the predefined gui styles in the prefs. So the only option right now is to manually edit that option list in the dialog_prefs.html file, which is inconvenient, and that file will be overwritten next time you update your urr Data installation.

Which is a bummer, because I'm sure that many developers and html/css buffs would like to play around with these GUI presets, and might well contribute some nifty new ones, if we only made this a little easier.

Which is what this MR is about. It discovers user-defined GUI presets (css files) in the css subdirectory of the gui folder, and adds them at the end of the corresponding dropdown menu in the GUI prefs. It is a convenience intended for users and developers who want to experiment with their own GUI styles.

The predefined presets are still hardcoded in the dialog_prefs.html file, and are always available (and displayed first in the dropdown menu). If the preset saved in the prefs doesn't exist anymore (e.g., because the user removed its css file), it will be ignored at startup and the default style will be used instead.

Note that this isn't entirely foolproof since the fallback may not exist if the user also removed the default.css file. But this could also happen previously when the css directory gets messed up, and in such a case the user simply gets what he or she deserves.

@jwilkes, honestly, I didn't plan for this one. ;-) But Joseph's inquiry reminded me that we need to do something to make it easier for the theme developers. As I've stuck my head quite a bit into the JS side of Purr lately thanks to Ico's contributions, I thought that I might as well give it a try, so there you go. Works well for me (I only tested on Linux so far, but I see no reason why it shouldn't work on the Mac or Windows and will of course test there later).

Edited by Albert Gräf

Merge request reports