[baobab/wip/vala: 12/23] clean up BaobabChart API



commit a2357c453ea2d3210b5be2c2ad0dfe04991b1119
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jan 5 14:15:48 2012 -0500

    clean up BaobabChart API
    
    Use BaobabChart* where appropriate instead of GtkWidget*.
    
    Clean up the whitespace.

 src/baobab-chart.c |  382 ++++++++++++++++++++++-----------------------------
 src/baobab-chart.h |  155 +++++++++++-----------
 2 files changed, 244 insertions(+), 293 deletions(-)
---
diff --git a/src/baobab-chart.c b/src/baobab-chart.c
index 5d9d6f2..a0c46b1 100644
--- a/src/baobab-chart.c
+++ b/src/baobab-chart.c
@@ -119,8 +119,8 @@ 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);
@@ -158,11 +158,11 @@ 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,
+static void baobab_chart_disconnect_signals (BaobabChart *chart,
                                                     GtkTreeModel *model);
-static inline void baobab_chart_connect_signals (GtkWidget *chart,
+static void baobab_chart_connect_signals (BaobabChart *chart,
                                                  GtkTreeModel *model);
-static void baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root);
+static void baobab_chart_get_items (BaobabChart *chart, GtkTreePath *root);
 static gboolean baobab_chart_query_tooltip (GtkWidget  *widget,
                                             gint        x,
                                             gint        y,
@@ -268,27 +268,24 @@ baobab_chart_init (BaobabChart *chart)
 static void
 baobab_chart_dispose (GObject *object)
 {
-  BaobabChartPrivate *priv;
-
-  baobab_chart_free_items (GTK_WIDGET (object));
+  BaobabChart *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);
+      baobab_chart_disconnect_signals (chart, chart->priv->model);
 
-      g_object_unref (priv->model);
+      g_object_unref (chart->priv->model);
 
-      priv->model = NULL;
+      chart->priv->model = NULL;
     }
 
-  if (priv->root)
+  if (chart->priv->root)
     {
-      gtk_tree_row_reference_free (priv->root);
+      gtk_tree_row_reference_free (chart->priv->root);
 
-      priv->root = NULL;
+      chart->priv->root = NULL;
     }
 
   G_OBJECT_CLASS (baobab_chart_parent_class)->dispose (object);
@@ -334,10 +331,10 @@ baobab_chart_realize (GtkWidget *widget)
 }
 
 static void
-baobab_chart_size_allocate (GtkWidget *widget,
+baobab_chart_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
 {
-  BaobabChartPrivate *priv;
+  BaobabChart *chart = BAOBAB_CHART (widget);
   BaobabChartClass *class;
   BaobabChartItem *item;
   GList *node;
@@ -345,8 +342,7 @@ 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);
+  class = BAOBAB_CHART_GET_CLASS (chart);
 
   gtk_widget_set_allocation (widget, allocation);
 
@@ -356,13 +352,13 @@ baobab_chart_size_allocate (GtkWidget *widget,
                   allocation->x, allocation->y,
                   allocation->width, allocation->height);
 
-      node = priv->first_item;
+      node = chart->priv->first_item;
       while (node != NULL)
         {
           item = (BaobabChartItem *) node->data;
           item->has_visible_children = FALSE;
           item->visible = FALSE;
-          class->calculate_item_geometry (widget, item);
+          class->calculate_item_geometry (chart, item);
 
           node = node->next;
         }
@@ -375,20 +371,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);
@@ -423,12 +417,12 @@ 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;
@@ -464,7 +458,7 @@ static GList
 }
 
 static void
-baobab_chart_free_items (GtkWidget *chart)
+baobab_chart_free_items (BaobabChart *chart)
 {
   BaobabChartPrivate *priv;
   BaobabChartItem *item;
@@ -498,9 +492,9 @@ baobab_chart_free_items (GtkWidget *chart)
 }
 
 static void
-baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root)
+baobab_chart_get_items (BaobabChart *chart,
+                        GtkTreePath *root)
 {
-  BaobabChartPrivate *priv;
   BaobabChartItem *item;
 
   GList *node;
@@ -515,26 +509,24 @@ baobab_chart_get_items (GtkWidget *chart, GtkTreePath *root)
   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);
@@ -545,9 +537,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);
@@ -559,14 +549,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,
@@ -577,7 +566,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;
@@ -585,14 +574,14 @@ 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;
@@ -751,8 +740,10 @@ baobab_chart_rows_reordered (GtkTreeModel    *model,
 }
 
 static gboolean
-baobab_chart_draw (GtkWidget *chart, cairo_t *cr)
+baobab_chart_draw (GtkWidget *widget,
+                   cairo_t   *cr)
 {
+  BaobabChart *chart = BAOBAB_CHART (widget);
   BaobabChartPrivate *priv;
 
   priv = BAOBAB_CHART (chart)->priv;
@@ -772,8 +763,8 @@ baobab_chart_draw (GtkWidget *chart, cairo_t *cr)
           w = cairo_image_surface_get_width (priv->memento);
           h = cairo_image_surface_get_height (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))
             {
@@ -903,30 +894,27 @@ baobab_chart_get_item_color (BaobabChartColor *color,
 }
 
 static gint
-baobab_chart_button_release (GtkWidget *widget,
+baobab_chart_button_release (GtkWidget      *widget,
                              GdkEventButton *event)
 {
-  BaobabChartPrivate *priv;
-
-  priv = BAOBAB_CHART (widget)->priv;
+  BaobabChart *chart = BAOBAB_CHART (widget);
 
-  if (priv->is_frozen)
+  if (chart->priv->is_frozen)
     return TRUE;
 
   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);
+      if (chart->priv->highlighted_item != NULL)
+        g_signal_emit (BAOBAB_CHART (widget), baobab_chart_signals[ITEM_ACTIVATED], 0,
+                       &((BaobabChartItem*) chart->priv->highlighted_item->data)->iter);
 
       break;
 
     case MIDDLE_BUTTON:
       /* Go back to the parent dir */
-      baobab_chart_move_up_root (widget);
+      baobab_chart_move_up_root (chart);
       break;
     }
 
@@ -937,20 +925,22 @@ 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;
     }
 
@@ -958,57 +948,54 @@ 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)),
                               &item->rect, TRUE);
 }
 
 static gint
-baobab_chart_motion_notify (GtkWidget *widget,
+baobab_chart_motion_notify (GtkWidget      *widget,
                             GdkEventMotion *event)
 {
-  BaobabChartPrivate *priv;
+  BaobabChart *chart = BAOBAB_CHART (widget);
   BaobabChartClass *class;
   GList *node;
   BaobabChartItem *item;
   gboolean found = FALSE;
 
-  priv = BAOBAB_CHART_GET_PRIVATE (widget);
-  class = BAOBAB_CHART_GET_CLASS (widget);
+  class = BAOBAB_CHART_GET_CLASS (chart);
 
   /* Check if the pointer is over an item */
-  node = priv->last_item;
+  node = chart->priv->last_item;
   while (node != NULL)
     {
       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, 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;
@@ -1021,7 +1008,7 @@ baobab_chart_motion_notify (GtkWidget *widget,
      redraw it to turn it off */
   if (! found)
     {
-      baobab_chart_set_item_highlight (widget, priv->highlighted_item, FALSE);
+      baobab_chart_set_item_highlight (chart, chart->priv->highlighted_item, FALSE);
       gtk_widget_set_has_tooltip (widget, FALSE);
     }
 
@@ -1032,19 +1019,18 @@ 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 = BAOBAB_CHART (widget);
 
-  priv = BAOBAB_CHART_GET_PRIVATE (widget);
-  baobab_chart_set_item_highlight (widget, priv->highlighted_item, FALSE);
+  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,
@@ -1085,8 +1071,8 @@ baobab_chart_connect_signals (GtkWidget *chart,
                     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,
@@ -1153,18 +1139,16 @@ baobab_chart_query_tooltip (GtkWidget  *widget,
 }
 
 GdkPixbuf*
-baobab_chart_get_pixbuf (GtkWidget *widget)
+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;
 }
@@ -1177,10 +1161,9 @@ 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);
 }
@@ -1221,14 +1204,14 @@ 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;
 
@@ -1269,42 +1252,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));
 }
 
 /**
@@ -1316,11 +1293,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;
 }
 
 /**
@@ -1335,27 +1312,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));
 }
 
 /**
@@ -1368,11 +1341,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;
 }
 
 /**
@@ -1388,33 +1361,29 @@ 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) {
+  if (chart->priv->root) {
     /* Check that given root is different from current */
