Fix craziness in template dialog focusing
setMode() is called multiple times, but it didn't
check whether the mode being set was already set.
Because it's a setter, make it idempotent.
This fixes the problem where the first input will
be focused first, then blurred later, but it
introduces a new problem because the label for
the 'mode' ActionWidget is set from setMode().
To solve that, factor the setting of this label
out into its own function and call it on setup.