[Bf-extensions-cvs] [8fcd2e98] blender-v2.81-release: Amaranth: Fix "Current Blend's Folder" button missing in file browser.

Pablo Vazquez noreply at git.blender.org
Tue Oct 22 16:54:46 CEST 2019


Commit: 8fcd2e98daee4ac97f86d40a3e6cf730c38ac49d
Author: Pablo Vazquez
Date:   Tue Oct 22 16:54:42 2019 +0200
Branches: blender-v2.81-release
https://developer.blender.org/rBAC8fcd2e98daee4ac97f86d40a3e6cf730c38ac49d

Amaranth: Fix "Current Blend's Folder" button missing in file browser.

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

M	amaranth/__init__.py
M	amaranth/scene/current_blend.py

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

diff --git a/amaranth/__init__.py b/amaranth/__init__.py
index bd3a49d2..07efa619 100644
--- a/amaranth/__init__.py
+++ b/amaranth/__init__.py
@@ -87,8 +87,8 @@ from amaranth.misc import (
 bl_info = {
     "name": "Amaranth Toolset",
     "author": "Pablo Vazquez, Bassam Kurdali, Sergey Sharybin, Lukas Tönne, Cesar Saez, CansecoGPC",
-    "version": (1, 0, 7),
-    "blender": (2, 80, 0),
+    "version": (1, 0, 8),
+    "blender": (2, 81, 0),
     "location": "Everywhere!",
     "description": "A collection of tools and settings to improve productivity",
     "warning": "",
diff --git a/amaranth/scene/current_blend.py b/amaranth/scene/current_blend.py
index 6b984d1a..e3f4ca91 100644
--- a/amaranth/scene/current_blend.py
+++ b/amaranth/scene/current_blend.py
@@ -21,6 +21,12 @@ shows up if the file is saved.
 
 import bpy
 
+# From space_filebrowser.py
+def panel_poll_is_upper_region(region):
+    # The upper region is left-aligned, the lower is split into it then.
+    # Note that after "Flip Regions" it's right-aligned.
+    return region.alignment in {'LEFT', 'RIGHT'}
+
 
 class AMTH_FILE_OT_directory_current_blend(bpy.types.Operator):
 
@@ -33,19 +39,42 @@ class AMTH_FILE_OT_directory_current_blend(bpy.types.Operator):
         return {"FINISHED"}
 
 
-def button_directory_current_blend(self, context):
-    if bpy.data.filepath:
-        self.layout.operator(
-            AMTH_FILE_OT_directory_current_blend.bl_idname,
-            text="Current Blend's Folder",
-            icon="APPEND_BLEND")
+class FILEBROWSER_PT_amaranth(bpy.types.Panel):
+    bl_space_type = 'FILE_BROWSER'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
+    bl_label = "Amaranth"
+    bl_options = {'HIDE_HEADER'}
 
+    @classmethod
+    def poll(cls, context):
+        return panel_poll_is_upper_region(context.region)
 
-def register():
-    bpy.utils.register_class(AMTH_FILE_OT_directory_current_blend)
-    bpy.types.FILEBROWSER_HT_header.append(button_directory_current_blend)
+    def draw(self, context):
+      layout = self.layout
+      layout.scale_x = 1.3
+      layout.scale_y = 1.3
+
+      if bpy.data.filepath:
+          row = layout.row()
+          flow = row.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=True)
+
+          subrow = flow.row()
+          subsubrow = subrow.row(align=True)
+          subsubrow.operator(
+              AMTH_FILE_OT_directory_current_blend.bl_idname,
+              icon="DESKTOP")
 
 
+classes = (
+    AMTH_FILE_OT_directory_current_blend,
+    FILEBROWSER_PT_amaranth
+)
+
+def register():
+    for cls in classes:
+        bpy.utils.register_class(cls)
+
 def unregister():
-    bpy.utils.unregister_class(AMTH_FILE_OT_directory_current_blend)
-    bpy.types.FILEBROWSER_HT_header.remove(button_directory_current_blend)
+    for cls in classes:
+        bpy.utils.unregister_class(cls)



More information about the Bf-extensions-cvs mailing list