Commit: cd62238c3ca285269025cc12e95528bceee474c7 Author: Campbell Barton Date: Thu Mar 23 10:50:03 2017 +1100 Branches: app-templates https://developer.blender.org/rBcd62238c3ca285269025cc12e95528bceee474c7
Merge branch 'master' into app-templates =================================================================== =================================================================== diff --cc source/blender/windowmanager/intern/wm_files.c index 17d4e521d0,241bd90bdf..63e9b41e63 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@@ -634,15 -632,13 +634,15 @@@ bool WM_file_read(bContext *C, const ch * Called on startup, (context entirely filled with NULLs) * or called for 'New File' both startup.blend and userpref.blend are checked. * - * \param from_memory: Ignore on-disk startup file, use bundled ``datatoc_startup_blend`` instead. + * \param use_factory_settings: Ignore on-disk startup file, use bundled ``datatoc_startup_blend`` instead. * Used for "Restore Factory Settings". * \param filepath_startup_override: Optional path pointing to an alternative blend file (may be NULL). + * \param app_template_override: Template to use instead of the template defined in user-preferences. + * When not-null, this is written into the user preferences. */ int wm_homefile_read( - bContext *C, ReportList *reports, bool from_memory, - bContext *C, ReportList *reports, - bool use_factory_settings, const char *filepath_startup_override) ++ bContext *C, ReportList *reports, bool use_factory_settings, + const char *filepath_startup_override, const char *app_template_override) { ListBase wmbase; char filepath_startup[FILE_MAX]; @@@ -707,43 -704,9 +708,42 @@@ } } - if (!use_factory_settings) { + /* insert template name into startup file */ + if (!filepath_startup_override) { + const char *app_template = NULL; + + if (app_template_override) { + app_template = app_template_override; + } - else if (!from_memory && U.app_template[0]) { ++ else if (!use_factory_settings && U.app_template[0]) { + app_template = U.app_template; + } + + if (app_template != NULL) { - if (!from_memory) { ++ if (!use_factory_settings) { + BLI_path_suffix(filepath_startup, sizeof(filepath_startup), app_template, "_"); + } + - if (from_memory || BLI_access(filepath_startup, R_OK)) { ++ if (use_factory_settings || BLI_access(filepath_startup, R_OK)) { + char temp_path[FILE_MAX]; + BLI_join_dirfile(temp_path, sizeof(temp_path), "app_templates", U.app_template); + const char *filepath_startup_template = BKE_appdir_folder_id(BLENDER_DATAFILES, temp_path); + if (filepath_startup_template) { - /* note that the path is being set even when 'from_memory == true' */ ++ /* note that the path is being set even when 'use_factory_settings == true' */ + BLI_join_dirfile( + filepath_startup, sizeof(filepath_startup), + filepath_startup_template, BLENDER_STARTUP_FILE); + } + } + } + } + - if (!from_memory || (filepath_startup[0] != '\0')) { ++ if (!use_factory_settings || (filepath_startup[0] != '\0')) { if (BLI_access(filepath_startup, R_OK) == 0) { success = (BKE_blendfile_read(C, filepath_startup, NULL, skip_flags) != BKE_BLENDFILE_READ_FAIL); + if (success) { + printf("Read startup: %s\n", filepath_startup); + } } if (BLI_listbase_is_empty(&U.themes)) { if (G.debug & G_DEBUG) @@@ -1504,22 -1435,9 +1507,22 @@@ static int wm_homefile_read_exec(bConte G.fileflags &= ~G_FILE_NO_UI; } - if (wm_homefile_read(C, op->reports, use_factory_settings, filepath)) { - /* Load a file but keep the splash open */ - if (!use_factory_settings && RNA_boolean_get(op->ptr, "use_splash")) { + char app_template_buf[sizeof(U.app_template)]; + const char *app_template; - /* const bool is_app_template = !from_memory && RNA_boolean_get(op->ptr, "app_template"); */ ++ /* const bool is_app_template = !use_factory_settings && RNA_boolean_get(op->ptr, "app_template"); */ + PropertyRNA *prop_app_template = RNA_struct_find_property(op->ptr, "app_template"); - const bool use_splash = !from_memory && RNA_boolean_get(op->ptr, "use_splash"); ++ const bool use_splash = !use_factory_settings && RNA_boolean_get(op->ptr, "use_splash"); + + if (prop_app_template && RNA_property_is_set(op->ptr, prop_app_template)) { + RNA_property_string_get(op->ptr, prop_app_template, app_template_buf); + app_template = app_template_buf; + } + else { + app_template = NULL; + } + - if (wm_homefile_read(C, op->reports, from_memory, filepath, app_template)) { ++ if (wm_homefile_read(C, op->reports, use_factory_settings, filepath, app_template)) { + if (use_splash) { WM_init_splash(C); } return OPERATOR_FINISHED; diff --cc source/blender/windowmanager/wm_files.h index c64e879664,048b5a997b..044fea6c3d --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@@ -36,8 -36,8 +36,8 @@@ struct wmOperatorType /* wm_files.c */ void wm_history_file_read(void); int wm_homefile_read( - struct bContext *C, struct ReportList *reports, bool from_memory, - struct bContext *C, struct ReportList *reports, - bool use_factory_settings, const char *filepath_startup_override); ++ struct bContext *C, struct ReportList *reports, bool use_factory_settings, + const char *filepath_startup_override, const char *startup_template); void wm_file_read_report(bContext *C); void WM_OT_save_homefile(struct wmOperatorType *ot); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs