summaryrefslogtreecommitdiffstats
path: root/LockWindow.py
diff options
context:
space:
mode:
Diffstat (limited to 'LockWindow.py')
-rw-r--r--LockWindow.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/LockWindow.py b/LockWindow.py
index 89d7576..25d7546 100644
--- a/LockWindow.py
+++ b/LockWindow.py
@@ -9,6 +9,7 @@ _ = locale.gettext
class LockWindow(Gtk.Window):
__gsignals__ = {
+ 'logout': (GObject.SIGNAL_RUN_FIRST, None, ()),
'tryUnlock': (GObject.SIGNAL_RUN_FIRST, None, (str,))
}
@@ -44,40 +45,56 @@ class LockWindow(Gtk.Window):
self.unlockWindow.connect('delete-event', lambda w, e: True)
self.promptEntry.connect('activate', lambda w: self._tryUnlock())
+ self.logoutButton.connect('clicked', lambda w: self._logout())
self.unlockButton.connect('clicked', lambda w: self._tryUnlock())
- self.reset()
+ self.reset(True)
+
+ def _logout(self):
+ self.promptEntry.set_sensitive(False)
+ self.unlockButton.set_sensitive(False)
+ self.logoutButton.set_sensitive(False)
+ GLib.idle_add(lambda: self.emit('logout'))
def _tryUnlock(self):
self.promptEntry.set_sensitive(False)
self.unlockButton.set_sensitive(False)
+ self.logoutButton.set_sensitive(False)
GLib.idle_add(lambda: self.emit('tryUnlock', self.promptEntry.get_text()))
- def reset(self):
- self.promptEntry.set_text('')
- self.promptEntry.set_sensitive(True)
- self.promptEntry.grab_focus()
+ def _update(self):
+ self.promptEntry.set_sensitive(self._enablePromptEntry)
+ self.logoutButton.set_sensitive(self._enableLogoutButton)
+ self.unlockButton.set_sensitive(self._enableUnlockButton)
- self.unlockButton.set_sensitive(True)
+ def reset(self, resetButtons = False):
+ if resetButtons:
+ self._enablePromptEntry = True
+ self._enableLogoutButton = False
+ self._enableUnlockButton = True
+ self.promptEntry.set_text('')
self.messageLabel.set_label('')
+ self._update()
+
+ self.promptEntry.grab_focus()
- self.logoutButton.set_sensitive(False)
def updateLockMessage(self, username, logoutTime = None):
if logoutTime is None:
self.lockLabel.set_markup(_('This computer is currently locked by the user <i>{username}</i>.').format(username=GLib.markup_escape_text(username)))
- self.logoutButton.set_sensitive(False)
+ self._enableLogoutButton = False
elif logoutTime > 0:
self.lockLabel.set_markup(
_('This computer is currently locked by the user <i>{username}</i>.\nThe user can be logged out in {minutes:02}:{seconds:02} minutes.').format(
username=GLib.markup_escape_text(username), minutes=logoutTime//60, seconds=logoutTime%60))
- self.logoutButton.set_sensitive(False)
+ self._enableLogoutButton = False
else:
self.lockLabel.set_markup(
_('This computer is currently locked by the user <i>{username}</i>.\nThe user can be logged out now.').format(
username=GLib.markup_escape_text(username)))
- self.logoutButton.set_sensitive(True)
+ self._enableLogoutButton = True
+ self._update()
def setAuthMessage(self, message):
self.messageLabel.set_label(message)
@@ -92,4 +109,4 @@ class LockWindow(Gtk.Window):
self.unlockWindow.hide()
self.hide()
- self.reset()
+ self.reset(True)