[baobab] baobab-chart: allow to zoom out by clicking on central sector



commit c9147aa782abd4aa1f325c239906b4c16e7e7e19
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu Mar 15 00:21:05 2012 +0100

    baobab-chart: allow to zoom out by clicking on central sector

 src/baobab-chart.c |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/baobab-chart.c b/src/baobab-chart.c
index c5ef26b..f2c6d5a 100644
--- a/src/baobab-chart.c
+++ b/src/baobab-chart.c
@@ -976,11 +976,35 @@ baobab_chart_button_press_event (GtkWidget      *widget,
           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);
+                  {
+                    GtkTreePath *path, *root_path;
+                    GtkTreeIter *iter;
+
+                    iter = &((BaobabChartItem*) chart->priv->highlighted_item->data)->iter;
+                    path = gtk_tree_model_get_path (chart->priv->model, iter);
+
+                    if (chart->priv->root)
+                      root_path = gtk_tree_row_reference_get_path (chart->priv->root);
+                    else
+                      root_path = gtk_tree_path_new_first ();
+
+                    if (gtk_tree_path_compare (path, root_path) == 0)
+                      {
+                        /* Go back to the parent dir */
+                        baobab_chart_move_up_root (chart);
+                      }
+                    else
+                      {
+                        /* Enter into a subdir */
+                        g_signal_emit (chart,
+                                       baobab_chart_signals[ITEM_ACTIVATED], 0,
+                                       iter);
+                      }
+
+                    gtk_tree_path_free (path);
+                  }
+
                 break;
 
               case 2:



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