diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-20 16:37:19 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-20 17:23:22 +0300 |
commit | 6cd3a67e36b6eb120ce4aad7267107674bc1b23c (patch) | |
tree | c6dc1237935d11c2e484a09dbf78710001ca3362 /source/blender/editors/screen | |
parent | 444934632a8d8e239bc0c6d79a638ec0943152a6 (diff) |
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.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 62 |
1 files changed, 48 insertions, 14 deletions
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); |