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:
authorMartin Poirier <theeth@yahoo.com>2010-01-22 00:58:40 +0300
committerMartin Poirier <theeth@yahoo.com>2010-01-22 00:58:40 +0300
commitb400703403dd87c482824a1b10f40923c67412e4 (patch)
treeea6a6f97b09936ae6a4e60c789077e84105d7868 /release
parent0d4583365a84078fac8351925b5caa663d64a108 (diff)
Macro operator properties using property groups in groups (initial code by brecht).
Works correctly with menu, keymap definitions and keymap export/import. Properties set in the macro definition overwrite those set by the user (there's no way to see that in the UI at this point). MISSING: Python operator calling code to fill in the properties hierarchy. Also contains some keymap export changes by Imran Syed (freakabcd on irc): the exported configuration will use the name of the file and the exported script will select the added configuration when ran.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/ui/space_userpref.py74
1 files changed, 53 insertions, 21 deletions
diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py
index 6622ebbc847..957a373d2f9 100644
--- a/release/scripts/ui/space_userpref.py
+++ b/release/scripts/ui/space_userpref.py
@@ -18,6 +18,7 @@
# <pep8 compliant>
import bpy
+import os.path
# General UI Theme Settings (User Interface)
def ui_items_general(col, context):
@@ -161,7 +162,8 @@ class USERPREF_HT_header(bpy.types.Header):
if userpref.active_section == 'INPUT':
layout.operator_context = 'INVOKE_DEFAULT'
- layout.operator("wm.keyconfig_export", "Export Key Configuration...").path = "keymap.py"
+ op = layout.operator("wm.keyconfig_export", "Export Key Configuration...")
+ op.path = "keymap.py"
class USERPREF_PT_tabs(bpy.types.Panel):
@@ -1166,15 +1168,24 @@ class USERPREF_PT_input(bpy.types.Panel):
subrow.prop(kmi, "alt")
subrow.prop(kmi, "oskey", text="Cmd")
subrow.prop(kmi, "key_modifier", text="", event=True)
+
+ def display_properties(properties, title = None):
+ box.separator()
+ if title:
+ box.label(text=title)
+ flow = box.column_flow(columns=2)
+ for pname in dir(properties):
+ if not properties.is_property_hidden(pname):
+ value = eval("properties." + pname)
+ if isinstance(value, bpy.types.OperatorProperties):
+ display_properties(value, title = pname)
+ else:
+ flow.prop(properties, pname)
# Operator properties
props = kmi.properties
if props is not None:
- box.separator()
- flow = box.column_flow(columns=2)
- for pname in dir(props):
- if not props.is_property_hidden(pname):
- flow.prop(props, pname)
+ display_properties(props)
# Modal key maps attached to this operator
if not km.modal:
@@ -1344,16 +1355,22 @@ class WM_OT_keyconfig_test(bpy.types.Operator):
s.append(", key_modifier=\'%s\'" % kmi.key_modifier)
s.append(")\n")
+
+ def export_properties(prefix, properties):
+ for pname in dir(properties):
+ if not properties.is_property_hidden(pname):
+ value = eval("properties.%s" % pname)
+ if isinstance(value, bpy.types.OperatorProperties):
+ export_properties(prefix + "." + pname, value)
+ elif properties.is_property_set(pname):
+ value = _string_value(value)
+ if value != "":
+ s.append(prefix + ".%s = %s\n" % (pname, value))
props = kmi.properties
if props is not None:
- for pname in dir(props):
- if props.is_property_set(pname) and not props.is_property_hidden(pname):
- value = eval("props.%s" % pname)
- value = _string_value(value)
- if value != "":
- s.append("kmi.properties.%s = %s\n" % (pname, value))
+ export_properties("kmi.properties", props)
return "".join(s).strip()
@@ -1451,6 +1468,9 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
bl_label = "Export Key Configuration..."
path = bpy.props.StringProperty(name="File Path", description="File path to write file to.")
+ filter_folder = bpy.props.BoolProperty(name="Filter folders", description="", default=True)
+ filter_text = bpy.props.BoolProperty(name="Filter text", description="", default=True)
+ filter_python = bpy.props.BoolProperty(name="Filter python", description="", default=True)
def execute(self, context):
if not self.properties.path:
@@ -1463,10 +1483,15 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
wm = context.manager
kc = wm.active_keyconfig
- f.write('# Configuration %s\n' % kc.name)
+ if kc.name == 'Blender':
+ name = os.path.splitext(os.path.basename(self.properties.path))[0]
+ else:
+ name = kc.name
+
+ f.write('# Configuration %s\n' % name)
f.write("wm = bpy.data.window_managers[0]\n")
- f.write("kc = wm.add_keyconfig(\'%s\')\n\n" % kc.name)
+ f.write("kc = wm.add_keyconfig(\'%s\')\n\n" % name)
for km in kc.keymaps:
km = km.active()
@@ -1492,18 +1517,25 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
f.write(", key_modifier=\'%s\'" % kmi.key_modifier)
f.write(")\n")
+ def export_properties(prefix, properties):
+ for pname in dir(properties):
+ if not properties.is_property_hidden(pname):
+ value = eval("properties.%s" % pname)
+ if isinstance(value, bpy.types.OperatorProperties):
+ export_properties(prefix + "." + pname, value)
+ elif properties.is_property_set(pname):
+ value = _string_value(value)
+ if value != "":
+ f.write(prefix + ".%s = %s\n" % (pname, value))
+
props = kmi.properties
-
+
if props is not None:
- for pname in dir(props):
- if props.is_property_set(pname) and not props.is_property_hidden(pname):
- value = eval("props.%s" % pname)
- value = _string_value(value)
- if value != "":
- f.write("kmi.properties.%s = %s\n" % (pname, value))
+ export_properties("kmi.properties", props)
f.write("\n")
+ f.write("wm.active_keyconfig = wm.keyconfigs[\'%s\']\n" % name)
f.close()
return {'FINISHED'}