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.
This commit is contained in:
@@ -44,9 +44,7 @@ class USERPREF_HT_header(Header):
|
|||||||
|
|
||||||
layout.operator_context = 'INVOKE_DEFAULT'
|
layout.operator_context = 'INVOKE_DEFAULT'
|
||||||
|
|
||||||
if userpref.active_section == 'INTERFACE':
|
if userpref.active_section == 'INPUT':
|
||||||
layout.operator("wm.save_workspace_file")
|
|
||||||
elif userpref.active_section == 'INPUT':
|
|
||||||
layout.operator("wm.keyconfig_import")
|
layout.operator("wm.keyconfig_import")
|
||||||
layout.operator("wm.keyconfig_export")
|
layout.operator("wm.keyconfig_export")
|
||||||
elif userpref.active_section == 'ADDONS':
|
elif userpref.active_section == 'ADDONS':
|
||||||
|
@@ -82,7 +82,6 @@ enum {
|
|||||||
|
|
||||||
#define BLENDER_STARTUP_FILE "startup.blend"
|
#define BLENDER_STARTUP_FILE "startup.blend"
|
||||||
#define BLENDER_USERPREF_FILE "userpref.blend"
|
#define BLENDER_USERPREF_FILE "userpref.blend"
|
||||||
#define BLENDER_WORKSPACES_FILE "workspaces.blend"
|
|
||||||
#define BLENDER_QUIT_FILE "quit.blend"
|
#define BLENDER_QUIT_FILE "quit.blend"
|
||||||
#define BLENDER_BOOKMARK_FILE "bookmarks.txt"
|
#define BLENDER_BOOKMARK_FILE "bookmarks.txt"
|
||||||
#define BLENDER_HISTORY_FILE "recent-files.txt"
|
#define BLENDER_HISTORY_FILE "recent-files.txt"
|
||||||
|
@@ -64,6 +64,8 @@
|
|||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
|
|
||||||
|
#include "BLT_translation.h"
|
||||||
|
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
#include "WM_types.h"
|
#include "WM_types.h"
|
||||||
#include "WM_toolsystem.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);
|
const char * const cfgdir = BKE_appdir_folder_id(folder_id, app_template);
|
||||||
|
|
||||||
if (cfgdir) {
|
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 {
|
else {
|
||||||
r_path[0] = '\0';
|
r_path[0] = '\0';
|
||||||
@@ -390,12 +392,7 @@ static WorkspaceConfigFileData *workspace_config_file_read(
|
|||||||
has_path = true;
|
has_path = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_path) {
|
return (has_path) ? BKE_blendfile_workspace_config_read(workspace_config_path, NULL, 0, reports) : NULL;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void workspace_append_button(
|
static void workspace_append_button(
|
||||||
@@ -425,18 +422,56 @@ ATTR_NONNULL(1, 2)
|
|||||||
static void workspace_config_file_append_buttons(
|
static void workspace_config_file_append_buttons(
|
||||||
uiLayout *layout, const Main *bmain, ReportList *reports)
|
uiLayout *layout, const Main *bmain, ReportList *reports)
|
||||||
{
|
{
|
||||||
WorkspaceConfigFileData *workspace_config = workspace_config_file_read(bmain, reports);
|
|
||||||
|
|
||||||
if (workspace_config) {
|
|
||||||
wmOperatorType *ot_append = WM_operatortype_find("WORKSPACE_OT_append_activate", true);
|
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;
|
||||||
|
|
||||||
|
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) {
|
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);
|
uiLayout *layout = UI_popup_menu_layout(pup);
|
||||||
|
|
||||||
uiItemO(layout, "Duplicate Current", ICON_NONE, "WORKSPACE_OT_workspace_duplicate");
|
uiItemO(layout, "Duplicate Current", ICON_NONE, "WORKSPACE_OT_workspace_duplicate");
|
||||||
uiItemS(layout);
|
|
||||||
workspace_config_file_append_buttons(layout, bmain, op->reports);
|
workspace_config_file_append_buttons(layout, bmain, op->reports);
|
||||||
|
|
||||||
UI_popup_menu_end(C, pup);
|
UI_popup_menu_end(C, pup);
|
||||||
|
@@ -1603,42 +1603,6 @@ void WM_OT_save_userpref(wmOperatorType *ot)
|
|||||||
ot->exec = wm_userpref_write_exec;
|
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))
|
static int wm_history_file_read_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
ED_file_read_bookmarks();
|
ED_file_read_bookmarks();
|
||||||
|
@@ -3211,7 +3211,6 @@ void wm_operatortypes_register(void)
|
|||||||
WM_operatortype_append(WM_OT_read_factory_settings);
|
WM_operatortype_append(WM_OT_read_factory_settings);
|
||||||
WM_operatortype_append(WM_OT_save_homefile);
|
WM_operatortype_append(WM_OT_save_homefile);
|
||||||
WM_operatortype_append(WM_OT_save_userpref);
|
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_add);
|
||||||
WM_operatortype_append(WM_OT_userpref_autoexec_path_remove);
|
WM_operatortype_append(WM_OT_userpref_autoexec_path_remove);
|
||||||
WM_operatortype_append(WM_OT_window_fullscreen_toggle);
|
WM_operatortype_append(WM_OT_window_fullscreen_toggle);
|
||||||
|
@@ -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_add(struct wmOperatorType *ot);
|
||||||
void WM_OT_userpref_autoexec_path_remove(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_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_history(struct wmOperatorType *ot);
|
||||||
void WM_OT_read_homefile(struct wmOperatorType *ot);
|
void WM_OT_read_homefile(struct wmOperatorType *ot);
|
||||||
void WM_OT_read_factory_settings(struct wmOperatorType *ot);
|
void WM_OT_read_factory_settings(struct wmOperatorType *ot);
|
||||||
|
Reference in New Issue
Block a user