Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-08-17 09:34:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-08-18 07:10:07 +0300
commit506d8448cc006a0c1c51947999a50addbfedcb15 (patch)
treebec2390fcca2b7914ea2a5b022685e9248e6b3da /source/blender
parentdb8ca0f17a9d9f44c63c76c79925019a2d5e1a00 (diff)
WM: app-template command line override
Without this, there was no simple way to have launchers for different app-templates. Also allows force-disabling the app-template stored in the preferences.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/windowmanager/WM_api.h3
-rw-r--r--source/blender/windowmanager/intern/wm_files.c33
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c3
3 files changed, 36 insertions, 3 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 2ae2a65e2c9..dd2f9b4c450 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -72,6 +72,9 @@ struct wmNDOFMotionData;
typedef struct wmJob wmJob;
/* general API */
+void WM_init_state_app_template_set(const char *app_template);
+const char *WM_init_state_app_template_get(void);
+
void WM_init_state_size_set (int stax, int stay, int sizx, int sizy);
void WM_init_state_fullscreen_set(void);
void WM_init_state_normal_set(void);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a802c695dd1..b56f95aca6f 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -638,6 +638,33 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
+struct {
+ char app_template[64];
+ bool override;
+} wm_init_state_app_template = {0};
+
+/**
+ * Used for setting app-template from the command line:
+ * - non-empty string: overrides.
+ * - empty string: override, using no app template.
+ * - NULL: clears override.
+ */
+void WM_init_state_app_template_set(const char *app_template)
+{
+ if (app_template) {
+ STRNCPY(wm_init_state_app_template.app_template, app_template);
+ wm_init_state_app_template.override = true;
+ }
+ else {
+ wm_init_state_app_template.app_template[0] = '\0';
+ wm_init_state_app_template.override = false;
+ }
+}
+
+const char *WM_init_state_app_template_get(void)
+{
+ return wm_init_state_app_template.override ? wm_init_state_app_template.app_template : NULL;
+}
/**
* Called on startup, (context entirely filled with NULLs)
@@ -1614,9 +1641,13 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
/* Always load preferences when switching templates. */
use_userdef = true;
+
+ /* Turn override off, since we're explicitly loading a different app-template. */
+ WM_init_state_app_template_set(NULL);
}
else {
- app_template = NULL;
+ /* Normally NULL, only set when overriding from the command-line. */
+ app_template = WM_init_state_app_template_get();
}
if (wm_homefile_read(C, op->reports, use_factory_settings, use_empty_data, use_userdef, filepath, app_template)) {
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 088327fa611..185cf3fad4f 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -195,8 +195,7 @@ void WM_init(bContext *C, int argc, const char **argv)
wm_init_reports(C);
/* get the default database, plus a wm */
- wm_homefile_read(C, NULL, G.factory_startup, false, true, NULL, NULL);
-
+ wm_homefile_read(C, NULL, G.factory_startup, false, true, NULL, WM_init_state_app_template_get());
BLT_lang_set(NULL);