[Bf-blender-cvs] [27ce761] asset-experiments: Reorganization: * Make 'clear preview' a C operator; * Move 'object preview generator' op in wm namespace; * Add those two to file-> data preview submenu.

Bastien Montagne noreply at git.blender.org
Mon Jan 12 17:47:03 CET 2015


Commit: 27ce761880f49c7074c1ad313e522507d2351011
Author: Bastien Montagne
Date:   Mon Jan 12 17:45:45 2015 +0100
Branches: asset-experiments
https://developer.blender.org/rB27ce761880f49c7074c1ad313e522507d2351011

Reorganization:
* Make 'clear preview' a C operator;
* Move 'object preview generator' op in wm namespace;
* Add those two to file-> data preview submenu.

===================================================================

D	release/scripts/startup/bl_operators/system_generate_blendfile_previews.py
M	release/scripts/startup/bl_operators/wm.py
M	release/scripts/startup/bl_ui/space_info.py
M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/release/scripts/startup/bl_operators/system_generate_blendfile_previews.py b/release/scripts/startup/bl_operators/system_generate_blendfile_previews.py
deleted file mode 100644
index 213dc4a..0000000
--- a/release/scripts/startup/bl_operators/system_generate_blendfile_previews.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# ##### 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 compliant>
-
-if "bpy" in locals():
-    import imp
-    imp.reload(preview_render)
-else:
-    import bpy
-    from bpy.types import (Operator,
-                          )
-    from bpy.props import (BoolProperty,
-                           CollectionProperty,
-                           EnumProperty,
-                           FloatProperty,
-                           FloatVectorProperty,
-                           IntProperty,
-                           PointerProperty,
-                           StringProperty,
-                           )
-    from bl_previews_utils import bl_previews_render as preview_render
-
-
-import os
-import subprocess
-
-
-class SYSTEM_OT_generate_previews(Operator):
-    """Generate selected .blend file's object previews"""
-    bl_idname = "system.blend_generate_previews"
-    bl_label = "Generate Blend Files Previews"
-    bl_options = {'REGISTER'}
-
-    # -----------
-    # File props.
-    files = CollectionProperty(type=bpy.types.OperatorFileListElement, options={'HIDDEN', 'SKIP_SAVE'})
-
-    directory = StringProperty(maxlen=1024, subtype='FILE_PATH', options={'HIDDEN', 'SKIP_SAVE'})
-
-    # Show only images/videos, and directories!
-    filter_blender = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
-    filter_folder = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
-
-    def invoke(self, context, event):
-        context.window_manager.fileselect_add(self)
-        return {'RUNNING_MODAL'}
-
-    def execute(self, context):
-        context.window_manager.progress_begin(0, len(self.files))
-        context.window_manager.progress_update(0)
-        for i, fn in enumerate(self.files):
-            blen_path = os.path.join(self.directory, fn.name)
-            cmmd = (
-                bpy.app.binary_path,
-                #~ "--background",
-                "--factory-startup",
-                blen_path,
-                "--python",
-                os.path.join(os.path.dirname(preview_render.__file__), "bl_previews_render.py"),
-                "--",
-                "bl_previews_render.py",  # arg parser expects first arg to be prog name!
-            )
-            # Not working (UI is not refreshed...).
-            #self.report({'INFO'}, "Extracting messages, this will take some time...")
-            if subprocess.call(cmmd):
-                self.report({'ERROR'}, "Previews generation process failed for file '%s'!" % blend_path)
-                context.window_manager.progress_end()
-                return {'CANCELLED'}
-            context.window_manager.progress_update(i + 1)
-        context.window_manager.progress_end()
-
-        return {'FINISHED'}
-
-class SYSTEM_OT_clear_previews(Operator):
-    """Clear selected .blend file's object previews"""
-    bl_idname = "system.blend_clear_previews"
-    bl_label = "Clear Blend Files Previews"
-    bl_options = {'REGISTER'}
-
-    # -----------
-    # File props.
-    files = CollectionProperty(type=bpy.types.OperatorFileListElement, options={'HIDDEN', 'SKIP_SAVE'})
-
-    directory = StringProperty(maxlen=1024, subtype='FILE_PATH', options={'HIDDEN', 'SKIP_SAVE'})
-
-    # Show only images/videos, and directories!
-    filter_blender = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
-    filter_folder = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
-
-    def invoke(self, context, event):
-        context.window_manager.fileselect_add(self)
-        return {'RUNNING_MODAL'}
-
-    def execute(self, context):
-        context.window_manager.progress_begin(0, len(self.files))
-        context.window_manager.progress_update(0)
-        for i, fn in enumerate(self.files):
-            blen_path = os.path.join(self.directory, fn.name)
-            cmmd = (
-                bpy.app.binary_path,
-                #~ "--background",
-                "--factory-startup",
-                blen_path,
-                "--python",
-                os.path.join(os.path.dirname(preview_render.__file__), "bl_previews_render.py"),
-                "--",
-                "bl_previews_render.py",  # arg parser expects first arg to be prog name!
-                "--clear",
-            )
-            # Not working (UI is not refreshed...).
-            #self.report({'INFO'}, "Extracting messages, this will take some time...")
-            if subprocess.call(cmmd):
-                self.report({'ERROR'}, "Previews clearing process failed for file '%s'!" % blend_path)
-                context.window_manager.progress_end()
-                return {'CANCELLED'}
-            context.window_manager.progress_update(i + 1)
-        context.window_manager.progress_end()
-
-        return {'FINISHED'}
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 8d04cb1..05d0a0c 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -25,6 +25,7 @@ from bpy.props import (StringProperty,
                        IntProperty,
                        FloatProperty,
                        EnumProperty,
+                       CollectionProperty,
                        )
 
 from bpy.app.translations import pgettext_tip as tip_
