[Bf-blender-cvs] [dd54b72] master: Add load_ui to WM_OT_read_homefile

Campbell Barton noreply at git.blender.org
Thu Apr 3 02:33:29 CEST 2014


Commit: dd54b721c6ff3e0614f771e76fb1ccfbb78f6d67
Author: Campbell Barton
Date:   Thu Apr 3 11:29:45 2014 +1100
https://developer.blender.org/rBdd54b721c6ff3e0614f771e76fb1ccfbb78f6d67

Add load_ui to WM_OT_read_homefile

Useful for implementing templates.

Patch D423 by Gaia Clary

===================================================================

M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 0d481bd..553f9a6 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -576,9 +576,6 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c
 		}
 	}
 	
-	/* prevent loading no UI */
-	G.fileflags &= ~G_FILE_NO_UI;
-	
 	/* put aside screens to match with persistent windows later */
 	wm_window_match_init(C, &wmbase);
 	
@@ -687,6 +684,12 @@ int wm_homefile_read_exec(bContext *C, wmOperator *op)
 
 	if (!from_memory) {
 		PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath");
+
+		/* This can be used when loading of a start-up file should only change
+		 * the scene content but keep the blender UI as it is. */
+		wm_open_init_load_ui(op, true);
+		BKE_BIT_TEST_SET(G.fileflags, !RNA_boolean_get(op->ptr, "load_ui"), G_FILE_NO_UI);
+
 		if (RNA_property_is_set(op->ptr, prop)) {
 			RNA_property_string_get(op->ptr, prop, filepath_buf);
 			filepath = filepath_buf;
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 5325ade..d4a23dc 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -161,6 +161,9 @@ void WM_init(bContext *C, int argc, const char **argv)
 	BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
 	BLF_lang_init();
 
+	/* Enforce loading the UI for the initial homefile */
+	G.fileflags &= ~G_FILE_NO_UI;
+
 	/* get the default database, plus a wm */
 	wm_homefile_read(C, NULL, G.factory_startup, NULL);
 	
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 50b0fa2..4ff987d 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2146,6 +2146,11 @@ static void WM_OT_read_homefile(wmOperatorType *ot)
 	                                "Path to an alternative start-up file");
 	RNA_def_property_flag(prop, PROP_HIDDEN);
 
+	/* So scripts can use an alternative start-up file without the UI */
+	prop = RNA_def_boolean(ot->srna, "load_ui", true, "Load UI",
+	                       "Load user interface setup from the .blend file");
+	RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+
 	/* ommit poll to run in background mode */
 }




More information about the Bf-blender-cvs mailing list