[Bf-extensions-cvs] [17d29368] master: POV-Ray: add templates to text editor menu when addon is enabled.
Bastien Montagne
noreply at git.blender.org
Thu Jun 15 09:59:41 CEST 2017
Commit: 17d293687324e86b2e94e6ca3574e294f3da3667
Author: Bastien Montagne
Date: Thu Jun 15 09:59:10 2017 +0200
Branches: master
https://developer.blender.org/rBA17d293687324e86b2e94e6ca3574e294f3da3667
POV-Ray: add templates to text editor menu when addon is enabled.
===================================================================
M render_povray/__init__.py
M render_povray/ui.py
===================================================================
diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index e66e44c2..b95103b9 100644
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -2175,6 +2175,7 @@ def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_add.prepend(ui.menu_func_add)
bpy.types.INFO_MT_file_import.append(ui.menu_func_import)
+ bpy.types.TEXT_MT_templates.append(ui.menu_func_templates)
#used for parametric objects:
addon_utils.enable("add_mesh_extra_objects", default_set=False, persistent=True)
@@ -2203,6 +2204,7 @@ def unregister():
#bpy.types.TEXTURE_PT_context_texture.remove(TEXTURE_PT_povray_type)
addon_utils.disable("add_mesh_extra_objects", default_set=False)
+ bpy.types.TEXT_MT_templates.remove(ui.menu_func_templates)
bpy.types.INFO_MT_file_import.remove(ui.menu_func_import)
bpy.types.INFO_MT_add.remove(ui.menu_func_add)
bpy.utils.unregister_module(__name__)
diff --git a/render_povray/ui.py b/render_povray/ui.py
index ba763871..0feecec9 100644
--- a/render_povray/ui.py
+++ b/render_povray/ui.py
@@ -1755,3 +1755,25 @@ class TEXT_PT_povray_custom_code(TextButtonsPanel, bpy.types.Panel):
if text:
layout.prop(text.pov, "custom_code", text="Add as POV code")
+
+###############################################"
+# Text editor templates.
+
+class TEXT_MT_templates_pov(bpy.types.Menu):
+ bl_label = "POV-Ray"
+
+ # We list templates on file evaluation, we can assume they are static data,
+ # and better avoid running this on every draw call.
+ import os
+ template_paths = [os.path.join(os.path.dirname(__file__), "templates_pov")]
+
+ def draw(self, context):
+ self.path_menu(
+ self.template_paths,
+ "text.open",
+ props_default={"internal": True},
+ )
+
+def menu_func_templates(self, context):
+ # Do not depend on POV-Ray being active renderer here...
+ self.layout.menu("TEXT_MT_templates_pov")
More information about the Bf-extensions-cvs
mailing list