[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28330] trunk/blender/release/scripts/ui/ space_userpref.py: filter 'Enable' wasnt working.

Campbell Barton ideasman42 at gmail.com
Wed Apr 21 18:50:53 CEST 2010


Revision: 28330
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28330
Author:   campbellbarton
Date:     2010-04-21 18:50:51 +0200 (Wed, 21 Apr 2010)

Log Message:
-----------
filter 'Enable' wasnt working.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2010-04-21 16:35:10 UTC (rev 28329)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2010-04-21 16:50:51 UTC (rev 28330)
@@ -1137,7 +1137,7 @@
 
         cats = ['All', 'Disabled', 'Enabled'] + sorted(cats)
 
-        bpy.types.Scene.EnumProperty(items=[(cats[i], cats[i], str(i)) for i in range(len(cats))],
+        bpy.types.Scene.EnumProperty(items=[(cat, cat, str(i)) for i, cat in enumerate(cats)],
             name="Category", attr="addon_filter", description="Filter add-ons by category")
         bpy.types.Scene.StringProperty(name="Search", attr="addon_search",
             description="Search within the selected filter")
@@ -1153,64 +1153,66 @@
         for mod, info in addons:
             module_name = mod.__name__
 
+            is_enabled = module_name in used_ext
+
             # check if add-on should be visible with current filters
-            if filter != "All" and \
-                    filter != info["category"] and \
-                    not (module_name not in used_ext and filter == "Disabled"):
+            if (filter == "All") or \
+                    (filter == info["category"]) or \
+                    (filter == "Enabled" and is_enabled) or \
+                    (filter == "Disabled" and not is_enabled):
 
-                continue
 
-            if search and search not in info["name"].lower():
-                if info["author"]:
-                    if search not in info["author"].lower():
+                if search and search not in info["name"].lower():
+                    if info["author"]:
+                        if search not in info["author"].lower():
+                            continue
+                    else:
                         continue
-                else:
-                    continue
 
-            # Addon UI Code
-            box = layout.column().box()
-            column = box.column()
-            row = column.row()
+                # Addon UI Code
+                box = layout.column().box()
+                column = box.column()
+                row = column.row()
 
-            # Arrow #
-            # If there are Infos or UI is expanded
-            if info["expanded"]:
-                row.operator("wm.addon_expand", icon="TRIA_DOWN").module = module_name
-            elif info["author"] or info["version"] or info["url"] or info["location"]:
-                row.operator("wm.addon_expand", icon="TRIA_RIGHT").module = module_name
-            else:
-                # Else, block UI
-                arrow = row.column()
-                arrow.enabled = False
-                arrow.operator("wm.addon_expand", icon="TRIA_RIGHT").module = module_name
+                # Arrow #
+                # If there are Infos or UI is expanded
+                if info["expanded"]:
+                    row.operator("wm.addon_expand", icon="TRIA_DOWN").module = module_name
+                elif info["author"] or info["version"] or info["url"] or info["location"]:
+                    row.operator("wm.addon_expand", icon="TRIA_RIGHT").module = module_name
+                else:
+                    # Else, block UI
+                    arrow = row.column()
+                    arrow.enabled = False
+                    arrow.operator("wm.addon_expand", icon="TRIA_RIGHT").module = module_name
 
-            row.label(text=info["name"])
-            row.operator("wm.addon_disable" if module_name in used_ext else "wm.addon_enable").module = module_name
+                row.label(text=info["name"])
+                row.operator("wm.addon_disable" if is_enabled else "wm.addon_enable").module = module_name
 
-            # Expanded UI (only if additional infos are available)
-            if info["expanded"]:
-                if info["author"]:
-                    split = column.row().split(percentage=0.15)
-                    split.label(text='Author:')
-                    split.label(text=info["author"])
-                if info["version"]:
-                    split = column.row().split(percentage=0.15)
-                    split.label(text='Version:')
-                    split.label(text=info["version"])
-                if info["location"]:
-                    split = column.row().split(percentage=0.15)
-                    split.label(text='Location:')
-                    split.label(text=info["location"])
-                if info["description"]:
-                    split = column.row().split(percentage=0.15)
-                    split.label(text='Description:')
-                    split.label(text=info["description"])
-                if info["url"]:
-                    split = column.row().split(percentage=0.15)
-                    split.label(text="Internet:")
-                    split.operator("wm.addon_links", text="Link to the Wiki").link = info["url"]
-                    split.separator()
-                    split.separator()
+                # Expanded UI (only if additional infos are available)
+                if info["expanded"]:
+                    if info["author"]:
+                        split = column.row().split(percentage=0.15)
+                        split.label(text='Author:')
+                        split.label(text=info["author"])
+                    if info["version"]:
+                        split = column.row().split(percentage=0.15)
+                        split.label(text='Version:')
+                        split.label(text=info["version"])
+                    if info["location"]:
+                        split = column.row().split(percentage=0.15)
+                        split.label(text='Location:')
+                        split.label(text=info["location"])
+                    if info["description"]:
+                        split = column.row().split(percentage=0.15)
+                        split.label(text='Description:')
+                        split.label(text=info["description"])
+                    if info["url"]:
+                        split = column.row().split(percentage=0.15)
+                        split.label(text="Internet:")
+                        split.operator("wm.addon_links", text="Link to the Wiki").link = info["url"]
+                        split.separator()
+                        split.separator()
 
         # Append missing scripts
         # First collect scripts that are used but have no script file.





More information about the Bf-blender-cvs mailing list