diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-03-01 03:20:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-03-01 03:22:46 +0300 |
commit | 61c8ed40f5df897da212b55dadeee252c8d3997b (patch) | |
tree | 45b820095458d8c4bdc891cb07b9273a2597f057 /release/scripts/modules | |
parent | 33b6f944c673bf76de9d5ed955f0e6ab1fe10aac (diff) |
WorkSpace: show/hode opt-out support for addons
In some cases it doesn't make sense for add-ons to be listed for hiding.
Especially for import/export which use minimal UI space.
This adds `bl_info["use_owner"]` to add-ons,
currently defaulting to True for all non Import-Export add-ons.
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/addon_utils.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 23874abd8c9..c74286c8fb6 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -352,10 +352,11 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non # 2) try register collected modules # removed, addons need to handle own registration now. - - from _bpy import _bl_owner_id_get, _bl_owner_id_set - owner_id_prev = _bl_owner_id_get() - _bl_owner_id_set(module_name) + use_owner = mod.bl_info.get("use_owner", True) + if use_owner: + from _bpy import _bl_owner_id_get, _bl_owner_id_set + owner_id_prev = _bl_owner_id_get() + _bl_owner_id_set(module_name) # 3) try run the modules register function try: @@ -369,7 +370,8 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non _addon_remove(module_name) return None finally: - _bl_owner_id_set(owner_id_prev) + if use_owner: + _bl_owner_id_set(owner_id_prev) # * OK loaded successfully! * mod.__addon_enabled__ = True @@ -480,6 +482,7 @@ def module_bl_info(mod, info_basis=None): "category": "", "warning": "", "show_expanded": False, + "use_owner": True, } addon_info = getattr(mod, "bl_info", {}) @@ -497,5 +500,9 @@ def module_bl_info(mod, info_basis=None): if not addon_info["name"]: addon_info["name"] = mod.__name__ + # Temporary auto-magic, don't use_owner for import export menus. + if mod.bl_info["category"] == "Import-Export": + mod.bl_info["use_owner"] = False + addon_info["_init"] = None return addon_info |