From c6705e464f0eaa53564f8c41ccd6c7956d7f4837 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 May 2011 18:11:59 +0000 Subject: use a dynamic enum for addons, annoyingly the enum was being generated from python for each of the addon buttons (~14 times per draw) which was noticeably slow, so disabling 'expand' for now. Eventually it would be good to have the expanded buttons all using the same result from itemf(). --- release/scripts/startup/bl_ui/__init__.py | 36 ++++++++++++------------- release/scripts/startup/bl_ui/space_userpref.py | 3 ++- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index 2f933fb5771..bf63c6071b9 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -85,26 +85,26 @@ def register(): from bpy.props import StringProperty, EnumProperty WindowManager = bpy.types.WindowManager + def addon_filter_items(self, context): + import addon_utils + + items = [('All', "All", ""), + ('Enabled', "Enabled", ""), + ('Disabled', "Disabled", ""), + ] + + items_unique = set() + + for mod in addon_utils.modules(space_userpref.USERPREF_PT_addons._addons_fake_modules): + info = addon_utils.module_bl_info(mod) + items_unique.add(info["category"]) + + items.extend([(cat, cat, "") for cat in sorted(items_unique)]) + return items + WindowManager.addon_search = StringProperty(name="Search", description="Search within the selected filter") WindowManager.addon_filter = EnumProperty( - items=[('All', "All", ""), - ('Enabled', "Enabled", ""), - ('Disabled', "Disabled", ""), - ('3D View', "3D View", ""), - ('Add Curve', "Add Curve", ""), - ('Add Mesh', "Add Mesh", ""), - ('Animation', "Animation", ""), - ('Development', "Development", ""), - ('Game Engine', "Game Engine", ""), - ('Import-Export', "Import-Export", ""), - ('Mesh', "Mesh", ""), - ('Object', "Object", ""), - ('Render', "Render", ""), - ('Rigging', "Rigging", ""), - ('Text Editor', "Text Editor", ""), - ('System', "System", ""), - ('Other', "Other", ""), - ], + items=addon_filter_items, name="Category", description="Filter add-ons by category", ) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index d4ebae04c34..e34755ae72e 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -889,7 +889,8 @@ class USERPREF_PT_addons(bpy.types.Panel): split = layout.split(percentage=0.2) col = split.column() col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM') - col.prop(context.window_manager, "addon_filter", expand=True) + col.label(text="Categories") + col.prop(context.window_manager, "addon_filter", text="") # , expand=True, too slow with dynamic enum. col.label(text="Supported Level") col.prop(context.window_manager, "addon_support", expand=True) -- cgit v1.2.3