-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path__init__.py
125 lines (110 loc) · 3.89 KB
/
__init__.py
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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.
#
# ##### END GPL LICENSE BLOCK #####
from os.path import join
from bpy.utils import register_class, unregister_class
from bpy.types import Menu
from bpy.types import Header
from bpy.types import Scene
from bpy.types import Operator, AddonPreferences
from bpy.props import StringProperty, BoolProperty, PointerProperty
from .ui import *
from .freesound import *
class ApiAddonPreferences(AddonPreferences):
# this must match the addon name, use '__package__'
# when defining this in a submodule of a python package.
"""Check the check the check"""
bl_idname = __package__
freesound_api : StringProperty(
subtype = "PASSWORD",
name = "Insert your API Key",
description = "Your freesound API Key.",
default = "Get it here http://www.freesound.org/apiv2/apply/"
)
freesound_project_folder_pattern : StringProperty(
name = "Folder name for download",
description = "Folder name for download in a specific folder alongside blend file",
default = "freesound_downloads"
)
freesound_download_folderpath : StringProperty(
name = "Common folder path for download",
description = "Common folder path where freesound downloads are stored",
subtype = 'DIR_PATH',
default = join(bpy.utils.user_resource('DATAFILES'), "freesound_downloads")
)
freesound_access : BoolProperty()
def draw(self, context):
layout = self.layout
box = layout.box()
box.prop(self, "freesound_api")
if (self.freesound_access):
box.operator("freesound.validate", text="Validated")
else:
box.operator("freesound.validate", text="Validate your API Key")
box = layout.box()
box.prop(self, "freesound_project_folder_pattern")
box.prop(self, "freesound_download_folderpath")
bl_info = {
"name": "Freesound",
"author": "Salvatore De Paolis",
"version": (2, 1),
"blender": (2, 80, 0),
"category": "Sequencer",
"location": "Sequencer",
"description": "Connect to freesound to list sounds",
"wiki_url": "http://freesound.org/apiv2/apply",
"tracker_url": "https://blenderartists.org/t/freesound-add-on/671946",
"support": "COMMUNITY"}
if "bpy" in locals():
import imp
from . import ui
imp.reload(ui)
else:
from . import ui
classes = (
ApiAddonPreferences,
FREESOUND_UL_List,
Freesound_Play,
FreeSoundItem,
FreeSoundData,
Freesound_Page,
Freesound_Validate,
Freesound_Info,
Freesound_Add,
Freesound_Search,
Freesound_Next,
Freesound_Next10,
Freesound_Last,
Freesound_Prev,
Freesound_Prev10,
Freesound_First,
Freesound_Pause,
FREESOUND_PT_Panel,
FREESOUND_PT_subpanel_search,
FREESOUND_PT_subpanel_settings,
)
# Registration
def register():
for cls in classes:
register_class(cls)
# Extend the scene class here to include the addon data
Scene.freesound_data = PointerProperty(type=FreeSoundData)
def unregister():
for cls in classes:
unregister_class(cls)
if __name__ == '__main__':
register()