1
1

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.
This commit is contained in:
2021-07-30 16:27:52 +02:00
parent 3316e28418
commit 3b2a6bf8e8

View File

@@ -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;
}
/** \} */