本文整理汇总了Python中stage.Stage.transition_in方法的典型用法代码示例。如果您正苦于以下问题:Python Stage.transition_in方法的具体用法?Python Stage.transition_in怎么用?Python Stage.transition_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stage.Stage
的用法示例。
在下文中一共展示了Stage.transition_in方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScreensaverManager
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import transition_in [as 别名]
#.........这里部分代码省略.........
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.Locked and self.stage.initialize_pam():
self.stage.raise_unlock_widget()
self.grab_helper.release_mouse()
self.stage.maybe_update_layout()
else:
GObject.idle_add(self.idle_deactivate)
def idle_deactivate(self):
self.set_active(False)
return False
def spawn_stage(self, away_message, effect_time=c.STAGE_SPAWN_TRANSITION, callback=None):
"""
Create the Stage and begin fading it in. This may run quickly, in the case of
user-initiated activation, or slowly, when the session has gone idle.
"""
try:
self.stage = Stage(self.screen, self, away_message)
self.stage.transition_in(effect_time, callback)
except Exception:
print("Could not spawn screensaver stage:\n")
traceback.print_exc()
self.grab_helper.release()
status.Active = False
self.cancel_timers()
def despawn_stage(self, effect_time=c.STAGE_DESPAWN_TRANSITION, callback=None):
"""
Begin destruction of the stage.
"""
self.stage.cancel_unlocking()
self.stage.transition_out(effect_time, callback)
def on_spawn_stage_complete(self):
"""
Called after the stage has faded in. All user events are now
redirected to GrabHelper, our status is updated, our active timer
is started, and emit an active-changed signal (Which is listened to
by our ConsoleKit client if we're using it, and our own ScreensaverService.)
"""
self.grab_stage()
status.Active = True
self.emit("active-changed", True)
self.start_timers()
def on_despawn_stage_complete(self):
"""
Called after the stage has faded out - the stage is destroyed, our status
示例2: ScreensaverManager
# 需要导入模块: from stage import Stage [as 别名]
# 或者: from stage.Stage import transition_in [as 别名]
class ScreensaverManager(GObject.Object):
__gsignals__ = {
'active-changed': (GObject.SignalFlags.RUN_LAST, None, (bool, )),
}
def __init__(self):
super(ScreensaverManager, self).__init__()
self.screen = Gdk.Screen.get_default()
self.activated_timestamp = 0
self.stage = None
# Ensure our state
status.Active = False
status.Locked = False
status.Awake = False
self.grab_helper = GrabHelper(self)
self.focus_nav = FocusNavigator()
self.session_client = singletons.SessionClient
trackers.con_tracker_get().connect(self.session_client,
"idle-changed",
self.on_session_idle_changed)
self.cinnamon_client = singletons.CinnamonClient
singletons.LoginClientResolver(self)
##### Service handlers (from service.py)
def is_locked(self):
return status.Locked
def lock(self, msg=""):
if not status.Active:
if self.set_active(True, msg):
self.stop_lock_delay()
if utils.user_can_lock():
status.Locked = True
else:
if utils.user_can_lock():
status.Locked = True
self.stage.set_message(msg)
def unlock(self):
self.set_active(False)
status.Locked = False
status.Awake = False
def set_active(self, active, msg=None):
if active:
if not status.Active:
self.cinnamon_client.exit_expo_and_overview()
if self.grab_helper.grab_root(False):
if not self.stage:
self.spawn_stage(msg, c.STAGE_SPAWN_TRANSITION, self.on_spawn_stage_complete)
return True
else:
status.Active = False
return False
else:
self.stage.set_message(msg)
return True
else:
if self.stage:
self.despawn_stage(c.STAGE_DESPAWN_TRANSITION, self.on_despawn_stage_complete)
self.grab_helper.release()
return True
return False
def get_active(self):
return status.Active
def get_active_time(self):
if self.activated_timestamp != 0:
return int(time.time() - self.activated_timestamp)
else:
return 0
def simulate_user_activity(self):
if not status.Active:
return
if status.Locked:
self.stage.raise_unlock_widget()
self.grab_helper.release_mouse()
else:
self.set_active(False)
self.stage.maybe_update_layout()
#####
def spawn_stage(self, away_message, effect_time=c.STAGE_SPAWN_TRANSITION, callback=None):
try:
self.stage = Stage(self.screen, self, away_message)
self.stage.transition_in(effect_time, callback)
#.........这里部分代码省略.........