[baobab/wip/vala: 5/44] wire up the chart properly



commit c712398b0d02cb0cdc8a09732227d665bab1bd29
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jan 5 11:32:04 2012 -0500

    wire up the chart properly
    
    and publish max_depth as a property on the model

 src/baobab-chart.c      |    4 ++--
 src/baobab-scanner.vala |    3 +++
 src/baobab-window.vala  |   16 ++++++++++++++--
 3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/baobab-chart.c b/src/baobab-chart.c
index 6f49b06..9d102c8 100644
--- a/src/baobab-chart.c
+++ b/src/baobab-chart.c
@@ -439,7 +439,7 @@ static GList
   BaobabChartItem *item;
 
   gchar *name;
-  gchar *size;
+  guint64 size;
 
   priv = BAOBAB_CHART_GET_PRIVATE (chart);
 
@@ -450,7 +450,7 @@ static GList
 
   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;
diff --git a/src/baobab-scanner.vala b/src/baobab-scanner.vala
index 3dc03d1..2f80230 100644
--- a/src/baobab-scanner.vala
+++ b/src/baobab-scanner.vala
@@ -159,9 +159,12 @@ namespace Baobab {
 				var info = directory.query_info (ATTRIBUTES, 0, cancellable);
 				var results = add_directory (directory, info);
 				add_percent (results.size);
+				max_depth = results.max_depth;
 			} catch { }
 		}
 
+		public int max_depth { get; private set; }
+
 		public Scanner (File directory) {
 			set_column_types (new Type[] {
 			                  typeof (string),  /* DIR_NAME */
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index d879d7f..74ab655 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -70,8 +70,20 @@ namespace Baobab {
 			model = new Scanner (directory);
 			var rings_chart = builder.get_object ("rings-chart") as Chart;
 			var treemap = builder.get_object ("treemap") as Chart;
-			rings_chart.set_model_with_columns (model, 0, 1, 2, 3, 4, null);
-			treemap.set_model_with_columns (model, 0, 1, 2, 3, 4, null);
+			model.bind_property ("max-depth", rings_chart, "max-depth", BindingFlags.SYNC_CREATE);
+			model.bind_property ("max-depth", treemap, "max-depth", BindingFlags.SYNC_CREATE);
+			treemap.set_model_with_columns (model,
+			                                Scanner.Columns.DISPLAY_NAME,
+			                                Scanner.Columns.SIZE,
+			                                Scanner.Columns.PARSE_NAME,
+			                                Scanner.Columns.PERCENT,
+			                                Scanner.Columns.ELEMENTS, null);
+			rings_chart.set_model_with_columns (model,
+			                                    Scanner.Columns.DISPLAY_NAME,
+			                                    Scanner.Columns.SIZE,
+			                                    Scanner.Columns.PARSE_NAME,
+			                                    Scanner.Columns.PERCENT,
+			                                    Scanner.Columns.ELEMENTS, null);
 			var treeview = builder.get_object ("treeview") as Gtk.TreeView;
 			treeview.model = model;
 		}



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