[gnome-session] Add a save-session-one-shot key



commit cb5bddf092fb50272b10b76a4d0190a9afa88c7b
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jan 31 15:51:07 2013 -0500

    Add a save-session-one-shot key
    
    This key is interpreted like save-session, except that it
    will be set from within the session, and reset after each use.
    https://bugzilla.gnome.org/show_bug.cgi?id=613270

 data/org.gnome.SessionManager.gschema.xml.in |    5 +++++
 gnome-session/gsm-manager.c                  |    5 +++--
 gnome-session/gsm-session-save.c             |   13 +++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.SessionManager.gschema.xml.in b/data/org.gnome.SessionManager.gschema.xml.in
index c9d857d..b2b220d 100644
--- a/data/org.gnome.SessionManager.gschema.xml.in
+++ b/data/org.gnome.SessionManager.gschema.xml.in
@@ -5,6 +5,11 @@
       <summary>Save sessions</summary>
       <description>If enabled, gnome-session will save the session automatically.</description>
     </key>
+    <key name="auto-save-session-one-shot" type="b">
+      <default>false</default>
+      <summary>Save this session</summary>
+      <description>When enabled, gnome-session will automatically save the next session at log out even if auto saving is disabled.</description>
+    </key>
     <key name="logout-prompt" type="b">
       <default>true</default>
       <summary>Logout prompt</summary>
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index fbe7cb5..27272bd 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -97,6 +97,7 @@
 
 #define GSM_MANAGER_SCHEMA        "org.gnome.SessionManager"
 #define KEY_AUTOSAVE              "auto-save-session"
+#define KEY_AUTOSAVE_ONE_SHOT     "auto-save-session-one-shot"
 #define KEY_LOGOUT_PROMPT         "logout-prompt"
 #define KEY_SHOW_FALLBACK_WARNING "show-fallback-warning"
 
@@ -2092,8 +2093,8 @@ on_xsmp_client_register_request (GsmXSMPClient *client,
 static gboolean
 auto_save_is_enabled (GsmManager *manager)
 {
-        return g_settings_get_boolean (manager->priv->settings,
-                                       KEY_AUTOSAVE);
+        return g_settings_get_boolean (manager->priv->settings, KEY_AUTOSAVE_ONE_SHOT)
+            || g_settings_get_boolean (manager->priv->settings, KEY_AUTOSAVE);
 }
 
 static void
diff --git a/gnome-session/gsm-session-save.c b/gnome-session/gsm-session-save.c
index 69d0d5b..aeb575f 100644
--- a/gnome-session/gsm-session-save.c
+++ b/gnome-session/gsm-session-save.c
@@ -22,6 +22,7 @@
 
 #include <glib.h>
 #include <glib/gstdio.h>
+#include <gio/gio.h>
 
 #include "gsm-util.h"
 #include "gsm-autostart-app.h"
@@ -29,6 +30,10 @@
 
 #include "gsm-session-save.h"
 
+#define GSM_MANAGER_SCHEMA        "org.gnome.SessionManager"
+#define KEY_AUTOSAVE_ONE_SHOT     "auto-save-session-one-shot"
+
+
 static gboolean gsm_session_clear_saved_session (const char *directory,
                                                  GHashTable *discard_hash);
 
@@ -134,11 +139,19 @@ void
 gsm_session_save (GsmStore  *client_store,
                   GError   **error)
 {
+        GSettings       *settings;
         const char      *save_dir;
         SessionSaveData  data;
 
         g_debug ("GsmSessionSave: Saving session");
 
+        /* Clear one shot key autosave in the event its set (so that it's actually
+         * one shot only)
+         */
+        settings = g_settings_new (GSM_MANAGER_SCHEMA);
+        g_settings_set_boolean (settings, KEY_AUTOSAVE_ONE_SHOT, FALSE);
+        g_object_unref (settings);
+
         save_dir = gsm_util_get_saved_session_dir ();
         if (save_dir == NULL) {
                 g_warning ("GsmSessionSave: cannot create saved session directory");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]