[Bf-blender-cvs] [6cd3a67e36b] blender2.8: Workspaces: remove separate workspaces.blend config file.

Brecht Van Lommel noreply at git.blender.org
Mon Aug 20 16:29:34 CEST 2018


Commit: 6cd3a67e36b6eb120ce4aad7267107674bc1b23c
Author: Brecht Van Lommel
Date:   Mon Aug 20 15:37:19 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB6cd3a67e36b6eb120ce4aad7267107674bc1b23c

Workspaces: remove separate workspaces.blend config file.

This is quite confusing in the current UI, with both startup.blend and
workspaces.blend containing a list of workspaces. In practice you'd usually
want to save workspaces to both files.

The downside of having a single file may be that you then can't disable
certain workspaces by default, but we could add a setting for that.

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenkernel/BKE_appdir.h
M	source/blender/editors/screen/workspace_edit.c
M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/wm_files.h

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index e8fdfc71ae8..ddcc19a3781 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -44,9 +44,7 @@ class USERPREF_HT_header(Header):
 
         layout.operator_context = 'INVOKE_DEFAULT'
 
-        if userpref.active_section == 'INTERFACE':
-            layout.operator("wm.save_workspace_file")
-        elif userpref.active_section == 'INPUT':
+        if userpref.active_section == 'INPUT':
             layout.operator("wm.keyconfig_import")
             layout.operator("wm.keyconfig_export")
         elif userpref.active_section == 'ADDONS':
