2.5: Load UI is now an operator property, and a user preference to

define what the default is, just like file compression for saving.
This commit is contained in:
Brecht Van Lommel 2009-08-21 14:33:53 +00:00
parent 1c614f6cf6
commit f2e7ca0de3
4 changed files with 22 additions and 0 deletions

@ -359,6 +359,7 @@ class USERPREF_PT_filepaths(bpy.types.Panel):
sub2.itemL(text="Save & Load:")
sub2.itemR(paths, "use_relative_paths")
sub2.itemR(paths, "compress_file")
sub2.itemR(paths, "load_ui")
sub2.itemL(text="Auto Save:")
sub2.itemR(paths, "save_version")
sub2.itemR(paths, "recent_files")

@ -369,6 +369,7 @@ extern UserDef U; /* from blenkernel blender.c */
#define USER_RELPATHS (1 << 20)
#define USER_DRAGIMMEDIATE (1 << 21)
#define USER_DONT_DOSCRIPTLINKS (1 << 22)
#define USER_FILENOUI (1 << 23)
/* viewzom */
#define USER_ZOOM_CONT 0

@ -2199,6 +2199,10 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_FILECOMPRESS);
RNA_def_property_ui_text(prop, "Compress File", "Enable file compression when saving .blend files.");
prop= RNA_def_property(srna, "load_ui", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_FILENOUI);
RNA_def_property_ui_text(prop, "Load UI", "Load user interface setup when loading .blend files.");
prop= RNA_def_property(srna, "fonts_directory", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_sdna(prop, NULL, "fontdir");
RNA_def_property_ui_text(prop, "Fonts Directory", "The default directory to search for loading fonts.");

@ -868,10 +868,17 @@ static void untitled(char *name)
}
}
static void load_set_load_ui(wmOperator *op)
{
if(!RNA_property_is_set(op->ptr, "load_ui"))
RNA_boolean_set(op->ptr, "load_ui", !(U.flag & USER_FILENOUI));
}
static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
RNA_string_set(op->ptr, "filename", G.sce);
load_set_load_ui(op);
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
@ -880,7 +887,14 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filename", filename);
load_set_load_ui(op);
if(RNA_boolean_get(op->ptr, "load_ui"))
G.fileflags &= ~G_FILE_NO_UI;
else
G.fileflags |= G_FILE_NO_UI;
// XXX wm in context is not set correctly after WM_read_file -> crash
// do it before for now, but is this correct with multiple windows?
@ -901,6 +915,8 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
ot->poll= WM_operator_winactive;
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE);
RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file.");
}
static int wm_recover_last_session_exec(bContext *C, wmOperator *op)