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 | |
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')
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 41 | ||||
-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 | ||||
-rw-r--r-- | source/blender/editors/space_image/SConscript | 1 | ||||
-rw-r--r-- | source/blender/editors/space_info/space_info.c | 31 |
7 files changed, 97 insertions, 56 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 622b9ddbfdf..499fe3b9767 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -457,25 +457,20 @@ static void init_internal_icons() ImBuf *bbuf= NULL; int x, y, icontype; char iconfilestr[FILE_MAXDIR+FILE_MAXFILE]; - char filenamestr[FILE_MAXFILE+16]; // 16 == strlen(".blender/icons/")+1 if ((btheme!=NULL) && (strlen(btheme->tui.iconfile) > 0)) { - -#ifdef WIN32 - sprintf(filenamestr, "icons/%s", btheme->tui.iconfile); -#else - sprintf(filenamestr, ".blender/icons/%s", btheme->tui.iconfile); -#endif - - BLI_make_file_string("/", iconfilestr, BLI_gethome(), filenamestr); - - if (BLI_exists(iconfilestr)) { - bbuf = IMB_loadiffname(iconfilestr, IB_rect); - if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) { - if (G.f & G_DEBUG) - printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr); - IMB_freeImBuf(bbuf); - bbuf= NULL; + char *datadir= BLI_get_folder(BLENDER_DATAFILES, NULL); + if (datadir) { + BLI_make_file_string("/", iconfilestr, datadir, btheme->tui.iconfile); + + if (BLI_exists(iconfilestr)) { + bbuf = IMB_loadiffname(iconfilestr, IB_rect); + if(bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H) { + if (G.f & G_DEBUG) + printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr); + IMB_freeImBuf(bbuf); + bbuf= NULL; + } } } } @@ -555,14 +550,14 @@ static void init_iconfile_list(struct ListBase *list) char icondirstr[FILE_MAX]; char iconfilestr[FILE_MAX+16]; /* allow 256 chars for file+dir */ char olddir[FILE_MAX]; - + char *datadir= NULL; + list->first = list->last = NULL; + datadir = BLI_get_folder(BLENDER_DATAFILES, NULL); -#ifdef WIN32 - BLI_make_file_string("/", icondirstr, BLI_gethome(), "icons"); -#else - BLI_make_file_string("/", icondirstr, BLI_gethome(), ".blender/icons"); -#endif + if (!datadir) return; + + BLI_make_file_string("/", icondirstr, datadir, ""); if(BLI_exists(icondirstr)==0) return; 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(); } diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index b38e1473a0c..4e1918bc327 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -11,6 +11,7 @@ defs = [] if env['WITH_BF_LCMS']: defs.append('WITH_LCMS') + incs += ' ' + env['BF_LCMS_INC'] if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') if env['WITH_BF_TIFF']: diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 0d9f1c90489..0f483f4bcec 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -38,6 +38,7 @@ #include "BKE_context.h" #include "BKE_colortools.h" +#include "BKE_global.h" #include "BKE_screen.h" #include "BKE_utildefines.h" @@ -49,7 +50,7 @@ #include "WM_types.h" #include "UI_resources.h" - +#include "UI_interface.h" #include "info_intern.h" // own include @@ -179,6 +180,31 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn) } +static void recent_files_menu(const bContext *C, Menu *menu) +{ + struct RecentFile *recent; + uiLayout *layout= menu->layout; + uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); + if (G.recent_files.first) { + for(recent = G.recent_files.first; (recent); recent = recent->next) { + uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath); + } + } else { + uiItemL(layout, "No Recent Files", 0); + } +} + +void recent_files_menu_register() +{ + MenuType *mt; + + mt= MEM_callocN(sizeof(MenuType), "spacetype info menu recent files"); + strcpy(mt->idname, "INFO_MT_file_open_recent"); + strcpy(mt->label, "Open Recent..."); + mt->draw= recent_files_menu; + WM_menutype_add(mt); +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_info(void) { @@ -217,7 +243,8 @@ void ED_spacetype_info(void) BLI_addhead(&st->regiontypes, art); - + recent_files_menu_register(); + BKE_spacetype_register(st); } |