diff --git a/source/blender/blenkernel/BKE_appdir.h b/source/blender/blenkernel/BKE_appdir.h
index ffbdc6972f4..ac8f861fa56 100644
--- a/source/blender/blenkernel/BKE_appdir.h
+++ b/source/blender/blenkernel/BKE_appdir.h
@@ -82,7 +82,6 @@ enum {
 
 #define BLENDER_STARTUP_FILE    "startup.blend"
 #define BLENDER_USERPREF_FILE   "userpref.blend"
-#define BLENDER_WORKSPACES_FILE "workspaces.blend"
 #define BLENDER_QUIT_FILE       "quit.blend"
 #define BLENDER_BOOKMARK_FILE   "bookmarks.txt"
 #define BLENDER_HISTORY_FILE    "recent-files.txt"
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 267dce87e26..4f8389d9f7d 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -64,6 +64,8 @@
 #include "UI_interface.h"
 #include "UI_resources.h"
 
+#include "BLT_translation.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 #include "WM_toolsystem.h"
@@ -371,7 +373,7 @@ static void workspace_config_file_path_from_folder_id(
 	const char * const cfgdir = BKE_appdir_folder_id(folder_id, app_template);
 
 	if (cfgdir) {
-		BLI_make_file_string(bmain->name, r_path, cfgdir, BLENDER_WORKSPACES_FILE);
+		BLI_make_file_string(bmain->name, r_path, cfgdir, BLENDER_STARTUP_FILE);
 	}
 	else {
 		r_path[0] = '\0';
@@ -390,12 +392,7 @@ static WorkspaceConfigFileData *workspace_config_file_read(
 		has_path = true;
 	}
 
-	if (has_path) {
-		return BKE_blendfile_workspace_config_read(workspace_config_path, NULL, 0, reports);
-	}
-	else {
-		return BKE_blendfile_workspace_config_read(NULL, datatoc_startup_blend, datatoc_startup_blend_size, reports);
-	}
+	return (has_path) ? BKE_blendfile_workspace_config_read(workspace_config_path, NULL, 0, reports) : NULL;
 }
 
 static void workspace_append_button(
@@ -425,18 +422,56 @@ ATTR_NONNULL(1, 2)
 static void workspace_config_file_append_buttons(
         uiLayout *layout, const Main *bmain, ReportList *reports)
 {
-	WorkspaceConfigFileData *workspace_config = workspace_config_file_read(bmain, reports);
+	wmOperatorType *ot_append = WM_operatortype_find("WORKSPACE_OT_append_activate", true);
+	WorkspaceConfigFileData *startup_config = workspace_config_file_read(bmain, reports);
+	WorkspaceConfigFileData *builtin_config = BKE_blendfile_workspace_config_read(NULL, datatoc_startup_blend, datatoc_startup_blend_size, reports);
+
+	if (startup_config) {
+		bool has_title = false;
 
-	if (workspace_config) {
-		wmOperatorType *ot_append = WM_operatortype_find("WORKSPACE_OT_append_activate", true);
+		for (WorkSpace *workspace = startup_config->workspaces.first; workspace; workspace = workspace->id.next) {
+			if (BLI_findstring(&bmain->workspaces, workspace->id.name, offsetof(ID, name))) {
+				continue;
+			}
+
+			if (!has_title) {
+				uiItemS(layout);
+				uiItemL(layout, IFACE_("Startup File"), ICON_NONE);
+				has_title = true;
+			}
+
+			workspace_append_button(layout, ot_append, workspace, startup_config->main);
+		}
+	}
+
+	if (builtin_config) {
+		bool has_title = false;
+
+		for (WorkSpace *workspace = builtin_config->workspaces.first; workspace; workspace = workspace->id.next) {
+			if (BLI_findstring(&bmain->workspaces, workspace->id.name, offsetof(ID, name))) {
+				continue;
+			}
+			if (startup_config && BLI_findstring(&startup_config->workspaces, workspace->id.name, offsetof(ID, name))) {
+				continue;
+			}
+
+			if (!has_title) {
+				uiItemS(layout);
+				uiItemL(layout, IFACE_("Builtin"), ICON_NONE);
+				has_title = true;
+			}
 
-		for (WorkSpace *workspace = workspace_config->workspaces.first; workspace; workspace = workspace->id.next) {
 			if (BLI_findstring(&bmain->workspaces, workspace->id.name, offsetof(ID, name)) == NULL) {
-				workspace_append_button(layout, ot_append, workspace, workspace_config->main);
+				workspace_append_button(layout, ot_append, workspace, builtin_config->main);
 			}
 		}
+	}
 
-		BKE_blendfile_workspace_config_data_free(workspace_config);
+	if (startup_config) {
+		BKE_blendfile_workspace_config_data_free(startup_config);
+	}
+	if (builtin_config) {
+		BKE_blendfile_workspace_config_data_free(builtin_config);
 	}
 }
 
@@ -448,7 +483,6 @@ static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
 	uiLayout *layout = UI_popup_menu_layout(pup);
 
 	uiItemO(layout, "Duplicate Current", ICON_NONE, "WORKSPACE_OT_workspace_duplicate");
-	uiItemS(layout);
 	workspace_config_file_append_buttons(layout, bmain, op->reports);
 
 	UI_popup_menu_end(C, pup);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 196e6cfa5ce..65f4823464a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1603,42 +1603,6 @@ void WM_OT_save_userpref(wmOperatorType *ot)
 	ot->exec = wm_userpref_write_exec;
 }
 
-static int wm_workspace_configuration_file_write_exec(bContext *C, wmOperator *op)
-{
-	Main *bmain = CTX_data_main(C);
-	char filepath[FILE_MAX];
-
-	const char *app_template = U.app_template[0] ? U.app_template : NULL;
-	const char * const cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, app_template);
-	if (cfgdir == NULL) {
-		BKE_report(op->reports, RPT_ERROR, "Unable to create workspace configuration file path");
-		return OPERATOR_CANCELLED;
-	}
-
-	BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_WORKSPACES_FILE, NULL);
-	printf("trying to save workspace configuration file at %s ", filepath);
-
-	if (BKE_blendfile_workspace_config_write(bmain, filepath, op->reports) != 0) {
-		printf("ok\n");
-		return OPERATOR_FINISHED;
-	}
-	else {
-		printf("fail\n");
-	}
-
-	return OPERATOR_CANCELLED;
-}
-
-void WM_OT_save_workspace_file(wmOperatorType *ot)
-{
-	ot->name = "Save Workspace Configuration";
-	ot->idname = "WM_OT_save_workspace_file";
-	ot->description = "Save workspaces of the current file as part of the user configuration";
-
-	ot->invoke = WM_operator_confirm;
-	ot->exec = wm_workspace_configuration_file_write_exec;
-}
-
 static int wm_history_file_read_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
 {
 	ED_file_read_bookmarks();
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 299624bc50b..4f39d2131b9 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3211,7 +3211,6 @@ void wm_operatortypes_register(void)
 	WM_operatortype_append(WM_OT_read_factory_settings);
 	WM_operatortype_append(WM_OT_save_homefile);
 	WM_operatortype_append(WM_OT_save_userpref);
-	WM_operatortype_append(WM_OT_save_workspace_file);
 	WM_operatortype_append(WM_OT_userpref_autoexec_path_add);
 	WM_operatortype_append(WM_OT_userpref_autoexec_path_remove);
 	WM_operatortype_append(WM_OT_window_fullscreen_toggle);
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index e1725156012..147ed882966 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -46,7 +46,6 @@ void        WM_OT_save_homefile(struct wmOperatorType *ot);
 void        WM_OT_userpref_autoexec_path_add(struct wmOperatorType *ot);
 void        WM_OT_userpref_autoexec_path_remove(struct wmOperatorType *ot);
 void        WM_OT_save_userpref(struct wmOperatorType *ot);
-void        WM_OT_save_workspace_file(struct wmOperatorType *ot);
 void        WM_OT_read_history(struct wmOperatorType *ot);
 void        WM_OT_read_homefile(struct wmOperatorType *ot);
 void        WM_OT_read_factory_settings(struct wmOperatorType *ot);



More information about the Bf-blender-cvs mailing list