blob: b1ea9e5b353f595d24c568c4e6711935553d5198 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# SPDX-License-Identifier: GPL-2.0-or-later
"""
File Browser: Libraries Bookmark
The "Libraries" panel on the File Browser displays the path to all the
libraries linked to that .blend. So you can quickly go to the folders
related to the file.
Click on any path to go to that directory.
Developed during Caminandes Open Movie Project
"""
import bpy
class AMTH_FILE_PT_libraries(bpy.types.Panel):
bl_space_type = "FILE_BROWSER"
bl_region_type = "TOOLS"
bl_category = "Bookmarks"
bl_label = "Libraries"
def draw(self, context):
layout = self.layout
libs = bpy.data.libraries
libslist = []
# Build the list of folders from libraries
import os.path
for lib in libs:
directory_name = os.path.dirname(lib.filepath)
libslist.append(directory_name)
# Remove duplicates and sort by name
libslist = set(libslist)
libslist = sorted(libslist)
# Draw the box with libs
row = layout.row()
box = row.box()
if libslist:
col = box.column()
for filepath in libslist:
if filepath != "//":
row = col.row()
row.alignment = "LEFT"
props = row.operator(
AMTH_FILE_OT_directory_go_to.bl_idname,
text=filepath, icon="BOOKMARKS",
emboss=False)
props.filepath = filepath
else:
box.label(text="No libraries loaded")
class AMTH_FILE_OT_directory_go_to(bpy.types.Operator):
"""Go to this library"s directory"""
bl_idname = "file.directory_go_to"
bl_label = "Go To"
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
def execute(self, context):
bpy.ops.file.select_bookmark(dir=self.filepath)
return {"FINISHED"}
def register():
bpy.utils.register_class(AMTH_FILE_PT_libraries)
bpy.utils.register_class(AMTH_FILE_OT_directory_go_to)
def unregister():
bpy.utils.unregister_class(AMTH_FILE_PT_libraries)
bpy.utils.unregister_class(AMTH_FILE_OT_directory_go_to)
|