[Bf-blender-cvs] [9795abec3e] app-templates: Make the test 101 profile remove all panels
Campbell Barton
noreply at git.blender.org
Thu Mar 16 01:50:06 CET 2017
Commit: 9795abec3ec816ad93b292fb43cc3218cfa515fc
Author: Campbell Barton
Date: Thu Mar 16 11:40:50 2017 +1100
Branches: app-templates
https://developer.blender.org/rB9795abec3ec816ad93b292fb43cc3218cfa515fc
Make the test 101 profile remove all panels
===================================================================
M release/app_templates/101/template/__init__.py
A release/scripts/modules/bl_app_override.py
===================================================================
diff --git a/release/app_templates/101/template/__init__.py b/release/app_templates/101/template/__init__.py
index 44e622c10e..fd606832ac 100644
--- a/release/app_templates/101/template/__init__.py
+++ b/release/app_templates/101/template/__init__.py
@@ -18,9 +18,28 @@
# <pep8-80 compliant>
+class_store = []
+
+import bl_app_override
+
def register():
+ import bpy
print("Template Register", __file__)
+ class_store.clear()
+
+ class_store.extend(bl_app_override.class_match.panel())
+ unregister = bpy.utils.unregister_class
+ for cls in class_store:
+ unregister(cls)
+
def unregister():
print("Template Unregister", __file__)
+ import bpy
+
+ register = bpy.utils.register_class
+ for cls in class_store:
+ register(cls)
+ class_store.clear()
+
diff --git a/release/scripts/modules/bl_app_override.py b/release/scripts/modules/bl_app_override.py
new file mode 100644
index 0000000000..837f3542e6
--- /dev/null
+++ b/release/scripts/modules/bl_app_override.py
@@ -0,0 +1,48 @@
+
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8-80 compliant>
+
+"""
+Module to manage overriding various parts of Blender.
+
+Intended for use with 'app_templates', though it can be used from anywhere.
+"""
+
+class class_match:
+ # TODO, how to check these aren't from add-ons,
+ # templates might need to un-register while filtering.
+
+ @staticmethod
+ def _rna_subclasses(cls_parent):
+ for cls in cls_parent.__subclasses__():
+ yield cls
+
+ @staticmethod
+ def panel(*, bl_category=None, bl_space_type=None, bl_region_type=None):
+ # None or set
+ import bpy
+ for cls in class_match._rna_subclasses(bpy.types.Panel):
+ if bl_category is not None and cls.bl_category not in bl_category:
+ continue
+ if bl_space_type is not None and cls.bl_space_type not in bl_space_type:
+ continue
+ if bl_region_type is not None and cls.bl_region_type not in bl_region_type:
+ continue
+ yield cls
More information about the Bf-blender-cvs
mailing list