[baobab] Cleanup BaobabChart API



commit b6642cd2d4e99fedf916aacc9b8a25566b8f2d9b
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Jan 29 16:02:49 2012 +0100

    Cleanup BaobabChart API
    
    Move the popup menu implementation in the chart object, cleanup the
    API to consistently use BaobabChart in all public functions and other
    cleanups

 src/baobab-chart.c      | 1022 ++++++++++++++++++++++++-----------------------
 src/baobab-chart.h      |  154 ++++----
 src/baobab-ringschart.c |  128 +++---
 src/baobab-ringschart.h |   10 +-
 src/baobab-treemap.c    |   73 ++--
 src/baobab-treemap.h    |    5 +-
 src/baobab.c            |  124 +-----
 src/baobab.h            |   13 -
 src/callbacks.c         |   28 +--
 src/callbacks.h         |    4 -
 10 files changed, 731 insertions(+), 830 deletions(-)
---
diff --git a/src/baobab-chart.c b/src/baobab-chart.c
index 6f49b06..5af0861 100644
--- a/src/baobab-chart.c
+++ b/src/baobab-chart.c
@@ -39,10 +39,6 @@
 #include <gtk/gtk.h>
 #include "baobab-chart.h"
 
-#define BAOBAB_CHART_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
-                                       BAOBAB_CHART_TYPE, \
-                                       BaobabChartPrivate))
-
 #define SNAPSHOT_DEF_FILENAME_FORMAT "%s-disk-usage"
 
 G_DEFINE_ABSTRACT_TYPE (BaobabChart, baobab_chart, GTK_TYPE_WIDGET);
@@ -50,13 +46,6 @@ G_DEFINE_ABSTRACT_TYPE (BaobabChart, baobab_chart, GTK_TYPE_WIDGET);
 #define BAOBAB_CHART_MAX_DEPTH 8
 #define BAOBAB_CHART_MIN_DEPTH 1
 
-enum
-{
-  LEFT_BUTTON   = 1,
-  MIDDLE_BUTTON = 2,
-  RIGHT_BUTTON  = 3
-};
-
 struct _BaobabChartPrivate
 {
   guint name_column;
@@ -77,6 +66,8 @@ struct _BaobabChartPrivate
   GList *first_item;
   GList *last_item;
   GList *highlighted_item;
+
+  GtkWidget *popup_menu;
 };
 
 /* Signals */
@@ -108,6 +99,7 @@ const BaobabChartColor baobab_chart_tango_colors[] = {{0.94, 0.16, 0.16}, /* tan
 static void baobab_chart_class_init (BaobabChartClass *class);
 static void baobab_chart_init (BaobabChart *object);
 static void baobab_chart_realize (GtkWidget *widget);
+static void baobab_chart_unrealize (GtkWidget *widget);
 static void baobab_chart_dispose (GObject *object);
 static void baobab_chart_size_allocate (GtkWidget *widget,
                                         GtkAllocation *allocation);
@@ -119,56 +111,39 @@ static void baobab_chart_get_property (GObject *object,
                                        guint prop_id,
                                        GValue *value,
                                        GParamSpec *pspec);
-static void baobab_chart_free_items (GtkWidget *chart);
-static void baobab_chart_draw_chart (GtkWidget *chart,
+static void baobab_chart_free_items (BaobabChart *chart);
+static void baobab_chart_draw_chart (BaobabChart *chart,
                                      cairo_t *cr);
 static void baobab_chart_update_draw (BaobabChart *chart,
                                       GtkTreePath *path);
-static void baobab_chart_row_changed (GtkTreeModel *model,
-                                      GtkTreePath *path,
-                                      GtkTreeIter *iter,
-                                      gpointer data);
-static void baobab_chart_row_inserted (GtkTreeModel *model,
-                                       GtkTreePath *path,
-                                       GtkTreeIter *iter,
-                                       gpointer data);
-static void baobab_chart_row_has_child_toggled (GtkTreeModel *model,
-                                                GtkTreePath *path,
-                                                GtkTreeIter *iter,
-                                                gpointer data);
-static void baobab_chart_row_deleted (GtkTreeModel *model,
-                                      GtkTreePath *path,
-                                      gpointer data);
-static void baobab_chart_rows_reordered (GtkTreeModel *model,
-                                         GtkTreePath *parent,
-                                         GtkTreeIter *iter,
-                                         gint *new_order,
-                                         gpointer data);
 static gboolean baobab_chart_draw (GtkWidget *chart,
                                    cairo_t *cr);
 static void baobab_chart_interpolate_colors (BaobabChartColor *color,
                                              BaobabChartColor colora,
                                              BaobabChartColor colorb,
                                              gdouble percentage);
-static gint baobab_chart_button_release (GtkWidget *widget,
-                                         GdkEventButton *event);
+static gint baobab_chart_button_press_event (GtkWidget      *widget,
+                                             GdkEventButton *event);
+static gboolean baobab_chart_popup_menu (GtkWidget *widget);
 static gint baobab_chart_scroll (GtkWidget *widget,
                                  GdkEventScroll *event);
 static gint baobab_chart_motion_notify (GtkWidget *widget,
                                         GdkEventMotion *event);
 static gint baobab_chart_leave_notify (GtkWidget *widget,
                                        GdkEventCrossing *event);
-static inline void baobab_chart_disconnect_signals (GtkWidget *chart,
-                                                    GtkTreeModel *model);
-static inline void baobab_chart_connect_signals (GtkWidget *chart,
-                                                 GtkTreeModel *model);
-static void baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root);
+static void baobab_chart_disconnect_signals (BaobabChart *chart,
+                                             GtkTreeModel *model);
+static void baobab_chart_connect_signals (BaobabChart *chart,
+                                          GtkTreeModel *model);
+static void baobab_chart_get_items (BaobabChart *chart, GtkTreePath *root);
 static gboolean baobab_chart_query_tooltip (GtkWidget  *widget,
                                             gint        x,
                                             gint        y,
                                             gboolean    keyboard_mode,
                                             GtkTooltip *tooltip,
                                             gpointer    user_data);
+static void baobab_chart_item_activated (BaobabChart *chart,
+                                         GtkTreeIter *iter);
 
 
 static void
@@ -187,11 +162,17 @@ baobab_chart_class_init (BaobabChartClass *class)
 
   /* GtkWidget signals */
   widget_class->realize = baobab_chart_realize;
+  widget_class->unrealize = baobab_chart_unrealize;
   widget_class->draw = baobab_chart_draw;
   widget_class->size_allocate = baobab_chart_size_allocate;
+  widget_class->button_press_event = baobab_chart_button_press_event;
+  widget_class->popup_menu = baobab_chart_popup_menu;
   widget_class->scroll_event = baobab_chart_scroll;
 
-  /* Baobab Chart abstract methods */
+  /* BaobabChart signals */
+  class->item_activated = baobab_chart_item_activated;
+
+  /* BaobabChart abstract methods */
   class->draw_item               = NULL;
   class->pre_draw                = NULL;
   class->post_draw               = NULL;
@@ -228,7 +209,7 @@ baobab_chart_class_init (BaobabChartClass *class)
                                    G_PARAM_READWRITE));
 
   baobab_chart_signals[ITEM_ACTIVATED] =
