Author: pollux
Date: 2006-07-20 00:09:15 +0000 (Thu, 20 Jul 2006)
New Revision: 22493

Modified:
   xfburn/trunk/xfburn/xfburn-disc-content.c
   xfburn/trunk/xfburn/xfburn-disc-usage.c
Log:
improve disc usage management

Modified: xfburn/trunk/xfburn/xfburn-disc-content.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-disc-content.c   2006-07-19 23:55:10 UTC (rev 
22492)
+++ xfburn/trunk/xfburn/xfburn-disc-content.c   2006-07-20 00:09:15 UTC (rev 
22493)
@@ -171,12 +171,6 @@
 }
 
 static void
-cb_row_deleted (GtkTreeModel *model, GtkTreePath  *path, 
XfburnDiscContentPrivate *priv)
-{
-  DBG ("%s", gtk_tree_path_to_string (path));
-}
-
-static void
 xfburn_disc_content_init (XfburnDiscContent * disc_content)
 {
   gint x, y;
@@ -242,9 +236,7 @@
   disc_content->priv->content = gtk_tree_view_new ();
   model = gtk_tree_store_new (DISC_CONTENT_N_COLUMNS, GDK_TYPE_PIXBUF, 
G_TYPE_STRING, G_TYPE_STRING,
                               G_TYPE_UINT64, G_TYPE_STRING, G_TYPE_UINT);
-  g_signal_connect (G_OBJECT (model), "row-deleted", G_CALLBACK 
(cb_row_deleted), disc_content->priv);
                                                          
-                                                         
   gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model), 
DISC_CONTENT_COLUMN_CONTENT,
                                    directory_tree_sortfunc, NULL, NULL);
   gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), 
DISC_CONTENT_COLUMN_CONTENT, GTK_SORT_ASCENDING);
@@ -486,7 +478,8 @@
   while (el) {
     GtkTreePath *path = NULL;
     GtkTreeIter *iter = NULL;
-    guint64 size;
+    GtkTreeIter parent, iter_temp;
+    guint64 size = 0;
 
     path = (GtkTreePath *) el->data;
     iter = g_new0 (GtkTreeIter, 1);
@@ -497,6 +490,24 @@
     gtk_tree_model_get (model, iter, DISC_CONTENT_COLUMN_SIZE, &size, -1);
     xfburn_disc_usage_sub_size (XFBURN_DISC_USAGE (dc->priv->disc_usage), 
size);
 
+    iter_temp = *iter;
+    while (gtk_tree_model_iter_parent (model, &parent, &iter_temp)) {
+      guint64 old_size;
+      gchar *humansize = NULL;
+
+      /* updates parent directories size */
+      gtk_tree_model_get (model, &parent, DISC_CONTENT_COLUMN_SIZE, &old_size, 
-1);
+
+      humansize = xfburn_humanreadable_filesize (old_size - size);
+      gtk_tree_store_set (GTK_TREE_STORE (model), &parent, 
+                         DISC_CONTENT_COLUMN_HUMANSIZE, humansize,
+                         DISC_CONTENT_COLUMN_SIZE, old_size - size, -1);
+
+      iter_temp = parent;
+
+      g_free (humansize);
+    }
+
     gtk_tree_path_free (path);
     el = g_list_next (el);
   }
@@ -639,7 +650,8 @@
       gtk_tree_store_set (GTK_TREE_STORE (model), iter,
                           DISC_CONTENT_COLUMN_ICON, icon_directory,
                           DISC_CONTENT_COLUMN_CONTENT, name,
-                          DISC_CONTENT_COLUMN_PATH, path, 
DISC_CONTENT_COLUMN_TYPE, DISC_CONTENT_TYPE_DIRECTORY, -1);
+                          DISC_CONTENT_COLUMN_PATH, path, 
DISC_CONTENT_COLUMN_TYPE, DISC_CONTENT_TYPE_DIRECTORY, 
+                         DISC_CONTENT_COLUMN_SIZE, (guint64) s.st_size, -1);
       xfburn_disc_usage_add_size (XFBURN_DISC_USAGE (dc->priv->disc_usage), 
s.st_size);
 
       while ((filename = g_dir_read_name (dir))) {

Modified: xfburn/trunk/xfburn/xfburn-disc-usage.c
===================================================================
--- xfburn/trunk/xfburn/xfburn-disc-usage.c     2006-07-19 23:55:10 UTC (rev 
22492)
+++ xfburn/trunk/xfburn/xfburn-disc-usage.c     2006-07-20 00:09:15 UTC (rev 
22493)
@@ -142,6 +142,11 @@
   gchar *size;
 
   fraction = disc_usage->size / datadisksizes[gtk_combo_box_get_active 
(GTK_COMBO_BOX (disc_usage->combo))].size;
+  if (fraction > 1.0)
+    fraction = 1.0;
+  if (fraction < 0.0)
+    fraction = 0.0;
+
   gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (disc_usage->progress_bar), 
fraction > 1.0 ? 1.0 : fraction);
 
   if (xfburn_settings_get_boolean ("human-readable-units", TRUE))

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to