UI: Open Folder of Recent Items #119988

Merged
Harley Acheson merged 6 commits from Harley/blender:RecentOpenExternal into main 2024-03-28 04:37:18 +01:00
1 changed files with 28 additions and 0 deletions

View File

@ -1012,6 +1012,34 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
}
}
}
else if (but->optype && but->opptr && RNA_struct_property_is_set(but->opptr, "filepath")) {
/* Operator with "filepath" string property of PROP_FILEPATH subtype. */
PropertyRNA *prop = RNA_struct_find_property(but->opptr, "filepath");
const PropertySubType subtype = RNA_property_subtype(prop);
if (prop && RNA_property_type(prop) == PROP_STRING &&
subtype == PropertySubType::PROP_FILEPATH)
{
char filepath[FILE_MAX] = {0};
RNA_property_string_get(but->opptr, prop, filepath);
Harley marked this conversation as resolved Outdated

How about BLI_path_split_dir_part if this doesn't use file anyway?

How about `BLI_path_split_dir_part` if this doesn't use `file` anyway?
if (filepath[0] && BLI_exists(filepath)) {
wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true);
PointerRNA props_ptr;
char dir[FILE_MAXDIR];
BLI_path_split_dir_part(filepath, dir, sizeof(dir));
uiItemFullO_ptr(layout,
ot,
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Open File Location"),
ICON_NONE,
nullptr,
WM_OP_INVOKE_DEFAULT,
UI_ITEM_NONE,
&props_ptr);
RNA_string_set(&props_ptr, "filepath", dir);
uiItemS(layout);
}
}
}
{
const ARegion *region = CTX_wm_menu(C) ? CTX_wm_menu(C) : CTX_wm_region(C);