Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCansecoGPC <machaquiro@yahoo.es>2019-12-09 16:42:04 +0300
committerCansecoGPC <machaquiro@yahoo.es>2019-12-09 16:42:04 +0300
commit75af6e5dcf84cc2d2693374a01ecbad0f874701b (patch)
tree86d5ad098857a591e9f997881d762e839b33e98a /amaranth/scene/goto_library.py
parent395ca8a4be7a66c72a5556c51f958644601a846b (diff)
Amaranth: Add back from addons contrib
Diffstat (limited to 'amaranth/scene/goto_library.py')
-rw-r--r--amaranth/scene/goto_library.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/amaranth/scene/goto_library.py b/amaranth/scene/goto_library.py
new file mode 100644
index 00000000..08f1689c
--- /dev/null
+++ b/amaranth/scene/goto_library.py
@@ -0,0 +1,90 @@
+# 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.
+"""
+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)