gnome-utils r8191 - in branches/gnome-2-24/baobab: . src



Author: pborelli
Date: Sat Nov 22 17:39:35 2008
New Revision: 8191
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=8191&view=rev

Log:
2008-11-22  Paolo Borelli  <pborelli katamail com>

	* src/baobab.c:
	Fix excluded locations sanity check.



Modified:
   branches/gnome-2-24/baobab/ChangeLog
   branches/gnome-2-24/baobab/src/baobab.c

Modified: branches/gnome-2-24/baobab/src/baobab.c
==============================================================================
--- branches/gnome-2-24/baobab/src/baobab.c	(original)
+++ branches/gnome-2-24/baobab/src/baobab.c	Sat Nov 22 17:39:35 2008
@@ -330,8 +330,12 @@
 	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (baobab.tree_view), FALSE);
 	gtk_tree_store_append (baobab.model, &firstiter, NULL);
 	size = g_format_size_for_display (g_fs.used);
-	g_assert (g_fs.total != 0);
-	perc = ((gdouble) g_fs.used * 100) / (gdouble) g_fs.total;
+	if (g_fs.total == 0 && g_fs.used == 0) {
+		perc = 100.0;
+	} else {
+		g_assert (g_fs.total != 0);
+		perc = ((gdouble) g_fs.used * 100) / (gdouble) g_fs.total;
+	}
 
 	label = g_strdup_printf ("<i>%s</i>", _("Total filesystem usage:"));
 	gtk_tree_store_set (baobab.model, &firstiter,
@@ -630,31 +634,42 @@
 }
 
 static void
+store_excluded_locations (void)
+{
+	GSList *l;
+	GSList *uri_list = NULL;
+
+	for (l = baobab.excluded_locations; l != NULL; l = l->next) {
+		GSList *uri_list = NULL;
+
+		uri_list = g_slist_prepend (uri_list, g_file_get_uri(l->data));
+	}
+
+	gconf_client_set_list (baobab.gconf_client,
+			       PROPS_SCAN_KEY,
+			       GCONF_VALUE_STRING, 
+			       uri_list,
+			       NULL);
+
+	g_slist_foreach (uri_list, (GFunc) g_free, NULL);
+	g_slist_free (uri_list);
+}
+
+static void
 sanity_check_excluded_locations (void)
 {
 	GFile *root;
+	GSList *l;
 
 	/* Verify if gconf wrongly contains root dir exclusion, and remove it from gconf. */
 	root = g_file_new_for_uri ("file:///");
-	if (baobab_is_excluded_location (root)) {
-		GSList *uri_list, *l;
-
-		baobab.excluded_locations = g_slist_delete_link (baobab.excluded_locations, 
-						g_slist_find (baobab.excluded_locations, 
-							      root));
 
-		for (l = baobab.excluded_locations; l != NULL; l = l->next) {
-			uri_list = g_slist_prepend (uri_list, g_file_get_uri(l->data));
+	for (l = baobab.excluded_locations; l != NULL; l = l->next) {
+		if (g_file_equal (l->data, root)) {
+			baobab.excluded_locations = g_slist_delete_link (baobab.excluded_locations, l);
+			store_excluded_locations ();
+			break;			
 		}
-		
-		gconf_client_set_list (baobab.gconf_client,
-				       PROPS_SCAN_KEY,
-				       GCONF_VALUE_STRING, 
-				       uri_list,
-				       NULL);
-
-		g_slist_foreach (uri_list, (GFunc) g_free, NULL);
-		g_slist_free (uri_list);
 	}
 
 	g_object_unref (root);



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