diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-04-20 04:57:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-04-20 05:07:01 +0300 |
commit | ebe04bd3cafaa1f88bd51eee5b3e7bef38ae69bc (patch) | |
tree | 7af16c8b05e7732b939ed40816ce9388364576af /source/blender/python/intern/bpy_rna_types_capi.c | |
parent | 985ccba77c6e907ae55ac47d8ac56d1e84b46286 (diff) |
PyAPI: support Operator.poll functions 'disabled' hint
Python scripts can now define the reason it's poll function fails using:
`Operator.poll_message_set(message, ...)`
This supports both regular text as well as delaying message creation
using a callback which should be used in situations where constructing
detailed messages is too much overhead for a poll function.
Ref D11001
Diffstat (limited to 'source/blender/python/intern/bpy_rna_types_capi.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna_types_capi.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_rna_types_capi.c b/source/blender/python/intern/bpy_rna_types_capi.c index 9b15e84663d..2f6e197d1e2 100644 --- a/source/blender/python/intern/bpy_rna_types_capi.c +++ b/source/blender/python/intern/bpy_rna_types_capi.c @@ -41,6 +41,8 @@ #include "bpy_rna_types_capi.h" #include "bpy_rna_ui.h" +#include "bpy_rna_operator.h" + #include "../generic/py_capi_utils.h" #include "RNA_access.h" @@ -87,6 +89,17 @@ static struct PyMethodDef pyrna_uilayout_methods[] = { /** \} */ /* -------------------------------------------------------------------- */ +/** \name Operator + * \{ */ + +static struct PyMethodDef pyrna_operator_methods[] = { + {NULL, NULL, 0, NULL}, /* #BPY_rna_operator_poll_message_set */ + {NULL, NULL, 0, NULL}, +}; + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Window Manager Clipboard Property * * Avoid using the RNA API because this value may change between checking its length @@ -228,6 +241,11 @@ void BPY_rna_types_extend_capi(void) /* Space */ pyrna_struct_type_extend_capi(&RNA_Space, pyrna_space_methods, NULL); + /* wmOperator */ + ARRAY_SET_ITEMS(pyrna_operator_methods, BPY_rna_operator_poll_message_set_method_def); + BLI_assert(ARRAY_SIZE(pyrna_operator_methods) == 2); + pyrna_struct_type_extend_capi(&RNA_Operator, pyrna_operator_methods, NULL); + /* WindowManager */ pyrna_struct_type_extend_capi( &RNA_WindowManager, pyrna_windowmanager_methods, pyrna_windowmanager_getset); |