Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-18 16:49:27 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-18 16:49:27 +0400
commit03222143c0cbd690fa125f5c3da36ca878d95e21 (patch)
treec53d66140be5d2638297676eaadeb98342fba5f0 /release
parentadb567f6b3f21f820e6b40d8530b374ee5cc2d7a (diff)
Add "Install Theme" button in user preferences, patch #31505 by Julien Duroure.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_operators/wm.py59
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py1
2 files changed, 60 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index c3638da5814..883bac84e78 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1545,6 +1545,65 @@ class WM_OT_addon_disable(Operator):
addon_utils.disable(self.module)
return {'FINISHED'}
+class WM_OT_theme_install(Operator):
+ "Install a theme"
+ bl_idname = "wm.theme_install"
+ bl_label = "Install Theme..."
+
+ overwrite = BoolProperty(
+ name="Overwrite",
+ description="Remove existing theme file if exists",
+ default=True,
+ )
+ filepath = StringProperty(
+ subtype='FILE_PATH',
+ )
+ filter_folder = BoolProperty(
+ name="Filter folders",
+ default=True,
+ options={'HIDDEN'},
+ )
+ filter_glob = StringProperty(
+ default="*.xml",
+ options={'HIDDEN'},
+ )
+
+ def execute(self, context):
+ import os
+ import shutil
+ import traceback
+
+ xmlfile = self.filepath
+
+ path_themes = bpy.utils.user_resource('SCRIPTS','presets/interface_theme',create=True)
+
+ if not path_themes:
+ self.report({'ERROR'}, "Failed to get themes path")
+ return {'CANCELLED'}
+
+ path_dest = os.path.join(path_themes, os.path.basename(xmlfile))
+
+ if not self.overwrite:
+ if os.path.exists(path_dest):
+ self.report({'WARNING'}, "File already installed to %r\n" % path_dest)
+ return {'CANCELLED'}
+
+ try:
+ shutil.copyfile(xmlfile, path_dest)
+ bpy.ops.script.execute_preset(filepath=path_dest,menu_idname="USERPREF_MT_interface_theme_presets")
+
+ except:
+ traceback.print_exc()
+ return {'CANCELLED'}
+
+ return {'FINISHED'}
+
+
+ def invoke(self, context, event):
+ wm = context.window_manager
+ wm.fileselect_add(self)
+ return {'RUNNING_MODAL'}
+
class WM_OT_addon_install(Operator):
"Install an addon"
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 01a8f1c6dcb..dec3960f376 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -96,6 +96,7 @@ class USERPREF_HT_header(Header):
layout.menu("USERPREF_MT_addons_dev_guides")
elif userpref.active_section == 'THEMES':
layout.operator("ui.reset_default_theme")
+ layout.operator("wm.theme_install")
class USERPREF_PT_tabs(Panel):