UI: Move Extensions repositories popover to header
[blender-addons-contrib.git] / system_project_folder.py
blob2ff1bce25d6d15ce10c404736f91ccb2cc1b34dc
1 # system_project_folder.py (c) 2010 Dany Lebel (Axon_D)
3 # ***** BEGIN GPL LICENSE BLOCK *****
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # ***** END GPL LICENCE BLOCK *****
22 bl_info = {
23 "name": "Project Folder",
24 "author": "Dany Lebel (Axon_D), Spirou4D",
25 "version": (0, 3, 1),
26 "blender": (2, 80, 0),
27 "location": "Info -> File Menu -> Project Folder",
28 "description": "Open the project folder in a file browser",
29 "warning": "",
30 "doc_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/System/Project_Folder",
31 "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
32 "category": "System"}
35 import bpy
36 import os
37 from platform import system as currentOS
40 class ProjectFolder(bpy.types.Operator):
41 """Open the Project Folder in a file Browser"""
42 bl_idname = "file.project_folder"
43 bl_label = "Project Folder"
46 def execute(self, context):
47 try :
48 path = self.path()
49 except ValueError:
50 self.report({'INFO'}, "No project folder yet")
51 return {'FINISHED'}
53 bpy.ops.wm.path_open(filepath=path)
56 return {'FINISHED'}
58 def path(self):
59 filepath = bpy.data.filepath
60 relpath = bpy.path.relpath(filepath)
61 path = filepath[0: -1 * (relpath.__len__() - 2)]
62 return path
65 # Registration
67 def menu_func(self, context):
68 self.layout.operator(
69 ProjectFolder.bl_idname,
70 text="Project Folder",
71 icon='FILEBROWSER')
73 def register():
74 bpy.utils.register_class(ProjectFolder)
75 bpy.types.TOPBAR_MT_file.prepend(menu_func)
77 def unregister():
78 bpy.utils.unregister_class(ProjectFolder)
79 bpy.types.TOPBAR_MT_file.remove(menu_func)
81 if __name__ == "__main__":
82 register()