diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-02-01 19:53:29 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-02-01 19:58:55 +0100 |
commit | 9981f9f6a2205ed56f16989b590d939d5dac974a (patch) | |
tree | 01c629eb1751483a77e9afc2175ff57a3b11d238 /Locker.py | |
parent | 2ea569c7ed70a40cccaaf32b3f8ea2e7127ac062 (diff) | |
download | pylock-9981f9f6a2205ed56f16989b590d939d5dac974a.tar pylock-9981f9f6a2205ed56f16989b590d939d5dac974a.zip |
Add logout button timeout. Add l10n support.
Diffstat (limited to 'Locker.py')
-rw-r--r-- | Locker.py | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -4,17 +4,18 @@ import Idle class Locker(object): - def __init__(self, lockTimeout, doLock, doUnlock, logoutTimeout = 0, doLogout = None): + def __init__(self, lockTimeout, doLock, doUnlock, logoutTimeout = 0, doLogout = None, updateLogoutTimeout = None): self.locked = False self.lockTimeout = lockTimeout self.logoutTimeout = logoutTimeout self.doLock = doLock self.doUnlock = doUnlock self.doLogout = doLogout + self.updateLogoutTimeout = updateLogoutTimeout - GLib.timeout_add_seconds(1, self.checkLock) + GLib.timeout_add_seconds(1, self._checkLock) - def checkLock(self): + def _checkLock(self): if self.locked: return False @@ -25,14 +26,27 @@ class Locker(object): else: return True + def _checkLogout(self): + self.currentLogoutTimeout = self.currentLogoutTimeout - 1 + if self.updateLogoutTimeout is not None: + self.updateLogoutTimeout(self.currentLogoutTimeout) + + return self.currentLogoutTimeout > 0 + def lock(self): if not self.locked: - self.doLock() + self.doLock(self.logoutTimeout) self.locked = True + if self.doLogout is not None: + self.currentLogoutTimeout = self.logoutTimeout + + if self.currentLogoutTimeout > 0: + GLib.timeout_add_seconds(1, self._checkLogout) + def unlock(self): if self.locked: self.doUnlock() self.locked = False - GLib.timeout_add(100, self.checkLock) + GLib.timeout_add_seconds(1, self._checkLock) |