Index: app/tools/gimpcolortool.c
===================================================================
RCS file: /cvs/gnome/gimp/app/tools/gimpcolortool.c,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 gimpcolortool.c
--- app/tools/gimpcolortool.c	3 Jun 2006 15:41:39 -0000	1.30
+++ app/tools/gimpcolortool.c	6 Jun 2006 11:38:53 -0000
@@ -610,27 +610,36 @@ gimp_color_tool_real_picked (GimpColorTo
                              GimpRGB            *color,
                              gint                color_index)
 {
-  GimpTool    *tool = GIMP_TOOL (color_tool);
-  GimpContext *user_context;
+  GimpTool          *tool = GIMP_TOOL (color_tool);
+  GimpContext       *user_context;
+  GimpDialogFactory *dialog_factory;
+  GimpPaletteEditor *palette_editor;
+  GimpSessionInfo   *info;
+  gint               index;
 
   user_context = gimp_get_user_context (tool->display->image->gimp);
+  dialog_factory = gimp_dialog_factory_from_name ("dock");
+  info = gimp_dialog_factory_find_session_info (dialog_factory,
+                                                "gimp-palette-editor");
+  palette_editor = NULL;
+  
+  if (info && info->widget)
+    palette_editor = GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (info->widget)));
 
   if ((color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND ||
        color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND) &&
       GIMP_IMAGE_TYPE_IS_INDEXED (sample_type))
     {
-      GimpDialogFactory *dialog_factory;
-      GimpSessionInfo   *info;
+      GimpSessionInfo   *cminfo;
 
-      dialog_factory = gimp_dialog_factory_from_name ("dock");
-      info = gimp_dialog_factory_find_session_info (dialog_factory,
+      cminfo = gimp_dialog_factory_find_session_info (dialog_factory,
                                                     "gimp-indexed-palette");
 
-      if (info && info->widget)
+      if (cminfo && cminfo->widget)
         {
           GtkWidget *colormap_editor;
 
-          colormap_editor = gtk_bin_get_child (GTK_BIN (info->widget));
+          colormap_editor = gtk_bin_get_child (GTK_BIN (cminfo->widget));
 
           gtk_adjustment_set_value
             (GIMP_COLORMAP_EDITOR (colormap_editor)->index_adjustment,
@@ -645,19 +654,25 @@ gimp_color_tool_real_picked (GimpColorTo
 
     case GIMP_COLOR_PICK_MODE_FOREGROUND:
       gimp_context_set_foreground (user_context, color);
+      index = gimp_palette_editor_get_index (palette_editor, color);
+      if (index != -1)
+        gimp_palette_editor_set_index (palette_editor, index, NULL);
+	
       break;
 
     case GIMP_COLOR_PICK_MODE_BACKGROUND:
       gimp_context_set_background (user_context, color);
+      index = gimp_palette_editor_get_index (palette_editor, color);
+      if (index != -1)
+        gimp_palette_editor_set_index (palette_editor, index, NULL);
+
       break;
 
     case GIMP_COLOR_PICK_MODE_PALETTE:
       {
-        GimpDialogFactory *dialog_factory;
         GdkScreen         *screen;
         GtkWidget         *dockable;
 
-        dialog_factory = gimp_dialog_factory_from_name ("dock");
         screen = gtk_widget_get_screen (tool->display->shell);
         dockable = gimp_dialog_factory_dialog_raise (dialog_factory, screen,
                                                      "gimp-palette-editor",
@@ -665,14 +680,11 @@ gimp_color_tool_real_picked (GimpColorTo
 
         if (dockable)
           {
-            GtkWidget *palette_editor;
             GimpData  *data;
 
             /* don't blink like mad when updating */
             if (pick_state == GIMP_COLOR_PICK_STATE_UPDATE)
               gimp_dockable_blink_cancel (GIMP_DOCKABLE (dockable));
-
-            palette_editor = gtk_bin_get_child (GTK_BIN (dockable));
 
             data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (palette_editor));
 
