diff options
author | hut <hut@lavabit.com> | 2013-04-24 21:49:24 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2013-04-24 21:49:24 +0200 |
commit | 89413ffe6da4f6ebc7663a678eb91f3cd6f1f374 (patch) | |
tree | e1f3b4082c09469786b1f958c561a730bc3de9e8 /ranger | |
parent | 16ac6f0bd6c71a886de23293018aab9c2fac4e64 (diff) | |
download | ranger-89413ffe6da4f6ebc7663a678eb91f3cd6f1f374.tar.gz |
core.actions: reduce code dupliaction
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/actions.py | 15 | ||||
-rw-r--r-- | ranger/gui/ui.py | 6 |
2 files changed, 9 insertions, 12 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 438b85e6..1816867b 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -480,10 +480,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): # -------------------------- def pager_move(self, narg=None, **kw): - if self.ui.pager.visible: - self.ui.pager.move(narg=narg, **kw) - if self.ui.browser.pager.visible: - self.ui.browser.pager.move(narg=narg, **kw) + self.ui.get_pager().move(narg=narg, **kw) def taskview_move(self, narg=None, **kw): self.ui.taskview.move(narg=narg, **kw) @@ -795,10 +792,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): return False def get_preview(self, file, width, height): - if self.ui.pager.visible: - pager = self.ui.pager - else: - pager = self.ui.browser.pager + pager = self.ui.get_pager() path = file.realpath if self.settings.preview_images and file.image: @@ -872,10 +866,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): if self.thisfile and self.thisfile.realpath == path: self.ui.browser.need_redraw = True data['loading'] = False - if self.ui.pager.visible: - pager = self.ui.pager - else: - pager = self.ui.browser.pager + pager = self.ui.get_pager() if self.thisfile and self.thisfile.is_file: pager.set_source(self.thisfile.get_preview_source( pager.wid, pager.hei)) diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 145e57c5..83b324e3 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -378,3 +378,9 @@ class UI(DisplayableContainer): def hint(self, text=None): self.status.hint = text + + def get_pager(self): + if self.browser.pager.visible: + return self.browser.pager + else: + return self.pager |