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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
# ##### 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 #####
# <pep8 compliant>
import bpy
from bpy.types import Header, Panel, Menu
class FILEBROWSER_HT_header(Header):
bl_space_type = 'FILE_BROWSER'
def draw(self, context):
layout = self.layout
st = context.space_data
params = st.params
if st.active_operator is None:
layout.template_header()
row = layout.row()
row.separator()
row = layout.row(align=True)
row.operator("file.previous", text="", icon='BACK')
row.operator("file.next", text="", icon='FORWARD')
row.operator("file.parent", text="", icon='FILE_PARENT')
row.operator("file.refresh", text="", icon='FILE_REFRESH')
layout.separator()
layout.operator_context = 'EXEC_DEFAULT'
layout.operator("file.directory_new", icon='NEWFOLDER', text="")
layout.separator()
layout.operator_context = 'INVOKE_DEFAULT'
# can be None when save/reload with a file selector open
if params:
is_lib_browser = params.use_library_browsing
layout.prop(params, "recursion_level", text="")
layout.prop(params, "display_type", expand=True, text="")
layout.prop(params, "display_size", text="")
layout.prop(params, "sort_method", expand=True, text="")
layout.prop(params, "show_hidden", text="", icon='FILE_HIDDEN')
layout.prop(params, "use_filter", text="", icon='FILTER')
row = layout.row(align=True)
row.active = params.use_filter
row.prop(params, "use_filter_folder", text="")
if params.filter_glob:
# if st.active_operator and hasattr(st.active_operator, "filter_glob"):
# row.prop(params, "filter_glob", text="")
row.label(params.filter_glob)
else:
row.prop(params, "use_filter_blender", text="")
row.prop(params, "use_filter_backup", text="")
row.prop(params, "use_filter_image", text="")
row.prop(params, "use_filter_movie", text="")
row.prop(params, "use_filter_script", text="")
row.prop(params, "use_filter_font", text="")
row.prop(params, "use_filter_sound", text="")
row.prop(params, "use_filter_text", text="")
if is_lib_browser:
row.prop(params, "use_filter_blendid", text="")
if params.use_filter_blendid:
row.separator()
row.prop(params, "filter_id_category", text="")
row.separator()
row.prop(params, "filter_search", text="", icon='VIEWZOOM')
layout.template_running_jobs()
class FILEBROWSER_UL_dir(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
direntry = item
# space = context.space_data
icon = 'NONE'
if active_propname == "system_folders_active":
icon = 'DISK_DRIVE'
if active_propname == "system_bookmarks_active":
icon = 'BOOKMARKS'
if active_propname == "bookmarks_active":
icon = 'BOOKMARKS'
if active_propname == "recent_folders_active":
icon = 'FILE_FOLDER'
if self.layout_type in {'DEFAULT', 'COMPACT'}:
row = layout.row(align=True)
row.enabled = direntry.is_valid
# Non-editable entries would show grayed-out, which is bad in this specific case, so switch to mere label.
if direntry.is_property_readonly("name"):
row.label(text=direntry.name, icon=icon)
else:
row.prop(direntry, "name", text="", emboss=False, icon=icon)
elif self.layout_type == 'GRID':
layout.alignment = 'CENTER'
layout.prop(direntry, "path", text="")
class FILEBROWSER_PT_system_folders(Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Bookmarks"
bl_label = "System"
def draw(self, context):
layout = self.layout
space = context.space_data
if space.system_folders:
row = layout.row()
row.template_list("FILEBROWSER_UL_dir", "system_folders", space, "system_folders",
space, "system_folders_active", item_dyntip_propname="path", rows=1, maxrows=10)
class FILEBROWSER_PT_system_bookmarks(Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Bookmarks"
bl_label = "System Bookmarks"
@classmethod
def poll(cls, context):
return not context.user_preferences.filepaths.hide_system_bookmarks
def draw(self, context):
layout = self.layout
space = context.space_data
if space.system_bookmarks:
row = layout.row()
row.template_list("FILEBROWSER_UL_dir", "system_bookmarks", space, "system_bookmarks",
space, "system_bookmarks_active", item_dyntip_propname="path", rows=1, maxrows=10)
class FILEBROWSER_MT_bookmarks_specials(Menu):
bl_label = "Bookmarks Specials"
def draw(self, context):
layout = self.layout
layout.operator("file.bookmark_cleanup", icon='X', text="Cleanup")
layout.separator()
layout.operator("file.bookmark_move", icon='TRIA_UP_BAR', text="Move To Top").direction = 'TOP'
layout.operator("file.bookmark_move", icon='TRIA_DOWN_BAR', text="Move To Bottom").direction = 'BOTTOM'
class FILEBROWSER_PT_bookmarks(Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Bookmarks"
bl_label = "Bookmarks"
def draw(self, context):
layout = self.layout
space = context.space_data
if space.bookmarks:
row = layout.row()
num_rows = len(space.bookmarks)
row.template_list("FILEBROWSER_UL_dir", "bookmarks", space, "bookmarks",
space, "bookmarks_active", item_dyntip_propname="path",
rows=(2 if num_rows < 2 else 4), maxrows=10)
col = row.column(align=True)
col.operator("file.bookmark_add", icon='ZOOMIN', text="")
col.operator("file.bookmark_delete", icon='ZOOMOUT', text="")
col.menu("FILEBROWSER_MT_bookmarks_specials", icon='DOWNARROW_HLT', text="")
if num_rows > 1:
col.separator()
col.operator("file.bookmark_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("file.bookmark_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
else:
layout.operator("file.bookmark_add", icon='ZOOMIN')
class FILEBROWSER_PT_recent_folders(Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Bookmarks"
bl_label = "Recent"
@classmethod
def poll(cls, context):
return not context.user_preferences.filepaths.hide_recent_locations
def draw(self, context):
layout = self.layout
space = context.space_data
if space.recent_folders:
row = layout.row()
row.template_list("FILEBROWSER_UL_dir", "recent_folders", space, "recent_folders",
space, "recent_folders_active", item_dyntip_propname="path", rows=1, maxrows=10)
col = row.column(align=True)
col.operator("file.reset_recent", icon='X', text="")
class FILEBROWSER_PT_advanced_filter(Panel):
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Filter"
bl_label = "Advanced Filter"
@classmethod
def poll(cls, context):
# only useful in append/link (library) context currently...
return context.space_data.params.use_library_browsing
def draw(self, context):
layout = self.layout
space = context.space_data
params = space.params
if params and params.use_library_browsing:
layout.prop(params, "use_filter_blendid")
if params.use_filter_blendid:
layout.separator()
col = layout.column()
col.prop(params, "filter_id")
classes = (
FILEBROWSER_HT_header,
FILEBROWSER_UL_dir,
FILEBROWSER_PT_system_folders,
FILEBROWSER_PT_system_bookmarks,
FILEBROWSER_MT_bookmarks_specials,
FILEBROWSER_PT_bookmarks,
FILEBROWSER_PT_recent_folders,
FILEBROWSER_PT_advanced_filter,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)
|