-    current_root = gtk_tree_row_reference_get_path (priv->root);
+    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);
+    gtk_tree_row_reference_free (chart->priv->root);
   }
 
-  priv->root = gtk_tree_row_reference_new (priv->model, root);
+  chart->priv->root = gtk_tree_row_reference_new (chart->priv->model, root);
 
   g_object_notify (G_OBJECT (chart), "root");
 
-  gtk_widget_queue_draw (chart);
+  gtk_widget_queue_draw (GTK_WIDGET (chart));
 }
 
 /**
@@ -1428,13 +1397,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;
 }
@@ -1452,22 +1421,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,
@@ -1492,14 +1457,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));
 }
 
 /**
@@ -1514,30 +1479,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));
     }
 }
 
@@ -1550,21 +1510,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);
 }
@@ -1578,12 +1536,11 @@ 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);
 }
 
 /**
@@ -1595,7 +1552,7 @@ 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;
 
@@ -1637,7 +1594,7 @@ baobab_chart_move_up_root (GtkWidget *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);
@@ -1653,10 +1610,8 @@ 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;
@@ -1691,8 +1646,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,
@@ -1702,7 +1655,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);
@@ -1767,14 +1720,13 @@ 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;
 }
 
 /**
@@ -1787,7 +1739,7 @@ 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;
 
@@ -1808,20 +1760,18 @@ baobab_chart_get_highlighted_item (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 gboolean
-baobab_chart_can_zoom_in (GtkWidget *chart)
+baobab_chart_can_zoom_in (BaobabChart *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;
+    return chart->priv->max_depth > 1;
 }
 
 /**
@@ -1834,7 +1784,7 @@ baobab_chart_can_zoom_in (GtkWidget *chart)
  * Fails if @chart is not a #BaobabChart.
  **/
 gboolean
-baobab_chart_can_zoom_out (GtkWidget *chart)
+baobab_chart_can_zoom_out (BaobabChart *chart)
 {
   BaobabChartPrivate *priv;
   BaobabChartClass *class;
@@ -1849,5 +1799,3 @@ baobab_chart_can_zoom_out (GtkWidget *chart)
   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..59ffd0a 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_CHART_TYPE                                   (baobab_chart_get_type ())
+#define BAOBAB_CHART(inst)                                  (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
+                                                             BAOBAB_CHART_TYPE, BaobabChart))
+#define BAOBAB_CHART_CLASS(class)                           (G_TYPE_CHECK_CLASS_CAST ((class),                       \
+                                                             BAOBAB_CHART_TYPE, BaobabChartClass))
+#define BAOBAB_IS_CHART(inst)                               (G_TYPE_CHECK_INSTANCE_TYPE ((inst), BAOBAB_CHART_TYPE))
+#define BAOBAB_IS_CHART_CLASS(class)                        (G_TYPE_CHECK_CLASS_TYPE ((class), BAOBAB_CHART_TYPE))
+#define BAOBAB_CHART_GET_CLASS(inst)                        (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
+                                                             BAOBAB_CHART_TYPE, 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,71 @@ 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);
+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
+#endif /* __BAOBAB_CHART_H__ */



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