Splash: add themes to first time setup in splash screen.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 8 Oct 2018 17:19:05 +0000 (19:19 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 8 Oct 2018 17:46:00 +0000 (19:46 +0200)
* Add default theme as Blender Dark.
* Rename Flatty Light to Blender Light.
* When setting theme, reset to default first for consistent results.

release/scripts/presets/interface_theme/blender_dark.xml [new file with mode: 0644]
release/scripts/presets/interface_theme/blender_light.xml [moved from release/scripts/presets/interface_theme/flatty_light.xml with 100% similarity]
release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/space_userpref.py

diff --git a/release/scripts/presets/interface_theme/blender_dark.xml b/release/scripts/presets/interface_theme/blender_dark.xml
new file mode 100644 (file)
index 0000000..8bbb747
--- /dev/null
@@ -0,0 +1,6 @@
+<bpy>
+  <Theme>
+  </Theme>
+  <ThemeStyle>
+  </ThemeStyle>
+</bpy>
index 9cc1591494a4a09818c0a719a0add6764dcb1b84..59bcae2a7898ddec69a5770c1ef79adcc9878fec 100644 (file)
@@ -238,6 +238,13 @@ class ExecutePreset(Operator):
 
         ext = splitext(filepath)[1].lower()
 
+        if ext not in {".py", ".xml"}:
+            self.report({'ERROR'}, "unknown filetype: %r" % ext)
+            return {'CANCELLED'}
+
+        if hasattr(preset_class, "pre_cb"):
+            preset_class.pre_cb(context)
+
         # execute the preset using script.python_file_run
         if ext == ".py":
             bpy.ops.script.python_file_run(filepath=filepath)
@@ -246,9 +253,9 @@ class ExecutePreset(Operator):
             rna_xml.xml_file_run(context,
                                  filepath,
                                  preset_class.preset_xml_map)
-        else:
-            self.report({'ERROR'}, "unknown filetype: %r" % ext)
-            return {'CANCELLED'}
+
+        if hasattr(preset_class, "post_cb"):
+            preset_class.post_cb(context)
 
         return {'FINISHED'}
 
@@ -564,6 +571,9 @@ class AddPresetInterfaceTheme(AddPresetBase, Operator):
     preset_menu = "USERPREF_MT_interface_theme_presets"
     preset_subdir = "interface_theme"
 
+    def pre_cb(self, context):
+        bpy.ops.ui.reset_default_theme()
+
 
 class AddPresetKeyconfig(AddPresetBase, Operator):
     """Add or remove a Key-config Preset"""
index 52b645685baf21b27d873baaf28e4766ff7ba4d6..4fcadbf63e3a44cb6ad81930a588d98abe3eb507 100644 (file)
@@ -2559,8 +2559,6 @@ class WM_MT_splash(Menu):
 
         col = split.column()
 
-        col.label()
-
         sub = col.column(align=True)
         sub.label(text="Input and Shortcuts:")
         text = bpy.path.display_name(context.window_manager.keyconfigs.active.name)
@@ -2570,13 +2568,19 @@ class WM_MT_splash(Menu):
 
         col.separator()
 
+        sub = col.column(align=True)
+        sub.label(text="Theme:")
+        label = bpy.types.USERPREF_MT_interface_theme_presets.bl_label
+        if label == "Presets":
+            label = "Blender Dark"
+        sub.menu("USERPREF_MT_interface_theme_presets", text=label)
+
         # We need to make switching to a language easier first
         #sub = col.column(align=False)
         # sub.label(text="Language:")
         #userpref = context.user_preferences
         #sub.prop(userpref.system, "language", text="")
 
-        col.label()
         col.label()
 
         layout.label()
index ce52e8cb8379ec38b5ae8bdcc8eaec9f6f0e02c4..21c2e32e932401e2a308b8c133ef3060ba4957ab 100644 (file)
@@ -505,6 +505,9 @@ class USERPREF_MT_interface_theme_presets(Menu):
     )
     draw = Menu.draw_preset
 
+    def pre_cb(context):
+        bpy.ops.ui.reset_default_theme()
+
 
 class USERPREF_PT_theme(Panel):
     bl_space_type = 'USER_PREFERENCES'