File Browser/BPY: Expose relative path of a file via BPY
There were requests to be able to track the file selection in the File Browser. Just using the file name for that wouldn't if the file browser has the recursive display enabled. File names could be duplicated then. So expose the entire path relative to the currently displayed directory.
This commit is contained in:
parent
8355e3fc77
commit
79281336c0
|
@ -2608,6 +2608,18 @@ static int rna_FileBrowser_FileSelectEntry_name_length(PointerRNA *ptr)
|
|||
return (int)strlen(entry->name);
|
||||
}
|
||||
|
||||
static void rna_FileBrowser_FileSelectEntry_relative_path_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
const FileDirEntry *entry = ptr->data;
|
||||
strcpy(value, entry->relpath);
|
||||
}
|
||||
|
||||
static int rna_FileBrowser_FileSelectEntry_relative_path_length(PointerRNA *ptr)
|
||||
{
|
||||
const FileDirEntry *entry = ptr->data;
|
||||
return (int)strlen(entry->relpath);
|
||||
}
|
||||
|
||||
static const EnumPropertyItem *rna_FileBrowser_FileSelectEntry_id_type_itemf(
|
||||
bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
|
||||
{
|
||||
|
@ -6184,6 +6196,17 @@ static void rna_def_fileselect_entry(BlenderRNA *brna)
|
|||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
|
||||
prop = RNA_def_property(srna, "relative_path", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_funcs(prop,
|
||||
"rna_FileBrowser_FileSelectEntry_relative_path_get",
|
||||
"rna_FileBrowser_FileSelectEntry_relative_path_length",
|
||||
NULL);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Relative Path",
|
||||
"Path relative to the directory currently displayed in the File "
|
||||
"Browser (includes the file name)");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_enum_id_type_items);
|
||||
RNA_def_property_enum_funcs(prop,
|
||||
|
|
Loading…
Reference in New Issue