From 9e456ca69565f245c7b3d76b134a72ef5d252bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 1 Oct 2021 16:44:59 +0200 Subject: Asset Browser: expose current catalog ID in RNA Add read-only access to the active catalog ID via `context.space_data.params.catalog_id` in the Asset Browser context. The UUID is exposed as string to Python. --- source/blender/makesrna/intern/rna_space.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 78c26df7be6..652d2545e67 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -39,6 +39,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" +#include "BLI_uuid.h" #include "DNA_action_types.h" #include "DNA_gpencil_types.h" @@ -3179,6 +3180,17 @@ static void rna_SpaceSpreadsheet_context_path_guess(SpaceSpreadsheet *sspreadshe WM_main_add_notifier(NC_SPACE | ND_SPACE_SPREADSHEET, NULL); } +static void rna_FileAssetSelectParams_catalog_id_get(PointerRNA *ptr, char *value) +{ + const FileAssetSelectParams *params = ptr->data; + BLI_uuid_format(value, params->catalog_id); +} + +static int rna_FileAssetSelectParams_catalog_id_length(PointerRNA *UNUSED(ptr)) +{ + return UUID_STRING_LEN - 1; +} + #else static const EnumPropertyItem dt_uv_items[] = { @@ -6611,6 +6623,14 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Asset Library", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + prop = RNA_def_property(srna, "catalog_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, + "rna_FileAssetSelectParams_catalog_id_get", + "rna_FileAssetSelectParams_catalog_id_length", + NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Catalog UUID", "The UUID of the catalog shown in the browser"); + prop = RNA_def_property(srna, "import_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, asset_import_type_items); RNA_def_property_ui_text(prop, "Import Type", "Determine how the asset will be imported"); -- cgit v1.2.3