about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-19 18:55:18 +0100
committerhut <hut@lavabit.com>2010-01-19 18:55:18 +0100
commitb42eb058fb9987d807d0a813573745bad1e68248 (patch)
treeff13980405105725c0a0f31c0ec440b3a8dc6c8d /ranger
parenta1274aba49793e6a48be95c2cece7d32e5d334f2 (diff)
downloadranger-b42eb058fb9987d807d0a813573745bad1e68248.tar.gz
done #35: display disk usage of files in current directory
Diffstat (limited to 'ranger')
-rw-r--r--ranger/fsobject/directory.py4
-rw-r--r--ranger/gui/widgets/statusbar.py9
2 files changed, 12 insertions, 1 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 79b39f69..d007f66e 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -47,6 +47,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 	scroll_offset = 0
 
 	mount_path = '/'
+	disk_usage = 0
 
 	last_update_time = -1
 	load_content_mtime = -1
@@ -184,6 +185,9 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 					files.append(item)
 					yield
 
+				self.disk_usage = sum(isinstance(f, File) and f.size or 0 \
+						for f in files)
+
 				self.scroll_offset = 0
 				self.filenames = filenames
 				self.infostring = ' %d' % len(self.filenames) # update the infostring
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index a1fc4973..2531206f 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -39,6 +39,7 @@ class StatusBar(Widget):
 
 	old_cf = None
 	old_mtime = None
+	old_du = None
 	old_hint = None
 	result = None
 
@@ -79,6 +80,10 @@ class StatusBar(Widget):
 		if not self.result:
 			self.need_redraw = True
 
+		if self.old_du and not self.env.pwd.disk_usage:
+			self.old_du = self.env.pwd.disk_usage
+			self.need_redraw = True
+
 		if self.old_cf != self.env.cf:
 			self.old_cf = self.env.cf
 			self.need_redraw = True
@@ -199,9 +204,11 @@ class StatusBar(Widget):
 		max_pos = len(target) - self.column.hei
 		base = 'scroll'
 
+		right.add(human_readable(target.disk_usage, seperator=''))
+		right.add(", ", "space")
 		right.add(human_readable(self.env.get_free_space(target.mount_path),
 			seperator=''))
-		right.add(" ", "space")
+		right.add("  ", "space")
 
 		if target.marked_items:
 			# Indicate that there are marked files. Useful if you scroll