Workspaces: replace bundled workspace.blend with embedded startup.blend.

We want these to have the same workspaces in both, so there is no reason
to have two files that are identical.
This commit is contained in:
Brecht Van Lommel 2018-08-20 13:52:50 +02:00
parent f1ab36d154
commit c9abb0fe26
8 changed files with 39 additions and 20 deletions

Binary file not shown.

View File

@ -61,7 +61,10 @@ struct UserDef *BKE_blendfile_userdef_read_from_memory(
bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_userdef_write_app_template(const char *filepath, struct ReportList *reports);
struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, struct ReportList *reports);
struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(
const char *filepath,
const void *filebuf, int filelength,
struct ReportList *reports);
bool BKE_blendfile_workspace_config_write(struct Main *bmain, const char *filepath, struct ReportList *reports);
void BKE_blendfile_workspace_config_data_free(struct WorkspaceConfigFileData *workspace_config);

View File

@ -561,12 +561,18 @@ bool BKE_blendfile_userdef_write_app_template(const char *filepath, ReportList *
return ok;
}
WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, ReportList *reports)
WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, const void *filebuf, int filelength, ReportList *reports)
{
BlendFileData *bfd;
WorkspaceConfigFileData *workspace_config = NULL;
bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_USERDEF);
if (filepath) {
bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_USERDEF);
}
else {
bfd = BLO_read_from_memory(filebuf, filelength, reports, BLO_READ_SKIP_USERDEF);
}
if (bfd) {
workspace_config = MEM_mallocN(sizeof(*workspace_config), __func__);
workspace_config->main = bfd->main;

View File

@ -115,6 +115,7 @@ void BLO_blendhandle_close(BlendHandle *bh);
/***/
#define BLO_GROUP_MAX 32
#define BLO_EMBEDDED_STARTUP_BLEND "<startup.blend>"
bool BLO_has_bfile_extension(const char *str);
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name);

View File

@ -1412,6 +1412,9 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
break;
}
else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
break;
}
if (prev_slash) {
*prev_slash = c;

View File

@ -50,6 +50,7 @@
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
#include "ED_datafiles.h"
#include "ED_object.h"
#include "ED_screen.h"
@ -388,14 +389,13 @@ static WorkspaceConfigFileData *workspace_config_file_read(
if (BLI_exists(workspace_config_path)) {
has_path = true;
}
else {
workspace_config_file_path_from_folder_id(bmain, BLENDER_SYSTEM_DATAFILES, workspace_config_path);
if (BLI_exists(workspace_config_path)) {
has_path = true;
}
}
return has_path ? BKE_blendfile_workspace_config_read(workspace_config_path, reports) : NULL;
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);
}
}
static void workspace_append_button(
@ -404,9 +404,14 @@ static void workspace_append_button(
const ID *id = (ID *)workspace;
PointerRNA opptr;
char lib_path[FILE_MAX_LIBEXTRA];
const char *filepath = from_main->name;
if (strlen(filepath) == 0) {
filepath = BLO_EMBEDDED_STARTUP_BLEND;
}
BLI_path_join(
lib_path, sizeof(lib_path), from_main->name, BKE_idcode_to_name(GS(id->name)), NULL);
lib_path, sizeof(lib_path), filepath, BKE_idcode_to_name(GS(id->name)), NULL);
BLI_assert(STREQ(ot_append->idname, "WORKSPACE_OT_append_activate"));
uiItemFullO_ptr(
@ -426,7 +431,9 @@ static void workspace_config_file_append_buttons(
wmOperatorType *ot_append = WM_operatortype_find("WORKSPACE_OT_append_activate", true);
for (WorkSpace *workspace = workspace_config->workspaces.first; workspace; workspace = workspace->id.next) {
workspace_append_button(layout, ot_append, workspace, workspace_config->main);
if (BLI_findstring(&bmain->workspaces, workspace->id.name, offsetof(ID, name)) == NULL) {
workspace_append_button(layout, ot_append, workspace, workspace_config->main);
}
}
BKE_blendfile_workspace_config_data_free(workspace_config);

View File

@ -74,6 +74,7 @@
#include "IMB_colormanagement.h"
#include "ED_datafiles.h"
#include "ED_screen.h"
#include "RNA_access.h"
@ -228,7 +229,12 @@ static void wm_link_do(
for (lib_idx = 0, liblink = lapp_data->libraries.list; liblink; lib_idx++, liblink = liblink->next) {
char *libname = liblink->link;
bh = BLO_blendhandle_from_file(libname, reports);
if (STREQ(libname, BLO_EMBEDDED_STARTUP_BLEND)) {
bh = BLO_blendhandle_from_memory(datatoc_startup_blend, datatoc_startup_blend_size);
}
else {
bh = BLO_blendhandle_from_file(libname, reports);
}
if (bh == NULL) {
/* Unlikely since we just browsed it, but possible

View File

@ -422,13 +422,6 @@ if(WITH_OPENCOLORIO)
)
endif()
# Add default workspaces.blend to build (under [version]/datafiles
install(
FILES ${CMAKE_SOURCE_DIR}/release/datafiles/workspaces.blend
DESTINATION ${TARGETDIR_VER}/datafiles
)
# helpful tip when using make
if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
# message after building.