Asset Browser: Allow changing active catalog from Python

The active catalog ID (UUID) was a read only property. From a studio I
got the request to make this editable, so their pipeline tooling can
make certain assets visible.

Differential Revision: https://developer.blender.org/D16356

Reviewed by: Sybren Stüvel
This commit is contained in:
Julian Eisel 2022-11-23 11:44:18 +01:00
parent e0c5ff87b7
commit 80249ce6e4
1 changed files with 22 additions and 2 deletions

View File

@ -3325,6 +3325,26 @@ static int rna_FileAssetSelectParams_catalog_id_length(PointerRNA *UNUSED(ptr))
return UUID_STRING_LEN - 1;
}
static void rna_FileAssetSelectParams_catalog_id_set(PointerRNA *ptr, const char *value)
{
FileAssetSelectParams *params = ptr->data;
if (value[0] == '\0') {
params->catalog_id = BLI_uuid_nil();
params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS;
return;
}
bUUID new_uuid;
if (!BLI_uuid_parse_string(&new_uuid, value)) {
printf("UUID %s not formatted correctly, ignoring new value\n", value);
return;
}
params->catalog_id = new_uuid;
params->asset_catalog_visibility = FILE_SHOW_ASSETS_FROM_CATALOG;
}
#else
static const EnumPropertyItem dt_uv_items[] = {
@ -6870,9 +6890,9 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna)
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_FileAssetSelectParams_catalog_id_set");
RNA_def_property_ui_text(prop, "Catalog UUID", "The UUID of the catalog shown in the browser");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
prop = RNA_def_property(srna, "filter_asset_id", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);