diff options
author | Stefano Karapetsas <[email protected]> | 2014-07-08 11:43:04 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2014-07-08 11:43:04 +0200 |
commit | 1cc02144b717d503fe285361f75819ca48089c79 (patch) | |
tree | 10ca1d696139665fdfafd98411d1024a2ceab40e | |
parent | 06778518d38fc40cd106ac1a2a525ee2f416dc10 (diff) | |
download | mate-session-manager-1cc02144b717d503fe285361f75819ca48089c79.tar.bz2 mate-session-manager-1cc02144b717d503fe285361f75819ca48089c79.tar.xz |
Add key in GSettings schema to set logout timeout in seconds
0 disables timeout
-rw-r--r-- | data/org.mate.session.gschema.xml.in.in | 6 | ||||
-rw-r--r-- | mate-session/gsm-logout-dialog.c | 32 |
2 files changed, 28 insertions, 10 deletions
diff --git a/data/org.mate.session.gschema.xml.in.in b/data/org.mate.session.gschema.xml.in.in index 2415c67..4ce615e 100644 --- a/data/org.mate.session.gschema.xml.in.in +++ b/data/org.mate.session.gschema.xml.in.in @@ -15,6 +15,12 @@ <_summary>Logout prompt</_summary> <_description>If enabled, mate-session will prompt the user before ending a session.</_description> </key> + <key name="logout-timeout" type="i"> + <default>60</default> + <range min="0" max="300"/> + <_summary>Logout timeout</_summary> + <_description>If logout prompt is enabled, this set the timeout in seconds before logout automatically. If 0, automatic logout is disabled.</_description> + </key> <key name="idle-delay" type="i"> <default>5</default> <_summary>Time before session is considered idle</_summary> diff --git a/mate-session/gsm-logout-dialog.c b/mate-session/gsm-logout-dialog.c index da3d651..8b48ced 100644 --- a/mate-session/gsm-logout-dialog.c +++ b/mate-session/gsm-logout-dialog.c @@ -41,11 +41,12 @@ #define GSM_LOGOUT_DIALOG_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_LOGOUT_DIALOG, GsmLogoutDialogPrivate)) -#define AUTOMATIC_ACTION_TIMEOUT 60 - #define GSM_ICON_LOGOUT "system-log-out" #define GSM_ICON_SHUTDOWN "system-shutdown" +#define SESSION_SCHEMA "org.mate.session" +#define KEY_LOGOUT_TIMEOUT "logout-timeout" + typedef enum { GSM_DIALOG_LOGOUT_TYPE_LOGOUT, GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN @@ -397,18 +398,29 @@ gsm_logout_dialog_timeout (gpointer data) static void gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog) { - logout_dialog->priv->timeout = AUTOMATIC_ACTION_TIMEOUT; + GSettings *settings; - /* Sets the secondary text */ - gsm_logout_dialog_timeout (logout_dialog); + settings = g_settings_new (SESSION_SCHEMA); - if (logout_dialog->priv->timeout_id != 0) { - g_source_remove (logout_dialog->priv->timeout_id); + logout_dialog->priv->timeout = g_settings_get_int (settings, KEY_LOGOUT_TIMEOUT); + + if (logout_dialog->priv->timeout > 0) { + /* Sets the secondary text */ + gsm_logout_dialog_timeout (logout_dialog); + + if (logout_dialog->priv->timeout_id != 0) { + g_source_remove (logout_dialog->priv->timeout_id); + } + + logout_dialog->priv->timeout_id = g_timeout_add (1000, + gsm_logout_dialog_timeout, + logout_dialog); + } + else { + gtk_widget_hide (logout_dialog->priv->progressbar); } - logout_dialog->priv->timeout_id = g_timeout_add (1000, - gsm_logout_dialog_timeout, - logout_dialog); + g_object_unref (settings); } static GtkWidget * |