[gnome-session] gsm: Use app-id when saving session instead of startup-id for .desktop



commit cc2560d9570077bcd1e0152b50462b4eb4e35eb8
Author: Vincent Untz <vuntz gnome org>
Date:   Tue Mar 22 15:55:02 2011 +0100

    gsm: Use app-id when saving session instead of startup-id for .desktop
    
    We try to use the app-id whenever possible for the .desktop filename
    when saving an app since this means the saved app can be used as
    required component on login. (Still fallback to startup-id if app-id
    doesn't work because it's empty or filename already exists)
    
    This is important because on login, the required component will be
    loaded first, and if it's in the saved session with another name, the
    saved version will get ignored: we first load all required components
    from saved/autostart/apps, and then we load other apps in the saved
    session (and the saved component, if using another name, will look like
    a random app so will be loaded at that time).

 gnome-session/gsm-session-save.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/gnome-session/gsm-session-save.c b/gnome-session/gsm-session-save.c
index b31d9fa..089e71c 100644
--- a/gnome-session/gsm-session-save.c
+++ b/gnome-session/gsm-session-save.c
@@ -45,6 +45,7 @@ save_one_client (char            *id,
 {
         GsmClient  *client;
         GKeyFile   *keyfile;
+        const char *app_id;
         char       *path = NULL;
         char       *filename = NULL;
         char       *contents = NULL;
@@ -68,10 +69,26 @@ save_one_client (char            *id,
                 goto out;
         }
 
-        filename = g_strdup_printf ("%s.desktop",
-                                    gsm_client_peek_startup_id (client));
+        app_id = gsm_client_peek_app_id (client);
+        if (!IS_STRING_EMPTY (app_id)) {
+                if (g_str_has_suffix (app_id, ".desktop"))
+                        filename = g_strdup (app_id);
+                else
+                        filename = g_strdup_printf ("%s.desktop", app_id);
 
-        path = g_build_filename (data->dir, filename, NULL);
+                path = g_build_filename (data->dir, filename, NULL);
+        }
+
+        if (!path || g_file_test (path, G_FILE_TEST_EXISTS)) {
+                if (filename)
+                        g_free (filename);
+                if (path)
+                        g_free (path);
+
+                filename = g_strdup_printf ("%s.desktop",
+                                            gsm_client_peek_startup_id (client));
+                path = g_build_filename (data->dir, filename, NULL);
+        }
 
         g_file_set_contents (path,
                              contents,



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