From 3b2a6bf8e8f87c2d1a8927637c562502af8083b9 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 30 Jul 2021 16:27:52 +0200 Subject: UI: Don't show Windows file association operator in search on other OSes The Windows-specific "Register File Association" operator would show in the search menu of other platforms. Decided to not disable it at compile-time, like we do it with "Toggle System Console" (another Windows-only operator), because that would require workarounds for the translation tools. Instead the operator poll function always returns false on unsupported platforms now. --- source/blender/editors/space_userpref/userpref_ops.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index 79f5d1818cb..63506678b70 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -197,6 +197,17 @@ static void PREFERENCES_OT_asset_library_remove(wmOperatorType *ot) /** \name Associate File Type Operator (Windows only) * \{ */ +static bool associate_blend_poll(bContext *C) +{ +#ifdef WIN32 + UNUSED_VARS(C); + return true; +#else + CTX_wm_operator_poll_msg_set(C, "Windows-only operator"); + return false; +#endif +} + static int associate_blend_exec(bContext *UNUSED(C), wmOperator *op) { #ifdef WIN32 @@ -212,7 +223,8 @@ static int associate_blend_exec(bContext *UNUSED(C), wmOperator *op) return OPERATOR_CANCELLED; } #else - BKE_report(op->reports, RPT_WARNING, "Operator Not supported"); + UNUSED_VARS(op); + BLI_assert_unreachable(); return OPERATOR_CANCELLED; #endif } @@ -226,6 +238,7 @@ static void PREFERENCES_OT_associate_blend(struct wmOperatorType *ot) /* api callbacks */ ot->exec = associate_blend_exec; + ot->poll = associate_blend_poll; } /** \} */ -- cgit v1.2.3