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-11 18:14:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-11 18:14:04 +0400
commitb308e613126f8c89e954705aa512a3ef6a1f551d (patch)
tree4a875450b2ba9766fbdf4914e8cb003e8132497c /release/scripts
parent98bdf0274b1052efe25b6216f488d2a40fa43d1c (diff)
parentcda5d1769d71832a6b04ed6c91bac101c482e5f7 (diff)
svn merge ^/trunk/blender -r43220:43278 --accept postpone
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/modules/bpy/utils.py6
-rw-r--r--release/scripts/modules/rna_xml.py82
-rw-r--r--release/scripts/startup/bl_operators/mesh.py2
-rw-r--r--release/scripts/startup/bl_operators/presets.py86
-rw-r--r--release/scripts/startup/bl_operators/wm.py57
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py4
-rw-r--r--release/scripts/startup/bl_ui/space_logic.py6
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py54
8 files changed, 193 insertions, 104 deletions
diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py
index 6fd15c146f2..442d257b237 100644
--- a/release/scripts/modules/bpy/utils.py
+++ b/release/scripts/modules/bpy/utils.py
@@ -408,7 +408,7 @@ def smpte_from_frame(frame, fps=None, fps_base=None):
return smpte_from_seconds((frame * fps_base) / fps, fps)
-def preset_find(name, preset_path, display_name=False):
+def preset_find(name, preset_path, display_name=False, ext=".py"):
if not name:
return None
@@ -417,11 +417,11 @@ def preset_find(name, preset_path, display_name=False):
if display_name:
filename = ""
for fn in _os.listdir(directory):
- if fn.endswith(".py") and name == _bpy.path.display_name(fn):
+ if fn.endswith(ext) and name == _bpy.path.display_name(fn):
filename = fn
break
else:
- filename = name + ".py"
+ filename = name + ext
if filename:
filepath = _os.path.join(directory, filename)
diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py
index 1a0cf4bab9d..634c74178fa 100644
--- a/release/scripts/modules/rna_xml.py
+++ b/release/scripts/modules/rna_xml.py
@@ -32,7 +32,13 @@ def build_property_typemap(skip_classes):
if issubclass(cls, skip_classes):
continue
- properties = cls.bl_rna.properties.keys()
+ ## to support skip-save we cant get all props
+ # properties = cls.bl_rna.properties.keys()
+ properties = []
+ for prop_id, prop in cls.bl_rna.properties.items():
+ if not prop.is_skip_save:
+ properties.append(prop_id)
+
properties.remove("rna_type")
property_typemap[attr] = properties
@@ -47,7 +53,8 @@ def rna2xml(fw=print_ln,
root_node="",
root_rna=None, # must be set
root_rna_skip=set(),
- ident_val=" ",
+ root_ident="",
+ ident_val=" ",
skip_classes=(bpy.types.Operator,
bpy.types.Panel,
bpy.types.KeyingSet,
@@ -173,10 +180,11 @@ def rna2xml(fw=print_ln,
# needs re-workign to be generic
if root_node:
- fw("<%s>\n" % root_node)
+ fw("%s<%s>\n" % (root_ident, root_node))
# bpy.data
if method == 'DATA':
+ ident = root_ident + ident_val
for attr in dir(root_rna):
# exceptions
@@ -192,16 +200,16 @@ def rna2xml(fw=print_ln,
ls = None
if type(ls) == list:
- fw("%s<%s>\n" % (ident_val, attr))
+ fw("%s<%s>\n" % (ident, attr))
for blend_id in ls:
- rna2xml_node(ident_val + ident_val, blend_id, None)
+ rna2xml_node(ident + ident_val, blend_id, None)
fw("%s</%s>\n" % (ident_val, attr))
# any attribute
elif method == 'ATTR':
- rna2xml_node("", root_rna, None)
+ rna2xml_node(root_ident, root_rna, None)
if root_node:
- fw("</%s>\n" % root_node)
+ fw("%s</%s>\n" % (root_ident, root_node))
def xml2rna(root_xml,
@@ -298,3 +306,63 @@ def xml2rna(root_xml,
pass
rna2xml_node(root_xml, root_rna)
+
+
+
+# -----------------------------------------------------------------------------
+# Utility function used by presets.
+# The idea is you can run a preset like a script with a few args.
+#
+# This roughly matches the operator 'bpy.ops.script.python_file_run'
+
+def _get_context_val(context, path):
+ path_full = "context." + path
+ try:
+ value = eval(path_full)
+ except:
+ import traceback
+ traceback.print_exc()
+ print("Error: %r could not be found" % path_full)
+
+ value = Ellipsis
+
+ return value
+
+def xml_file_run(context, filepath, rna_map):
+
+ import xml.dom.minidom
+
+ xml_nodes = xml.dom.minidom.parse(filepath)
+ bpy_xml = xml_nodes.getElementsByTagName("bpy")[0]
+
+ for rna_path, xml_tag in rna_map:
+
+ # first get xml
+ # TODO, error check
+ xml_node = bpy_xml.getElementsByTagName(xml_tag)[0]
+
+ value = _get_context_val(context, rna_path)
+
+ if value is not Ellipsis and value is not None:
+ print(" loading XML: %r" % rna_path)
+ xml2rna(xml_node, root_rna=value)
+
+
+def xml_file_write(context, filepath, rna_map):
+
+ file = open(filepath, 'w', encoding='utf-8')
+ fw = file.write
+
+ fw("<bpy>\n")
+
+ for rna_path, xml_tag in rna_map:
+ # xml_tag is ignored, we get this from the rna
+ value = _get_context_val(context, rna_path)
+ rna2xml(fw,
+ root_rna=value,
+ method='ATTR',
+ root_ident=" ",
+ ident_val=" ")
+
+ fw("</bpy>\n")
+ file.close()
diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py
index bf9fa562ee1..3e206017238 100644
--- a/release/scripts/startup/bl_operators/mesh.py
+++ b/release/scripts/startup/bl_operators/mesh.py
@@ -25,7 +25,7 @@ from bpy.props import EnumProperty
class MeshSelectInteriorFaces(Operator):
- '''Select faces where all edges have more then 2 face users'''
+ '''Select faces where all edges have more than 2 face users'''
bl_idname = "mesh.faces_select_interior"
bl_label = "Select Interior Faces"
diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 308c46ca416..0ba19ad8109 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -55,6 +55,13 @@ class AddPresetBase():
preset_menu_class = getattr(bpy.types, self.preset_menu)
+ is_xml = getattr(preset_menu_class, "preset_type", None) == 'XML'
+
+ if is_xml:
+ ext = ".xml"
+ else:
+ ext = ".py"
+
if not self.remove_active:
name = self.name.strip()
if not name:
@@ -71,32 +78,40 @@ class AddPresetBase():
self.report({'WARNING'}, "Failed to create presets path")
return {'CANCELLED'}
- filepath = os.path.join(target_path, filename) + ".py"
+ filepath = os.path.join(target_path, filename) + ext
if hasattr(self, "add"):
self.add(context, filepath)
else:
print("Writing Preset: %r" % filepath)
- file_preset = open(filepath, 'w')
- file_preset.write("import bpy\n")
-
- if hasattr(self, "preset_defines"):
- for rna_path in self.preset_defines:
- exec(rna_path)
- file_preset.write("%s\n" % rna_path)
- file_preset.write("\n")
-
- for rna_path in self.preset_values:
- value = eval(rna_path)
- # convert thin wrapped sequences to simple lists to repr()
- try:
- value = value[:]
- except:
- pass
-
- file_preset.write("%s = %r\n" % (rna_path, value))
- file_preset.close()
+ if is_xml:
+ import rna_xml
+ rna_xml.xml_file_write(context,
+ filepath,
+ preset_menu_class.preset_xml_map)
+ else:
+ file_preset = open(filepath, 'w')
+ file_preset.write("import bpy\n")
+
+ if hasattr(self, "preset_defines"):
+ for rna_path in self.preset_defines:
+ exec(rna_path)
+ file_preset.write("%s\n" % rna_path)
+ file_preset.write("\n")
+
+ for rna_path in self.preset_values:
+ value = eval(rna_path)
+ # convert thin wrapped sequences
+ # to simple lists to repr()
+ try:
+ value = value[:]
+ except:
+ pass
+
+ file_preset.write("%s = %r\n" % (rna_path, value))
+
+ file_preset.close()
preset_menu_class.bl_label = bpy.path.display_name(filename)
@@ -104,12 +119,15 @@ class AddPresetBase():
preset_active = preset_menu_class.bl_label
# fairly sloppy but convenient.
- filepath = bpy.utils.preset_find(preset_active, self.preset_subdir)
+ filepath = bpy.utils.preset_find(preset_active,
+ self.preset_subdir,
+ ext=ext)
if not filepath:
filepath = bpy.utils.preset_find(preset_active,
self.preset_subdir,
- display_name=True)
+ display_name=True,
+ ext=ext)
if not filepath:
return {'CANCELLED'}
@@ -158,15 +176,27 @@ class ExecutePreset(Operator):
)
def execute(self, context):
- from os.path import basename
+ from os.path import basename, splitext
filepath = self.filepath
# change the menu title to the most recently chosen option
preset_class = getattr(bpy.types, self.menu_idname)
preset_class.bl_label = bpy.path.display_name(basename(filepath))
+ ext = splitext(filepath)[1].lower()
+
# execute the preset using script.python_file_run
- bpy.ops.script.python_file_run(filepath=filepath)
+ if ext == ".py":
+ bpy.ops.script.python_file_run(filepath=filepath)
+ elif ext == ".xml":
+ import rna_xml
+ rna_xml.xml_file_run(context,
+ filepath,
+ preset_class.preset_xml_map)
+ else:
+ self.report({'ERROR'}, "unknown filetype: %r" % ext)
+ return {'CANCELLED '}
+
return {'FINISHED'}
@@ -385,6 +415,14 @@ class AddPresetTrackingSettings(AddPresetBase, Operator):
preset_subdir = "tracking_settings"
+class AddPresetInterfaceTheme(AddPresetBase, Operator):
+ '''Add a theme preset'''
+ bl_idname = "wm.interface_theme_preset_add"
+ bl_label = "Add Tracking Settings Preset"
+ preset_menu = "USERPREF_MT_interface_theme_presets"
+ preset_subdir = "interface_theme"
+
+
class AddPresetKeyconfig(AddPresetBase, Operator):
'''Add a Keyconfig Preset'''
bl_idname = "wm.keyconfig_preset_add"
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 11326377a79..d7f970218a5 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -1769,60 +1769,3 @@ class WM_OT_addon_expand(Operator):
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_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 62889baf550..aa31b8493ec 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -856,6 +856,10 @@ class CLIP_MT_track(Menu):
layout.operator("clip.clean_tracks")
layout.separator()
+ layout.operator("clip.copy_tracks")
+ layout.operator("clip.paste_tracks")
+
+ layout.separator()
props = layout.operator("clip.track_markers",
text="Track Frame Backwards")
props.backwards = True
diff --git a/release/scripts/startup/bl_ui/space_logic.py b/release/scripts/startup/bl_ui/space_logic.py
index 1d0e2221ce2..1593f2c71ec 100644
--- a/release/scripts/startup/bl_ui/space_logic.py
+++ b/release/scripts/startup/bl_ui/space_logic.py
@@ -41,7 +41,7 @@ class LOGIC_PT_properties(Panel):
if is_font:
prop_index = game.properties.find("Text")
if prop_index != -1:
- layout.operator("object.game_property_remove", text="Renove Text Game Property", icon='X').index = prop_index
+ layout.operator("object.game_property_remove", text="Remove Text Game Property", icon='X').index = prop_index
row = layout.row()
sub = row.row()
sub.enabled = 0
@@ -49,9 +49,9 @@ class LOGIC_PT_properties(Panel):
sub.prop(prop, "name", text="")
row.prop(prop, "type", text="")
# get the property from the body, not the game property
- # note, dont do this - its too slow and body can potentually be a really long string.
+ # note, don't do this - it's too slow and body can potentually be a really long string.
# row.prop(ob.data, "body", text="")
- row.label("See Font Object")
+ row.label("See Text Object")
else:
props = layout.operator("object.game_property_new", text="Add Text Game Property", icon='ZOOMIN')
props.name = 'Text'
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 046026a3b6e..92419a2b609 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -96,8 +96,6 @@ 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):
@@ -388,13 +386,9 @@ class USERPREF_PT_system(Panel):
col.prop(system, "dpi")
col.prop(system, "frame_server_port")
col.prop(system, "scrollback", text="Console Scrollback")
- col.prop(system, "author", text="Author")
- col.prop(system, "use_scripts_auto_execute")
- col.prop(system, "use_tabs_as_spaces")
col.separator()
col.separator()
- col.separator()
col.label(text="Sound:")
col.row().prop(system, "audio_device", expand=True)
@@ -408,15 +402,21 @@ class USERPREF_PT_system(Panel):
col.separator()
col.separator()
- col.separator()
col.label(text="Screencast:")
col.prop(system, "screencast_fps")
col.prop(system, "screencast_wait_time")
- col.separator()
+
col.separator()
col.separator()
+ if hasattr(system, 'compute_device'):
+ col.label(text="Compute Device:")
+ col.row().prop(system, "compute_device_type", expand=True)
+ sub = col.row()
+ sub.active = system.compute_device_type != 'CPU'
+ sub.prop(system, "compute_device", text="")
+
# 2. Column
column = split.column()
colsplit = column.split(percentage=0.85)
@@ -489,6 +489,15 @@ class USERPREF_PT_system(Panel):
row.prop(system, "use_translate_tooltips", text="Tooltips")
+class USERPREF_MT_interface_theme_presets(Menu):
+ bl_label = "Presets"
+ preset_subdir = "interface_theme"
+ preset_operator = "script.execute_preset"
+ preset_type = 'XML'
+ preset_xml_map = (("user_preferences.themes[0]", "Theme"), )
+ draw = Menu.draw_preset
+
+
class USERPREF_PT_theme(Panel):
bl_space_type = 'USER_PREFERENCES'
bl_label = "Themes"
@@ -536,7 +545,18 @@ class USERPREF_PT_theme(Panel):
theme = context.user_preferences.themes[0]
split_themes = layout.split(percentage=0.2)
- split_themes.prop(theme, "theme_area", expand=True)
+
+ sub = split_themes.column()
+
+ sub.label(text="Presets:")
+ subrow = sub.row(align=True)
+
+ subrow.menu("USERPREF_MT_interface_theme_presets", text=USERPREF_MT_interface_theme_presets.bl_label)
+ subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMIN')
+ subrow.operator("wm.interface_theme_preset_add", text="", icon='ZOOMOUT').remove_active = True
+ sub.separator()
+
+ sub.prop(theme, "theme_area", expand=True)
split = layout.split(percentage=0.4)
@@ -727,6 +747,7 @@ class USERPREF_PT_file(Panel):
userpref = context.user_preferences
paths = userpref.filepaths
+ system = userpref.system
split = layout.split(percentage=0.7)
@@ -762,6 +783,14 @@ class USERPREF_PT_file(Panel):
subsplit.prop(paths, "animation_player_preset", text="")
subsplit.prop(paths, "animation_player", text="")
+ col.separator()
+ col.separator()
+
+ colsplit = col.split(percentage=0.95)
+ sub = colsplit.column()
+ sub.label(text="Author:")
+ sub.prop(system, "author", text="")
+
col = split.column()
col.label(text="Save & Load:")
col.prop(paths, "use_relative_paths")
@@ -784,6 +813,13 @@ class USERPREF_PT_file(Panel):
sub.active = paths.use_auto_save_temporary_files
sub.prop(paths, "auto_save_time", text="Timer (mins)")
+ col.separator()
+
+ col.label(text="Scripts:")
+ col.prop(system, "use_scripts_auto_execute")
+ col.prop(system, "use_tabs_as_spaces")
+
+
from .space_userpref_keymap import InputKeyMapPanel