Keymap: allow filling in existing key-configs

Needed so we can get the preferences of a key-config
which are sent to a function that generates the contents.
This commit is contained in:
2018-11-16 15:59:44 +11:00
parent cb79b691cd
commit c1f5ccb11a

View File

@@ -488,6 +488,15 @@ def keymap_items_from_data(km, km_items, is_modal=False):
_kmi_props_setattr(kmi_props, attr, value)
def keyconfig_init_from_data(kc, keyconfig_data):
# Load data in the format defined above.
#
# Runs at load time, keep this fast!
for (km_name, km_args, km_content) in keyconfig_data:
km = kc.keymaps.new(km_name, **km_args)
keymap_items_from_data(km, km_content["items"], is_modal=km_args.get("modal", False))
def keyconfig_import_from_data(name, keyconfig_data):
# Load data in the format defined above.
#
@@ -496,10 +505,7 @@ def keyconfig_import_from_data(name, keyconfig_data):
import bpy
wm = bpy.context.window_manager
kc = wm.keyconfigs.new(name)
for (km_name, km_args, km_content) in keyconfig_data:
km = kc.keymaps.new(km_name, **km_args)
keymap_items_from_data(km, km_content["items"], is_modal=km_args.get("modal", False))
keyconfig_init_from_data(kc, keyconfig_data)
return kc