<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_window_losefocus(self, window, event):
 """Hides terminal main window when it loses the focus and if the window_losefocus gconf variable is True. """

        if not HidePrevention(self.window).may_hide():
            return

        value = self.settings.general.get_boolean('window-losefocus')
        visible = window.get_property('visible')
        self.losefocus_time = get_server_time(self.window)
        if visible and value:
            log.info("Hiding on focus lose")
            self.hide()