Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-05-26 22:11:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-26 22:11:59 +0400
commitc6705e464f0eaa53564f8c41ccd6c7956d7f4837 (patch)
tree62ba1594f0b5892896885584e586e9d1b32c0b85
parent57c3c9e70f0f5ad043f07ddaa25ed7d0cd5020e0 (diff)
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().
-rw-r--r--release/scripts/startup/bl_ui/__init__.py36
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py3
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)