Index: baobab/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-utils/baobab/ChangeLog,v
retrieving revision 1.49
diff -u -p -r1.49 ChangeLog
--- baobab/ChangeLog	24 Oct 2006 12:57:03 -0000	1.49
+++ baobab/ChangeLog	28 Oct 2006 06:09:14 -0000
@@ -1,3 +1,8 @@
+2006-10-28  Alejandro G. Castro  <acastro@igalia.com>
+
+	* src/baobab-ringschart.c: added sector highlightning, patch
+cotributed by Miguel Gomez <magomez@igalia.com>
+
 2006-10-24  Fabio Marzocca  <thesaltydog@gmail.com>
 
 	* pixmaps/Makefile.am:
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	28 Oct 2006 06:09:14 -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,
@@ -187,7 +188,8 @@ static Color *interpolate_colors (Color 
                                   Color colorb,
                                   gdouble percentage);
 static Color *get_color (gdouble angle,
-                         gint circle_number);
+                         gint circle_number,
+                         gboolean highlighted);
 static void tree_traverse (cairo_t *cr,
                            BaobabRingschart *rchart,
                            GtkTreeIter *iter,
@@ -658,6 +660,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 +693,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,21 +751,25 @@ 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;
+  
+  fill_color = get_color (0, 0, highlighted);
   
   cairo_save (cr);
 
   cairo_set_line_width (cr, 1);
   cairo_arc (cr, center_x, center_y, radius, 0, 2*M_PI);
 
-  cairo_set_source_rgb (cr, fill_color.red, fill_color.green, fill_color.blue);
+  cairo_set_source_rgb (cr, fill_color -> red, fill_color -> green, fill_color -> blue);
   cairo_fill_preserve (cr);
   cairo_set_source_rgb (cr, 0, 0, 0);
   cairo_stroke (cr);
 
   cairo_restore (cr);
+  g_free (fill_color);
 }
 
 static void 
@@ -907,7 +920,8 @@ interpolate_colors (Color colora,
 
 static Color *
 get_color (gdouble angle,
-	   gint circle_number)
+      	   gint circle_number,
+      	   gboolean highlighted)
 {
   Color *color;
   gdouble intensity;
@@ -916,17 +930,39 @@ get_color (gdouble angle,
 
   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 tango_color = {0.83, 0.84, 0.82};
+
+      color = g_new0 (Color, 1);
+
+      *color = tango_color;
+    }
+  else
+    {
+      color_number = angle / (M_PI/3);
+      next_color_number = (color_number+1) % 6;
 
-  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 = 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;
+    }
   
+  if (highlighted)
+    {
+      gdouble maximum;
+      
+      maximum = MAX (color -> red,
+                     MAX (color -> green,
+                          color -> blue));
+      color -> red /= maximum;
+      color -> green /= maximum;
+      color -> blue /= maximum;
+    }
+
   return color;
 }
 
@@ -944,6 +980,7 @@ tree_traverse (cairo_t *cr,
   BaobabRingschartPrivate *priv;
   Color *fill_color;
   GtkTreeIter child;
+  gboolean highlighted = FALSE;
 
   priv = BAOBAB_RINGSCHART_GET_PRIVATE (rchart);
 
@@ -997,6 +1034,7 @@ tree_traverse (cairo_t *cr,
                   tip->size = size_column;
                   
                   *tooltips = g_slist_prepend (*tooltips , tip);
+                  highlighted = TRUE;
                 }
             }
           else 
@@ -1012,9 +1050,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 +1057,14 @@ 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); 
+          fill_color = get_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);
-
-	  /* Update drawn elements count */
-	  priv->drawn_elements++;
-          
           g_free (fill_color);
-        }
-      else
-        draw_circle (cr, priv->center_x, priv->center_y, radius); 
 
+      	  /* Update drawn elements count */
+      	  priv->drawn_elements++;
+        }
     }
 
   if (gtk_tree_model_iter_has_child (priv -> model, iter) && (depth < priv->max_depth))
