diff options
author | hut <hut@lavabit.com> | 2011-10-22 04:23:36 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2011-10-22 04:23:36 +0200 |
commit | b2b58e7f15e5700a1f8248fb1bf32386b4b45c57 (patch) | |
tree | 07ab83bf101bf11ac42c50e9a55adb4d3ae228a4 | |
parent | 812447408be9b67850b253fe9d53a88ad31856ae (diff) | |
download | ranger-b2b58e7f15e5700a1f8248fb1bf32386b4b45c57.tar.gz |
New key "dc" to get cumulative size of selected directories
-rw-r--r-- | ranger/core/actions.py | 5 | ||||
-rw-r--r-- | ranger/defaults/rc.conf | 2 | ||||
-rw-r--r-- | ranger/fsobject/directory.py | 38 | ||||
-rw-r--r-- | ranger/fsobject/fsobject.py | 3 |
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]K ffUh~=Tf j_,3М)GH^\![=S(h?`b66.h!h1Bm~e3@"F Ri4 `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)&N |