diff options
author | Andrea Weikert <elubie@gmx.net> | 2010-07-04 19:35:23 +0400 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2010-07-04 19:35:23 +0400 |
commit | ca81aa704e958a73a55e79654f70eaa9a0fad85a (patch) | |
tree | 8b40e3a7613df4e707fcc8efb3a099f9445ac350 /source/blender/editors/space_file | |
parent | 3ca7b160a664e74c6815056a4a8596bb4c2b70be (diff) |
Patch [#22339] File/installation paths changes
Patch Tracker: http://projects.blender.org/tracker/?func=detail&aid=22339&group_id=9&atid=127
This patch implements the proposal outlined here:
http://wiki.blender.org/index.php/Dev:2.5/Source/Installation/Proposal
Original patch by Matt Ebb.
Contributions by Nathan Letwory, Damien Plisson and Andrea Weikert
NOTE:
This is a work in progress commit, some work still needs to be done on the SCons and CMake files for this to work properly, but at least should compile and the files should be created in the right directory.
Commit discussed on IRC with Ton and Campbell.
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 56 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 13 |
4 files changed, 49 insertions, 31 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 7c2a2f436cc..55a44b36a52 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -391,7 +391,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *op) char name[FILE_MAX]; fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1); - BLI_make_file_string("/", name, BLI_gethome(), ".Bfs"); + BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); } @@ -423,7 +423,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) char name[FILE_MAX]; fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index); - BLI_make_file_string("/", name, BLI_gethome(), ".Bfs"); + BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); ED_area_tag_redraw(sa); } @@ -619,7 +619,7 @@ int file_exec(bContext *C, wmOperator *exec_op) folderlist_free(sfile->folders_next); fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1); - BLI_make_file_string(G.sce, filepath, BLI_gethome(), ".Bfs"); + BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu_get(), filepath); WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 08a6b5a8f34..a7d6288c3c9 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -248,7 +248,37 @@ void fsmenu_write_file(struct FSMenu* fsmenu, const char *filename) fclose(fp); } -void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename) +void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename) +{ + char line[256]; + FSMenuCategory category = FS_CATEGORY_BOOKMARKS; + FILE *fp; + + fp = fopen(filename, "r"); + if (!fp) return; + + while ( fgets ( line, 256, fp ) != NULL ) /* read a line */ + { + if (strncmp(line, "[Bookmarks]", 11)==0){ + category = FS_CATEGORY_BOOKMARKS; + } else if (strncmp(line, "[Recent]", 8)==0){ + category = FS_CATEGORY_RECENT; + } else { + int len = strlen(line); + if (len>0) { + if (line[len-1] == '\n') { + line[len-1] = '\0'; + } + if (BLI_exist(line)) { + fsmenu_insert_entry(fsmenu, category, line, 0, 1); + } + } + } + } + fclose(fp); +} + +void fsmenu_read_system(struct FSMenu* fsmenu) { char line[256]; FSMenuCategory category = FS_CATEGORY_BOOKMARKS; @@ -482,31 +512,9 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename) } #endif #endif - - fp = fopen(filename, "r"); - if (!fp) return; - - while ( fgets ( line, 256, fp ) != NULL ) /* read a line */ - { - if (strncmp(line, "[Bookmarks]", 11)==0){ - category = FS_CATEGORY_BOOKMARKS; - } else if (strncmp(line, "[Recent]", 8)==0){ - category = FS_CATEGORY_RECENT; - } else { - int len = strlen(line); - if (len>0) { - if (line[len-1] == '\n') { - line[len-1] = '\0'; - } - if (BLI_exist(line)) { - fsmenu_insert_entry(fsmenu, category, line, 0, 1); - } - } - } - } - fclose(fp); } + static void fsmenu_free_category(struct FSMenu* fsmenu, FSMenuCategory category) { FSMenuEntry *fsme= fsmenu_get_category(fsmenu, category); diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index 8304b104a4f..dcf8d3eb632 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -68,7 +68,10 @@ void fsmenu_remove_entry (struct FSMenu* fsmenu, FSMenuCategory category, int i void fsmenu_write_file (struct FSMenu* fsmenu, const char *filename); /** reads the 'bookmarks' from the specified file */ -void fsmenu_read_file (struct FSMenu* fsmenu, const char *filename); +void fsmenu_read_bookmarks (struct FSMenu* fsmenu, const char *filename); + + /** adds system specific directories */ +void fsmenu_read_system (struct FSMenu* fsmenu); /** Free's all the memory associated with the fsmenu */ void fsmenu_free (struct FSMenu* fsmenu); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 300a72851a4..261b7058151 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -591,9 +591,16 @@ void ED_spacetype_file(void) void ED_file_init(void) { - char name[FILE_MAX]; - BLI_make_file_string("/", name, BLI_gethome(), ".Bfs"); - fsmenu_read_file(fsmenu_get(), name); + char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL); + + fsmenu_read_system(fsmenu_get()); + + if (cfgdir) { + char name[FILE_MAX]; + BLI_make_file_string("/", name, cfgdir, BLENDER_BOOKMARK_FILE); + fsmenu_read_bookmarks(fsmenu_get(), name); + } + filelist_init_icons(); IMB_thumb_makedirs(); } |