change python scripts so modules which register with blender have a register() functi...
[blender.git] / release / scripts / ui / space_view3d_toolbar.py
index 98ea4c67b851241d96162ab2bc7b4d3b5ca43529..243c9304ae49ef12ee6315a01516452b934e410f 100644 (file)
@@ -903,28 +903,27 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel):
         sub = col.column()
         sub.prop(ipaint, "seam_bleed")
 
-    class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
-        bl_label = "Clone Layer"
 
-        def draw(self, context):
-            layout = self.layout
-            for i, tex in enumerate(context.active_object.data.uv_textures):
-                prop = layout.operator("wm.context_set_int", text=tex.name)
-                prop.path = "active_object.data.uv_texture_clone_index"
-                prop.value = i
+class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
+    bl_label = "Clone Layer"
+
+    def draw(self, context):
+        layout = self.layout
+        for i, tex in enumerate(context.active_object.data.uv_textures):
+            prop = layout.operator("wm.context_set_int", text=tex.name)
+            prop.path = "active_object.data.uv_texture_clone_index"
+            prop.value = i
 
-    class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
-        bl_label = "Mask Layer"
 
-        def draw(self, context):
-            layout = self.layout
-            for i, tex in enumerate(context.active_object.data.uv_textures):
-                prop = layout.operator("wm.context_set_int", text=tex.name)
-                prop.path = "active_object.data.uv_texture_stencil_index"
-                prop.value = i
+class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
+    bl_label = "Mask Layer"
 
-    bpy.types.register(VIEW3D_MT_tools_projectpaint_clone)
-    bpy.types.register(VIEW3D_MT_tools_projectpaint_stencil)
+    def draw(self, context):
+        layout = self.layout
+        for i, tex in enumerate(context.active_object.data.uv_textures):
+            prop = layout.operator("wm.context_set_int", text=tex.name)
+            prop.path = "active_object.data.uv_texture_stencil_index"
+            prop.value = i
 
 
 class VIEW3D_PT_tools_particlemode(View3DPanel):
@@ -990,26 +989,43 @@ class VIEW3D_PT_tools_particlemode(View3DPanel):
         sub.active = pe.fade_time
         sub.prop(pe, "fade_frames", slider=True)
 
-bpy.types.register(VIEW3D_PT_tools_weightpaint)
-bpy.types.register(VIEW3D_PT_tools_objectmode)
-bpy.types.register(VIEW3D_PT_tools_meshedit)
-bpy.types.register(VIEW3D_PT_tools_meshedit_options)
-bpy.types.register(VIEW3D_PT_tools_curveedit)
-bpy.types.register(VIEW3D_PT_tools_surfaceedit)
-bpy.types.register(VIEW3D_PT_tools_textedit)
-bpy.types.register(VIEW3D_PT_tools_armatureedit)
-bpy.types.register(VIEW3D_PT_tools_armatureedit_options)
-bpy.types.register(VIEW3D_PT_tools_mballedit)
-bpy.types.register(VIEW3D_PT_tools_latticeedit)
-bpy.types.register(VIEW3D_PT_tools_posemode)
-bpy.types.register(VIEW3D_PT_tools_posemode_options)
-bpy.types.register(VIEW3D_PT_tools_brush)
-bpy.types.register(VIEW3D_PT_tools_brush_texture)
-bpy.types.register(VIEW3D_PT_tools_brush_tool)
-bpy.types.register(VIEW3D_PT_tools_brush_stroke)
-bpy.types.register(VIEW3D_PT_tools_brush_curve)
-bpy.types.register(VIEW3D_PT_sculpt_options)
-bpy.types.register(VIEW3D_PT_tools_vertexpaint)
-bpy.types.register(VIEW3D_PT_tools_weightpaint_options)
-bpy.types.register(VIEW3D_PT_tools_projectpaint)
-bpy.types.register(VIEW3D_PT_tools_particlemode)
+
+classes = [
+    VIEW3D_PT_tools_weightpaint,
+    VIEW3D_PT_tools_objectmode,
+    VIEW3D_PT_tools_meshedit,
+    VIEW3D_PT_tools_meshedit_options,
+    VIEW3D_PT_tools_curveedit,
+    VIEW3D_PT_tools_surfaceedit,
+    VIEW3D_PT_tools_textedit,
+    VIEW3D_PT_tools_armatureedit,
+    VIEW3D_PT_tools_armatureedit_options,
+    VIEW3D_PT_tools_mballedit,
+    VIEW3D_PT_tools_latticeedit,
+    VIEW3D_PT_tools_posemode,
+    VIEW3D_PT_tools_posemode_options,
+    VIEW3D_PT_tools_brush,
+    VIEW3D_PT_tools_brush_texture,
+    VIEW3D_PT_tools_brush_tool,
+    VIEW3D_PT_tools_brush_stroke,
+    VIEW3D_PT_tools_brush_curve,
+    VIEW3D_PT_sculpt_options,
+    VIEW3D_PT_tools_vertexpaint,
+    VIEW3D_PT_tools_weightpaint_options,
+
+    VIEW3D_PT_tools_projectpaint,
+    VIEW3D_MT_tools_projectpaint_clone,
+    VIEW3D_MT_tools_projectpaint_stencil,
+
+    VIEW3D_PT_tools_particlemode]
+
+
+def register():
+    register = bpy.types.register
+    for cls in classes:
+        register(cls)
+
+def unregister():
+    unregister = bpy.types.unregister
+    for cls in classes:
+        unregister(cls)