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 | |
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')
-rw-r--r-- | source/blender/blenkernel/BKE_appdir.h | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 62 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 36 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_files.h | 1 |
5 files changed, 48 insertions, 53 deletions
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); |