From cf75e5b78cf197ce24551db2d084be90adecfb78 Mon Sep 17 00:00:00 2001 From: Willian Padovani Germano Date: Fri, 2 Mar 2007 18:15:41 +0000 Subject: [PATCH] Interface: Added option "Load Factory Settings" in the "File" menu. With this, users don't have to remove .B.blend if they want to load the default data stored in Blender. Thanks Ton for ok'ing it and suggesting a better place in the menu (I had put it as "New (factory defaults)"). --- source/blender/include/BIF_usiblender.h | 2 +- source/blender/python/api2_2x/Blender.c | 2 +- source/blender/src/header_info.c | 10 ++++++++-- source/blender/src/toets.c | 2 +- source/blender/src/usiblender.c | 8 ++++---- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/source/blender/include/BIF_usiblender.h b/source/blender/include/BIF_usiblender.h index 75435cc4279..e7475af3ab7 100644 --- a/source/blender/include/BIF_usiblender.h +++ b/source/blender/include/BIF_usiblender.h @@ -43,7 +43,7 @@ void exit_usiblender(void); void BIF_init(void); void BIF_read_file(char *name); -int BIF_read_homefile(void); +int BIF_read_homefile(int from_memory); void BIF_read_autosavefile(void); void BIF_write_file(char *target); diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index e6f98b0e8d3..4700c221bff 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -640,7 +640,7 @@ static PyObject *Blender_Load( PyObject * self, PyObject * args ) * enough here. Note: the default file requires extra clean-up done by * BIF_read_homefile: freeing the user theme data. */ if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) ) - BIF_read_homefile( ); + BIF_read_homefile(0); else BIF_read_file( fname ); diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index be863259bd8..4749d616e70 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -828,7 +828,7 @@ static void do_info_filemenu(void *arg, int event) switch(event) { case 0: if (okee("Erase All")) { - if (!BIF_read_homefile()) + if (!BIF_read_homefile(0)) error("No file ~/.B.blend"); } break; @@ -907,7 +907,12 @@ static void do_info_filemenu(void *arg, int event) case 31: /* save default settings */ BIF_write_homefile(); break; - + case 32: + if (okee("Erase All")) { + if (!BIF_read_homefile(1)) + error("Can't read data from memory!"); + } + break; case 35: /* compress toggle */ U.flag ^= (USER_FILECOMPRESS); break; @@ -996,6 +1001,7 @@ static uiBlock *info_filemenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Default Settings|Ctrl U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 31, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Load Factory Settings", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 32, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index 5ee1a2991d4..7d45b432b2b 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -884,7 +884,7 @@ int blenderqread(unsigned short event, short val) if(textspace==0 && textediting==0) { if(G.qual==LR_CTRLKEY) { if(okee("Erase all")) { - if( BIF_read_homefile()==0) error("No file ~/.B.blend"); + if( BIF_read_homefile(0)==0) error("No file ~/.B.blend"); } return 0; } diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index 725d8742892..140e97d4028 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -470,7 +470,7 @@ static void outliner_242_patch(void) } /* only here settings for fullscreen */ -int BIF_read_homefile(void) +int BIF_read_homefile(int from_memory) { char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR]; char *home= BLI_gethome(); @@ -490,13 +490,13 @@ int BIF_read_homefile(void) BLI_freelistN(&G.ttfdata); G.relbase_valid = 0; - BLI_make_file_string(G.sce, tstr, home, ".B.blend"); + if (!from_memory) BLI_make_file_string(G.sce, tstr, home, ".B.blend"); strcpy(scestr, G.sce); /* temporal store */ /* prevent loading no UI */ G.fileflags &= ~G_FILE_NO_UI; - if (BLI_exists(tstr)) { + if (!from_memory && BLI_exists(tstr)) { success = BKE_read_file(tstr, NULL); } else { success = BKE_read_file_from_memory(datatoc_B_blend, datatoc_B_blend_size, NULL); @@ -858,7 +858,7 @@ void BIF_init(void) init_node_butfuncs(); BIF_preview_init_dbase(); - BIF_read_homefile(); + BIF_read_homefile(0); BIF_resources_init(); /* after homefile, to dynamically load an icon file based on theme settings */