Revision: 36930
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36930
Author:   campbellbarton
Date:     2011-05-26 18:11:59 +0000 (Thu, 26 May 2011)
Log Message:
-----------
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().

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/__init__.py
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py

Modified: trunk/blender/release/scripts/startup/bl_ui/__init__.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/__init__.py     2011-05-26 
17:07:38 UTC (rev 36929)
+++ trunk/blender/release/scripts/startup/bl_ui/__init__.py     2011-05-26 
18:11:59 UTC (rev 36930)
@@ -85,26 +85,26 @@
     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",
             )

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py       
2011-05-26 17:07:38 UTC (rev 36929)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py       
2011-05-26 18:11:59 UTC (rev 36930)
@@ -889,7 +889,8 @@
         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)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to