diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-02-28 17:26:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-02-28 17:31:07 +0300 |
commit | d937d06c02f62c11385c1c1f58d963fec03365d9 (patch) | |
tree | c9a7052205b4cbcc4c9219ed2e9838cc5414c56c /source/blender/python | |
parent | 80d1d9629e1d4dd12aca580e3844a24f5d160356 (diff) |
WorkSpace: UI filtering for add-ons
Allows for each workspace to have it's own add-ons on display.
Filtering for: Panels, Menus, Keymaps & Manipulators.
Automatically applies to add-ons at the moment.
Access from workspace, toggled off by default
once enabled, add-ons can be white-listed.
See D3076
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy.c | 3 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 37 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.h | 4 |
3 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 0b791b6acaa..e07fa46424c 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -376,6 +376,9 @@ void BPy_init_modules(void) PyModule_AddObject(mod, meth_bpy_register_class.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_register_class, NULL)); PyModule_AddObject(mod, meth_bpy_unregister_class.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_unregister_class, NULL)); + PyModule_AddObject(mod, meth_bpy_owner_id_get.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_owner_id_get, NULL)); + PyModule_AddObject(mod, meth_bpy_owner_id_set.ml_name, (PyObject *)PyCFunction_New(&meth_bpy_owner_id_set, NULL)); + /* add our own modules dir, this is a python package */ bpy_package_py = bpy_import_test("bpy"); } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4ce9ba59a0b..2aff61dc2b8 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -8257,6 +8257,43 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla Py_RETURN_NONE; } +/* Access to 'owner_id' internal global. */ + +static PyObject *pyrna_bl_owner_id_get(PyObject *UNUSED(self)) +{ + const char *name = RNA_struct_state_owner_get(); + if (name) { + return PyUnicode_FromString(name); + } + Py_RETURN_NONE; +} + +static PyObject *pyrna_bl_owner_id_set(PyObject *UNUSED(self), PyObject *value) +{ + const char *name; + if (value == Py_None) { + name = NULL; + } + else if (PyUnicode_Check(value)) { + name = _PyUnicode_AsString(value); + } + else { + PyErr_Format(PyExc_ValueError, + "owner_set(...): " + "expected None or a string, not '%.200s'", Py_TYPE(value)->tp_name); + return NULL; + } + RNA_struct_state_owner_set(name); + Py_RETURN_NONE; +} + +PyMethodDef meth_bpy_owner_id_get = { + "_bl_owner_id_get", (PyCFunction)pyrna_bl_owner_id_get, METH_NOARGS, NULL, +}; +PyMethodDef meth_bpy_owner_id_set = { + "_bl_owner_id_set", (PyCFunction)pyrna_bl_owner_id_set, METH_O, NULL, +}; + /* currently this is fairly limited, we would need to make some way to split up * pyrna_callback_classmethod_... if we want more than one callback per type */ typedef struct BPyRNA_CallBack { diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index f666294666e..32a63acde40 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -225,4 +225,8 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self); extern PyMethodDef meth_bpy_register_class; extern PyMethodDef meth_bpy_unregister_class; +/* bpy.utils._bl_owner_(get/set) */ +extern PyMethodDef meth_bpy_owner_id_set; +extern PyMethodDef meth_bpy_owner_id_get; + #endif |