[baobab/wip/vala: 13/41] More cleanup in the chart widgets.



commit 63c06c806288a0e0df83c5cc5c8fcbce420787a5
Author: Paolo Borelli <pborelli gnome org>
Date:   Thu Jan 5 20:17:35 2012 +0100

    More cleanup in the chart widgets.

 src/baobab-chart.c      |  245 +++++++++++++++++++----------------------------
 src/baobab-chart.h      |    5 +-
 src/baobab-ringschart.c |   94 +++++++++---------
 src/baobab-ringschart.h |   10 +-
 src/baobab-treemap.c    |   56 ++++++-----
 src/baobab-treemap.h    |    5 +-
 6 files changed, 183 insertions(+), 232 deletions(-)
---
diff --git a/src/baobab-chart.c b/src/baobab-chart.c
index 2afdb05..212ee8c 100644
--- a/src/baobab-chart.c
+++ b/src/baobab-chart.c
@@ -120,26 +120,6 @@ 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,
@@ -155,9 +135,9 @@ static gint baobab_chart_motion_notify (GtkWidget *widget,
 static gint baobab_chart_leave_notify (GtkWidget *widget,
                                        GdkEventCrossing *event);
 static void baobab_chart_disconnect_signals (BaobabChart *chart,
-                                                    GtkTreeModel *model);
+                                             GtkTreeModel *model);
 static void baobab_chart_connect_signals (BaobabChart *chart,
-                                                 GtkTreeModel *model);
+                                          GtkTreeModel *model);
 static void baobab_chart_get_items (BaobabChart *chart, GtkTreePath *root);
 static gboolean baobab_chart_query_tooltip (GtkWidget  *widget,
                                             gint        x,
@@ -166,7 +146,6 @@ static gboolean baobab_chart_query_tooltip (GtkWidget  *widget,
                                             GtkTooltip *tooltip,
                                             gpointer    user_data);
 
-
 static void
 baobab_chart_class_init (BaobabChartClass *class)
 {
@@ -261,23 +240,22 @@ baobab_chart_init (BaobabChart *chart)
 static void
 baobab_chart_dispose (GObject *object)
 {
-  BaobabChart *chart = BAOBAB_CHART (object);
+  BaobabChart *chart;
+
+  chart = BAOBAB_CHART (object);
 
   baobab_chart_free_items (chart);
 
   if (chart->priv->model)
     {
       baobab_chart_disconnect_signals (chart, chart->priv->model);
-
       g_object_unref (chart->priv->model);
-
       chart->priv->model = NULL;
     }
 
   if (chart->priv->root)
     {
       gtk_tree_row_reference_free (chart->priv->root);
-
       chart->priv->root = NULL;
     }
 
@@ -331,7 +309,7 @@ static void
 baobab_chart_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
 {
-  BaobabChart *chart = BAOBAB_CHART (widget);
+  BaobabChart *chart;
   BaobabChartClass *class;
   BaobabChartItem *item;
   GList *node;
@@ -339,6 +317,7 @@ baobab_chart_size_allocate (GtkWidget     *widget,
   g_return_if_fail (BAOBAB_IS_CHART (widget));
   g_return_if_fail (allocation != NULL);
 
+  chart = BAOBAB_CHART (widget);
   class = BAOBAB_CHART_GET_CLASS (chart);
 
   gtk_widget_set_allocation (widget, allocation);
@@ -349,15 +328,12 @@ baobab_chart_size_allocate (GtkWidget     *widget,
                   allocation->x, allocation->y,
                   allocation->width, allocation->height);
 
-      node = chart->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 (chart, item);
-
-          node = node->next;
         }
     }
 }
@@ -420,7 +396,6 @@ baobab_chart_add_item (BaobabChart *chart,
                        GtkTreeIter  iter)
 {
   BaobabChartItem *item;
-
   gchar *name;
   guint64 size;
 
@@ -457,6 +432,7 @@ baobab_chart_free_items (BaobabChart *chart)
   GList *next;
 
   node = chart->priv->first_item;
+
   while (node != NULL)
     {
       next = node->next;
@@ -485,13 +461,11 @@ baobab_chart_get_items (BaobabChart *chart,
                         GtkTreePath *root)
 {
   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;
@@ -508,8 +482,6 @@ baobab_chart_get_items (BaobabChart *chart,
       return;
     }
 
-
-
   model_root_path = gtk_tree_path_new_first ();
   gtk_tree_model_get_iter (chart->priv->model, &model_root_iter, model_root_path);
   gtk_tree_path_free (model_root_path);
@@ -583,8 +555,7 @@ baobab_chart_draw_chart (BaobabChart *chart,
 
   cairo_save (cr);
 
-  node = chart->priv->first_item;
-  while (node != NULL)
+  for (node = chart->priv->first_item; node != NULL; node = node->next)
     {
       BaobabChartItem *item;
       GdkRectangle clip;
@@ -599,11 +570,8 @@ baobab_chart_draw_chart (BaobabChart *chart,
           gboolean highlighted;
 
           highlighted = (node == chart->priv->highlighted_item);
-
           class->draw_item (chart, cr, item, highlighted);
         }
-
-      node = node->next;
     }
 
   cairo_restore (cr);
@@ -652,93 +620,72 @@ baobab_chart_update_draw (BaobabChart* chart,
 }
 
 static void
-baobab_chart_row_changed (GtkTreeModel    *model,
-                          GtkTreePath     *path,
-                          GtkTreeIter     *iter,
-                          gpointer         user_data)
+baobab_chart_row_changed (GtkTreeModel *model,
+                          GtkTreePath  *path,
+                          GtkTreeIter  *iter,
+                          BaobabChart  *chart)
 {
-  BaobabChart *chart = user_data;
-
-  g_return_if_fail (BAOBAB_IS_CHART (chart));
   g_return_if_fail (path != NULL || iter != NULL);
 
   chart->priv->model_changed = TRUE;
-
   baobab_chart_update_draw (chart, path);
 }
 
 static void
-baobab_chart_row_inserted (GtkTreeModel    *model,
-                           GtkTreePath     *path,
-                           GtkTreeIter     *iter,
-                           gpointer         user_data)
+baobab_chart_row_inserted (GtkTreeModel *model,
+                           GtkTreePath  *path,
+                           GtkTreeIter  *iter,
+                           BaobabChart  *chart)
 {
-  BaobabChart *chart = user_data;
-
-  g_return_if_fail (BAOBAB_IS_CHART (chart));
   g_return_if_fail (path != NULL || iter != NULL);
 
   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         user_data)
+baobab_chart_row_has_child_toggled (GtkTreeModel *model,
+                                    GtkTreePath  *path,
+                                    GtkTreeIter  *iter,
+                                    BaobabChart  *chart)
 {
-  BaobabChart *chart = user_data;
-
-  g_return_if_fail (BAOBAB_IS_CHART (chart));
   g_return_if_fail (path != NULL || iter != NULL);
 
   chart->priv->model_changed = TRUE;
-
   baobab_chart_update_draw (chart, path);
 }
 
 static void
-baobab_chart_row_deleted (GtkTreeModel    *model,
-                          GtkTreePath     *path,
-                          gpointer         user_data)
+baobab_chart_row_deleted (GtkTreeModel *model,
+                          GtkTreePath  *path,
+                          BaobabChart  *chart)
 {
-  BaobabChart *chart = user_data;
-
-  g_return_if_fail (BAOBAB_IS_CHART (chart));
   g_return_if_fail (path != NULL);
 
   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         user_data)
+baobab_chart_rows_reordered (GtkTreeModel *model,
+                             GtkTreePath  *path,
+                             GtkTreeIter  *iter,
+                             gint         *new_order,
+                             BaobabChart  *chart)
 {
-  BaobabChart *chart = user_data;
-
-  g_return_if_fail (BAOBAB_IS_CHART (chart));
   g_return_if_fail (path != NULL || iter != NULL);
 
   chart->priv->model_changed = TRUE;
-
   baobab_chart_update_draw (chart, path);
-
 }
 
 static gboolean
 baobab_chart_draw (GtkWidget *widget,
                    cairo_t   *cr)
 {
-  BaobabChart *chart = BAOBAB_CHART (widget);
+  BaobabChart *chart;
 
+  chart = BAOBAB_CHART (widget);
 
   /* the columns are not set we paint nothing */
   if (chart->priv->name_column == chart->priv->percentage_column)
@@ -903,7 +850,7 @@ baobab_chart_button_release (GtkWidget      *widget,
 
     case MIDDLE_BUTTON:
       /* Go back to the parent dir */
-      baobab_chart_move_up_root (chart);
+      baobab_chart_move_up_root (BAOBAB_CHART (widget));
       break;
     }
 
@@ -942,20 +889,18 @@ baobab_chart_set_item_highlight (BaobabChart *chart,
                                  gboolean     highlighted)
 {
   BaobabChartItem *item;
-  BaobabChartClass *class;
 
   if (node == NULL)
     return;
 
   item = (BaobabChartItem *) node->data;
-  class = BAOBAB_CHART_GET_CLASS (chart);
 
   if (highlighted)
     chart->priv->highlighted_item = node;
   else
     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);
 }
 
@@ -963,17 +908,20 @@ static gint
 baobab_chart_motion_notify (GtkWidget      *widget,
                             GdkEventMotion *event)
 {
-  BaobabChart *chart = BAOBAB_CHART (widget);
+  BaobabChart *chart;
+  BaobabChartPrivate *priv;
   BaobabChartClass *class;
   GList *node;
   BaobabChartItem *item;
   gboolean found = FALSE;
 
-  class = BAOBAB_CHART_GET_CLASS (chart);
+  chart = BAOBAB_CHART (widget);
+  priv = chart->priv;
+
+  class = BAOBAB_CHART_GET_CLASS (widget);
 
   /* Check if the pointer is over an item */
-  node = chart->priv->last_item;
-  while (node != NULL)
+  for (node = priv->last_item; node != NULL; node = node->prev)
     {
       item = (BaobabChartItem *) node->data;
 
@@ -981,7 +929,7 @@ baobab_chart_motion_notify (GtkWidget      *widget,
         {
           if (chart->priv->highlighted_item != node)
             {
-              baobab_chart_set_item_highlight (chart, chart->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 (chart, node, TRUE);
@@ -990,14 +938,13 @@ baobab_chart_motion_notify (GtkWidget      *widget,
           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 (chart, chart->priv->highlighted_item, FALSE);
+      baobab_chart_set_item_highlight (chart, priv->highlighted_item, FALSE);
       gtk_widget_set_has_tooltip (widget, FALSE);
     }
 
@@ -1011,7 +958,9 @@ static gint
 baobab_chart_leave_notify (GtkWidget        *widget,
                            GdkEventCrossing *event)
 {
-  BaobabChart *chart = BAOBAB_CHART (widget);
+  BaobabChart *chart;
+
+  chart = BAOBAB_CHART (widget);
 
   baobab_chart_set_item_highlight (chart, chart->priv->highlighted_item, FALSE);
 
@@ -1125,7 +1074,7 @@ baobab_chart_query_tooltip (GtkWidget  *widget,
   return TRUE;
 }
 
-GdkPixbuf*
+static GdkPixbuf *
 baobab_chart_get_pixbuf (BaobabChart *chart)
 {
   gint w, h;
@@ -1528,6 +1477,54 @@ baobab_chart_zoom_out (BaobabChart *chart)
 }
 
 /**
+ * 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);
+
+  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);
+
+  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);
+}
+
+/**
  * baobab_chart_move_up_root:
  * @chart: the #BaobabChart whose root is requested to move up one level.
  *
@@ -1593,7 +1590,6 @@ void
 baobab_chart_save_snapshot (BaobabChart *chart)
 {
   GdkPixbuf *pixbuf;
-
   GtkWidget *fs_dlg;
   GtkWidget *vbox;
   GtkWidget *hbox;
@@ -1721,53 +1717,6 @@ baobab_chart_get_highlighted_item (BaobabChart *chart)
 {
   g_return_val_if_fail (BAOBAB_IS_CHART (chart), 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 (BaobabChart *chart)
-{
-  BaobabChartClass *class;
-
-  g_return_val_if_fail (BAOBAB_IS_CHART (chart), 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);
-
-  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);
+  return (chart->priv->highlighted_item ?
+    (BaobabChartItem *) chart->priv->highlighted_item->data : NULL);
 }
diff --git a/src/baobab-chart.h b/src/baobab-chart.h
index f5fe632..f813fc6 100644
--- a/src/baobab-chart.h
+++ b/src/baobab-chart.h
@@ -150,13 +150,12 @@ void                    baobab_chart_get_item_color                     (BaobabC
 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);
 
-gboolean                baobab_chart_can_zoom_in                        (BaobabChart *chart);
-gboolean                baobab_chart_can_zoom_out                       (BaobabChart *chart);
-
 G_END_DECLS
 
 #endif /* __BAOBAB_CHART_H__ */
diff --git a/src/baobab-ringschart.c b/src/baobab-ringschart.c
index 4e093da..f801862 100644
--- a/src/baobab-ringschart.c
+++ b/src/baobab-ringschart.c
@@ -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;
 
@@ -431,24 +431,20 @@ baobab_ringschart_draw_subfolder_tips (GtkWidget *chart, cairo_t *cr)
   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;
-
   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;
@@ -589,25 +585,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 +615,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 +658,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 bae122b..1a84539 100644
--- a/src/baobab-treemap.c
+++ b/src/baobab-treemap.c
@@ -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;
@@ -151,19 +154,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 +183,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 +191,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 +217,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 +269,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 +289,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 +308,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 +321,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
 



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