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:
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_appdir.h1
-rw-r--r--source/blender/blenkernel/BKE_blendfile.h2
-rw-r--r--source/blender/blenkernel/intern/appdir.c20
-rw-r--r--source/blender/blenkernel/intern/blendfile.c54
4 files changed, 77 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h
index 7ff8514f675..e956aeb769a 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -36,6 +36,7 @@ const char *BKE_appdir_folder_id_version(const int folder_id, const int ver, con
bool BKE_appdir_app_is_portable_install(void);
bool BKE_appdir_app_template_any(void);
bool BKE_appdir_app_template_id_search(const char *app_template, char *path, size_t path_len);
+bool BKE_appdir_app_template_has_userpref(const char *app_template);
void BKE_appdir_app_templates(struct ListBase *templates);
/* Initialize path to program executable */
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h
index 216bef0d1e3..76c05b0411a 100644
--- a/source/blender/blenkernel/BKE_blendfile.h
+++ b/source/blender/blenkernel/BKE_blendfile.h
@@ -62,6 +62,8 @@ struct UserDef *BKE_blendfile_userdef_read_from_memory(const void *filebuf,
bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_userdef_write_app_template(const char *filepath, struct ReportList *reports);
+bool BKE_blendfile_userdef_write_all(struct ReportList *reports);
+
struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath,
const void *filebuf,
int filelength,
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c
index 2b4123c74e2..c1ea57c5fcc 100644
--- a/source/blender/blenkernel/intern/appdir.c
+++ b/source/blender/blenkernel/intern/appdir.c
@@ -838,6 +838,26 @@ bool BKE_appdir_app_template_id_search(const char *app_template, char *path, siz
return false;
}
+bool BKE_appdir_app_template_has_userpref(const char *app_template)
+{
+ /* Test if app template provides a userpref.blend.
+ * If not, we will share user preferences with the rest of Blender. */
+ if (!app_template && app_template[0]) {
+ return false;
+ }
+
+ char app_template_path[FILE_MAX];
+ if (!BKE_appdir_app_template_id_search(
+ app_template, app_template_path, sizeof(app_template_path))) {
+ return false;
+ }
+
+ char userpref_path[FILE_MAX];
+ BLI_path_join(
+ userpref_path, sizeof(userpref_path), app_template_path, BLENDER_USERPREF_FILE, NULL);
+ return BLI_exists(userpref_path);
+}
+
void BKE_appdir_app_templates(ListBase *templates)
{
BLI_listbase_clear(templates);
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index d1a3045a829..f54d938c0ca 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -566,6 +566,60 @@ bool BKE_blendfile_userdef_write_app_template(const char *filepath, ReportList *
return ok;
}
+bool BKE_blendfile_userdef_write_all(ReportList *reports)
+{
+ char filepath[FILE_MAX];
+ const char *cfgdir;
+ bool ok = true;
+ const bool use_template_userpref = BKE_appdir_app_template_has_userpref(U.app_template);
+
+ if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL))) {
+ bool ok_write;
+ BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
+
+ printf("Writing userprefs: '%s' ", filepath);
+ if (use_template_userpref) {
+ ok_write = BKE_blendfile_userdef_write_app_template(filepath, reports);
+ }
+ else {
+ ok_write = BKE_blendfile_userdef_write(filepath, reports);
+ }
+
+ if (ok_write) {
+ printf("ok\n");
+ }
+ else {
+ printf("fail\n");
+ ok = false;
+ }
+ }
+ else {
+ BKE_report(reports, RPT_ERROR, "Unable to create userpref path");
+ }
+
+ if (use_template_userpref) {
+ if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) {
+ /* Also save app-template prefs */
+ BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
+
+ printf("Writing userprefs app-template: '%s' ", filepath);
+ if (BKE_blendfile_userdef_write(filepath, reports) != 0) {
+ printf("ok\n");
+ }
+ else {
+ printf("fail\n");
+ ok = false;
+ }
+ }
+ else {
+ BKE_report(reports, RPT_ERROR, "Unable to create app-template userpref path");
+ ok = false;
+ }
+ }
+
+ return ok;
+}
+
WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath,
const void *filebuf,
int filelength,