Index: baobab/src/baobab-ringschart.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/baobab/src/baobab-ringschart.c,v
retrieving revision 1.1
diff -u -p -r1.1 baobab-ringschart.c
--- baobab/src/baobab-ringschart.c	2 Oct 2006 10:34:09 -0000	1.1
+++ baobab/src/baobab-ringschart.c	29 Oct 2006 17:23:09 -0000
@@ -20,7 +20,7 @@
  *
  * Authors:
  *   Mario Sanchez <msanchez@igalia.com>
- *   Miguel Gomez <mgomez@igalia.com>
+ *   Miguel Gomez <magomez@igalia.com>
  *   Henrique Ferreiro <hferreiro@igalia.com>
  *   Alejandro Pinheiro <apinheiro@igalia.com>
  *   Carlos Sanmartin <csanmartin@igalia.com>
@@ -175,7 +175,8 @@ static void draw_sector (cairo_t *cr, 
 static void draw_circle (cairo_t *cr, 
                          gdouble center_x, 
                          gdouble center_y,
-                         gdouble radius);
+                         gdouble radius,
+                         gboolean highlighted);
 static void draw_tip (cairo_t *cr,
                       GtkWidget *rchart,
                       gdouble init_angle,
@@ -183,11 +184,14 @@ static void draw_tip (cairo_t *cr,
                       gdouble depth,
                       gchar *name,
                       gchar *size);
-static Color *interpolate_colors (Color colora,
-                                  Color colorb,
-                                  gdouble percentage);
-static Color *get_color (gdouble angle,
-                         gint circle_number);
+static void interpolate_colors (Color *color,
+                                Color colora,
+                                Color colorb,
+                                gdouble percentage);
+static void get_color (Color *color,
+                       gdouble angle,
+                       gint circle_number,
+                       gboolean highlighted);
 static void tree_traverse (cairo_t *cr,
                            BaobabRingschart *rchart,
                            GtkTreeIter *iter,
@@ -658,6 +662,9 @@ baobab_ringschart_draw (GtkWidget *rchar
       max_angle = 2*M_PI*perc*0.01;
     }
 
+  if (priv->draw_center)
+    draw_circle (cr, priv->center_x, priv->center_y, priv->min_radius, FALSE);
+
   tree_traverse(cr, BAOBAB_RINGSCHART (rchart), &initial_iter, 
                 priv->init_depth, priv -> min_radius, 0, max_angle, &tooltips, 
                 !priv->button_pressed);
@@ -688,6 +695,10 @@ baobab_ringschart_draw (GtkWidget *rchar
 
         tooltip = tips_iter->data;
 
+        /* check if the root is highlihgted in order to redraw it*/
+        if ((priv->draw_center) && (tooltip->depth == -1))
+            draw_circle (cr, priv->center_x, priv->center_y, priv->min_radius, TRUE);
+
         draw_tip (cr, rchart, tooltip->init_angle, tooltip->final_angle, 
                   tooltip->depth , tooltip->name, tooltip->size);
 
@@ -742,9 +753,12 @@ static void 
 draw_circle (cairo_t *cr, 
              gdouble center_x, 
              gdouble center_y,
-             gdouble radius)
+             gdouble radius,
+             gboolean highlighted)
 {
-  const Color fill_color  = {0.83, 0.84, 0.82}; /* tango: d3d7cf */
+  Color fill_color;
+  
+  get_color (&fill_color, 0, 0, highlighted);
   
   cairo_save (cr);
 
@@ -885,12 +899,12 @@ draw_tip (cairo_t *cr,
   g_free (text);
 }
 
-static Color *
-interpolate_colors (Color colora,
+static void
+interpolate_colors (Color *color,
+                    Color colora,
                     Color colorb,
                     gdouble percentage)
 {
-  Color *color = g_new0 (Color, 1);
   gdouble diff;
 
   diff = colora.red - colorb.red;
@@ -900,34 +914,52 @@ interpolate_colors (Color colora,
   color->green = colora.green-diff*percentage;
 
   diff = colora.blue - colorb.blue;
-  color->blue = colora.blue-diff*percentage;
-  
-  return color;
+  color->blue = colora.blue-diff*percentage; 
 }
 
-static Color *
-get_color (gdouble angle,
-	   gint circle_number)
+static void
+get_color (Color *color,
+           gdouble angle,
+      	   gint circle_number,
+      	   gboolean highlighted)
 {
-  Color *color;
   gdouble intensity;
   gint color_number;
   gint next_color_number;
 
   intensity = 1-((circle_number*0.3)/MAX_DRAWABLE_DEPTH);
 
-  color_number = angle / (M_PI/3);
-  next_color_number = (color_number+1) % 6;
+  if (circle_number == 0)
+    {
+      static const Color circle_color = {0.83, 0.84, 0.82};
 
-  color = interpolate_colors (tango_colors[color_number], 
-                              tango_colors[next_color_number],
-                              (angle-color_number*M_PI/3)/(M_PI/3));
-
-  color->red = color->red * intensity;
-  color->green = color->green * intensity;
-  color->blue = color->blue * intensity;
+      *color = circle_color;
+    }
+  else
+    {
+      color_number = angle / (M_PI/3);
+      next_color_number = (color_number+1) % 6;
+
+      interpolate_colors (color,
+                          tango_colors[color_number],
+                          tango_colors[next_color_number],
+                          (angle-color_number*M_PI/3)/(M_PI/3));
+      color->red = color->red * intensity;
+      color->green = color->green * intensity;
+      color->blue = color->blue * intensity;
+    }
   
-  return color;
+  if (highlighted)
+    {
+      gdouble maximum;
+      
+      maximum = MAX (color->red,
+                     MAX (color->green,
+                          color->blue));
+      color->red /= maximum;
+      color->green /= maximum;
+      color->blue /= maximum;
+    }
 }
 
 static void
@@ -942,8 +974,9 @@ tree_traverse (cairo_t *cr,
                gboolean real_draw)
 {
   BaobabRingschartPrivate *priv;
-  Color *fill_color;
+  Color fill_color;
   GtkTreeIter child;
+  gboolean highlighted = FALSE;
 
   priv = BAOBAB_RINGSCHART_GET_PRIVATE (rchart);
 
@@ -997,6 +1030,7 @@ tree_traverse (cairo_t *cr,
                   tip->size = size_column;
                   
                   *tooltips = g_slist_prepend (*tooltips , tip);
+                  highlighted = TRUE;
                 }
             }
           else 
@@ -1012,9 +1046,6 @@ tree_traverse (cairo_t *cr,
         {
           gboolean has_child_max_depth;
 
-          if ((priv->draw_center) && (depth == 1))
-            draw_circle (cr, priv->center_x, priv->center_y, radius); 
-
           /* FIXME: there is a problem when we are not in the
              max_depth but we are not going to paint any child because
              they are too small, the sector will not have a line but
@@ -1022,18 +1053,13 @@ tree_traverse (cairo_t *cr,
           has_child_max_depth = gtk_tree_model_iter_has_child (priv -> model, iter) 
             && (depth >= priv->max_depth);
 
-          fill_color = get_color(init_angle, depth); 
+          get_color (&fill_color, init_angle, depth, highlighted);
           draw_sector(cr, priv->center_x, priv->center_y, radius, priv->thickness, 
-                      init_angle, final_angle, *fill_color, has_child_max_depth);
+                      init_angle, final_angle, fill_color, has_child_max_depth);
 
-	  /* Update drawn elements count */
-	  priv->drawn_elements++;
-          
-          g_free (fill_color);
+      	  /* Update drawn elements count */
+      	  priv->drawn_elements++;
         }
-      else
-        draw_circle (cr, priv->center_x, priv->center_y, radius); 
-
     }
 
   if (gtk_tree_model_iter_has_child (priv -> model, iter) && (depth < priv->max_depth))
