DrewNaylor / Retiled

An attempt at creating a "desktop" environment mainly for Linux phones and tablets that's similar in function to some parts of Microsoft's Windows Phone 8.x, primarily the Start screen, Search app, navigation bar, Action Center, and the status bar. Development is mainly being done using the PinePhone, so that'll be the main supported device.
https://codeberg.org/DrewNaylor/Retiled
Apache License 2.0
66 stars 3 forks source link

Themes should allow importing other themes as a base. #236

Open DrewNaylor opened 1 year ago

DrewNaylor commented 1 year ago

It could get really bad for theme maintenance at some point if it doesn't. I'd need to have a file that says what keys are expected for themes to contain for each version of Retiled, and that would be used for when we load themes where we'll see if a theme has a required key, and if it doesn't, use the theme it imports instead. If that theme doesn't have it, ideally we should keep going until we run out of themes to import from, then use the default value, but I don't know how to reasonably do the recursive import thing so for now I'm going to just do a one-layer import as that's simpler.

So in summary when loading into the dict, we'll check if each key is in the theme, and if not, substitute it with the one it imports or the default value if its import doesn't have it.

I think KDE Plasma has this feature, but I don't remember.

DrewNaylor commented 1 year ago

To check if a theme doesn't have a required key, there should be a script that takes the default theme (the dark one) and converts it into minified JSON that we load in to compare the requested theme at runtime. The script would need to be run after adding new supported keys. This JSON only has keys, no values, and values are either filled from the imported theme or the default theme (which should also be loaded at runtime along with the imported theme if it exists but both should be thrown out after we're done loading everything into the dict, because all that remains will be the "compiled" theme consisting of the requested theme and any gaps that were filled in). Maybe there should be support for versioning the theme engine, I'm not sure because that may be a lot more difficult to put into every program.

(The following paragraph was copied into #238 because it needs to be its own issue but I'm leaving it here because it leaves off from the previous paragraph) What I should do is have a "real" version of shared/reused libraries and just have a script that copies them to each program's libs folder. Then the copies in each folder that aren't the main one would be gitignored. I'd still need to have a message in the readme where it says how to run stuff to run a script to copy the libs into each subfolder. This would also allow me to pull out the settings and theme-related code from each main.py file instead of copying everything every time I make a change. Would also help other developers too, but they'd probably find it easier to just copy the libs folder manually instead of editing the script. I'd also have to change stuff so the path to the themes folder can be modified in case a program is not in my folder, but my goal is to have themes be installed to /usr/share/themes and the home folder version, so I'll need to change my paths when it's ready to be released.

DrewNaylor commented 1 year ago

Ok that last comment isn't getting the link to #238 correctly even after editing it.

DrewNaylor commented 1 year ago

I know an easy way to check if a theme has what's needed: load themes in using configparser and check if it has_option and return it, otherwise return the default like I do for loading settings. The default for certain things like theme publisher and copyright would be "unknown" or whatever I do for UXL Launcher Theme Engine/PortableThemeEngine.