2023-08-16 00:20:26 +10:00
|
|
|
# SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-06-14 23:06:58 +10:00
|
|
|
#
|
2023-02-21 16:39:58 +01:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
# this script updates XML themes once new settings are added
|
|
|
|
|
#
|
|
|
|
|
# ./blender.bin --background --python ./tools/utils_maintenance/blender_update_themes.py
|
|
|
|
|
|
2025-01-04 20:27:07 +11:00
|
|
|
__all__ = (
|
|
|
|
|
"main",
|
|
|
|
|
)
|
|
|
|
|
|
2023-02-21 16:39:58 +01:00
|
|
|
import bpy
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update(filepath):
|
|
|
|
|
import rna_xml
|
|
|
|
|
context = bpy.context
|
|
|
|
|
|
2024-04-27 16:06:53 +10:00
|
|
|
print("Updating theme: {!r}".format(filepath))
|
2023-02-21 16:39:58 +01:00
|
|
|
preset_xml_map = (
|
|
|
|
|
("preferences.themes[0]", "Theme"),
|
|
|
|
|
("preferences.ui_styles[0]", "Theme"),
|
|
|
|
|
)
|
|
|
|
|
rna_xml.xml_file_run(
|
|
|
|
|
context,
|
|
|
|
|
filepath,
|
|
|
|
|
preset_xml_map,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
rna_xml.xml_file_write(
|
|
|
|
|
context,
|
|
|
|
|
filepath,
|
|
|
|
|
preset_xml_map,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_default(filepath):
|
|
|
|
|
with open(filepath, 'w', encoding='utf-8') as fh:
|
2024-10-16 14:45:08 +11:00
|
|
|
fh.write("""<bpy>
|
2023-02-21 16:39:58 +01:00
|
|
|
<Theme>
|
|
|
|
|
</Theme>
|
|
|
|
|
<ThemeStyle>
|
|
|
|
|
</ThemeStyle>
|
|
|
|
|
</bpy>
|
2024-10-16 14:45:08 +11:00
|
|
|
""")
|
2023-02-21 16:39:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
for path in bpy.utils.preset_paths("interface_theme"):
|
|
|
|
|
for fn in os.listdir(path):
|
|
|
|
|
if fn.endswith(".xml"):
|
|
|
|
|
fn_full = os.path.join(path, fn)
|
|
|
|
|
if fn == "blender_dark.xml":
|
|
|
|
|
update_default(fn_full)
|
|
|
|
|
else:
|
|
|
|
|
update(fn_full)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|