def METHOD_NAME(self, enabled):
    self._enabled = enabled
    if not enabled:
        last_selected_task_name = self.get_selected_task_name()
        if last_selected_task_name:
            self._last_selected_task_name = last_selected_task_name
        self._clear_selection()
    elif self._last_selected_task_name is not None:
        self.select_task_name(self._last_selected_task_name)