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:
authorCampbell Barton <ideasman42@gmail.com>2012-01-01 12:12:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-01 12:12:51 +0400
commit418d66242fd00ffdbef5447d055811e5eb1bb46e (patch)
tree60f43f0db62551655f28dd5657fc2437e15a64bb /release
parente32e6004e43d22f215cb279de482b655a5007b4f (diff)
theme import/export - uses generic rna_xml py module.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/startup/bl_operators/wm.py60
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py2
2 files changed, 62 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 4f498e72f4b..cf6d62a330b 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1462,6 +1462,8 @@ class WM_OT_operator_cheat_sheet(Operator):
self.report({'INFO'}, "See OperatorList.txt textblock")
return {'FINISHED'}
+# -----------------------------------------------------------------------------
+# Addon Operators
class WM_OT_addon_enable(Operator):
"Enable an addon"
@@ -1762,3 +1764,61 @@ class WM_OT_addon_expand(Operator):
info = addon_utils.module_bl_info(mod)
info["show_expanded"] = not info["show_expanded"]
return {'FINISHED'}
+
+
+# -----------------------------------------------------------------------------
+# Theme IO
+from bpy_extras.io_utils import (ImportHelper,
+ ExportHelper,
+ )
+
+
+class WM_OT_theme_import(Operator, ImportHelper):
+ bl_idname = "wm.theme_import"
+ bl_label = "Import Theme"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ filename_ext = ".xml"
+ filter_glob = StringProperty(default="*.xml", options={'HIDDEN'})
+
+ def execute(self, context):
+ import rna_xml
+ import xml.dom.minidom
+
+ filepath = self.filepath
+
+ xml_nodes = xml.dom.minidom.parse(filepath)
+ theme_xml = xml_nodes.getElementsByTagName("Theme")[0]
+
+ # XXX, why always 0?, allow many?
+ theme = context.user_preferences.themes[0]
+
+ rna_xml.xml2rna(theme_xml,
+ root_rna=theme,
+ )
+
+ return {'FINISHED'}
+
+
+class WM_OT_theme_export(Operator, ExportHelper):
+ bl_idname = "wm.theme_export"
+ bl_label = "Export Theme"
+
+ filename_ext = ".xml"
+ filter_glob = StringProperty(default="*.xml", options={'HIDDEN'})
+
+ def execute(self, context):
+ import rna_xml
+
+ filepath = self.filepath
+ file = open(filepath, 'w', encoding='utf-8')
+
+ # XXX, why always 0?, allow many?
+ theme = context.user_preferences.themes[0]
+
+ rna_xml.rna2xml(file.write,
+ root_rna=theme,
+ method='ATTR',
+ )
+
+ return {'FINISHED'}
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index df8c085d77e..09286287541 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -96,6 +96,8 @@ 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_import")
+ layout.operator("wm.theme_export")
class USERPREF_PT_tabs(Panel):