diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-06 14:16:47 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-06 14:16:47 +0100 |
commit | 4659883ba00bd499f41f4cc1a5f96e4bdd5ac9de (patch) | |
tree | 74211870b90bb20c0041c8a76d677579a88206a9 /Locker.py | |
parent | e342d5c7241cd04352948fb6937e05a98000b70c (diff) | |
download | pylock-4659883ba00bd499f41f4cc1a5f96e4bdd5ac9de.tar pylock-4659883ba00bd499f41f4cc1a5f96e4bdd5ac9de.zip |
Rework pylock to behave like xlock
Diffstat (limited to 'Locker.py')
-rw-r--r-- | Locker.py | 25 |
1 files changed, 2 insertions, 23 deletions
@@ -24,35 +24,16 @@ from gi.repository import Gtk, GLib -import Idle - class Locker(object): - def __init__(self, lockTimeout, doLock, doUnlock, logoutTimeout = None, doLogout = None, updateLogoutTimeout = None): + def __init__(self, doLock, doUnlock, logoutTimeout = None, 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 - if self.lockTimeout > 0: - GLib.timeout_add_seconds(1, self._checkLock) - else: - GLib.idle_add(self.lock) - - def _checkLock(self): - if self.locked: - return False - - idle = Idle.getIdleSec() - if (idle >= self.lockTimeout): - GLib.idle_add(self.lock) - return False - else: - return True - def _checkLogout(self): if not self.locked: return False @@ -68,7 +49,7 @@ class Locker(object): self.locked = True if not self.doLock(self.logoutTimeout): self.locked = False - GLib.timeout_add_seconds(1, self._checkLock) + GLib.timeout_add_seconds(1, self.lock) return False if self.doLogout is not None: @@ -84,8 +65,6 @@ class Locker(object): self.doUnlock() self.locked = False - GLib.timeout_add_seconds(1, self._checkLock) - def _canLogout(self): return (self.locked and self.doLogout is not None and self.currentLogoutTimeout <= 0) |