@@ -2114,3 +2115,60 @@ class WM_OT_addon_expand(Operator):
         info = addon_utils.module_bl_info(mod)
         info["show_expanded"] = not info["show_expanded"]
         return {'FINISHED'}
+
+# ########## Datablock previews... ##########
+
+class WM_OT_generate_previews(Operator):
+    """Generate selected .blend file's object and groups previews"""
+    bl_idname = "wm.previews_generate_objects"
+    bl_label = "Generate Object/Groups Previews"
+    bl_options = {'REGISTER'}
+
+    # -----------
+    # File props.
+    files = CollectionProperty(type=bpy.types.OperatorFileListElement, options={'HIDDEN', 'SKIP_SAVE'})
+
+    directory = StringProperty(maxlen=1024, subtype='FILE_PATH', options={'HIDDEN', 'SKIP_SAVE'})
+
+    # Show only images/videos, and directories!
+    filter_blender = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
+    filter_folder = BoolProperty(default=True, options={'HIDDEN', 'SKIP_SAVE'})
+
+    def invoke(self, context, event):
+        context.window_manager.fileselect_add(self)
+        return {'RUNNING_MODAL'}
+
+    def execute(self, context):
+        if "subprocess" in locals():
+            import imp
+            imp.reload(preview_render)
+        else:
+            import os
+            import subprocess
+            from bl_previews_utils import bl_previews_render as preview_render
+
+        context.window_manager.progress_begin(0, len(self.files))
+        context.window_manager.progress_update(0)
+        for i, fn in enumerate(self.files):
+            blen_path = os.path.join(self.directory, fn.name)
+            cmmd = (
+                bpy.app.binary_path,
+                #~ "--background",
+                "--factory-startup",
+                blen_path,
+                "--python",
+                os.path.join(os.path.dirname(preview_render.__file__), "bl_previews_render.py"),
+                "--",
+                "bl_previews_render.py",  # arg parser expects first arg to be prog name!
+            )
+            # Not working (UI is not refreshed...).
+            #self.report({'INFO'}, "Extracting messages, this will take some time...")
+            if subprocess.call(cmmd):
+                self.report({'ERROR'}, "Previews generation process failed for file '%s'!" % blend_path)
+                context.window_manager.progress_end()
+                return {'CANCELLED'}
+            context.window_manager.progress_update(i + 1)
+        context.window_manager.progress_end()
+
+        return {'FINISHED'}
+
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index b642b61..eaf653a 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -203,6 +203,10 @@ class INFO_MT_file_previews(Menu):
         layout = self.layout
 
         layout.operator("wm.previews_ensure")
+        layout.operator("wm.previews_generate_objects")
+
+        layout.separator()
+        layout.operator("wm.previews_clear")
 
 
 class INFO_MT_game(Menu):
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 4460af8..c50e648 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -74,6 +74,8 @@
 #include "BKE_brush.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
+#include "BKE_icons.h"
+#include "BKE_idcode.h"
 #include "BKE_idprop.h"
 #include "BKE_image.h"
 #include "BKE_library.h"
@@ -87,8 +89,6 @@
 #include "BKE_unit.h"
 #include "BKE_utildefines.h"
 
-#include "BKE_idcode.h"
-
 #include "BIF_gl.h"
 #include "BIF_glutil.h" /* for paint cursor */
 #include "BLF_api.h"
@@ -4883,6 +4883,74 @@ static void WM_OT_previews_ensure(wmOperatorType *ot)
 	ot->exec = previews_ensure_exec;
 }
 
+

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list