summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-22 04:23:36 +0200
committerhut <hut@lavabit.com>2011-10-22 04:23:36 +0200
commitb2b58e7f15e5700a1f8248fb1bf32386b4b45c57 (patch)
tree07ab83bf101bf11ac42c50e9a55adb4d3ae228a4
parent812447408be9b67850b253fe9d53a88ad31856ae (diff)
downloadranger-b2b58e7f15e5700a1f8248fb1bf32386b4b45c57.tar.gz
New key "dc" to get cumulative size of selected directories
-rw-r--r--ranger/core/actions.py5
-rw-r--r--ranger/defaults/rc.conf2
-rw-r--r--ranger/fsobject/directory.py38
-rw-r--r--ranger/fsobject/fsobject.py3
4 files changed, 46 insertions, 2 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 0fd60b9a..5966789a 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -87,6 +87,11 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 			self.notify("Aborting: " + item.get_description())
 			self.loader.remove(index=0)
 
+	def get_cumulative_size(self):
+		for f in self.env.get_selection() or ():
+			f.look_up_cumulative_size()
+		self.ui.redraw_main_column()
+
 	def redraw_window(self):
 		"""Redraw the window"""
 		self.ui.redraw_window()
diff --git a/ranger/defaults/rc.conf b/ranger/defaults/rc.conf
index a9e64622..b75c188e 100644
--- a/ranger/defaults/rc.conf
+++ b/ranger/defaults/rc.conf
@@ -216,6 +216,8 @@ map oC chain set sort=ctime;     set sort_reverse=True
 map oA chain set sort=atime;     set sort_reverse=True
 map oT chain set sort="type";    set sort_reverse=True
 
+map dc get_cumulative_size
+
 # Settings
 map zc    toggle_option collapse_preview
 map zd    toggle_option sort_directories_first
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index b3a35a0a..04ed35e0 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -25,6 +25,7 @@ from ranger.fsobject import File, FileSystemObject
 from ranger.core.shared import SettingsAware
 from ranger.ext.accumulator import Accumulator
 from ranger.ext.lazy_property import lazy_property
+from ranger.ext.human_readable import human_readable
 
 def sort_by_basename(path):
 	"""returns path.basename (for sorting)"""
@@ -79,6 +80,8 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 	content_outdated = False
 	content_loaded = False
 
+	_cumulative_size_calculated = False
+
 	sort_dict = {
 		'basename': sort_by_basename,
 		'natural': sort_naturally,
@@ -185,8 +188,14 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 				hidden_filter = not self.settings.show_hidden \
 						and self.settings.hidden_filter
 				filelist = os.listdir(mypath)
-				self.size = len(filelist)
-				self.infostring = ' %d' % self.size
+				if not self._cumulative_size_calculated \
+						or self.content_loaded:
+					self.size = len(filelist)
+					self.infostring = ' %d' % self.size
+				if self._cumulative_size_calculated:
+					self._cumulative_size_calculated = False
+				if self.is_link:
+					self.infostring = '->' + self.infostring
 				filenames = [mypath + (mypath == '/' and fname or '/' + fname)\
 						for fname in filelist if accept_file(
 							fname, mypath, hidden_filter, self.filter)]
@@ -327,6 +336,31 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 		else:
 			s4`DH9qf$T4C
|1]KffUh~=Tf
j_,3М)GH^\![=S(h?`b66.h!h1Bm~e3@"FRi4
 `RWR9d!ESVbj58!Jr	Th_e^$i={nًKpBs}1]TlI>y+PDȼGehRe6ƇR
O=A)=
8:q~ct=Þ{ٳ`PlGo
(;9(>@7gOw>;d?Yn치aQB@5xb%ÐIjJÌIV6r;ȦDѣfAd{Rx@x{=N	îȨ[O[ȦMҁDy;l6qSmZY>TR&QV(GmlpȤINJ$̕q &$񵮆i;@6Onm,SY/_qefd#F`e=ce@S8^V$ji`S)&NazEQA	=}M=WNeF^iq;U>m22LfJxѭ
;yObw~F?zwd!{$#ߪwb@tohD(
2VRu]{&
ur萤5*̝d.*N3A[B]eS$
ab&Ix|#4㘿t15WXo&XF4:[a@i'B0_&LܣꊺhK]DBжبF3ƳxAIuѶ@n@0|G+zP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