--- gnome-session-2.13.92/gnome-session/startup-programs.c.desensitize-invalid-buttons	2006-03-06 14:38:08.000000000 -0500
+++ gnome-session-2.13.92/gnome-session/startup-programs.c	2006-03-06 15:48:12.000000000 -0500
@@ -22,6 +22,7 @@
 #include <config.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <glib/gstdio.h>
 #include <gnome.h>
 #include <libgnome/gnome-desktop-item.h>
@@ -552,6 +553,48 @@ startup_list_delete (GSList **sl, GtkTre
   spc_write_state ();
 }
 
+gboolean
+startup_list_can_edit (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel)
+{
+  ManualClient *client;
+  GtkTreeIter iter;
+  char *path, *basename;
+  const char * const * system_dirs;
+  int i;
+  gboolean can_edit = TRUE;
+
+  if (!gtk_tree_selection_get_selected (sel, NULL, &iter)) return FALSE;
+
+  gtk_tree_model_get (model, &iter, 0, &client, -1);
+
+  if (g_file_test (client->desktop_file, G_FILE_TEST_EXISTS) && 
+      access (client->desktop_file, W_OK) != 0)
+    return FALSE;
+
+  basename = g_path_get_basename (client->desktop_file);
+
+  system_dirs = g_get_system_data_dirs ();
+  for (i = 0; system_dirs[i] != NULL && can_edit; i++)
+    {
+      path = g_build_filename (system_dirs[i], "gnome", "autostart", basename, NULL);
+      if (g_file_test (path, G_FILE_TEST_EXISTS) && access (path, W_OK) != 0)
+        can_edit = FALSE;
+      g_free (path);
+    }
+
+  system_dirs = g_get_system_config_dirs ();
+  for (i = 0; system_dirs[i] != NULL && can_edit; i++)
+    {
+      path = g_build_filename (system_dirs[i], "autostart", basename, NULL);
+      if (g_file_test (path, G_FILE_TEST_EXISTS) && access (path, W_OK) != 0)
+        can_edit = FALSE;
+      g_free (path);
+    }
+
+  g_free (basename);
+  return can_edit;
+}
+
 /* Check if the selected client can be enabled */
 gboolean
 startup_list_can_enable (GSList **sl, GtkTreeModel *model, GtkTreeSelection *sel)
--- gnome-session-2.13.92/gnome-session/session-properties-capplet.c.desensitize-invalid-buttons	2006-03-06 14:50:12.000000000 -0500
+++ gnome-session-2.13.92/gnome-session/session-properties-capplet.c	2006-03-06 15:51:46.000000000 -0500
@@ -91,7 +91,7 @@ static void saved_sessions (GtkWidget *w
 #define SESSION_STOCK_EDIT "session-stock-edit"
 
 static void
-selection_changed_cb (GtkTreeSelection *selection, GtkTreeView *view)
+session_selection_changed_cb (GtkTreeSelection *selection, GtkTreeView *view)
 {
   gboolean sel;
   GtkWidget *edit_button;
@@ -100,15 +100,42 @@ selection_changed_cb (GtkTreeSelection *
 
   edit_button = g_object_get_data (G_OBJECT (view), "edit");
   delete_button = g_object_get_data (G_OBJECT (view), "delete");
-  enable_button = g_object_get_data (G_OBJECT (view), "enable");
 
-  if (!edit_button || !delete_button || !enable_button)
+  if (!edit_button || !delete_button)
 	return;
 
   sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
 
   gtk_widget_set_sensitive (edit_button, sel);
   gtk_widget_set_sensitive (delete_button, sel);
+}
+
+static void
+startup_selection_changed_cb (GtkTreeSelection *selection, GtkTreeView *view)
+{
+  gboolean sel;
+  GtkWidget *edit_button;
+  GtkWidget *delete_button;
+  GtkWidget *enable_button;
+
+  edit_button = g_object_get_data (G_OBJECT (view), "edit");
+  delete_button = g_object_get_data (G_OBJECT (view), "delete");
+  enable_button = g_object_get_data (G_OBJECT (view), "enable");
+
+  if (!edit_button || !delete_button || !enable_button)
+	return;
+
+  sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
+
+  if (sel && startup_list_can_edit (&startup_list, startup_store, startup_sel))
+    gtk_widget_set_sensitive (edit_button, TRUE);
+  else
+    gtk_widget_set_sensitive (edit_button, FALSE);
+
+  if (sel && startup_list_can_edit (&startup_list, startup_store, startup_sel))
+    gtk_widget_set_sensitive (delete_button, TRUE);
+  else
+    gtk_widget_set_sensitive (delete_button, FALSE);
 
   if (sel)
     {
@@ -342,7 +369,7 @@ capplet_build (void)
 		  		 GTK_WIDGET (sessions_view));
   sessions_sel = gtk_tree_view_get_selection (sessions_view);
   gtk_tree_selection_set_mode (sessions_sel, GTK_SELECTION_SINGLE);
-  g_signal_connect (G_OBJECT (sessions_sel), "changed", (GCallback) selection_changed_cb, sessions_view);
+  g_signal_connect (G_OBJECT (sessions_sel), "changed", (GCallback) session_selection_changed_cb, sessions_view);
   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes (_("Session Name"), renderer, "text", 0, NULL);
   gtk_tree_view_append_column (sessions_view, column);
@@ -430,7 +457,7 @@ capplet_build (void)
 		  		 GTK_WIDGET (startup_view));
   startup_sel = gtk_tree_view_get_selection (startup_view);
   gtk_tree_selection_set_mode (startup_sel, GTK_SELECTION_SINGLE);
-  g_signal_connect (G_OBJECT (startup_sel), "changed", (GCallback) selection_changed_cb, startup_view);
+  g_signal_connect (G_OBJECT (startup_sel), "changed", (GCallback) startup_selection_changed_cb, startup_view);
   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes (_("Command"), renderer, "text", 2, NULL);
   gtk_tree_view_append_column (startup_view, column);
@@ -601,7 +628,7 @@ enable_startup_cb (void)
   else
     startup_list_disable (&startup_list, startup_store, startup_sel);
 
-  selection_changed_cb (startup_sel, startup_view);
+  startup_selection_changed_cb (startup_sel, startup_view);
 }
 
 static void 
