Drag and drop 2.5 integration! Finally, slashdot regulars can use
[blender-staging.git] / source / blender / editors / space_file / space_file.c
1 /**
2  * $Id:
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
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. 
10  *
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.
15  *
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <string.h>
30 #include <stdio.h>
31
32 #include "DNA_object_types.h"
33 #include "DNA_space_types.h"
34 #include "DNA_scene_types.h"
35 #include "DNA_screen_types.h"
36
37 #include "RNA_access.h"
38
39 #include "MEM_guardedalloc.h"
40
41 #include "BIF_gl.h"
42
43 #include "BLO_readfile.h"
44
45 #include "BLI_blenlib.h"
46 #include "BLI_math.h"
47 #include "BLI_rand.h"
48 #include "BLI_storage_types.h"
49
50 #include "BKE_colortools.h"
51 #include "BKE_context.h"
52 #include "BKE_screen.h"
53
54 #include "ED_space_api.h"
55 #include "ED_screen.h"
56 #include "ED_fileselect.h"
57
58 #include "IMB_imbuf_types.h"
59 #include "IMB_thumbs.h"
60
61 #include "WM_api.h"
62 #include "WM_types.h"
63
64 #include "UI_interface.h"
65 #include "UI_resources.h"
66 #include "UI_view2d.h"
67
68
69 #include "ED_markers.h"
70 #include "ED_fileselect.h"
71
72 #include "file_intern.h"        // own include
73 #include "fsmenu.h"
74 #include "filelist.h"
75
76 /* ******************** default callbacks for file space ***************** */
77
78 static SpaceLink *file_new(const bContext *C)
79 {
80         ARegion *ar;
81         SpaceFile *sfile;
82         
83         sfile= MEM_callocN(sizeof(SpaceFile), "initfile");
84         sfile->spacetype= SPACE_FILE;
85
86         /* header */
87         ar= MEM_callocN(sizeof(ARegion), "header for file");
88         BLI_addtail(&sfile->regionbase, ar);
89         ar->regiontype= RGN_TYPE_HEADER;
90         ar->alignment= RGN_ALIGN_TOP;
91
92         /* channel list region */
93         ar= MEM_callocN(sizeof(ARegion), "channel area for file");
94         BLI_addtail(&sfile->regionbase, ar);
95         ar->regiontype= RGN_TYPE_CHANNELS;
96         ar->alignment= RGN_ALIGN_LEFT;  
97
98         /* ui list region */
99         ar= MEM_callocN(sizeof(ARegion), "ui area for file");
100         BLI_addtail(&sfile->regionbase, ar);
101         ar->regiontype= RGN_TYPE_UI;
102         ar->alignment= RGN_ALIGN_TOP;
103
104         /* main area */
105         ar= MEM_callocN(sizeof(ARegion), "main area for file");
106         BLI_addtail(&sfile->regionbase, ar);
107         ar->regiontype= RGN_TYPE_WINDOW;
108         ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
109         ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
110         ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
111         ar->v2d.keeptot= V2D_KEEPTOT_STRICT;
112         ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
113
114         return (SpaceLink *)sfile;
115 }
116
117 /* not spacelink itself */
118 static void file_free(SpaceLink *sl)
119 {       
120         SpaceFile *sfile= (SpaceFile *) sl;
121         
122         if(sfile->files) {
123                 filelist_freelib(sfile->files);
124                 filelist_free(sfile->files);
125                 MEM_freeN(sfile->files);
126                 sfile->files= NULL;
127         }
128
129         if(sfile->folders_prev) {
130                 folderlist_free(sfile->folders_prev);
131                 MEM_freeN(sfile->folders_prev);
132                 sfile->folders_prev= NULL;
133         }
134
135         if(sfile->folders_next) {
136                 folderlist_free(sfile->folders_next);
137                 MEM_freeN(sfile->folders_next);
138                 sfile->folders_next= NULL;
139         }
140
141         if (sfile->params) {
142                 if(sfile->params->pupmenu)
143                         MEM_freeN(sfile->params->pupmenu);
144                 MEM_freeN(sfile->params);
145                 sfile->params= NULL;
146         }
147
148         if (sfile->layout) {
149                 MEM_freeN(sfile->layout);
150                 sfile->layout = NULL;
151         }
152 }
153
154
155 /* spacetype; init callback, area size changes, screen set, etc */
156 static void file_init(struct wmWindowManager *wm, ScrArea *sa)
157 {
158         SpaceFile *sfile= (SpaceFile*)sa->spacedata.first;
159         //printf("file_init\n");
160
161         if(sfile->layout) sfile->layout->dirty= 1;
162 }
163
164
165 static SpaceLink *file_duplicate(SpaceLink *sl)
166 {
167         SpaceFile *sfileo= (SpaceFile*)sl;
168         SpaceFile *sfilen= MEM_dupallocN(sl);
169         
170         /* clear or remove stuff from old */
171         sfilen->op = NULL; /* file window doesn't own operators */
172
173         if (sfileo->params)
174                 sfilen->files = filelist_new(sfileo->params->type);
175         if(sfileo->folders_prev)
176                 sfilen->folders_prev = folderlist_duplicate(sfileo->folders_prev);
177
178         if(sfileo->folders_next)
179                 sfilen->folders_next = folderlist_duplicate(sfileo->folders_next);
180
181         if(sfileo->params) {
182                 sfilen->params= MEM_dupallocN(sfileo->params);
183                 file_change_dir(sfilen, 0);
184         }
185         if (sfileo->layout) {
186                 sfilen->layout= MEM_dupallocN(sfileo->layout);
187         }
188         return (SpaceLink *)sfilen;
189 }
190
191 static void file_refresh(const bContext *C, ScrArea *sa)
192 {
193         SpaceFile *sfile= CTX_wm_space_file(C);
194         FileSelectParams *params = ED_fileselect_get_params(sfile);
195
196         if (!sfile->folders_prev)
197                 sfile->folders_prev = folderlist_new();
198         if (!sfile->files) {
199                 sfile->files = filelist_new(params->type);
200                 file_change_dir(sfile, 0);
201                 params->active_file = -1; // added this so it opens nicer (ton)
202         }
203         filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT);
204         filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0);      
205         if (filelist_empty(sfile->files))
206         {
207                 filelist_readdir(sfile->files);
208                 BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX);
209         }
210         if(params->sort!=FILE_SORT_NONE) filelist_sort(sfile->files, params->sort);             
211         
212         if (params->renamefile[0] != '\0') {
213                 int idx = filelist_find(sfile->files, params->renamefile);
214                 if (idx >= 0) {
215                         struct direntry *file= filelist_file(sfile->files, idx);
216                         if (file) {
217                                 file->flags |= EDITING;
218                         }
219                 }
220                 params->renamefile[0] = '\0';
221         }
222         if (sfile->layout) sfile->layout->dirty= 1;
223
224 }
225
226 static void file_listener(ScrArea *sa, wmNotifier *wmn)
227 {
228         SpaceFile* sfile = (SpaceFile*)sa->spacedata.first;
229
230         /* context changes */
231         switch(wmn->category) {
232                 case NC_SPACE:
233                         switch (wmn->data) {
234                                 case ND_SPACE_FILE_LIST:
235                                         if (sfile->files) filelist_free(sfile->files);
236                                         ED_area_tag_refresh(sa);
237                                         ED_area_tag_redraw(sa);
238                                         break;
239                                 case ND_SPACE_FILE_PARAMS:
240                                         ED_area_tag_refresh(sa);
241                                         ED_area_tag_redraw(sa);
242                                         break;
243                         }
244                         break;
245         }
246 }
247
248 /* add handlers, stuff you only do once or on area/region changes */
249 static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
250 {
251         wmKeyMap *keymap;
252         
253         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
254         
255         /* own keymaps */
256         keymap= WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
257         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
258
259         keymap= WM_keymap_find(wm->defaultconf, "File Browser Main", SPACE_FILE, 0);
260         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
261                                                            
262
263 }
264
265 static void file_main_area_listener(ARegion *ar, wmNotifier *wmn)
266 {
267         /* context changes */
268         switch(wmn->category) {
269                 case NC_SPACE:
270                         switch (wmn->data) {
271                                 case ND_SPACE_FILE_LIST:
272                                         ED_region_tag_redraw(ar);
273                                         break;
274                                 case ND_SPACE_FILE_PARAMS:
275                                         ED_region_tag_redraw(ar);
276                                         break;
277                         }
278                         break;
279         }
280 }
281
282 static void file_main_area_draw(const bContext *C, ARegion *ar)
283 {
284         /* draw entirely, view changes should be handled here */
285         SpaceFile *sfile= CTX_wm_space_file(C);
286         FileSelectParams *params = ED_fileselect_get_params(sfile);
287         FileLayout *layout=NULL;
288
289         View2D *v2d= &ar->v2d;
290         View2DScrollers *scrollers;
291         float col[3];
292
293         /* Needed, because filelist is not initialized on loading */
294         if (!sfile->files || filelist_empty(sfile->files))
295                 file_refresh(C, NULL);
296
297         layout = ED_fileselect_get_layout(sfile, ar);
298
299         /* clear and setup matrix */
300         UI_GetThemeColor3fv(TH_BACK, col);
301         glClearColor(col[0], col[1], col[2], 0.0);
302         glClear(GL_COLOR_BUFFER_BIT);
303         
304         /* Allow dynamically sliders to be set, saves notifiers etc. */
305         if (layout && (layout->flag == FILE_LAYOUT_VER)) {
306                 v2d->scroll = V2D_SCROLL_RIGHT;
307                 v2d->keepofs &= ~V2D_LOCKOFS_Y;
308                 v2d->keepofs |= V2D_LOCKOFS_X;
309         }
310         else {
311                 v2d->scroll = V2D_SCROLL_BOTTOM;
312                 v2d->keepofs &= ~V2D_LOCKOFS_X;
313                 v2d->keepofs |= V2D_LOCKOFS_Y;
314         }
315         /* v2d has initialized flag, so this call will only set the mask correct */
316         UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
317
318         /* sets tile/border settings in sfile */
319         file_calc_previews(C, ar);
320
321         /* set view */
322         UI_view2d_view_ortho(C, v2d);
323         
324         /* on first read, find active file */
325         if (params->active_file == -1) {
326                 wmEvent *event= CTX_wm_window(C)->eventstate;
327                 file_hilight_set(sfile, ar, event->x, event->y);
328         }
329         
330         file_draw_list(C, ar);
331         
332         /* reset view matrix */
333         UI_view2d_view_restore(C);
334         
335         /* scrollers */
336         scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
337         UI_view2d_scrollers_draw(C, v2d, scrollers);
338         UI_view2d_scrollers_free(scrollers);
339
340 }
341
342 void file_operatortypes(void)
343 {
344         WM_operatortype_append(FILE_OT_select);
345         WM_operatortype_append(FILE_OT_select_all_toggle);
346         WM_operatortype_append(FILE_OT_select_border);
347         WM_operatortype_append(FILE_OT_select_bookmark);
348         WM_operatortype_append(FILE_OT_loadimages);
349         WM_operatortype_append(FILE_OT_highlight);
350         WM_operatortype_append(FILE_OT_execute);
351         WM_operatortype_append(FILE_OT_cancel);
352         WM_operatortype_append(FILE_OT_parent);
353         WM_operatortype_append(FILE_OT_previous);
354         WM_operatortype_append(FILE_OT_next);
355         WM_operatortype_append(FILE_OT_refresh);
356         WM_operatortype_append(FILE_OT_bookmark_toggle);
357         WM_operatortype_append(FILE_OT_bookmark_add);
358         WM_operatortype_append(FILE_OT_delete_bookmark);
359         WM_operatortype_append(FILE_OT_hidedot);
360         WM_operatortype_append(FILE_OT_filenum);
361         WM_operatortype_append(FILE_OT_directory_new);
362         WM_operatortype_append(FILE_OT_delete);
363         WM_operatortype_append(FILE_OT_rename);
364 }
365
366 /* NOTE: do not add .blend file reading on this level */
367 void file_keymap(struct wmKeyConfig *keyconf)
368 {
369         wmKeyMapItem *kmi;
370         /* keys for all areas */
371         wmKeyMap *keymap= WM_keymap_find(keyconf, "File Browser", SPACE_FILE, 0);
372         WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", NKEY, KM_PRESS, 0, 0);
373         WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
374         WM_keymap_add_item(keymap, "FILE_OT_bookmark_add", BKEY, KM_PRESS, KM_CTRL, 0);
375         WM_keymap_add_item(keymap, "FILE_OT_hidedot", HKEY, KM_PRESS, 0, 0);
376         WM_keymap_add_item(keymap, "FILE_OT_previous", BACKSPACEKEY, KM_PRESS, 0, 0);
377         WM_keymap_add_item(keymap, "FILE_OT_next", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0);
378         WM_keymap_add_item(keymap, "FILE_OT_directory_new", IKEY, KM_PRESS, 0, 0);  /* XXX needs button */
379         WM_keymap_add_item(keymap, "FILE_OT_delete", XKEY, KM_PRESS, 0, 0);
380         WM_keymap_add_item(keymap, "FILE_OT_delete", DELKEY, KM_PRESS, 0, 0);
381
382         /* keys for main area */
383         keymap= WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0);
384         WM_keymap_add_item(keymap, "FILE_OT_select_execute", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
385         WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, 0, 0);
386         kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0);
387         RNA_boolean_set(kmi->ptr, "extend", 1);
388         WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
389         WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
390         WM_keymap_add_item(keymap, "FILE_OT_select_border", EVT_TWEAK_L, KM_ANY, 0, 0);
391         WM_keymap_add_item(keymap, "FILE_OT_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
392         WM_keymap_add_item(keymap, "FILE_OT_highlight", MOUSEMOVE, KM_ANY, KM_ANY, 0);
393         WM_keymap_add_item(keymap, "FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0);
394         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
395         RNA_int_set(kmi->ptr, "increment", 1);
396         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0);
397         RNA_int_set(kmi->ptr, "increment", 10);
398         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
399         RNA_int_set(kmi->ptr, "increment", 100);
400         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0,0);
401         RNA_int_set(kmi->ptr, "increment", -1);
402         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT, 0);
403         RNA_int_set(kmi->ptr, "increment", -10);
404         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0);
405         RNA_int_set(kmi->ptr, "increment",-100);
406         
407         /* keys for button area (top) */
408         keymap= WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0);
409         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0);
410         RNA_int_set(kmi->ptr, "increment", 1);
411         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_SHIFT, 0);
412         RNA_int_set(kmi->ptr, "increment", 10);
413         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
414         RNA_int_set(kmi->ptr, "increment", 100);
415         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, 0, 0);
416         RNA_int_set(kmi->ptr, "increment", -1);
417         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_SHIFT,0);
418         RNA_int_set(kmi->ptr, "increment", -10);
419         kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL,0);
420         RNA_int_set(kmi->ptr, "increment",-100);
421 }
422
423
424 static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
425 {
426         wmKeyMap *keymap;
427
428         ED_region_panels_init(wm, ar);
429
430         /* own keymaps */
431         keymap= WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); 
432         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
433 }
434
435 static void file_channel_area_draw(const bContext *C, ARegion *ar)
436 {
437         ED_region_panels(C, ar, 1, NULL, -1);
438 }
439
440 static void file_channel_area_listener(ARegion *ar, wmNotifier *wmn)
441 {
442         /* context changes */
443         switch(wmn->category) {
444                 
445         }
446 }
447
448 /* add handlers, stuff you only do once or on area/region changes */
449 static void file_header_area_init(wmWindowManager *wm, ARegion *ar)
450 {
451         ED_region_header_init(ar);
452 }
453
454 static void file_header_area_draw(const bContext *C, ARegion *ar)
455 {
456         ED_region_header(C, ar);
457 }
458
459 /* add handlers, stuff you only do once or on area/region changes */
460 static void file_ui_area_init(wmWindowManager *wm, ARegion *ar)
461 {
462         wmKeyMap *keymap;
463
464         UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
465
466         /* own keymap */
467         keymap= WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0);
468         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
469
470         keymap= WM_keymap_find(wm->defaultconf, "File Browser Buttons", SPACE_FILE, 0);
471         WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
472 }
473
474 static void file_ui_area_draw(const bContext *C, ARegion *ar)
475 {
476         float col[3];
477         /* clear */
478         UI_GetThemeColor3fv(TH_PANEL, col);
479         glClearColor(col[0], col[1], col[2], 0.0);
480         glClear(GL_COLOR_BUFFER_BIT);
481
482         /* set view2d view matrix for scrolling (without scrollers) */
483         UI_view2d_view_ortho(C, &ar->v2d);
484
485         file_draw_buttons(C, ar);
486
487         UI_view2d_view_restore(C);
488 }
489
490 static void file_ui_area_listener(ARegion *ar, wmNotifier *wmn)
491 {
492         /* context changes */
493         switch(wmn->category) {
494                 case NC_SPACE:
495                         switch (wmn->data) {
496                                 case ND_SPACE_FILE_LIST:
497                                         ED_region_tag_redraw(ar);
498                                         break;
499                         }
500                         break;
501         }
502 }
503
504 /* only called once, from space/spacetypes.c */
505 void ED_spacetype_file(void)
506 {
507         SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype file");
508         ARegionType *art;
509         
510         st->spaceid= SPACE_FILE;
511         strncpy(st->name, "File", BKE_ST_MAXNAME);
512         
513         st->new= file_new;
514         st->free= file_free;
515         st->init= file_init;
516         st->duplicate= file_duplicate;
517         st->refresh= file_refresh;
518         st->listener= file_listener;
519         st->operatortypes= file_operatortypes;
520         st->keymap= file_keymap;
521         
522         /* regions: main window */
523         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
524         art->regionid = RGN_TYPE_WINDOW;
525         art->init= file_main_area_init;
526         art->draw= file_main_area_draw;
527         art->listener= file_main_area_listener;
528         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
529         BLI_addhead(&st->regiontypes, art);
530         
531         /* regions: header */
532         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
533         art->regionid = RGN_TYPE_HEADER;
534         art->prefsizey= HEADERY;
535         art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
536         art->init= file_header_area_init;
537         art->draw= file_header_area_draw;
538         // art->listener= file_header_area_listener;
539         BLI_addhead(&st->regiontypes, art);
540         
541         /* regions: ui */
542         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
543         art->regionid = RGN_TYPE_UI;
544         art->prefsizey= 60;
545         art->keymapflag= ED_KEYMAP_UI;
546         art->listener= file_ui_area_listener;
547         art->init= file_ui_area_init;
548         art->draw= file_ui_area_draw;
549         BLI_addhead(&st->regiontypes, art);
550
551         /* regions: channels (directories) */
552         art= MEM_callocN(sizeof(ARegionType), "spacetype file region");
553         art->regionid = RGN_TYPE_CHANNELS;
554         art->prefsizex= 240;
555         art->keymapflag= ED_KEYMAP_UI;
556         art->listener= file_channel_area_listener;
557         art->init= file_channel_area_init;
558         art->draw= file_channel_area_draw;
559         BLI_addhead(&st->regiontypes, art);
560         file_panels_register(art);
561
562         BKE_spacetype_register(st);
563
564 }
565
566 void ED_file_init(void)
567 {
568         char name[FILE_MAX];
569         BLI_make_file_string("/", name, BLI_gethome(), ".Bfs");
570         fsmenu_read_file(fsmenu_get(), name);
571         filelist_init_icons();
572         IMB_thumb_makedirs();
573 }
574
575 void ED_file_exit(void)
576 {
577         fsmenu_free(fsmenu_get());
578         filelist_free_icons();
579 }