-    g_signal_new ("item_activated",
+    g_signal_new ("item-activated",
           G_TYPE_FROM_CLASS (obj_class),
           G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
           G_STRUCT_OFFSET (BaobabChartClass, item_activated),
@@ -243,52 +224,45 @@ baobab_chart_class_init (BaobabChartClass *class)
 static void
 baobab_chart_init (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
-
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-  chart->priv = priv;
-
-  priv->model = NULL;
-  priv->max_depth = BAOBAB_CHART_MAX_DEPTH;
-  priv->name_column = 0;
-  priv->size_column = 0;
-  priv->info_column = 0;
-  priv->percentage_column = 0;
-  priv->valid_column = 0;
-  priv->button_pressed = FALSE;
-  priv->is_frozen = FALSE;
-  priv->memento = NULL;
-  priv->root = NULL;
-
-  priv->first_item = NULL;
-  priv->last_item = NULL;
-  priv->highlighted_item = NULL;
+  chart->priv = G_TYPE_INSTANCE_GET_PRIVATE (chart, BAOBAB_TYPE_CHART, BaobabChartPrivate);
+
+  chart->priv->model = NULL;
+  chart->priv->max_depth = BAOBAB_CHART_MAX_DEPTH;
+  chart->priv->name_column = 0;
+  chart->priv->size_column = 0;
+  chart->priv->info_column = 0;
+  chart->priv->percentage_column = 0;
+  chart->priv->valid_column = 0;
+  chart->priv->button_pressed = FALSE;
+  chart->priv->is_frozen = FALSE;
+  chart->priv->memento = NULL;
+  chart->priv->root = NULL;
+
+  chart->priv->first_item = NULL;
+  chart->priv->last_item = NULL;
+  chart->priv->highlighted_item = NULL;
 }
 
 static void
 baobab_chart_dispose (GObject *object)
 {
-  BaobabChartPrivate *priv;
+  BaobabChart *chart;
 
-  baobab_chart_free_items (GTK_WIDGET (object));
+  chart = BAOBAB_CHART (object);
 
-  priv = BAOBAB_CHART (object)->priv;
+  baobab_chart_free_items (chart);
 
-  if (priv->model)
+  if (chart->priv->model)
     {
-      baobab_chart_disconnect_signals (GTK_WIDGET (object),
-                                       priv->model);
-
-      g_object_unref (priv->model);
-
-      priv->model = NULL;
+      baobab_chart_disconnect_signals (chart, chart->priv->model);
+      g_object_unref (chart->priv->model);
+      chart->priv->model = NULL;
     }
 
-  if (priv->root)
+  if (chart->priv->root)
     {
-      gtk_tree_row_reference_free (priv->root);
-
-      priv->root = NULL;
+      gtk_tree_row_reference_free (chart->priv->root);
+      chart->priv->root = NULL;
     }
 
   G_OBJECT_CLASS (baobab_chart_parent_class)->dispose (object);
@@ -302,6 +276,7 @@ baobab_chart_realize (GtkWidget *widget)
   gint attributes_mask;
   GtkAllocation allocation;
   GdkWindow *window;
+  GtkStyleContext *context;
 
   g_return_if_fail (BAOBAB_IS_CHART (widget));
 
@@ -327,10 +302,8 @@ baobab_chart_realize (GtkWidget *widget)
   gtk_widget_set_window (widget, window);
   gdk_window_set_user_data (window, chart);
 
-  gtk_widget_style_attach (widget);
-  gtk_style_set_background (gtk_widget_get_style (widget),
-                            window,
-                            GTK_STATE_NORMAL);
+  context = gtk_widget_get_style_context (widget);
+  gtk_style_context_set_background (context, window);
 
   gtk_widget_add_events (widget,
                          GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
@@ -339,10 +312,26 @@ baobab_chart_realize (GtkWidget *widget)
 }
 
 static void
-baobab_chart_size_allocate (GtkWidget *widget,
+baobab_chart_unrealize (GtkWidget *widget)
+{
+  BaobabChart *chart;
+
+  chart = BAOBAB_CHART (widget);
+
+  if (chart->priv->popup_menu)
+    {
+      gtk_widget_destroy (chart->priv->popup_menu);
+      chart->priv->popup_menu = NULL;
+    }
+
+  GTK_WIDGET_CLASS (baobab_chart_parent_class)->unrealize (widget);
+}
+
+static void
+baobab_chart_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
 {
-  BaobabChartPrivate *priv;
+  BaobabChart *chart;
   BaobabChartClass *class;
   BaobabChartItem *item;
   GList *node;
@@ -350,8 +339,8 @@ baobab_chart_size_allocate (GtkWidget *widget,
   g_return_if_fail (BAOBAB_IS_CHART (widget));
   g_return_if_fail (allocation != NULL);
 
-  priv = BAOBAB_CHART (widget)->priv;
-  class = BAOBAB_CHART_GET_CLASS (widget);
+  chart = BAOBAB_CHART (widget);
+  class = BAOBAB_CHART_GET_CLASS (chart);
 
   gtk_widget_set_allocation (widget, allocation);
 
@@ -361,15 +350,12 @@ baobab_chart_size_allocate (GtkWidget *widget,
                   allocation->x, allocation->y,
                   allocation->width, allocation->height);
 
-      node = priv->first_item;
-      while (node != NULL)
+      for (node = chart->priv->first_item; node != NULL; node = node->next)
         {
           item = (BaobabChartItem *) node->data;
           item->has_visible_children = FALSE;
           item->visible = FALSE;
-          class->calculate_item_geometry (widget, item);
-
-          node = node->next;
+          class->calculate_item_geometry (chart, item);
         }
     }
 }
@@ -380,20 +366,18 @@ baobab_chart_set_property (GObject         *object,
                            const GValue    *value,
                            GParamSpec      *pspec)
 {
-  BaobabChart *chart;
-
-  chart = BAOBAB_CHART (object);
+  BaobabChart *chart = BAOBAB_CHART (object);
 
   switch (prop_id)
     {
     case PROP_MAX_DEPTH:
-      baobab_chart_set_max_depth (GTK_WIDGET (chart), g_value_get_int (value));
+      baobab_chart_set_max_depth (chart, g_value_get_int (value));
       break;
     case PROP_MODEL:
-      baobab_chart_set_model (GTK_WIDGET (chart), g_value_get_object (value));
+      baobab_chart_set_model (chart, g_value_get_object (value));
       break;
     case PROP_ROOT:
-      baobab_chart_set_root (GTK_WIDGET (chart), g_value_get_object (value));
+      baobab_chart_set_root (chart, g_value_get_object (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -407,20 +391,18 @@ baobab_chart_get_property (GObject    *object,
                            GValue     *value,
                            GParamSpec *pspec)
 {
-  BaobabChartPrivate *priv;
-
-  priv = BAOBAB_CHART (object)->priv;
+  BaobabChart *chart = BAOBAB_CHART (object);
 
   switch (prop_id)
     {
     case PROP_MAX_DEPTH:
-      g_value_set_int (value, priv->max_depth);
+      g_value_set_int (value, chart->priv->max_depth);
       break;
     case PROP_MODEL:
-      g_value_set_object (value, priv->model);
+      g_value_set_object (value, chart->priv->model);
       break;
     case PROP_ROOT:
-      g_value_set_object (value, priv->root);
+      g_value_set_object (value, chart->priv->root);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -428,29 +410,25 @@ baobab_chart_get_property (GObject    *object,
     }
 }
 
-static GList
-*baobab_chart_add_item (GtkWidget *chart,
-                        guint depth,
-                        gdouble rel_start,
-                        gdouble rel_size,
-                        GtkTreeIter iter)
+static GList *
+baobab_chart_add_item (BaobabChart *chart,
+                       guint        depth,
+                       gdouble      rel_start,
+                       gdouble      rel_size,
+                       GtkTreeIter  iter)
 {
-  BaobabChartPrivate *priv;
   BaobabChartItem *item;
-
   gchar *name;
-  gchar *size;
-
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
+  guint64 size;
 
-  gtk_tree_model_get (priv->model, &iter,
-                      priv->name_column, &name, -1);
-  gtk_tree_model_get (priv->model, &iter,
-                      priv->size_column, &size, -1);
+  gtk_tree_model_get (chart->priv->model, &iter,
+                      chart->priv->name_column, &name,
+                      chart->priv->size_column, &size,
+                      -1);
 
   item = g_new (BaobabChartItem, 1);
   item->name = name;
-  item->size = size;
+  item->size = g_format_size (size);
   item->depth = depth;
   item->rel_start = rel_start;
   item->rel_size = rel_size;
@@ -463,22 +441,20 @@ static GList
   item->parent = NULL;
   item->data = NULL;
 
-  priv->last_item = g_list_prepend (priv->last_item, item);
+  chart->priv->last_item = g_list_prepend (chart->priv->last_item, item);
 
-  return priv->last_item;
+  return chart->priv->last_item;
 }
 
 static void
-baobab_chart_free_items (GtkWidget *chart)
+baobab_chart_free_items (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
   BaobabChartItem *item;
   GList *node;
   GList *next;
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
+  node = chart->priv->first_item;
 
-  node = priv->first_item;
   while (node != NULL)
     {
       next = node->next;
@@ -497,49 +473,43 @@ baobab_chart_free_items (GtkWidget *chart)
       node = next;
     }
 
-  priv->first_item = NULL;
-  priv->last_item = NULL;
-  priv->highlighted_item = NULL;
+  chart->priv->first_item = NULL;
+  chart->priv->last_item = NULL;
+  chart->priv->highlighted_item = NULL;
 }
 
 static void
-baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root)
+baobab_chart_get_items (BaobabChart *chart,
+                        GtkTreePath *root)
 {
-  BaobabChartPrivate *priv;
   BaobabChartItem *item;
-
   GList *node;
   GtkTreeIter initial_iter = {0};
   gdouble size;
   GtkTreePath *model_root_path;
   GtkTreeIter model_root_iter;
-
   BaobabChartClass *class;
   GtkTreeIter child_iter = {0};
   GList *child_node;
   BaobabChartItem *child;
   gdouble rel_start;
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-
   /* First we free current item list */
   baobab_chart_free_items (chart);
 
   /* Get the tree iteration corresponding to root */
-  if (!gtk_tree_model_get_iter (priv->model, &initial_iter, root))
+  if (!gtk_tree_model_get_iter (chart->priv->model, &initial_iter, root))
     {
-      priv->model_changed = FALSE;
+      chart->priv->model_changed = FALSE;
       return;
     }
 
-
-
   model_root_path = gtk_tree_path_new_first ();
-  gtk_tree_model_get_iter (priv->model, &model_root_iter, model_root_path);
+  gtk_tree_model_get_iter (chart->priv->model, &model_root_iter, model_root_path);
   gtk_tree_path_free (model_root_path);
 
-  gtk_tree_model_get (priv->model, &model_root_iter,
-                      priv->percentage_column, &size, -1);
+  gtk_tree_model_get (chart->priv->model, &model_root_iter,
+                      chart->priv->percentage_column, &size, -1);
 
   /* Create first item */
   node = baobab_chart_add_item (chart, 0, 0, 100, initial_iter);
@@ -550,9 +520,7 @@ baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root)
   do
     {
       item = (BaobabChartItem *) node->data;
-      item->has_any_child = gtk_tree_model_iter_children (priv->model, 
-                                                          &child_iter, 
-                                                          &(item->iter));
+      item->has_any_child = gtk_tree_model_iter_children (chart->priv->model, &child_iter, &(item->iter));
 
       /* Calculate item geometry */
       class->calculate_item_geometry (chart, item);
@@ -564,14 +532,13 @@ baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root)
         }
 
       /* Get item's children and add them to the list */
-      if ((item->has_any_child) && (item->depth < priv->max_depth + 1))
+      if ((item->has_any_child) && (item->depth < chart->priv->max_depth + 1))
         {
           rel_start = 0;
 
           do
             {
-              gtk_tree_model_get (priv->model, &child_iter,
-                                  priv->percentage_column, &size, -1);
+              gtk_tree_model_get (chart->priv->model, &child_iter, chart->priv->percentage_column, &size, -1);
 
               child_node = baobab_chart_add_item (chart,
                                                   item->depth + 1,
@@ -582,7 +549,7 @@ baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root)
               child->parent = node;
               rel_start += size;
             }
-          while (gtk_tree_model_iter_next (priv->model, &child_iter));
+          while (gtk_tree_model_iter_next (chart->priv->model, &child_iter));
         }
 
       node = node->prev;
@@ -590,20 +557,18 @@ baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root)
   while (node != NULL);
 
   /* Reverse the list, 'cause we created it from the tail, for efficiency reasons */
-  priv->first_item = g_list_reverse (priv->last_item);
+  chart->priv->first_item = g_list_reverse (chart->priv->last_item);
 
-  priv->model_changed = FALSE;
+  chart->priv->model_changed = FALSE;
 }
 
 static void
-baobab_chart_draw_chart (GtkWidget *chart,
-                         cairo_t *cr)
+baobab_chart_draw_chart (BaobabChart *chart,
+                         cairo_t     *cr)
 {
-  BaobabChartPrivate *priv;
   BaobabChartClass *class;
   GList *node;
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
   class = BAOBAB_CHART_GET_CLASS (chart);
 
   /* call pre-draw abstract method */
@@ -612,8 +577,7 @@ baobab_chart_draw_chart (GtkWidget *chart,
 
   cairo_save (cr);
 
-  node = priv->first_item;
-  while (node != NULL)
+  for (node = chart->priv->first_item; node != NULL; node = node->next)
     {
       BaobabChartItem *item;
       GdkRectangle clip;
@@ -623,16 +587,13 @@ baobab_chart_draw_chart (GtkWidget *chart,
       if (gdk_cairo_get_clip_rectangle (cr, &clip) &&
           (item->visible) &&
           (gdk_rectangle_intersect (&clip, &item->rect, NULL)) &&
-          (item->depth <= priv->max_depth))
+          (item->depth <= chart->priv->max_depth))
         {
           gboolean highlighted;
 
-          highlighted = (node == priv->highlighted_item);
-
+          highlighted = (node == chart->priv->highlighted_item);
           class->draw_item (chart, cr, item, highlighted);
         }
-
-      node = node->next;
     }
 
   cairo_restore (cr);
@@ -646,34 +607,31 @@ static void
 baobab_chart_update_draw (BaobabChart* chart,
                           GtkTreePath *path)
 {
-  BaobabChartPrivate *priv;
   GtkTreePath *root_path = NULL;
   gint root_depth, node_depth;
 
   if (!gtk_widget_get_realized ( GTK_WIDGET (chart)))
     return;
 
-  priv = BAOBAB_CHART (chart)->priv;
-
-  if (priv->root != NULL)
+  if (chart->priv->root != NULL)
     {
-      root_path = gtk_tree_row_reference_get_path (priv->root);
+      root_path = gtk_tree_row_reference_get_path (chart->priv->root);
 
       if (root_path == NULL)
         {
-          gtk_tree_row_reference_free (priv->root);
-          priv->root = NULL;
+          gtk_tree_row_reference_free (chart->priv->root);
+          chart->priv->root = NULL;
         }
     }
 
-  if (priv->root == NULL)
+  if (chart->priv->root == NULL)
     root_path = gtk_tree_path_new_first ();
 
 
   root_depth = gtk_tree_path_get_depth (root_path);
   node_depth = gtk_tree_path_get_depth (path);
 
-  if (((node_depth-root_depth)<=priv->max_depth)&&
+  if (((node_depth-root_depth)<=chart->priv->max_depth)&&
       ((gtk_tree_path_is_ancestor (root_path, path))||
        (gtk_tree_path_compare (root_path, path) == 0)))
     {
@@ -684,101 +642,90 @@ baobab_chart_update_draw (BaobabChart* chart,
 }
 
 static void
-baobab_chart_row_changed (GtkTreeModel    *model,
-                          GtkTreePath     *path,
-                          GtkTreeIter     *iter,
-                          gpointer         data)
+baobab_chart_row_changed (GtkTreeModel *model,
+                          GtkTreePath  *path,
+                          GtkTreeIter  *iter,
+                          BaobabChart  *chart)
 {
-  g_return_if_fail (BAOBAB_IS_CHART (data));
   g_return_if_fail (path != NULL || iter != NULL);
 
-  BAOBAB_CHART_GET_PRIVATE (data)->model_changed = TRUE;
-
-  baobab_chart_update_draw (BAOBAB_CHART (data), path);
+  chart->priv->model_changed = TRUE;
+  baobab_chart_update_draw (chart, path);
 }
 
 static void
-baobab_chart_row_inserted (GtkTreeModel    *model,
-                           GtkTreePath     *path,
-                           GtkTreeIter     *iter,
-                           gpointer         data)
+baobab_chart_row_inserted (GtkTreeModel *model,
+                           GtkTreePath  *path,
+                           GtkTreeIter  *iter,
+                           BaobabChart  *chart)
 {
-  g_return_if_fail (BAOBAB_IS_CHART (data));
   g_return_if_fail (path != NULL || iter != NULL);
 
-  BAOBAB_CHART_GET_PRIVATE (data)->model_changed = TRUE;
-
-  baobab_chart_update_draw (BAOBAB_CHART (data), path);
+  chart->priv->model_changed = TRUE;
+  baobab_chart_update_draw (chart, path);
 }
 
 static void
-baobab_chart_row_has_child_toggled (GtkTreeModel    *model,
-                                    GtkTreePath     *path,
-                                    GtkTreeIter     *iter,
-                                    gpointer         data)
+baobab_chart_row_has_child_toggled (GtkTreeModel *model,
+                                    GtkTreePath  *path,
+                                    GtkTreeIter  *iter,
+                                    BaobabChart  *chart)
 {
-  g_return_if_fail (BAOBAB_IS_CHART (data));
   g_return_if_fail (path != NULL || iter != NULL);
 
-  BAOBAB_CHART_GET_PRIVATE (data)->model_changed = TRUE;
-
-  baobab_chart_update_draw (BAOBAB_CHART (data), path);
+  chart->priv->model_changed = TRUE;
+  baobab_chart_update_draw (chart, path);
 }
 
 static void
-baobab_chart_row_deleted (GtkTreeModel    *model,
-                          GtkTreePath     *path,
-                          gpointer         data)
+baobab_chart_row_deleted (GtkTreeModel *model,
+                          GtkTreePath  *path,
+                          BaobabChart  *chart)
 {
-  g_return_if_fail (BAOBAB_IS_CHART (data));
   g_return_if_fail (path != NULL);
 
-  BAOBAB_CHART_GET_PRIVATE (data)->model_changed = TRUE;
-
-  baobab_chart_update_draw (BAOBAB_CHART (data), path);
-
+  chart->priv->model_changed = TRUE;
+  baobab_chart_update_draw (chart, path);
 }
 
 static void
-baobab_chart_rows_reordered (GtkTreeModel    *model,
-                             GtkTreePath     *path,
-                             GtkTreeIter     *iter,
-                             gint            *new_order,
-                             gpointer         data)
+baobab_chart_rows_reordered (GtkTreeModel *model,
+                             GtkTreePath  *path,
+                             GtkTreeIter  *iter,
+                             gint         *new_order,
+                             BaobabChart  *chart)
 {
-  g_return_if_fail (BAOBAB_IS_CHART (data));
   g_return_if_fail (path != NULL || iter != NULL);
 
-  BAOBAB_CHART_GET_PRIVATE (data)->model_changed = TRUE;
-
-  baobab_chart_update_draw (BAOBAB_CHART (data), path);
-
+  chart->priv->model_changed = TRUE;
+  baobab_chart_update_draw (chart, path);
 }
 
 static gboolean
-baobab_chart_draw (GtkWidget *chart, cairo_t *cr)
+baobab_chart_draw (GtkWidget *widget,
+                   cairo_t   *cr)
 {
-  BaobabChartPrivate *priv;
+  BaobabChart *chart;
 
-  priv = BAOBAB_CHART (chart)->priv;
+  chart = BAOBAB_CHART (widget);
 
   /* the columns are not set we paint nothing */
-  if (priv->name_column == priv->percentage_column)
+  if (chart->priv->name_column == chart->priv->percentage_column)
     return FALSE;
 
   /* there is no model we can not paint */
-  if ((priv->is_frozen) || (priv->model == NULL))
+  if ((chart->priv->is_frozen) || (chart->priv->model == NULL))
     {
-      if (priv->memento != NULL)
+      if (chart->priv->memento != NULL)
         {
           gint w, h, aw, ah;
           gdouble p, sx, sy;
 
-          w = cairo_image_surface_get_width (priv->memento);
-          h = cairo_image_surface_get_height (priv->memento);
+          w = cairo_image_surface_get_width (chart->priv->memento);
+          h = cairo_image_surface_get_height (chart->priv->memento);
 
-          aw = gtk_widget_get_allocated_width (chart);
-          ah = gtk_widget_get_allocated_height (chart);
+          aw = gtk_widget_get_allocated_width (widget);
+          ah = gtk_widget_get_allocated_height (widget);
 
           if (w > 0 && h > 0 && !(aw == w && aw == h))
             {
@@ -792,9 +739,7 @@ baobab_chart_draw (GtkWidget *chart, cairo_t *cr)
               cairo_scale (cr, p, p);
             }
 
-          cairo_set_source_surface (cr,
-                                    priv->memento,
-                                    0, 0);
+          cairo_set_source_surface (cr, chart->priv->memento, 0, 0);
           cairo_paint (cr);
         }
     }
@@ -805,18 +750,17 @@ baobab_chart_draw (GtkWidget *chart, cairo_t *cr)
       cairo_set_source_rgb (cr, 1, 1, 1);
       cairo_fill_preserve (cr);
 
-      if (priv->root != NULL)
-        root_path = gtk_tree_row_reference_get_path (priv->root);
+      if (chart->priv->root != NULL)
+        root_path = gtk_tree_row_reference_get_path (chart->priv->root);
 
       if (root_path == NULL)
         {
           root_path = gtk_tree_path_new_first ();
-          priv->root = NULL;
+          chart->priv->root = NULL;
         }
 
       /* Check if tree model was modified in any way */
-      if ((priv->model_changed) ||
-           (priv->first_item == NULL))
+      if ((chart->priv->model_changed) || (chart->priv->first_item == NULL))
         {
           baobab_chart_get_items (chart, root_path);
         }
@@ -825,8 +769,8 @@ baobab_chart_draw (GtkWidget *chart, cairo_t *cr)
           GtkTreePath *current_path;
 
           /* Check if root was changed */
-          current_path = gtk_tree_model_get_path (priv->model,
-                         &((BaobabChartItem*) priv->first_item->data)->iter);
+          current_path = gtk_tree_model_get_path (chart->priv->model,
+                         &((BaobabChartItem*) chart->priv->first_item->data)->iter);
 
           if (gtk_tree_path_compare (root_path, current_path) != 0)
             baobab_chart_get_items (chart, root_path);
@@ -907,55 +851,178 @@ baobab_chart_get_item_color (BaobabChartColor *color,
     }
 }
 
-static gint
-baobab_chart_button_release (GtkWidget *widget,
-                             GdkEventButton *event)
+static void
+popup_menu_detach (GtkWidget *attach_widget,
+                   GtkMenu   *menu)
 {
-  BaobabChartPrivate *priv;
+  BAOBAB_CHART (attach_widget)->priv->popup_menu = NULL;
+}
 
-  priv = BAOBAB_CHART (widget)->priv;
+static void
+popup_menu_activate_up (GtkMenuItem *checkmenuitem,
+                        BaobabChart *chart)
+{
+  baobab_chart_move_up_root (chart);
+}
 
-  if (priv->is_frozen)
-    return TRUE;
+static void
+popup_menu_activate_zoom_in (GtkMenuItem *checkmenuitem,
+                             BaobabChart *chart)
+{
+  baobab_chart_zoom_in (chart);
+}
 
-  switch (event->button)
-    {
-    case LEFT_BUTTON:
-      /* Enter into a subdir */
-      if (priv->highlighted_item != NULL)
-        g_signal_emit (BAOBAB_CHART (widget),
-                       baobab_chart_signals[ITEM_ACTIVATED],
-                       0, &((BaobabChartItem*) priv->highlighted_item->data)->iter);
+static void
+popup_menu_activate_zoom_out (GtkMenuItem *checkmenuitem,
+                              BaobabChart *chart)
+{
+  baobab_chart_zoom_out (chart);
+}
 
-      break;
+static void
+popup_menu_activate_snapshot (GtkMenuItem *checkmenuitem,
+                              BaobabChart *chart)
+{
+  baobab_chart_save_snapshot (chart);
+}
 
-    case MIDDLE_BUTTON:
-      /* Go back to the parent dir */
-      baobab_chart_move_up_root (widget);
-      break;
+static void
+do_popup_menu (BaobabChart    *chart,
+               GdkEventButton *event)
+{
+  GtkWidget *menu;
+  GtkWidget *up_item;
+  GtkWidget *zoom_in_item;
+  GtkWidget *zoom_out_item;
+  GtkWidget *snapshot_item;
+  GtkTreePath *root_path;
+
+  menu = gtk_menu_new ();
+  chart->priv->popup_menu = menu;
+
+  gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (chart), popup_menu_detach);
+
+  up_item = gtk_image_menu_item_new_with_label (_("Move to parent folder"));
+  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (up_item),
+                                 gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU));
+
+  zoom_in_item = gtk_image_menu_item_new_with_label (_("Zoom in")) ;
+  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (zoom_in_item),
+                                 gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
+
+  zoom_out_item = gtk_image_menu_item_new_with_label (_("Zoom out"));
+  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (zoom_out_item),
+                                 gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
+
+  snapshot_item = gtk_image_menu_item_new_with_label (_("Save screenshot"));
+  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (snapshot_item),
+                                 gtk_image_new_from_file (BAOBAB_PIX_DIR "shot.png"));
+
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), up_item);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), zoom_in_item);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), zoom_out_item);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), snapshot_item);
+
+  g_signal_connect (up_item, "activate",
+                    G_CALLBACK (popup_menu_activate_up), chart);
+  g_signal_connect (zoom_in_item, "activate",
+                    G_CALLBACK (popup_menu_activate_zoom_in), chart);
+  g_signal_connect (zoom_out_item, "activate",
+                    G_CALLBACK (popup_menu_activate_zoom_out), chart);
+  g_signal_connect (snapshot_item, "activate",
+                    G_CALLBACK (popup_menu_activate_snapshot), chart);
+
+  gtk_widget_show_all (menu);
+
+  root_path = baobab_chart_get_root (chart);
+
+  gtk_widget_set_sensitive (up_item,
+                            (!chart->priv->is_frozen) &&
+                            ((root_path != NULL) &&
+                            (gtk_tree_path_get_depth (root_path) > 1)));
+  gtk_widget_set_sensitive (zoom_in_item,
+                            baobab_chart_can_zoom_in (chart));
+  gtk_widget_set_sensitive (zoom_out_item,
+                            baobab_chart_can_zoom_out (chart));
+  gtk_widget_set_sensitive (snapshot_item,
+                            (!chart->priv->is_frozen));
+
+  gtk_menu_popup (GTK_MENU (menu),
+                  NULL, NULL, NULL, NULL,
+                  event ? event->button : 0,
+                  event ? event->time : gtk_get_current_event_time ());
+
+  gtk_tree_path_free (root_path);
+}
+
+static gint
+baobab_chart_button_press_event (GtkWidget      *widget,
+                                 GdkEventButton *event)
+{
+  BaobabChart *chart = BAOBAB_CHART (widget);
+
+  if (event->type == GDK_BUTTON_PRESS)
+    {
+      if (gdk_event_triggers_context_menu ((GdkEvent *) event))
+        {
+          do_popup_menu (chart, event);
+          return TRUE;
+        }
+      else if (!chart->priv->is_frozen)
+        {
+          switch (event->button)
+            {
+              case 1:
+                /* Enter into a subdir */
+                if (chart->priv->highlighted_item != NULL)
+                  g_signal_emit (chart,
+                                 baobab_chart_signals[ITEM_ACTIVATED], 0,
+                                 &((BaobabChartItem*) chart->priv->highlighted_item->data)->iter);
+                break;
+
+              case 2:
+                /* Go back to the parent dir */
+                baobab_chart_move_up_root (chart);
+                break;
+            }
+
+          return TRUE;
+        }
     }
 
   return FALSE;
 }
 
