Sun position: remove unused prop in HDRI mode
[blender-addons.git] / amaranth / scene / goto_library.py
blob08f1689c32cc6f682a7216a6b83d0107e2ae8a61
1 # This program is free software; you can redistribute it and/or
2 # modify it under the terms of the GNU General Public License
3 # as published by the Free Software Foundation; either version 2
4 # of the License, or (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software Foundation,
13 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 """
15 File Browser: Libraries Bookmark
17 The "Libraries" panel on the File Browser displays the path to all the
18 libraries linked to that .blend. So you can quickly go to the folders
19 related to the file.
21 Click on any path to go to that directory.
22 Developed during Caminandes Open Movie Project
23 """
25 import bpy
28 class AMTH_FILE_PT_libraries(bpy.types.Panel):
29 bl_space_type = "FILE_BROWSER"
30 bl_region_type = "TOOLS"
31 bl_category = "Bookmarks"
32 bl_label = "Libraries"
34 def draw(self, context):
35 layout = self.layout
37 libs = bpy.data.libraries
38 libslist = []
40 # Build the list of folders from libraries
41 import os.path
43 for lib in libs:
44 directory_name = os.path.dirname(lib.filepath)
45 libslist.append(directory_name)
47 # Remove duplicates and sort by name
48 libslist = set(libslist)
49 libslist = sorted(libslist)
51 # Draw the box with libs
52 row = layout.row()
53 box = row.box()
55 if libslist:
56 col = box.column()
57 for filepath in libslist:
58 if filepath != "//":
59 row = col.row()
60 row.alignment = "LEFT"
61 props = row.operator(
62 AMTH_FILE_OT_directory_go_to.bl_idname,
63 text=filepath, icon="BOOKMARKS",
64 emboss=False)
65 props.filepath = filepath
66 else:
67 box.label(text="No libraries loaded")
70 class AMTH_FILE_OT_directory_go_to(bpy.types.Operator):
72 """Go to this library"s directory"""
73 bl_idname = "file.directory_go_to"
74 bl_label = "Go To"
76 filepath: bpy.props.StringProperty(subtype="FILE_PATH")
78 def execute(self, context):
79 bpy.ops.file.select_bookmark(dir=self.filepath)
80 return {"FINISHED"}
83 def register():
84 bpy.utils.register_class(AMTH_FILE_PT_libraries)
85 bpy.utils.register_class(AMTH_FILE_OT_directory_go_to)
88 def unregister():
89 bpy.utils.unregister_class(AMTH_FILE_PT_libraries)
90 bpy.utils.unregister_class(AMTH_FILE_OT_directory_go_to)