1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 File Browser > Go to Current Blend's Folder
8 For when you're lost browsing files and want to go back to the currently
9 open blend's directory. Look for it on the File Browser's header, only
10 shows up if the file is saved.
15 # From space_filebrowser.py
16 def panel_poll_is_upper_region(region
):
17 # The upper region is left-aligned, the lower is split into it then.
18 # Note that after "Flip Regions" it's right-aligned.
19 return region
.alignment
in {'LEFT', 'RIGHT'}
22 class AMTH_FILE_OT_directory_current_blend(bpy
.types
.Operator
):
24 """Go to the directory of the currently open blend file"""
25 bl_idname
= "file.directory_current_blend"
26 bl_label
= "Current Blend's Folder"
28 def execute(self
, context
):
29 bpy
.ops
.file.select_bookmark(dir="//")
33 class FILEBROWSER_PT_amaranth(bpy
.types
.Panel
):
34 bl_space_type
= 'FILE_BROWSER'
35 bl_region_type
= 'TOOLS'
36 bl_category
= "Bookmarks"
38 bl_options
= {'HIDE_HEADER'}
41 def poll(cls
, context
):
42 return context
.area
.ui_type
== 'FILES' and panel_poll_is_upper_region(context
.region
)
44 def draw(self
, context
):
51 flow
= row
.grid_flow(row_major
=False, columns
=0, even_columns
=False, even_rows
=False, align
=True)
54 subsubrow
= subrow
.row(align
=True)
56 AMTH_FILE_OT_directory_current_blend
.bl_idname
,
61 AMTH_FILE_OT_directory_current_blend
,
62 FILEBROWSER_PT_amaranth
67 bpy
.utils
.register_class(cls
)
71 bpy
.utils
.unregister_class(cls
)