def start_positioning(self): self.show() if settings.get_allow_floating(): trackers.timer_tracker_get().cancel(str(self) + "positioning") trackers.timer_tracker_get().start_seconds(str(self) + "positioning", POSITIONING_TIMEOUT, self.positioning_callback)
def simulate_user_activity(self): """ Called upon any key, motion or button event, does different things depending on our current state. If we're idle: - do nothing If we're locked: - show the unlock widget (if it's already visible, this also has the effect of resetting the unlock timeout - see Stage.py) - show the mouse pointer, so the user can navigate the unlock screen. If we're Active but not Locked, simply deactivate (destroying the Stage and returning the screensaver back to idle mode.) """ if not status.Active: return if status.Debug and not status.Awake: print("manager: user activity, waking") if status.Locked and self.stage.initialize_pam(): if status.Debug and not status.Awake: print("manager: locked, raising unlock widget") self.stage.raise_unlock_widget() self.grab_helper.release_mouse() self.stage.maybe_update_layout() else: if status.Debug: print("manager: not locked, queueing idle deactivation") trackers.timer_tracker_get().add_idle("idle-deactivate", self.idle_deactivate)
def align_clock(self): current_halign = int(self.get_halign()) horizontal = current_halign current_valign = int(self.get_valign()) vertical = current_valign while horizontal == current_halign: horizontal = ALIGNMENTS[random.randint(0, 2)] while vertical == current_valign: vertical = ALIGNMENTS[random.randint(0, 2)] self.set_halign(Gtk.Align(horizontal)) self.set_valign(Gtk.Align(vertical)) if self.screen.get_n_monitors() > 1: new_monitor = self.current_monitor n = self.screen.get_n_monitors() while new_monitor == self.current_monitor: new_monitor = random.randint(0, n - 1) self.current_monitor = new_monitor self.queue_resize() self.reveal() trackers.timer_tracker_get().cancel("align-clock-timeout") return False
def positioning_callback(self): self.unreveal() self.queue_resize() trackers.timer_tracker_get().start(str(self) + "align-timeout", self.REVEALER_DURATION + 10, self.align_clock) return True
def set_timeout_active(self, dialog, active): if active: trackers.timer_tracker_get().start("wake-timeout", c.UNLOCK_TIMEOUT * 1000, self.on_wake_timeout) else: trackers.timer_tracker_get().cancel("wake-timeout")
def update_position_timer(self, status): """ Starts or stops the position update timer - this is based upon the provided rate property of the player, which is defined as the recommended update frequency for position data. """ if status == PlaybackStatus.Playing: trackers.timer_tracker_get().start("position-timer", self.player.get_rate() * 1000, self.update_position_display) else: trackers.timer_tracker_get().cancel("position-timer")
def set_timeout_active(self, dialog, active): """ Start or stop the dialog timer """ if active and not status.InteractiveDebug: trackers.timer_tracker_get().start("wake-timeout", c.UNLOCK_TIMEOUT * 1000, self.on_wake_timeout) else: trackers.timer_tracker_get().cancel("wake-timeout")
def on_session_idle_changed(self, proxy, idle): if idle and not status.Active: if self.grab_helper.grab_offscreen(False): self.spawn_stage("", c.STAGE_IDLE_SPAWN_TRANSITION, self.on_spawn_stage_complete) else: print("Can't fade in screensaver, unable to grab the keyboard") else: if not status.Active: if self.stage: self.despawn_stage(c.STAGE_IDLE_CANCEL_SPAWN_TRANSITION, self.on_despawn_stage_complete) trackers.timer_tracker_get().start("release-grab-timeout", c.GRAB_RELEASE_TIMEOUT, self.on_release_grab_timeout)
def on_widget_destroy(self, widget, data=None): trackers.con_tracker_get().disconnect(self.player, "position-changed", self.on_position_changed) trackers.con_tracker_get().disconnect(self.player, "status-changed", self.on_playback_status_changed) trackers.con_tracker_get().disconnect(self, "destroy", self.on_widget_destroy) trackers.timer_tracker_get().cancel("position-timer")
def start_lock_delay(self): if not settings.get_idle_lock_enabled(): return if not utils.user_can_lock(): return lock_delay = settings.get_idle_lock_delay() if lock_delay == 0: self.on_lock_delay_timeout() else: trackers.timer_tracker_get().start_seconds("idle-lock-delay", lock_delay, self.on_lock_delay_timeout)
def on_session_idle_changed(self, proxy, idle): """ Call back for the session client - initiates a slow fade-in for the stage when the session goes idle. Cancels the stage fade-in if idle becomes False before it has completed its animation. """ if idle and not status.Active: if self.grab_helper.grab_offscreen(False): self.spawn_stage("", c.STAGE_IDLE_SPAWN_TRANSITION, self.on_spawn_stage_complete) else: print("Can't fade in screensaver, unable to grab the keyboard") else: if not status.Active: if self.stage: self.despawn_stage(c.STAGE_IDLE_CANCEL_SPAWN_TRANSITION, self.on_despawn_stage_complete) trackers.timer_tracker_get().start("release-grab-timeout", c.GRAB_RELEASE_TIMEOUT, self.on_release_grab_timeout)
def start_lock_delay(self): """ Setup the lock delay timer based on user prefs - if there is no delay, or if idle locking isn't enabled, we run the callback immediately, or simply return, respectively. """ if not settings.get_idle_lock_enabled(): return if not utils.user_can_lock(): return lock_delay = settings.get_idle_lock_delay() if lock_delay == 0: self.on_lock_delay_timeout() else: trackers.timer_tracker_get().start_seconds("idle-lock-delay", lock_delay, self.on_lock_delay_timeout)
def on_despawn_stage_complete(self): """ Called after the stage has faded out - the stage is destroyed, our status is updated, timer is canceled and active-changed is fired. """ was_active = status.Active == True status.Active = False if was_active: self.emit("active-changed", False) self.cancel_timers() self.stage.destroy_stage() self.stage = None # Ideal time to check for leaking connections that might prevent GC by python and gobject if trackers.DEBUG_SIGNALS: trackers.con_tracker_get().dump_connections_list() if trackers.DEBUG_TIMERS: trackers.timer_tracker_get().dump_timer_list()
def stop_positioning(self): trackers.timer_tracker_get().cancel(str(self) + "positioning")
def update_position_timer(self, status): if status == PlaybackStatus.Playing: trackers.timer_tracker_get().start("position-timer", self.player.get_rate() * 1000, self.update_position_display) else: trackers.timer_tracker_get().cancel("position-timer")
def stop_positioning(self): if settings.get_allow_floating(): trackers.timer_tracker_get().cancel(str(self) + "positioning")
def idle_deactivate(self): self.set_active(False) trackers.timer_tracker_get().cancel("idle-deactivate") return False
def start_positioning(self): trackers.timer_tracker_get().cancel(str(self) + "positioning") trackers.timer_tracker_get().start_seconds( str(self) + "positioning", POSITIONING_TIMEOUT, self.positioning_callback)
def stop_positioning(self): trackers.timer_tracker_get().cancel("clock-positioning")
def stop_progress(self): trackers.timer_tracker_get().cancel("auth-progress") self.set_progress_fraction(0.0)
def start_positioning(self): trackers.timer_tracker_get().cancel("clock-positioning") trackers.timer_tracker_get().start_seconds("clock-positioning", CLOCK_POSITIONING_TIMEOUT, self.positioning_callback)
def stop_lock_delay(self): trackers.timer_tracker_get().cancel("idle-lock-delay")
def start_positioning(self): trackers.timer_tracker_get().cancel(str(self) + "positioning") trackers.timer_tracker_get().start_seconds( str(self) + "positioning", POSITIONING_TIMEOUT, self.positioning_callback )
def start_progress(self): self.set_progress_pulse_step(0.2) trackers.timer_tracker_get().start("auth-progress", 100, self.pulse)
def stop_lock_delay(self): """ Cancels the lock delay timer. """ trackers.timer_tracker_get().cancel("idle-lock-delay")