From fe274d91a1295ea16cd71b25691c0a492e95dbb8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 2 Nov 2021 14:47:21 +0100 Subject: Link/Append: Move most of core link/append code from WM to new `BKE_blendflie_link_append` module. This will allow to expose all those advanced features of the WM operators to other parts of the code, like the python library context manager, copy/paste code, etc. This is expected to be a strictly no-behavioral-change commit. Part of T91414: Unify link/append between WM operators and BPY context manager API, and cleanup usages of `BKE_library_make_local`. Maniphest Tasks: T91414 Differential Revision: https://developer.blender.org/D13222 --- .../blender/blenkernel/BKE_blendfile_link_append.h | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 source/blender/blenkernel/BKE_blendfile_link_append.h (limited to 'source/blender/blenkernel/BKE_blendfile_link_append.h') diff --git a/source/blender/blenkernel/BKE_blendfile_link_append.h b/source/blender/blenkernel/BKE_blendfile_link_append.h new file mode 100644 index 00000000000..184f1ef1511 --- /dev/null +++ b/source/blender/blenkernel/BKE_blendfile_link_append.h @@ -0,0 +1,91 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#pragma once + +/** \file + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct ID; +struct Library; +struct Main; +struct ReportList; +struct Scene; +struct ViewLayer; +struct View3D; + +typedef struct BlendfileLinkAppendContext BlendfileLinkAppendContext; +typedef struct BlendfileLinkAppendContextItem BlendfileLinkAppendContextItem; + +BlendfileLinkAppendContext *BKE_blendfile_link_append_context_new(const int flag); +void BKE_blendfile_link_append_context_free(struct BlendfileLinkAppendContext *lapp_context); +void BKE_blendfile_link_append_context_flag_set(struct BlendfileLinkAppendContext *lapp_context, + const int flag, + const bool do_set); + +void BKE_blendfile_link_append_context_embedded_blendfile_set( + struct BlendfileLinkAppendContext *lapp_context, + const void *blendfile_mem, + int blendfile_memsize); +void BKE_blendfile_link_append_context_embedded_blendfile_clear( + struct BlendfileLinkAppendContext *lapp_context); + +void BKE_blendfile_link_append_context_library_add(struct BlendfileLinkAppendContext *lapp_context, + const char *libname); +struct BlendfileLinkAppendContextItem *BKE_blendfile_link_append_context_item_add( + struct BlendfileLinkAppendContext *lapp_context, + const char *idname, + const short idcode, + void *userdata); +void BKE_blendfile_link_append_context_item_library_index_enable( + struct BlendfileLinkAppendContext *lapp_context, + struct BlendfileLinkAppendContextItem *item, + const int library_index); +bool BKE_blendfile_link_append_context_is_empty(struct BlendfileLinkAppendContext *lapp_context); + +void *BKE_blendfile_link_append_context_item_userdata_get( + struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item); +struct ID *BKE_blendfile_link_append_context_item_newid_get( + struct BlendfileLinkAppendContext *lapp_context, struct BlendfileLinkAppendContextItem *item); + +void BKE_blendfile_append(struct BlendfileLinkAppendContext *lapp_context, + struct ReportList *reports, + struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer, + const struct View3D *v3d); +void BKE_blendfile_link(struct BlendfileLinkAppendContext *lapp_context, + struct ReportList *reports, + struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer, + const struct View3D *v3d); + +void BKE_blendfile_library_relocate(struct BlendfileLinkAppendContext *lapp_context, + struct ReportList *reports, + struct Library *library, + const bool do_reload, + struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer); + +#ifdef __cplusplus +} +#endif -- cgit v1.2.3