+static gboolean
+baobab_chart_popup_menu (GtkWidget *widget)
+{
+  do_popup_menu (BAOBAB_CHART (widget), NULL);
+
+  return TRUE;
+}
+
 static gint
 baobab_chart_scroll (GtkWidget *widget,
                      GdkEventScroll *event)
 {
+  BaobabChart *chart = BAOBAB_CHART (widget);
+
   switch (event->direction)
     {
     case GDK_SCROLL_LEFT :
     case GDK_SCROLL_UP :
-      if (baobab_chart_can_zoom_out (widget))
-        baobab_chart_zoom_out (widget);
+      if (baobab_chart_can_zoom_out (chart))
+        baobab_chart_zoom_out (chart);
       /* change the selected item when zooming */
       baobab_chart_motion_notify (widget, (GdkEventMotion *)event);
       break;
 
     case GDK_SCROLL_RIGHT :
     case GDK_SCROLL_DOWN :
-      if (baobab_chart_can_zoom_in (widget))
-        baobab_chart_zoom_in (widget);
+      if (baobab_chart_can_zoom_in (chart))
+        baobab_chart_zoom_in (chart);
       break;
     }
 
@@ -963,70 +1030,67 @@ baobab_chart_scroll (GtkWidget *widget,
 }
 
 static void
-baobab_chart_set_item_highlight (GtkWidget *chart,
-                                 GList *node,
-                                 gboolean highlighted)
+baobab_chart_set_item_highlight (BaobabChart *chart,
+                                 GList       *node,
+                                 gboolean     highlighted)
 {
   BaobabChartItem *item;
-  BaobabChartPrivate *priv;
-  BaobabChartClass *class;
 
   if (node == NULL)
     return;
 
   item = (BaobabChartItem *) node->data;
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-  class = BAOBAB_CHART_GET_CLASS (chart);
 
   if (highlighted)
-    priv->highlighted_item = node;
+    chart->priv->highlighted_item = node;
   else
-    priv->highlighted_item = NULL;
+    chart->priv->highlighted_item = NULL;
 
-  gdk_window_invalidate_rect (gtk_widget_get_window ( GTK_WIDGET (chart)),
+  gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (chart)),
                               &item->rect, TRUE);
 }
 
 static gint
