Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/ChangeLog,v
retrieving revision 1.478
diff -u -p -r1.478 ChangeLog
--- ChangeLog	6 Mar 2006 13:30:08 -0000	1.478
+++ ChangeLog	6 Mar 2006 18:47:32 -0000
@@ -1,3 +1,13 @@
+2006-03-06  Vincent Untz  <vuntz@gnome.org>
+
+	* startup-programs.c: (startup_list_add_dialog): do not hard code the
+	user configuration directory, always put the .desktop extension at the
+	end of the filename
+	(startup_list_enable): look at all the relevant system-wide
+	directories for the .desktop file
+	(startup_list_disable): look if the .desktop file is in one of the
+	relevant system-wide directories
+
 2006-03-02  Rodrigo Moya <rodrigo@novell.com>
 
 	* main.c (set_lang): fixed leak.
Index: startup-programs.c
===================================================================
RCS file: /cvs/gnome/gnome-session/gnome-session/startup-programs.c,v
retrieving revision 1.21
diff -u -p -r1.21 startup-programs.c
--- startup-programs.c	28 Feb 2006 16:21:56 -0000	1.21
+++ startup-programs.c	6 Mar 2006 18:47:32 -0000
@@ -500,11 +500,11 @@ startup_list_add_dialog (GSList **sl, Gt
       int i = 2;
 
       basename = g_path_get_basename (client->argv[0]);
-      orig_filename = g_strdup_printf ("%s/.config/autostart/%s.desktop", g_get_home_dir (), basename);
-      filename = g_strdup (orig_filename);
+      orig_filename = g_build_filename (g_get_user_config_dir (), "autostart", basename, NULL);
+      filename = g_strdup_printf ("%s.desktop", orig_filename);
       while (g_file_exists (filename))
         {
-	  char *tmp = g_strdup_printf ("%s-%d", orig_filename, i);
+	  char *tmp = g_strdup_printf ("%s-%d.desktop", orig_filename, i);
 
 	  g_free (filename);
 	  filename = tmp;
@@ -577,15 +577,34 @@ startup_list_enable (GSList **sl, GtkTre
   if (!client->enabled)
     {
      char *path, *basename;
+     const char * const * system_dirs;
+      int i;
 
      basename = g_path_get_basename (client->desktop_file);
 
       /* if the desktop file is in the user's home and there is one file with the same
 	 name in the system-wide dir, just remove it */
      path = g_build_filename (PREFIX, "share", "autostart", basename, NULL);
-     if (g_str_has_prefix (client->desktop_file, g_get_home_dir ())
-	 && g_file_test (path, G_FILE_TEST_EXISTS))
-       client->to_remove = TRUE;
+     if (g_str_has_prefix (client->desktop_file, g_get_user_config_dir ())) {
+       system_dirs = g_get_system_data_dirs ();
+       for (i = 0; system_dirs[i] != NULL && !client->to_remove; i++)
+         {
+           path = g_build_filename (system_dirs[i], "gnome", "autostart", NULL);
+           if (g_file_test (path, G_FILE_TEST_EXISTS))
+             client->to_remove = TRUE;
+           g_free (path);
+         }
+
+       /* support old place (/etc/xdg/autostart) */
+       system_dirs = g_get_system_config_dirs ();
+       for (i = 0; system_dirs[i] != NULL && !client->to_remove; i++)
+         {
+           path = g_build_filename (system_dirs[i], "autostart", NULL);
+           if (g_file_test (path, G_FILE_TEST_EXISTS))
+             client->to_remove = TRUE;
+           g_free (path);
+         }
+     }
 
      client->enabled = TRUE;
 
@@ -608,17 +627,39 @@ startup_list_disable (GSList **sl, GtkTr
   if (client->enabled)
     {
       char *path, *basename;
+      const char * const * system_dirs;
+      int i;
 
       basename = g_path_get_basename (client->desktop_file);
 
       /* if the desktop file is in the system-wide dir, create another one on
        the user's home */
-      if (g_str_has_prefix (client->desktop_file, PREFIX))
+      system_dirs = g_get_system_data_dirs ();
+      for (i = 0; system_dirs[i] != NULL && !client->to_remove; i++)
         {
-          path = g_build_filename (g_get_home_dir (), ".config", "autostart", basename, NULL);
-	  g_free (client->desktop_file);
-	  client->desktop_file = path;
-	}
+          if (g_str_has_prefix (client->desktop_file, system_dirs[i]))
+            {
+              path = g_build_filename (g_get_user_config_dir (), "autostart", basename, NULL);
+              g_free (client->desktop_file);
+              client->desktop_file = path;
+
+	      break;
+            }
+        }
+
+      /* support old place (/etc/xdg/autostart) */
+      system_dirs = g_get_system_config_dirs ();
+      for (i = 0; system_dirs[i] != NULL && !client->to_remove; i++)
+        {
+          if (g_str_has_prefix (client->desktop_file, system_dirs[i]))
+            {
+              path = g_build_filename (g_get_user_config_dir (), "autostart", basename, NULL);
+              g_free (client->desktop_file);
+              client->desktop_file = path;
+
+	      break;
+            }
+        }
 
       client->enabled = FALSE;
       spc_write_state ();
