diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index a97c545e502..202d5cdbed4 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -853,8 +853,8 @@ class USERPREF_PT_addons(bpy.types.Panel): bl_region_type = 'WINDOW' bl_options = {'HIDE_HEADER'} - _addons_cats = None - _addons_sups = None + # _addons_cats = None + # _addons_sups = None _addons_fake_modules = {} @classmethod @@ -875,6 +875,8 @@ class USERPREF_PT_addons(bpy.types.Panel): # collect the categories that can be filtered on addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(USERPREF_PT_addons._addons_fake_modules)] + # XXX. we need dynamic enums to properly support this. + """ cats = {info["category"] for mod, info in addons} cats.discard("") @@ -882,6 +884,8 @@ class USERPREF_PT_addons(bpy.types.Panel): bpy.types.WindowManager.addon_filter = EnumProperty(items=[(cat, cat, "") for cat in ["All", "Enabled", "Disabled"] + sorted(cats)], name="Category", description="Filter add-ons by category") bpy.types.WindowManager.addon_search = StringProperty(name="Search", description="Search within the selected filter") USERPREF_PT_addons._addons_cats = cats + + [('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', ''), ('System', 'System', '')] sups_default = {'OFFICIAL', 'COMMUNITY'} sups = sups_default | {info["support"] for mod, info in addons} @@ -890,6 +894,7 @@ class USERPREF_PT_addons(bpy.types.Panel): if USERPREF_PT_addons._addons_sups != sups: bpy.types.WindowManager.addon_support = EnumProperty(items=[(sup, sup.title(), "") for sup in reversed(sorted(sups))], name="Support", description="Display support level", default=sups_default, options={'ENUM_FLAG'}) USERPREF_PT_addons._addons_sups = sups + """ split = layout.split(percentage=0.2) col = split.column() @@ -1193,6 +1198,37 @@ class WM_OT_addon_expand(bpy.types.Operator): def register(): bpy.utils.register_module(__name__) + WindowManager = bpy.types.WindowManager + + 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", ""), + ('System', "System", "") + ], + name="Category", + description="Filter add-ons by category", + ) + + WindowManager.addon_support = EnumProperty( + items=[('OFFICIAL', "Official", ""), + ('COMMUNITY', 'Community', ""), + ], + name="Support", + description="Display support level", default={'OFFICIAL', 'COMMUNITY'}, options={'ENUM_FLAG'}) + def unregister(): bpy.utils.unregister_module(__name__) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index a06d44c7e27..5d4a4993f39 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2967,9 +2967,15 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyObject *value) { StructRNA *srna= srna_from_self(cls, "StructRNA.__setattr__"); + const int is_deferred_prop= pyrna_is_deferred_prop(value); + + if(srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr)))) { + PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() can't set in readonly state '%.200s.%S'", ((PyTypeObject *)cls)->tp_name, attr); + return -1; + } if(srna == NULL) { - if(value && pyrna_is_deferred_prop(value)) { + if(value && is_deferred_prop) { PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'", ((PyTypeObject *)cls)->tp_name); return -1; } @@ -2981,7 +2987,7 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb if(value) { /* check if the value is a property */ - if(pyrna_is_deferred_prop(value)) { + if(is_deferred_prop) { int ret= deferred_register_prop(srna, attr, value); if(ret == -1) { /* error set */