-baobab_chart_motion_notify (GtkWidget *widget,
+baobab_chart_motion_notify (GtkWidget      *widget,
                             GdkEventMotion *event)
 {
+  BaobabChart *chart;
   BaobabChartPrivate *priv;
   BaobabChartClass *class;
   GList *node;
   BaobabChartItem *item;
   gboolean found = FALSE;
 
-  priv = BAOBAB_CHART_GET_PRIVATE (widget);
+  chart = BAOBAB_CHART (widget);
+  priv = chart->priv;
+
   class = BAOBAB_CHART_GET_CLASS (widget);
 
   /* Check if the pointer is over an item */
-  node = priv->last_item;
-  while (node != NULL)
+  for (node = priv->last_item; node != NULL; node = node->prev)
     {
       item = (BaobabChartItem *) node->data;
 
-      if ((item->visible) && (class->is_point_over_item (widget, item, event->x, event->y)))
+      if ((item->visible) && (class->is_point_over_item (chart, item, event->x, event->y)))
         {
-          if (priv->highlighted_item != node)
+          if (chart->priv->highlighted_item != node)
             {
-              baobab_chart_set_item_highlight (widget, priv->highlighted_item, FALSE);
+              baobab_chart_set_item_highlight (chart, priv->highlighted_item, FALSE);
 
               gtk_widget_set_has_tooltip (widget, TRUE);
-              baobab_chart_set_item_highlight (widget, node, TRUE);
+              baobab_chart_set_item_highlight (chart, node, TRUE);
             }
 
           found = TRUE;
           break;
         }
-      node = node->prev;
     }
 
   /* If we never found a highlighted item, but there is an old highlighted item,
      redraw it to turn it off */
   if (! found)
     {
-      baobab_chart_set_item_highlight (widget, priv->highlighted_item, FALSE);
+      baobab_chart_set_item_highlight (chart, priv->highlighted_item, FALSE);
       gtk_widget_set_has_tooltip (widget, FALSE);
     }
 
@@ -1037,19 +1101,20 @@ baobab_chart_motion_notify (GtkWidget *widget,
 }
 
 static gint
-baobab_chart_leave_notify (GtkWidget *widget,
+baobab_chart_leave_notify (GtkWidget        *widget,
                            GdkEventCrossing *event)
 {
-  BaobabChartPrivate *priv;
+  BaobabChart *chart;
 
-  priv = BAOBAB_CHART_GET_PRIVATE (widget);
-  baobab_chart_set_item_highlight (widget, priv->highlighted_item, FALSE);
+  chart = BAOBAB_CHART (widget);
+
+  baobab_chart_set_item_highlight (chart, chart->priv->highlighted_item, FALSE);
 
   return FALSE;
 }
 
-static inline void
-baobab_chart_connect_signals (GtkWidget *chart,
+static void
+baobab_chart_connect_signals (BaobabChart *chart,
                               GtkTreeModel *model)
 {
   g_signal_connect (model,
@@ -1084,14 +1149,10 @@ baobab_chart_connect_signals (GtkWidget *chart,
                     "leave-notify-event",
                     G_CALLBACK (baobab_chart_leave_notify),
                     chart);
-  g_signal_connect (chart,
-                    "button-release-event",
-                    G_CALLBACK (baobab_chart_button_release),
-                    chart);
 }
 
-static inline void
-baobab_chart_disconnect_signals (GtkWidget *chart,
+static void
+baobab_chart_disconnect_signals (BaobabChart  *chart,
                                  GtkTreeModel *model)
 {
   g_signal_handlers_disconnect_by_func (model,
@@ -1118,9 +1179,6 @@ baobab_chart_disconnect_signals (GtkWidget *chart,
   g_signal_handlers_disconnect_by_func (chart,
                                         baobab_chart_leave_notify,
                                         chart);
-  g_signal_handlers_disconnect_by_func (chart,
-                                        baobab_chart_button_release,
-                                        chart);
 }
 
 static gboolean
@@ -1131,16 +1189,14 @@ baobab_chart_query_tooltip (GtkWidget  *widget,
                             GtkTooltip *tooltip,
                             gpointer    user_data)
 {
-  BaobabChartPrivate *priv;
+  BaobabChart *chart = BAOBAB_CHART (widget);
   BaobabChartItem *item;
   char *markup;
 
-  priv = BAOBAB_CHART_GET_PRIVATE (widget);
-
-  if (priv->highlighted_item == NULL)
+  if (chart->priv->highlighted_item == NULL)
     return FALSE;
 
-  item = (BaobabChartItem *) priv->highlighted_item->data;
+  item = (BaobabChartItem *) chart->priv->highlighted_item->data;
 
   if ( (item->name == NULL) || (item->size == NULL) )
     return FALSE;
@@ -1157,19 +1213,29 @@ baobab_chart_query_tooltip (GtkWidget  *widget,
   return TRUE;
 }
 
-GdkPixbuf*
-baobab_chart_get_pixbuf (GtkWidget *widget)
+static void
+baobab_chart_item_activated (BaobabChart *chart,
+                             GtkTreeIter *iter)
+{
+  GtkTreePath *path;
+
+  path = gtk_tree_model_get_path (chart->priv->model, iter);
+  baobab_chart_set_root (chart, path);
+
+  gtk_tree_path_free (path);
+}
+
+static GdkPixbuf *
+baobab_chart_get_pixbuf (BaobabChart *chart)
 {
   gint w, h;
   GdkPixbuf *pixbuf;
 
-  g_return_val_if_fail (BAOBAB_IS_CHART (widget), NULL);
+  g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
 
-  w = gtk_widget_get_allocated_width (widget);
-  h = gtk_widget_get_allocated_height (widget);
-  pixbuf = gdk_pixbuf_get_from_window (gtk_widget_get_window (widget),
-                                       0, 0,
-                                       w, h);
+  w = gtk_widget_get_allocated_width (GTK_WIDGET (chart));
+  h = gtk_widget_get_allocated_height (GTK_WIDGET (chart));
+  pixbuf = gdk_pixbuf_get_from_window (gtk_widget_get_window (GTK_WIDGET (chart)), 0, 0, w, h);
 
   return pixbuf;
 }
@@ -1182,12 +1248,11 @@ baobab_chart_get_pixbuf (GtkWidget *widget)
  * Constructor for the baobab_chart class
  *
  * Returns: a new #BaobabChart object
- *
  **/
-GtkWidget *
-baobab_chart_new ()
+BaobabChart *
+baobab_chart_new (void)
 {
-  return g_object_new (BAOBAB_CHART_TYPE, NULL);
+  return g_object_new (BAOBAB_TYPE_CHART, NULL);
 }
 
 /**
@@ -1226,35 +1291,32 @@ baobab_chart_new ()
  * #GtkTreeModel.
  **/
 void
-baobab_chart_set_model_with_columns (GtkWidget *chart,
+baobab_chart_set_model_with_columns (BaobabChart  *chart,
                                      GtkTreeModel *model,
-                                     guint name_column,
-                                     guint size_column,
-                                     guint info_column,
-                                     guint percentage_column,
-                                     guint valid_column,
-                                     GtkTreePath *root)
+                                     guint         name_column,
+                                     guint         size_column,
+                                     guint         info_column,
+                                     guint         percentage_column,
+                                     guint         valid_column,
+                                     GtkTreePath  *root)
 {
-  BaobabChartPrivate *priv;
-
   g_return_if_fail (BAOBAB_IS_CHART (chart));
   g_return_if_fail (GTK_IS_TREE_MODEL (model));
 
-  priv = BAOBAB_CHART (chart)->priv;
 
   baobab_chart_set_model (chart, model);
 
   if (root != NULL)
     {
-      priv->root = gtk_tree_row_reference_new (model, root);
+      chart->priv->root = gtk_tree_row_reference_new (model, root);
       g_object_notify (G_OBJECT (chart), "root");
     }
 
-  priv->name_column = name_column;
-  priv->size_column = size_column;
-  priv->info_column = info_column;
-  priv->percentage_column = percentage_column;
-  priv->valid_column = valid_column;
+  chart->priv->name_column = name_column;
+  chart->priv->size_column = size_column;
+  chart->priv->info_column = info_column;
+  chart->priv->percentage_column = percentage_column;
+  chart->priv->valid_column = valid_column;
 }
 
 /**
@@ -1274,42 +1336,36 @@ baobab_chart_set_model_with_columns (GtkWidget *chart,
  * #GtkTreeModel.
  **/
 void
-baobab_chart_set_model (GtkWidget *chart,
-                             GtkTreeModel *model)
+baobab_chart_set_model (BaobabChart  *chart,
+                        GtkTreeModel *model)
 {
-  BaobabChartPrivate *priv;
-
   g_return_if_fail (BAOBAB_IS_CHART (chart));
   g_return_if_fail (GTK_IS_TREE_MODEL (model));
 
-  priv = BAOBAB_CHART (chart)->priv;
-
-  if (model == priv->model)
+  if (model == chart->priv->model)
     return;
 
-  if (priv->model)
+  if (chart->priv->model)
     {
-      if (! priv->is_frozen)
-        baobab_chart_disconnect_signals (chart,
-                                         priv->model);
-      g_object_unref (priv->model);
+      if (! chart->priv->is_frozen)
+        baobab_chart_disconnect_signals (chart, chart->priv->model);
+      g_object_unref (chart->priv->model);
     }
 
-  priv->model = model;
-  g_object_ref (priv->model);
+  chart->priv->model = model;
+  g_object_ref (chart->priv->model);
 
-  if (! priv->is_frozen)
-    baobab_chart_connect_signals (chart,
-                                  priv->model);
+  if (! chart->priv->is_frozen)
+    baobab_chart_connect_signals (chart, chart->priv->model);
 
-  if (priv->root)
-    gtk_tree_row_reference_free (priv->root);
+  if (chart->priv->root)
+    gtk_tree_row_reference_free (chart->priv->root);
 
-  priv->root = NULL;
+  chart->priv->root = NULL;
 
   g_object_notify (G_OBJECT (chart), "model");
 
-  gtk_widget_queue_draw (chart);
+  gtk_widget_queue_draw (GTK_WIDGET (chart));
 }
 
 /**
@@ -1321,11 +1377,11 @@ baobab_chart_set_model (GtkWidget *chart,
  * Returns: %NULL if @chart is not a #BaobabChart.
  **/
 GtkTreeModel *
-baobab_chart_get_model (GtkWidget *chart)
+baobab_chart_get_model (BaobabChart *chart)
 {
   g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
 
-  return BAOBAB_CHART (chart)->priv->model;
+  return chart->priv->model;
 }
 
 /**
@@ -1340,27 +1396,23 @@ baobab_chart_get_model (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 void
-baobab_chart_set_max_depth (GtkWidget *chart,
-                            guint max_depth)
+baobab_chart_set_max_depth (BaobabChart *chart,
+                            guint        max_depth)
 {
-  BaobabChartPrivate *priv;
-
   g_return_if_fail (BAOBAB_IS_CHART (chart));
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-
   max_depth = MIN (max_depth, BAOBAB_CHART_MAX_DEPTH);
   max_depth = MAX (max_depth, BAOBAB_CHART_MIN_DEPTH);
 
-  if (max_depth == priv->max_depth)
+  if (max_depth == chart->priv->max_depth)
     return;
 
-  priv->max_depth = max_depth;
+  chart->priv->max_depth = max_depth;
   g_object_notify (G_OBJECT (chart), "max-depth");
 
-  priv->model_changed = TRUE;
+  chart->priv->model_changed = TRUE;
 
-  gtk_widget_queue_draw (chart);
+  gtk_widget_queue_draw (GTK_WIDGET (chart));
 }
 
 /**
@@ -1373,11 +1425,11 @@ baobab_chart_set_max_depth (GtkWidget *chart,
  * Fails if @chart is not a #BaobabChart.
  **/
 guint
-baobab_chart_get_max_depth (GtkWidget *chart)
+baobab_chart_get_max_depth (BaobabChart *chart)
 {
   g_return_val_if_fail (BAOBAB_IS_CHART (chart), 0);
 
-  return BAOBAB_CHART (chart)->priv->max_depth;
+  return chart->priv->max_depth;
 }
 
 /**
@@ -1393,33 +1445,30 @@ baobab_chart_get_max_depth (GtkWidget *chart)
  * a #GtkTreeModel set.
  **/
 void
-baobab_chart_set_root (GtkWidget *chart,
+baobab_chart_set_root (BaobabChart *chart,
                        GtkTreePath *root)
 {
-  BaobabChartPrivate *priv;
-  GtkTreePath *current_root;
-
   g_return_if_fail (BAOBAB_IS_CHART (chart));
+  g_return_if_fail (chart->priv->model != NULL);
 
-  priv = BAOBAB_CHART (chart)->priv;
-
-  g_return_if_fail (priv->model != NULL);
-
-  if (priv->root) {
-    /* Check that given root is different from current */
-    current_root = gtk_tree_row_reference_get_path (priv->root);
-    if ( (current_root) && (gtk_tree_path_compare (current_root, root) == 0) )
-      return;
+  if (chart->priv->root)
+    {
+      /* Check that given root is different from current */
+      GtkTreePath *current_root = gtk_tree_row_reference_get_path (chart->priv->root);
+      if (current_root && (gtk_tree_path_compare (current_root, root) == 0))
+        return;
 
-    /* Free current root */
-    gtk_tree_row_reference_free (priv->root);
-  }
+      /* Free current root */
+      gtk_tree_row_reference_free (chart->priv->root);
+    }
+  else if (!root)
+    return;
 
-  priv->root = gtk_tree_row_reference_new (priv->model, root);
+  chart->priv->root = root ? gtk_tree_row_reference_new (chart->priv->model, root) : NULL;
 
   g_object_notify (G_OBJECT (chart), "root");
 
-  gtk_widget_queue_draw (chart);
+  gtk_widget_queue_draw (GTK_WIDGET (chart));
 }
 
 /**
@@ -1433,13 +1482,13 @@ baobab_chart_set_root (GtkWidget *chart,
  *
  * Fails if @chart is not a #BaobabChart.
  **/
-GtkTreePath*
-baobab_chart_get_root (GtkWidget *chart)
+GtkTreePath *
+baobab_chart_get_root (BaobabChart *chart)
 {
   g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
 
-  if (BAOBAB_CHART (chart)->priv->root)
-    return gtk_tree_row_reference_get_path (BAOBAB_CHART (chart)->priv->root);
+  if (chart->priv->root)
+    return gtk_tree_row_reference_get_path (chart->priv->root);
   else
     return NULL;
 }
@@ -1457,22 +1506,18 @@ baobab_chart_get_root (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 void
-baobab_chart_freeze_updates (GtkWidget *chart)
+baobab_chart_freeze_updates (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
   cairo_surface_t *surface = NULL;
   GtkAllocation allocation;
 
   g_return_if_fail (BAOBAB_IS_CHART (chart));
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-
-  if (priv->is_frozen)
+  if (chart->priv->is_frozen)
     return;
 
-  if (priv->model)
-    baobab_chart_disconnect_signals (chart,
-                                     priv->model);
+  if (chart->priv->model)
+    baobab_chart_disconnect_signals (chart, chart->priv->model);
 
   gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
@@ -1497,14 +1542,14 @@ baobab_chart_freeze_updates (GtkWidget *chart)
 
       cairo_clip (cr);
 
-      priv->memento = surface;
+      chart->priv->memento = surface;
 
       cairo_destroy (cr);
     }
 
-  priv->is_frozen = TRUE;
+  chart->priv->is_frozen = TRUE;
 
-  gtk_widget_queue_draw (chart);
+  gtk_widget_queue_draw (GTK_WIDGET (chart));
 }
 
 /**
@@ -1519,30 +1564,25 @@ baobab_chart_freeze_updates (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 void
-baobab_chart_thaw_updates (GtkWidget *chart)
+baobab_chart_thaw_updates (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
-
   g_return_if_fail (BAOBAB_IS_CHART (chart));
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-
-  if (priv->is_frozen)
+  if (chart->priv->is_frozen)
     {
-      if (priv->model)
-        baobab_chart_connect_signals (chart,
-                                      priv->model);
+      if (chart->priv->model)
+        baobab_chart_connect_signals (chart, chart->priv->model);
 
-      if (priv->memento)
+      if (chart->priv->memento)
         {
-          cairo_surface_destroy (priv->memento);
-          priv->memento = NULL;
+          cairo_surface_destroy (chart->priv->memento);
+          chart->priv->memento = NULL;
         }
 
-      priv->is_frozen = FALSE;
+      chart->priv->is_frozen = FALSE;
 
-      priv->model_changed = TRUE;
-      gtk_widget_queue_draw (chart);
+      chart->priv->model_changed = TRUE;
+      gtk_widget_queue_draw (GTK_WIDGET (chart));
     }
 }
 
@@ -1555,21 +1595,19 @@ baobab_chart_thaw_updates (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 void
-baobab_chart_zoom_in (GtkWidget *chart)
+baobab_chart_zoom_in (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
   BaobabChartClass *class;
   guint new_max_depth;
 
   g_return_if_fail (BAOBAB_IS_CHART (chart));
 
-  priv = BAOBAB_CHART (chart)->priv;
   class = BAOBAB_CHART_GET_CLASS (chart);
 
   if (class->can_zoom_in != NULL)
     new_max_depth = class->can_zoom_in (chart);
   else
-    new_max_depth = priv->max_depth - 1;
+    new_max_depth = chart->priv->max_depth - 1;
 
   baobab_chart_set_max_depth (chart, new_max_depth);
 }
@@ -1583,12 +1621,65 @@ baobab_chart_zoom_in (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 void
-baobab_chart_zoom_out (GtkWidget *chart)
+baobab_chart_zoom_out (BaobabChart *chart)
 {
   g_return_if_fail (BAOBAB_IS_CHART (chart));
 
-  baobab_chart_set_max_depth (chart,
-                              baobab_chart_get_max_depth (chart) + 1);
+  baobab_chart_set_max_depth (chart, baobab_chart_get_max_depth (chart) + 1);
+}
+
+/**
+ * baobab_chart_can_zoom_in:
+ * @chart: the #BaobabChart to ask if can be zoomed in.
+ *
+ * Returns a boolean telling whether the chart can be zoomed in, given its current
+ * visualization conditions.
+ *
+ * Fails if @chart is not a #BaobabChart.
+ **/
+gboolean
+baobab_chart_can_zoom_in (BaobabChart *chart)
+{
+  BaobabChartClass *class;
+
+  g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
+
+  if (chart->priv->is_frozen)
+    return FALSE;
+
+  class = BAOBAB_CHART_GET_CLASS (chart);
+
+  if (class->can_zoom_in != NULL)
+    return class->can_zoom_in (chart) > 0;
+  else
+    return chart->priv->max_depth > 1;
+}
+
+/**
+ * baobab_chart_can_zoom_out:
+ * @chart: the #BaobabChart to ask if can be zoomed out.
+ *
+ * Returns a boolean telling whether the chart can be zoomed out, given its current
+ * visualization conditions.
+ *
+ * Fails if @chart is not a #BaobabChart.
+ **/
+gboolean
+baobab_chart_can_zoom_out (BaobabChart *chart)
+{
+  BaobabChartClass *class;
+
+  g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
+
+  if (chart->priv->is_frozen)
+    return FALSE;
+
+  class = BAOBAB_CHART_GET_CLASS (chart);
+
+  if (class->can_zoom_out != NULL)
+    return class->can_zoom_out (chart) > 0;
+  else
+    return (chart->priv->max_depth < BAOBAB_CHART_MAX_DEPTH);
 }
 
 /**
@@ -1600,10 +1691,8 @@ baobab_chart_zoom_out (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 void
-baobab_chart_move_up_root (GtkWidget *chart)
+baobab_chart_move_up_root (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
-
   GtkTreeIter parent_iter;
   GtkTreePath *path;
   GtkTreeIter root_iter;
@@ -1613,36 +1702,34 @@ baobab_chart_move_up_root (GtkWidget *chart)
 
   g_return_if_fail (BAOBAB_IS_CHART (chart));
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-
-  if (priv->root == NULL)
+  if (chart->priv->root == NULL)
     return;
 
-  path = gtk_tree_row_reference_get_path (priv->root);
+  path = gtk_tree_row_reference_get_path (chart->priv->root);
 
   if (path != NULL)
-    gtk_tree_model_get_iter (priv->model, &root_iter, path);
+    gtk_tree_model_get_iter (chart->priv->model, &root_iter, path);
   else
     return;
 
-  if (gtk_tree_model_iter_parent (priv->model, &parent_iter, &root_iter))
+  if (gtk_tree_model_iter_parent (chart->priv->model, &parent_iter, &root_iter))
     {
-      gtk_tree_model_get (priv->model, &parent_iter, priv->valid_column,
+      gtk_tree_model_get (chart->priv->model, &parent_iter, chart->priv->valid_column,
                           &valid, -1);
 
       if (valid == -1)
         return;
 
-      gtk_tree_row_reference_free (priv->root);
-      parent_path = gtk_tree_model_get_path (priv->model, &parent_iter);
-      priv->root = gtk_tree_row_reference_new (priv->model, parent_path);
+      gtk_tree_row_reference_free (chart->priv->root);
+      parent_path = gtk_tree_model_get_path (chart->priv->model, &parent_iter);
+      chart->priv->root = gtk_tree_row_reference_new (chart->priv->model, parent_path);
       gtk_tree_path_free (parent_path);
 
       g_signal_emit (BAOBAB_CHART (chart),
                      baobab_chart_signals[ITEM_ACTIVATED],
                      0, &parent_iter);
 
-      gtk_widget_queue_draw (chart);
+      gtk_widget_queue_draw (GTK_WIDGET (chart));
     }
 
   gtk_tree_path_free (path);
@@ -1658,12 +1745,9 @@ baobab_chart_move_up_root (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 void
-baobab_chart_save_snapshot (GtkWidget *chart)
+baobab_chart_save_snapshot (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
-
   GdkPixbuf *pixbuf;
-
   GtkWidget *fs_dlg;
   GtkWidget *vbox;
   GtkWidget *hbox;
@@ -1696,8 +1780,6 @@ baobab_chart_save_snapshot (GtkWidget *chart)
       return;
     }
 
-  priv = BAOBAB_CHART (chart)->priv;
-
   /* Popup the File chooser dialog */
   fs_dlg = gtk_file_chooser_dialog_new (_("Save Snapshot"),
                                         NULL,
@@ -1707,7 +1789,7 @@ baobab_chart_save_snapshot (GtkWidget *chart)
                                         GTK_STOCK_SAVE,
                                         GTK_RESPONSE_ACCEPT, NULL);
 
-  item = (BaobabChartItem *) priv->first_item->data;
+  item = (BaobabChartItem *) chart->priv->first_item->data;
   def_filename = g_strdup_printf (SNAPSHOT_DEF_FILENAME_FORMAT, item->name);
 
   gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (fs_dlg), def_filename);
@@ -1719,11 +1801,11 @@ baobab_chart_save_snapshot (GtkWidget *chart)
   gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (fs_dlg), TRUE);
 
   /* extra widget */
-  vbox = gtk_vbox_new (FALSE, 0);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
   gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (fs_dlg), vbox);
 
-  hbox = gtk_hbox_new (FALSE, 12);
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 6);
 
   label = gtk_label_new_with_mnemonic (_("_Image type:"));
@@ -1772,14 +1854,11 @@ baobab_chart_save_snapshot (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 gboolean
-baobab_chart_is_frozen (GtkWidget *chart)
+baobab_chart_is_frozen (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
-
   g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-  return priv->is_frozen;
+  return chart->priv->is_frozen;
 }
 
 /**
@@ -1792,67 +1871,10 @@ baobab_chart_is_frozen (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 BaobabChartItem *
-baobab_chart_get_highlighted_item (GtkWidget *chart)
+baobab_chart_get_highlighted_item (BaobabChart *chart)
 {
-  BaobabChartPrivate *priv;
-
   g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
 
-  priv = BAOBAB_CHART_GET_PRIVATE (chart);
-  return (priv->highlighted_item ? 
-    (BaobabChartItem *) priv->highlighted_item->data : NULL);
+  return (chart->priv->highlighted_item ?
+    (BaobabChartItem *) chart->priv->highlighted_item->data : NULL);
 }
-
-/**
- * baobab_chart_can_zoom_in:
- * @chart: the #BaobabChart to ask if can be zoomed in.
- *
- * Returns a boolean telling whether the chart can be zoomed in, given its current
- * visualization conditions.
- *
- * Fails if @chart is not a #BaobabChart.
- **/
-gboolean
-baobab_chart_can_zoom_in (GtkWidget *chart)
-{
-  BaobabChartPrivate *priv;
-  BaobabChartClass *class;
-
-  g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
-
-  priv = BAOBAB_CHART (chart)->priv;
-  class = BAOBAB_CHART_GET_CLASS (chart);
-
-  if (class->can_zoom_in != NULL)
-    return class->can_zoom_in (chart) > 0;
-  else
-    return priv->max_depth > 1;
-}
-
-/**
- * baobab_chart_can_zoom_out:
- * @chart: the #BaobabChart to ask if can be zoomed out.
- *
- * Returns a boolean telling whether the chart can be zoomed out, given its current
- * visualization conditions.
- *
- * Fails if @chart is not a #BaobabChart.
- **/
-gboolean
-baobab_chart_can_zoom_out (GtkWidget *chart)
-{
-  BaobabChartPrivate *priv;
-  BaobabChartClass *class;
-
-  g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
-
-  priv = BAOBAB_CHART (chart)->priv;
-  class = BAOBAB_CHART_GET_CLASS (chart);
-
-  if (class->can_zoom_out != NULL)
-    return class->can_zoom_out (chart) > 0;
-  else
-    return (priv->max_depth < BAOBAB_CHART_MAX_DEPTH);
-}
-
-/* ex:set ts=8 noet: */
diff --git a/src/baobab-chart.h b/src/baobab-chart.h
index 1977302..f813fc6 100644
--- a/src/baobab-chart.h
+++ b/src/baobab-chart.h
@@ -5,18 +5,18 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation; either version 2 of the licence, or (at
+ * your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA  02110-1301  USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+ * USA
  *
  * Authors:
  *   Felipe Erias <femorandeira igalia com>
@@ -38,24 +38,27 @@
 
 G_BEGIN_DECLS
 
-#define BAOBAB_CHART_TYPE       (baobab_chart_get_type ())
-#define BAOBAB_CHART(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_CHART_TYPE, BaobabChart))
-#define BAOBAB_CHART_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), BAOBAB_CHART_TYPE, BaobabChartClass))
-#define BAOBAB_IS_CHART(obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_CHART_TYPE))
-#define BAOBAB_IS_CHART_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE ((obj), BAOBAB_CHART_TYPE))
-#define BAOBAB_CHART_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_CHART_TYPE, BaobabChartClass))
-
-typedef struct _BaobabChart BaobabChart;
-typedef struct _BaobabChartClass BaobabChartClass;
-typedef struct _BaobabChartPrivate BaobabChartPrivate;
-typedef struct _BaobabChartColor BaobabChartColor;
-typedef struct _BaobabChartItem BaobabChartItem;
+#define BAOBAB_TYPE_CHART                                   (baobab_chart_get_type ())
+#define BAOBAB_CHART(inst)                                  (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
+                                                             BAOBAB_TYPE_CHART, BaobabChart))
+#define BAOBAB_CHART_CLASS(class)                           (G_TYPE_CHECK_CLASS_CAST ((class),                       \
+                                                             BAOBAB_TYPE_CHART, BaobabChartClass))
+#define BAOBAB_IS_CHART(inst)                               (G_TYPE_CHECK_INSTANCE_TYPE ((inst), BAOBAB_TYPE_CHART))
+#define BAOBAB_IS_CHART_CLASS(class)                        (G_TYPE_CHECK_CLASS_TYPE ((class), BAOBAB_TYPE_CHART))
+#define BAOBAB_CHART_GET_CLASS(inst)                        (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
+                                                             BAOBAB_TYPE_CHART, BaobabChartClass))
+
+typedef struct _BaobabChart                                 BaobabChart;
+typedef struct _BaobabChartClass                            BaobabChartClass;
+typedef struct _BaobabChartPrivate                          BaobabChartPrivate;
+typedef struct _BaobabChartColor                            BaobabChartColor;
+typedef struct _BaobabChartItem                             BaobabChartItem;
 
 struct _BaobabChart
 {
   GtkWidget parent;
 
-  /* < private > */
+  /*< private >*/
   BaobabChartPrivate *priv;
 };
 
@@ -89,71 +92,70 @@ struct _BaobabChartClass
   GtkWidgetClass parent_class;
 
   /* Signal prototypes */
-  void (* item_activated) (BaobabChart *chart,
-                             GtkTreeIter *iter);
+  void       (* item_activated)                 (BaobabChart     *chart,
+                                                 GtkTreeIter     *iter);
 
   /* Abstract methods */
-  void (* draw_item) (GtkWidget *chart,
-                      cairo_t *cr,
-                      BaobabChartItem *item,
-                      gboolean highlighted);
+  void       (* draw_item)                      (BaobabChart     *chart,
+                                                 cairo_t         *cr,
+                                                 BaobabChartItem *item,
+                                                 gboolean         highlighted);
 
-  void (* pre_draw) (GtkWidget *chart,
-                     cairo_t *cr);
+  void       (* pre_draw)                       (BaobabChart     *chart,
+                                                 cairo_t         *cr);
 
-  void (* post_draw) (GtkWidget *chart,
-                      cairo_t *cr);
+  void       (* post_draw)                      (BaobabChart     *chart,
+                                                 cairo_t         *cr);
 
-  void (* calculate_item_geometry) (GtkWidget *chart,
-                                    BaobabChartItem *item);
+  void       (* calculate_item_geometry)        (BaobabChart     *chart,
+                                                 BaobabChartItem *item);
 
-  gboolean (* is_point_over_item) (GtkWidget *chart,
-                                   BaobabChartItem *item,
-                                   gdouble x,
-                                   gdouble y);
+  gboolean   (* is_point_over_item)             (BaobabChart     *chart,
+                                                 BaobabChartItem *item,
+                                                 gdouble          x,
+                                                 gdouble          y);
 
-  void (* get_item_rectangle) (GtkWidget *chart,
-                               BaobabChartItem *item);
+  void       (* get_item_rectangle)             (BaobabChart     *chart,
+                                                 BaobabChartItem *item);
 
-  guint (* can_zoom_in) (GtkWidget *chart);
-  guint (* can_zoom_out) (GtkWidget *chart);
+  guint      (* can_zoom_in)                    (BaobabChart     *chart);
+  guint      (* can_zoom_out)                   (BaobabChart     *chart);
 };
 
-GType baobab_chart_get_type (void) G_GNUC_CONST;
-GtkWidget* baobab_chart_new (void);
-void baobab_chart_set_model_with_columns (GtkWidget *chart,
-                                          GtkTreeModel *model,
-                                          guint name_column,
-                                          guint size_column,
-                                          guint info_column,
-                                          guint percentage_column,
-                                          guint valid_column,
-                                          GtkTreePath *root);
-void baobab_chart_set_model (GtkWidget *chart,
-                             GtkTreeModel *model);
-GtkTreeModel* baobab_chart_get_model (GtkWidget *chart);
-void baobab_chart_set_max_depth (GtkWidget *chart,
-                                 guint max_depth);
-guint baobab_chart_get_max_depth (GtkWidget *chart);
-void baobab_chart_set_root (GtkWidget *chart,
-                            GtkTreePath *root);
-GtkTreePath *baobab_chart_get_root (GtkWidget *chart);
-void baobab_chart_freeze_updates (GtkWidget *chart);
-void baobab_chart_thaw_updates (GtkWidget *chart);
-void baobab_chart_get_item_color (BaobabChartColor *color,
-                                  gdouble position,
-                                  gint depth,
-                                  gboolean highlighted);
-void  baobab_chart_move_up_root (GtkWidget *chart);
-void baobab_chart_zoom_in (GtkWidget *chart);
-void baobab_chart_zoom_out (GtkWidget *chart);
-void baobab_chart_save_snapshot (GtkWidget *chart);
-gboolean baobab_chart_is_frozen (GtkWidget *chart);
-BaobabChartItem *baobab_chart_get_highlighted_item (GtkWidget *chart);
-
-gboolean baobab_chart_can_zoom_in (GtkWidget *chart);
-gboolean baobab_chart_can_zoom_out (GtkWidget *chart);
+GType                   baobab_chart_get_type                           (void) G_GNUC_CONST;
+BaobabChart *           baobab_chart_new                                (void);
+void                    baobab_chart_set_model_with_columns             (BaobabChart  *chart,
+                                                                         GtkTreeModel *model,
+                                                                         guint         name_column,
+                                                                         guint         size_column,
+                                                                         guint         info_column,
+                                                                         guint         percentage_column,
+                                                                         guint         valid_column,
+                                                                         GtkTreePath  *root);
+void                    baobab_chart_set_model                          (BaobabChart *chart,
+                                                                         GtkTreeModel *model);
+GtkTreeModel *          baobab_chart_get_model                          (BaobabChart *chart);
+void                    baobab_chart_set_max_depth                      (BaobabChart *chart,
+                                                                         guint max_depth);
+guint                   baobab_chart_get_max_depth                      (BaobabChart *chart);
+void                    baobab_chart_set_root                           (BaobabChart *chart,
+                                                                         GtkTreePath *root);
+GtkTreePath *           baobab_chart_get_root                           (BaobabChart *chart);
+void                    baobab_chart_freeze_updates                     (BaobabChart *chart);
+void                    baobab_chart_thaw_updates                       (BaobabChart *chart);
+void                    baobab_chart_get_item_color                     (BaobabChartColor *color,
+                                                                         gdouble position,
+                                                                         gint depth,
+                                                                         gboolean highlighted);
+void                    baobab_chart_move_up_root                       (BaobabChart *chart);
+void                    baobab_chart_zoom_in                            (BaobabChart *chart);
+void                    baobab_chart_zoom_out                           (BaobabChart *chart);
+gboolean                baobab_chart_can_zoom_in                        (BaobabChart *chart);
+gboolean                baobab_chart_can_zoom_out                       (BaobabChart *chart);
+void                    baobab_chart_save_snapshot                      (BaobabChart *chart);
+gboolean                baobab_chart_is_frozen                          (BaobabChart *chart);
+BaobabChartItem *       baobab_chart_get_highlighted_item               (BaobabChart *chart);
 
 G_END_DECLS
 
-#endif
+#endif /* __BAOBAB_CHART_H__ */
diff --git a/src/baobab-ringschart.c b/src/baobab-ringschart.c
index ab604f5..8f10abe 100644
--- a/src/baobab-ringschart.c
+++ b/src/baobab-ringschart.c
@@ -53,7 +53,7 @@
 
 #define SUBFOLDER_TIP_PADDING 3
 
-G_DEFINE_TYPE (BaobabRingschart, baobab_ringschart, BAOBAB_CHART_TYPE);
+G_DEFINE_TYPE (BaobabRingschart, baobab_ringschart, BAOBAB_TYPE_CHART);
 
 typedef struct _BaobabRingschartItem BaobabRingschartItem;
 
@@ -84,23 +84,23 @@ static void baobab_ringschart_draw_sector (cairo_t *cr,
                                            gdouble init_angle, gdouble final_angle,
                                            BaobabChartColor fill_color,
                                            gboolean continued, guint border);
-static void baobab_ringschart_draw_item (GtkWidget *chart,
+static void baobab_ringschart_draw_item (BaobabChart *chart,
                                          cairo_t *cr,
                                          BaobabChartItem *item,
                                          gboolean highlighted);
-static void baobab_ringschart_calculate_item_geometry (GtkWidget *chart,
+static void baobab_ringschart_calculate_item_geometry (BaobabChart *chart,
                                                        BaobabChartItem *item);
-static gboolean baobab_ringschart_is_point_over_item (GtkWidget *chart,
+static gboolean baobab_ringschart_is_point_over_item (BaobabChart *chart,
                                                       BaobabChartItem *item,
                                                       gdouble x,
                                                       gdouble y);
 static void baobab_ringschart_get_point_min_rect (gdouble cx, gdouble cy,
                                                   gdouble radius, gdouble angle,
                                                   GdkRectangle *rect);
-static void baobab_ringschart_get_item_rectangle (GtkWidget *chart,
+static void baobab_ringschart_get_item_rectangle (BaobabChart *chart,
                                                   BaobabChartItem *item);
-static void baobab_ringschart_pre_draw (GtkWidget *chart, cairo_t *cr);
-static void baobab_ringschart_post_draw (GtkWidget *chart, cairo_t *cr);
+static void baobab_ringschart_pre_draw (BaobabChart *chart, cairo_t *cr);
+static void baobab_ringschart_post_draw (BaobabChart *chart, cairo_t *cr);
 
 
 static void
@@ -126,21 +126,20 @@ baobab_ringschart_class_init (BaobabRingschartClass *class)
 static void
 baobab_ringschart_init (BaobabRingschart *chart)
 {
-  BaobabRingschartPrivate *priv;
   GtkSettings* settings;
   gint timeout;
 
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
+  chart->priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
 
-  priv->subfoldertips_enabled = TRUE;
-  priv->highlighted_item = NULL;
-  priv->tips_timeout_event = 0;
-  priv->subtip_items = NULL;
-  priv->drawing_subtips = FALSE;
+  chart->priv->subfoldertips_enabled = TRUE;
+  chart->priv->highlighted_item = NULL;
+  chart->priv->tips_timeout_event = 0;
+  chart->priv->subtip_items = NULL;
+  chart->priv->drawing_subtips = FALSE;
 
   settings = gtk_settings_get_default ();
   g_object_get (G_OBJECT (settings), "gtk-tooltip-timeout", &timeout, NULL);
-  priv->subtip_timeout = 2 * timeout;
+  chart->priv->subtip_timeout = 2 * timeout;
 }
 
 static void
@@ -177,17 +176,17 @@ baobab_ringschart_draw_sector (cairo_t *cr,
 }
 
 static void
-baobab_ringschart_draw_item (GtkWidget *chart,
-                             cairo_t *cr,
+baobab_ringschart_draw_item (BaobabChart     *chart,
+                             cairo_t         *cr,
                              BaobabChartItem *item,
-                             gboolean highlighted)
+                             gboolean         highlighted)
 {
   BaobabRingschartPrivate *priv;
   BaobabRingschartItem *data;
   BaobabChartColor fill_color;
   GtkAllocation allocation;
 
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
+  priv = BAOBAB_RINGSCHART (chart)->priv;
 
   data = (BaobabRingschartItem *) item->data;
 
@@ -210,7 +209,8 @@ baobab_ringschart_draw_item (GtkWidget *chart,
                                item->depth,
                                highlighted);
 
-  gtk_widget_get_allocation (chart, &allocation);
+  gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
+
   baobab_ringschart_draw_sector (cr,
                                  allocation.width / 2,
                                  allocation.height / 2,
@@ -224,7 +224,7 @@ baobab_ringschart_draw_item (GtkWidget *chart,
 }
 
 static void
-baobab_ringschart_calculate_item_geometry (GtkWidget *chart,
+baobab_ringschart_calculate_item_geometry (BaobabChart *chart,
                                            BaobabChartItem *item)
 {
   BaobabRingschartItem *data;
@@ -246,7 +246,7 @@ baobab_ringschart_calculate_item_geometry (GtkWidget *chart,
   data->continued = FALSE;
   item->visible = FALSE;
 
-  gtk_widget_get_allocation (chart, &allocation);
+  gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
   max_radius = MIN (allocation.width / 2, allocation.height / 2) - CHART_PADDING;
   thickness = max_radius / (max_depth + 1);
 
@@ -285,7 +285,7 @@ baobab_ringschart_calculate_item_geometry (GtkWidget *chart,
 }
 
 static gboolean
-baobab_ringschart_is_point_over_item (GtkWidget *chart,
+baobab_ringschart_is_point_over_item (BaobabChart *chart,
                                       BaobabChartItem *item,
                                       gdouble x,
                                       gdouble y)
@@ -295,7 +295,7 @@ baobab_ringschart_is_point_over_item (GtkWidget *chart,
   GtkAllocation allocation;
 
   data = (BaobabRingschartItem *) item->data;
-  gtk_widget_get_allocation (chart, &allocation);
+  gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
   x = x - allocation.width / 2;
   y = y - allocation.height / 2;
 
@@ -328,8 +328,8 @@ baobab_ringschart_get_point_min_rect (gdouble cx,
 }
 
 static void
-baobab_ringschart_get_item_rectangle (GtkWidget *chart,
-                                       BaobabChartItem *item)
+baobab_ringschart_get_item_rectangle (BaobabChart *chart,
+                                      BaobabChartItem *item)
 {
   BaobabRingschartItem *data;
   GdkRectangle rect;
@@ -338,7 +338,7 @@ baobab_ringschart_get_item_rectangle (GtkWidget *chart,
 
   data = (BaobabRingschartItem *) item->data;
 
-  gtk_widget_get_allocation (chart, &allocation);
+  gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
   cx = allocation.width / 2;
   cy = allocation.height / 2;
   r1 = data->min_radius;
@@ -374,12 +374,12 @@ baobab_ringschart_get_item_rectangle (GtkWidget *chart,
   item->rect = rect;
 }
 
-gboolean
+static gboolean
 baobab_ringschart_subfolder_tips_timeout (gpointer data)
 {
   BaobabRingschartPrivate *priv;
 
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (data);
+  priv = BAOBAB_RINGSCHART (data)->priv;
 
   priv->drawing_subtips = TRUE;
 
@@ -389,15 +389,15 @@ baobab_ringschart_subfolder_tips_timeout (gpointer data)
 }
 
 void
-baobab_ringschart_clean_subforlder_tips_state (GtkWidget *chart)
+baobab_ringschart_clean_subforlder_tips_state (BaobabRingschart *chart)
 {
   BaobabRingschartPrivate *priv;
   GList *node;
 
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
+  priv = chart->priv;
 
   if (priv->drawing_subtips)
-    gtk_widget_queue_draw (chart);
+    gtk_widget_queue_draw (GTK_WIDGET (chart));
 
   priv->drawing_subtips = FALSE;
 
@@ -429,26 +429,11 @@ baobab_ringschart_draw_subfolder_tips (GtkWidget *chart, cairo_t *cr)
 {
   BaobabRingschartPrivate *priv;
   GList *node;
-  BaobabChartItem *item;
-  BaobabRingschartItem *data;
-
   gdouble q_angle, q_width, q_height;
-
-  gdouble tip_x, tip_y;
-  gdouble middle_angle, middle_angle_n, middle_radius;
-  gdouble sector_center_x, sector_center_y;
-  gdouble a;
-  guint i;
   GtkAllocation allocation;
+  GdkRectangle last_rect;
 
-  PangoLayout *layout;
-  PangoRectangle layout_rect;
-  gchar *markup = NULL;
-
-  cairo_rectangle_t tooltip_rect;
-  GdkRectangle _rect, last_rect;
-
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
+  priv = BAOBAB_RINGSCHART (chart)->priv;
 
   gtk_widget_get_allocation (chart, &allocation);
   q_width = allocation.width / 2;
@@ -462,6 +447,20 @@ baobab_ringschart_draw_subfolder_tips (GtkWidget *chart, cairo_t *cr)
   node = priv->subtip_items;
   while (node != NULL)
     {
+      BaobabChartItem *item;
+      BaobabRingschartItem *data;
+      gdouble middle_angle, middle_angle_n, middle_radius;
+      gdouble tip_x, tip_y;
+      gdouble sector_center_x, sector_center_y;
+      gdouble a;
+      guint i;
+      char *escaped;
+      char *markup;
+      PangoLayout *layout;
+      PangoRectangle layout_rect;
+      GdkRectangle _rect;
+      cairo_rectangle_t tooltip_rect;
+
       item = (BaobabChartItem *) node->data;
       data = (BaobabRingschartItem *) item->data;
 
@@ -476,9 +475,12 @@ baobab_ringschart_draw_subfolder_tips (GtkWidget *chart, cairo_t *cr)
 
       /* get the pango layout and its enclosing rectangle */
       layout = gtk_widget_create_pango_layout (chart, NULL);
-      markup = g_strconcat ("<span size=\"small\">", item->name, "</span>", NULL);
+      escaped = g_markup_escape_text (item->name, -1);
+      markup = g_strconcat ("<span size=\"small\">", escaped, "</span>", NULL);
       pango_layout_set_markup (layout, markup, -1);
+      g_free (escaped);
       g_free (markup);
+
       pango_layout_set_indent (layout, 0);
       pango_layout_set_spacing (layout, 0);
       pango_layout_get_pixel_extents (layout, NULL, &layout_rect);
@@ -589,25 +591,25 @@ baobab_ringschart_draw_subfolder_tips (GtkWidget *chart, cairo_t *cr)
 }
 
 static void
-baobab_ringschart_pre_draw (GtkWidget *chart, cairo_t *cr)
+baobab_ringschart_pre_draw (BaobabChart *chart,
+                            cairo_t     *cr)
 {
   BaobabRingschartPrivate *priv;
   BaobabChartItem *hl_item;
 
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
+  priv = BAOBAB_RINGSCHART (chart)->priv;
 
   hl_item = baobab_chart_get_highlighted_item (chart);
 
-  if ( (hl_item == NULL) || (! hl_item->has_visible_children) )
+  if ((hl_item == NULL) || (! hl_item->has_visible_children))
     {
-      baobab_ringschart_clean_subforlder_tips_state (chart);
-
+      baobab_ringschart_clean_subforlder_tips_state (BAOBAB_RINGSCHART (chart));
       return;
     }
 
   if (hl_item != priv->highlighted_item)
     {
-      baobab_ringschart_clean_subforlder_tips_state (chart);
+      baobab_ringschart_clean_subforlder_tips_state (BAOBAB_RINGSCHART (chart));
 
       priv->highlighted_item = hl_item;
 
@@ -619,18 +621,19 @@ baobab_ringschart_pre_draw (GtkWidget *chart, cairo_t *cr)
 }
 
 static void
-baobab_ringschart_post_draw (GtkWidget *chart, cairo_t *cr)
+baobab_ringschart_post_draw (BaobabChart *chart,
+                             cairo_t     *cr)
 {
   BaobabRingschartPrivate *priv;
 
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
+  priv = BAOBAB_RINGSCHART (chart)->priv;
 
   if (priv->drawing_subtips)
     {
       /* Reverse the glist, which was created from the tail */
       priv->subtip_items = g_list_reverse (priv->subtip_items);
 
-      baobab_ringschart_draw_subfolder_tips (chart, cr);
+      baobab_ringschart_draw_subfolder_tips (GTK_WIDGET (chart), cr);
     }
 }
 
@@ -661,15 +664,16 @@ baobab_ringschart_new (void)
  *
  **/
 void
-baobab_ringschart_set_subfoldertips_enabled (GtkWidget *chart, gboolean enabled)
+baobab_ringschart_set_subfoldertips_enabled (BaobabRingschart *chart,
+                                             gboolean          enabled)
 {
   BaobabRingschartPrivate *priv;
 
-  priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart);
+  priv = chart->priv;
 
   priv->subfoldertips_enabled = enabled;
 
-  if ( (! enabled) && (priv->drawing_subtips) )
+  if (!enabled && priv->drawing_subtips)
     {
       /* Turn off currently drawn tips */
       baobab_ringschart_clean_subforlder_tips_state (chart);
diff --git a/src/baobab-ringschart.h b/src/baobab-ringschart.h
index 276bd7f..7552f09 100644
--- a/src/baobab-ringschart.h
+++ b/src/baobab-ringschart.h
@@ -62,10 +62,12 @@ struct _BaobabRingschartClass
   BaobabChartClass parent_class;
 };
 
-GType baobab_ringschart_get_type (void) G_GNUC_CONST;
-GtkWidget *baobab_ringschart_new (void);
-void baobab_ringschart_set_subfoldertips_enabled (GtkWidget *chart, 
-                                                  gboolean enabled);
+GType       baobab_ringschart_get_type                   (void) G_GNUC_CONST;
+
+GtkWidget  *baobab_ringschart_new                        (void);
+
+void        baobab_ringschart_set_subfoldertips_enabled  (BaobabRingschart *chart,
+                                                          gboolean enabled);
 
 G_END_DECLS
 
diff --git a/src/baobab-treemap.c b/src/baobab-treemap.c
index 30fd446..b9d0956 100644
--- a/src/baobab-treemap.c
+++ b/src/baobab-treemap.c
@@ -48,7 +48,7 @@
 
 #define ITEM_SHOW_LABEL   TRUE
 
-G_DEFINE_TYPE (BaobabTreemap, baobab_treemap, BAOBAB_CHART_TYPE);
+G_DEFINE_TYPE (BaobabTreemap, baobab_treemap, BAOBAB_TYPE_CHART);
 
 struct _BaobabTreemapPrivate
 {
@@ -64,20 +64,20 @@ static void baobab_treemap_draw_rectangle (GtkWidget *chart,
                                            BaobabChartColor fill_color,
                                            const char *text,
                                            gboolean show_text);
-static void baobab_treemap_draw_item (GtkWidget *chart,
+static void baobab_treemap_draw_item (BaobabChart *chart,
                                       cairo_t *cr,
                                       BaobabChartItem *item,
                                       gboolean highlighted);
-static void baobab_treemap_calculate_item_geometry (GtkWidget *chart,
+static void baobab_treemap_calculate_item_geometry (BaobabChart *chart,
                                                     BaobabChartItem *item);
-static gboolean baobab_treemap_is_point_over_item (GtkWidget *chart,
+static gboolean baobab_treemap_is_point_over_item (BaobabChart *chart,
                                                    BaobabChartItem *item,
                                                    gdouble x,
                                                    gdouble y);
-static void baobab_treemap_get_item_rectangle (GtkWidget *chart,
+static void baobab_treemap_get_item_rectangle (BaobabChart *chart,
                                                BaobabChartItem *item);
-guint baobab_treemap_can_zoom_in (GtkWidget *chart);
-guint baobab_treemap_can_zoom_out (GtkWidget *chart);
+guint baobab_treemap_can_zoom_in (BaobabChart *chart);
+guint baobab_treemap_can_zoom_out (BaobabChart *chart);
 
 static void
 baobab_treemap_class_init (BaobabTreemapClass *class)
@@ -93,8 +93,8 @@ baobab_treemap_class_init (BaobabTreemapClass *class)
   chart_class->calculate_item_geometry = baobab_treemap_calculate_item_geometry;
   chart_class->is_point_over_item = baobab_treemap_is_point_over_item;
   chart_class->get_item_rectangle = baobab_treemap_get_item_rectangle;
-  chart_class->can_zoom_in        = baobab_treemap_can_zoom_in;
-  chart_class->can_zoom_out       = baobab_treemap_can_zoom_out;
+  chart_class->can_zoom_in = baobab_treemap_can_zoom_in;
+  chart_class->can_zoom_out = baobab_treemap_can_zoom_out;
 
   g_type_class_add_private (obj_class, sizeof (BaobabTreemapPrivate));
 }
@@ -110,12 +110,15 @@ baobab_treemap_init (BaobabTreemap *chart)
 }
 
 static void
-baobab_treemap_draw_rectangle (GtkWidget *chart,
-                               cairo_t *cr,
-                               gdouble x, gdouble y, gdouble width, gdouble height,
-                               BaobabChartColor fill_color,
-                               const char *text,
-                               gboolean show_text)
+baobab_treemap_draw_rectangle (GtkWidget        *chart,
+                               cairo_t          *cr,
+                               gdouble           x,
+                               gdouble           y,
+                               gdouble           width,
+                               gdouble           height,
+                               BaobabChartColor  fill_color,
+                               const char       *text,
+                               gboolean          show_text)
 {
   guint border = ITEM_BORDER_WIDTH;
   PangoRectangle rect;
@@ -134,15 +137,20 @@ baobab_treemap_draw_rectangle (GtkWidget *chart,
 
   if ((show_text) && (ITEM_SHOW_LABEL))
     {
+      char *markup;
+
       layout = gtk_widget_create_pango_layout (chart, NULL);
-      pango_layout_set_markup (layout, text, -1);
+      markup = g_markup_escape_text (text, -1);
+      pango_layout_set_markup (layout, markup, -1);
+      g_free (markup);
+
       pango_layout_get_pixel_extents (layout, NULL, &rect);
 
-      if ((rect.width + ITEM_TEXT_PADDING*2 <= width) &&
-          (rect.height + ITEM_TEXT_PADDING*2 <= height))
+      if ((rect.width + ITEM_TEXT_PADDING * 2 <= width) &&
+          (rect.height + ITEM_TEXT_PADDING * 2 <= height))
         {
-          cairo_move_to (cr, x + width/2 - rect.width/2,
-                         y + height/2 - rect.height/2);
+          cairo_move_to (cr, x + width / 2 - rect.width / 2,
+                         y + height / 2 - rect.height / 2);
           pango_cairo_show_layout (cr, layout);
         }
 
@@ -151,19 +159,19 @@ baobab_treemap_draw_rectangle (GtkWidget *chart,
 }
 
 static void
-baobab_treemap_draw_item (GtkWidget *chart,
+baobab_treemap_draw_item (BaobabChart *chart,
                           cairo_t *cr,
                           BaobabChartItem *item,
                           gboolean highlighted)
 {
-  cairo_rectangle_t * rect;
+  cairo_rectangle_t *rect;
   BaobabChartColor fill_color;
   GtkAllocation allocation;
   gdouble width, height;
 
   rect = (cairo_rectangle_t *) item->data;
 
-  gtk_widget_get_allocation (chart, &allocation);
+  gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
 
   if (item->depth % 2 != 0)
     {
@@ -180,7 +188,7 @@ baobab_treemap_draw_item (GtkWidget *chart,
       height = rect->height - ITEM_PADDING;
     }
 
-  baobab_treemap_draw_rectangle (chart,
+  baobab_treemap_draw_rectangle (GTK_WIDGET (chart),
                                  cr,
                                  rect->x,
                                  rect->y,
@@ -188,11 +196,11 @@ baobab_treemap_draw_item (GtkWidget *chart,
                                  height,
                                  fill_color,
                                  item->name,
-                                 (! item->has_visible_children) );
+                                 (!item->has_visible_children) );
 }
 
 static void
-baobab_treemap_calculate_item_geometry (GtkWidget *chart,
+baobab_treemap_calculate_item_geometry (BaobabChart *chart,
                                         BaobabChartItem *item)
 {
   BaobabTreemapPrivate *priv;
@@ -214,7 +222,7 @@ baobab_treemap_calculate_item_geometry (GtkWidget *chart,
 
   if (item->parent == NULL)
     {
-      gtk_widget_get_allocation (chart, &allocation);
+      gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
       p_area.x = 0 - ITEM_PADDING/2;
       p_area.y = 0 - ITEM_PADDING/2;
       p_area.width = allocation.width + ITEM_PADDING * 2;
@@ -266,14 +274,14 @@ baobab_treemap_calculate_item_geometry (GtkWidget *chart,
 
   baobab_treemap_get_item_rectangle (chart, item);
 
-  if (item->depth == baobab_chart_get_max_depth (chart) + 1)
+  if (item->depth == baobab_chart_get_max_depth (BAOBAB_CHART (chart)) + 1)
     priv->more_visible_childs = TRUE;
   else
     priv->max_visible_depth = MAX (priv->max_visible_depth, item->depth);
 }
 
 static gboolean
-baobab_treemap_is_point_over_item (GtkWidget *chart,
+baobab_treemap_is_point_over_item (BaobabChart *chart,
                                    BaobabChartItem *item,
                                    gdouble x,
                                    gdouble y)
@@ -286,7 +294,7 @@ baobab_treemap_is_point_over_item (GtkWidget *chart,
 }
 
 static void
-baobab_treemap_get_item_rectangle (GtkWidget *chart,
+baobab_treemap_get_item_rectangle (BaobabChart *chart,
                                    BaobabChartItem *item)
 {
   cairo_rectangle_t *_rect;
@@ -305,11 +313,10 @@ baobab_treemap_get_item_rectangle (GtkWidget *chart,
       item->rect.width = _rect->width;
       item->rect.height = _rect->height - ITEM_PADDING;
     }
-
 }
 
 guint
-baobab_treemap_can_zoom_in (GtkWidget *chart)
+baobab_treemap_can_zoom_in (BaobabChart *chart)
 {
   BaobabTreemapPrivate *priv;
 
@@ -319,7 +326,7 @@ baobab_treemap_can_zoom_in (GtkWidget *chart)
 }
 
 guint
-baobab_treemap_can_zoom_out (GtkWidget *chart)
+baobab_treemap_can_zoom_out (BaobabChart *chart)
 {
   BaobabTreemapPrivate *priv;
 
diff --git a/src/baobab-treemap.h b/src/baobab-treemap.h
index 734bc27..f6bbf98 100644
--- a/src/baobab-treemap.h
+++ b/src/baobab-treemap.h
@@ -56,8 +56,9 @@ struct _BaobabTreemapClass
   BaobabChartClass parent_class;
 };
 
-GType baobab_treemap_get_type (void) G_GNUC_CONST;
-GtkWidget* baobab_treemap_new (void);
+GType            baobab_treemap_get_type          (void) G_GNUC_CONST;
+
+GtkWidget       *baobab_treemap_new               (void);
 
 G_END_DECLS
 
diff --git a/src/baobab.c b/src/baobab.c
index ec9423c..8b0ff0c 100644
--- a/src/baobab.c
+++ b/src/baobab.c
@@ -82,9 +82,8 @@ baobab_set_busy (gboolean busy)
 		gtk_widget_show (baobab.spinner);
 		gtk_spinner_start (GTK_SPINNER (baobab.spinner));
 
-		baobab_chart_freeze_updates (baobab.rings_chart);
-
-		baobab_chart_freeze_updates (baobab.treemap_chart);
+		baobab_chart_freeze_updates (BAOBAB_CHART (baobab.rings_chart));
+		baobab_chart_freeze_updates (BAOBAB_CHART (baobab.treemap_chart));
 
 		gtk_widget_set_sensitive (baobab.chart_type_combo, FALSE);
 	}
@@ -92,8 +91,8 @@ baobab_set_busy (gboolean busy)
 		gtk_widget_hide (baobab.spinner);
 		gtk_spinner_stop (GTK_SPINNER (baobab.spinner));
 
-		baobab_chart_thaw_updates (baobab.rings_chart);
-		baobab_chart_thaw_updates (baobab.treemap_chart);
+		baobab_chart_thaw_updates (BAOBAB_CHART (baobab.rings_chart));
+		baobab_chart_thaw_updates (BAOBAB_CHART (baobab.treemap_chart));
 
 		gtk_widget_set_sensitive (baobab.chart_type_combo, TRUE);
 	}
@@ -270,8 +269,8 @@ baobab_scan_location (GFile *file)
 				show_bars,
 				NULL);
 
-	baobab_chart_set_max_depth (baobab.rings_chart, baobab.model_max_depth);
-	baobab_chart_set_max_depth (baobab.treemap_chart, baobab.model_max_depth);
+	baobab_chart_set_max_depth (BAOBAB_CHART (baobab.rings_chart), baobab.model_max_depth);
+	baobab_chart_set_max_depth (BAOBAB_CHART (baobab.treemap_chart), baobab.model_max_depth);
 
 	baobab_set_busy (FALSE);
 	check_menu_sens (FALSE);
@@ -929,60 +928,6 @@ baobab_shutdown (void)
 	g_settings_sync ();
 }
 
-static BaobabChartMenu *
-create_context_menu (void)
-{
-	BaobabChartMenu *menu = NULL;
-
-	baobab.chart_menu = g_new0 (BaobabChartMenu, 1);
-	menu = baobab.chart_menu;
-
-	menu->widget = gtk_menu_new ();
-
-	menu->up_item = gtk_image_menu_item_new_with_label (_("Move to parent folder"));
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu->up_item),
-				       gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU));
-
-	menu->zoom_in_item = gtk_image_menu_item_new_with_label (_("Zoom in")) ;
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu->zoom_in_item),
-				       gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
-
-	menu->zoom_out_item = gtk_image_menu_item_new_with_label (_("Zoom out"));
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu->zoom_out_item),
-				       gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
-
-	menu->snapshot_item = gtk_image_menu_item_new_with_label (_("Save screenshot"));
-	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu->snapshot_item),
-				       gtk_image_new_from_file (BAOBAB_PIX_DIR "shot.png"));
-
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu->widget),
-			       menu->up_item);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu->widget),
-			       gtk_separator_menu_item_new ());
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu->widget),
-			       menu->zoom_in_item);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu->widget),
-			       menu->zoom_out_item);
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu->widget),
-			       gtk_separator_menu_item_new ());
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu->widget),
-			       menu->snapshot_item);
-
-	/* connect signals */
-	g_signal_connect (menu->up_item, "activate",
-			  G_CALLBACK (on_move_upwards_cb), NULL);
-	g_signal_connect (menu->zoom_in_item, "activate",
-			  G_CALLBACK (on_zoom_in_cb), NULL);
-	g_signal_connect (menu->zoom_out_item, "activate",
-			  G_CALLBACK (on_zoom_out_cb), NULL);
-	g_signal_connect (menu->snapshot_item, "activate",
-					  G_CALLBACK (on_chart_snapshot_cb), NULL);
-
-	gtk_widget_show_all (menu->widget);
-
-	return menu;
-}
-
 static void
 on_chart_item_activated (BaobabChart *chart, GtkTreeIter *iter)
 {
@@ -998,41 +943,6 @@ on_chart_item_activated (BaobabChart *chart, GtkTreeIter *iter)
 	gtk_tree_path_free (path);
 }
 
-static gboolean
-on_chart_button_release (BaobabChart *chart,
-			 GdkEventButton *event,
-			 gpointer data)
-{
-	if (baobab_chart_is_frozen (baobab.current_chart))
-		return FALSE;
-
-	if (event->button== 3) /* right button */
-	{
-		GtkTreePath *root_path;
-		BaobabChartMenu *menu;
-
-		root_path = baobab_chart_get_root (baobab.current_chart);
-
-		menu = baobab.chart_menu;
-		gtk_widget_set_sensitive (menu->up_item,
-					  ((root_path != NULL) &&
-					  (gtk_tree_path_get_depth (root_path) > 1)));
-		gtk_widget_set_sensitive (menu->zoom_in_item,
-					  baobab_chart_can_zoom_in (baobab.current_chart));
-		gtk_widget_set_sensitive (menu->zoom_out_item,
-					  baobab_chart_can_zoom_out (baobab.current_chart));
-
-		/* show the menu */
-		gtk_menu_popup (GTK_MENU (menu->widget),
-				NULL, NULL, NULL, NULL,
-				event->button, event->time);
-
-		gtk_tree_path_free (root_path);
-	}
-
-	return FALSE;
-}
-
 static void
 drag_data_received_handl (GtkWidget *widget,
 			 GdkDragContext *context,
@@ -1075,7 +985,7 @@ set_active_chart (GtkWidget *chart)
 {
 	if (baobab.current_chart != chart) {
 		if (baobab.current_chart) {
-			baobab_chart_freeze_updates (baobab.current_chart);
+			baobab_chart_freeze_updates (BAOBAB_CHART (baobab.current_chart));
 
 			g_object_ref (baobab.current_chart);
 			gtk_container_remove (GTK_CONTAINER (baobab.chart_frame),
@@ -1085,7 +995,7 @@ set_active_chart (GtkWidget *chart)
 		gtk_container_add (GTK_CONTAINER (baobab.chart_frame), chart);
 		g_object_unref (chart);
 
-		baobab_chart_thaw_updates (chart);
+		baobab_chart_thaw_updates (BAOBAB_CHART (chart));
 
 		baobab.current_chart = chart;
 
@@ -1154,11 +1064,9 @@ initialize_charts (void)
 				   TRUE,
 				   0, GTK_PACK_END);
 
-	baobab.chart_menu = create_context_menu ();
-
 	/* Baobab's Treemap Chart */
 	baobab.treemap_chart = baobab_treemap_new ();
-	baobab_chart_set_model_with_columns (baobab.treemap_chart,
+	baobab_chart_set_model_with_columns (BAOBAB_CHART (baobab.treemap_chart),
 					     GTK_TREE_MODEL (baobab.model),
 					     COL_DIR_NAME,
 					     COL_DIR_SIZE,
@@ -1166,20 +1074,18 @@ initialize_charts (void)
 					     COL_H_PERC,
 					     COL_H_ELEMENTS,
 					     NULL);
-	baobab_chart_set_max_depth (baobab.treemap_chart, 1);
+	baobab_chart_set_max_depth (BAOBAB_CHART (baobab.treemap_chart), 1);
 	g_signal_connect (baobab.treemap_chart, "item_activated",
 			  G_CALLBACK (on_chart_item_activated), NULL);
-	g_signal_connect (baobab.treemap_chart, "button-release-event",
-			  G_CALLBACK (on_chart_button_release), NULL);
 	g_signal_connect (baobab.treemap_chart, "drag-data-received",
 			  G_CALLBACK (drag_data_received_handl), NULL);
 	gtk_widget_show (baobab.treemap_chart);
 	g_object_ref_sink (baobab.treemap_chart);
-	baobab_chart_freeze_updates (baobab.treemap_chart);
+	baobab_chart_freeze_updates (BAOBAB_CHART (baobab.treemap_chart));
 
 	/* Baobab's Rings Chart */
 	baobab.rings_chart = (GtkWidget *) baobab_ringschart_new ();
-	baobab_chart_set_model_with_columns (baobab.rings_chart,
+	baobab_chart_set_model_with_columns (BAOBAB_CHART (baobab.rings_chart),
 					     GTK_TREE_MODEL (baobab.model),
 					     COL_DIR_NAME,
 					     COL_DIR_SIZE,
@@ -1188,16 +1094,14 @@ initialize_charts (void)
 					     COL_H_ELEMENTS,
 					     NULL);
 
-	baobab_chart_set_max_depth (baobab.rings_chart, 1);
+	baobab_chart_set_max_depth (BAOBAB_CHART (baobab.rings_chart), 1);
 	g_signal_connect (baobab.rings_chart, "item_activated",
 			  G_CALLBACK (on_chart_item_activated), NULL);
-	g_signal_connect (baobab.rings_chart, "button-release-event",
-			  G_CALLBACK (on_chart_button_release), NULL);
 	g_signal_connect (baobab.rings_chart, "drag-data-received",
 			  G_CALLBACK (drag_data_received_handl), NULL);
 	gtk_widget_show (baobab.rings_chart);
 	g_object_ref_sink (baobab.rings_chart);
-	baobab_chart_freeze_updates (baobab.rings_chart);
+	baobab_chart_freeze_updates (BAOBAB_CHART (baobab.rings_chart));
 
 	saved_chart = g_settings_get_string (baobab.ui_settings,
 					     BAOBAB_SETTINGS_ACTIVE_CHART);
diff --git a/src/baobab.h b/src/baobab.h
index bfdbb0a..76826a3 100644
--- a/src/baobab.h
+++ b/src/baobab.h
@@ -39,18 +39,6 @@ struct BaobabSearchOpt;
 #define BAOBAB_SETTINGS_EXCLUDED_URIS "excluded-uris"
 #define DESKTOP_SETTINGS_TOOLBAR_STYLE "toolbar-style"
 
-typedef struct _BaobabChartMenu BaobabChartMenu;
-
-struct _BaobabChartMenu {
-	GtkWidget *widget;
-	GtkWidget *up_item;
-	GtkWidget *zoom_in_item;
-	GtkWidget *zoom_out_item;
-	GtkWidget *subfolders_item;
-	GtkWidget *snapshot_item;
-	GtkWidget *set_root_item;
-};
-
 typedef struct _BaobabApplication BaobabApplication;
 
 struct _BaobabApplication {
@@ -62,7 +50,6 @@ struct _BaobabApplication {
 	GtkWidget *treemap_chart;
 	GtkWidget *current_chart;
 	GtkWidget *chart_type_combo;
-	BaobabChartMenu *chart_menu;
 	GtkWidget *toolbar;
 	GtkWidget *spinner;
 	GtkWidget *statusbar;
diff --git a/src/callbacks.c b/src/callbacks.c
index 9cdd05f..4d6e32d 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -302,35 +302,11 @@ on_tv_selection_changed (GtkTreeSelection *selection, gpointer user_data)
 
 		path = gtk_tree_model_get_path (GTK_TREE_MODEL (baobab.model), &iter);
 
-		baobab_chart_set_root (baobab.rings_chart, path);
-		baobab_chart_set_root (baobab.treemap_chart, path);
+		baobab_chart_set_root (BAOBAB_CHART (baobab.rings_chart), path);
+		baobab_chart_set_root (BAOBAB_CHART (baobab.treemap_chart), path);
 
 		gtk_tree_path_free (path);
 	}
 }
 
-void
-on_move_upwards_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data)
-{
-	baobab_chart_move_up_root (baobab.current_chart);
-}
-
-void
-on_zoom_in_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data)
-{
-	baobab_chart_zoom_in (baobab.current_chart);
-}
-
-void
-on_zoom_out_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data)
-{
-	baobab_chart_zoom_out (baobab.current_chart);
-}
-
-void
-on_chart_snapshot_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data)
-{
-	baobab_chart_save_snapshot (baobab.current_chart);
-}
-
 /* ex:set ts=8 noet: */
diff --git a/src/callbacks.h b/src/callbacks.h
index 0f51796..d00e2d3 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -51,9 +51,5 @@ void on_menu_scan_rem_activate (GtkMenuItem *menuitem, gpointer user_data);
 void on_ck_allocated_activate (GtkToggleAction *action, gpointer user_data);
 void on_helpcontents_activate (GtkAction *a, gpointer user_data);
 void on_tv_selection_changed (GtkTreeSelection *selection, gpointer user_data);
-void on_move_upwards_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
-void on_zoom_in_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
-void on_zoom_out_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
-void on_chart_snapshot_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
 
 #endif /* __BAOBAB_CALLBACKS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]