Dialog windows open conditionally

From #641.