Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/properties_workspace.py
| Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| addon_map = {mod.__name__: mod for mod in addon_utils.modules()} | addon_map = {mod.__name__: mod for mod in addon_utils.modules()} | ||||
| owner_ids = {owner_id.name for owner_id in workspace.owner_ids} | owner_ids = {owner_id.name for owner_id in workspace.owner_ids} | ||||
| for addon in prefs.addons: | for addon in prefs.addons: | ||||
| module_name = addon.module | module_name = addon.module | ||||
| module = addon_map.get(module_name) | module = addon_map.get(module_name) | ||||
| if module is None: | if module is None: | ||||
| continue | continue | ||||
| info = addon_utils.module_bl_info(module) | info = addon_utils.module_bl_info(module) | ||||
| if not info["use_owner"]: | |||||
| continue | |||||
| is_enabled = module_name in owner_ids | is_enabled = module_name in owner_ids | ||||
| if not info["use_owner"]: | |||||
| # always enable those (Import-Export) Addons, dont show UI though | |||||
| if not is_enabled: | |||||
| workspace.owner_ids.new(module_name) | |||||
| else: | |||||
| row = col.row() | row = col.row() | ||||
| row.alignment = 'LEFT' | row.alignment = 'LEFT' | ||||
| row.operator( | row.operator( | ||||
| "wm.owner_disable" if is_enabled else "wm.owner_enable", | "wm.owner_disable" if is_enabled else "wm.owner_enable", | ||||
| icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', | icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', | ||||
| text="%s: %s" % (info["category"], info["name"]), | text="%s: %s" % (info["category"], info["name"]), | ||||
| emboss=False, | emboss=False, | ||||
| ).owner_id = module_name | ).owner_id = module_name | ||||
| if is_enabled: | if is_enabled: | ||||
| owner_ids.remove(module_name) | owner_ids.remove(module_name) | ||||
| # Detect unused | # Detect unused | ||||
| if owner_ids: | if owner_ids: | ||||
| layout.label(text="Unknown add-ons", icon='ERROR') | layout.label(text="Unknown add-ons", icon='ERROR') | ||||
| col = layout.box().column(align=True) | col = layout.box().column(align=True) | ||||
| for module_name in sorted(owner_ids): | for module_name in sorted(owner_ids): | ||||
| Show All 27 Lines | |||||