diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2025-01-05 10:42:36 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2025-01-05 10:42:36 -0300 |
commit | b38b86deab7a5f61b5487744cb4e0c0b344d8cdf (patch) | |
tree | 4e0f0721763d38e07eecdd315c9675bea0096f92 | |
parent | db13ef776569dff1f2d5a4fd1c34216758cea203 (diff) | |
download | finder-b38b86deab7a5f61b5487744cb4e0c0b344d8cdf.tar.gz finder-b38b86deab7a5f61b5487744cb4e0c0b344d8cdf.tar.bz2 |
Fix: improve how items are processed
-rw-r--r-- | TODO.md | 6 | ||||
-rw-r--r-- | packages/finder/main.py | 21 | ||||
-rw-r--r-- | packages/finder/plugin/opener/file/rifle.py | 9 |
3 files changed, 21 insertions, 15 deletions
@@ -1,5 +1,11 @@ # TODO +## Fixes + +* [ ] Rifle opener breaks the interface if item is opened in the terminal. +* [ ] Rifle opener is breaking the interface if item is + opened in the terminal. + ## Improvements * [ ] Cache compression. diff --git a/packages/finder/main.py b/packages/finder/main.py index bfc037a..4c8f752 100644 --- a/packages/finder/main.py +++ b/packages/finder/main.py @@ -82,20 +82,27 @@ class FinderMain(): return self.opener.options(os.path.join(path, item)) - def open(self, option = 1): + def process_item(self, callback, option): + "Generic process item method" + # Heuristics: if path is a file, folder is the dirname of that file # so right now file lists need to be put in the same folder of the # files it lists. path = self.path if os.path.isdir(self.path) else os.path.dirname(self.path) item = self.list_buffer.document.current_line - self.opener.open(os.path.join(path, item), option) + callback(os.path.join(path, item), option) - def view(self): - path = self.path if os.path.isdir(self.path) else os.path.dirname(self.path) - item = self.list_buffer.document.current_line + # Make sure to "invalidate" the app after the callback returned, to + # ensure the UI is refreshed. + self.app.invalidate() + refresh = asyncio.create_task(self.refresh()) + + def open(self, option = 1): + self.process_item(self.opener.open, option) - self.viewer.open(os.path.join(path, item)) + def view(self, option = 1): + self.process_item(self.viewer.open, option) def clear_list_buffer(self): self.list_buffer.set_document(Document(''), bypass_readonly=True) @@ -243,7 +250,7 @@ class FinderMain(): options_status += '[F' + str(option_list[1]+1) + ': ' + str(option_list[0]) + '] ' #return f"Results: {lines}; selected: {selected}" - return f"Results: {lines} | Open selected with: {options_status}[ENTER: default]" + return f"Results: {lines} | Open selected with: {options_status}[ENTER: xdg-open]" def get_statusbar_right(self): #return "[Tab] change focus [Enter] Select" diff --git a/packages/finder/plugin/opener/file/rifle.py b/packages/finder/plugin/opener/file/rifle.py index 71c0144..23f7483 100644 --- a/packages/finder/plugin/opener/file/rifle.py +++ b/packages/finder/plugin/opener/file/rifle.py @@ -33,8 +33,6 @@ except ImportError: print("Please install platformdirs first!") raise ImportError -from prompt_toolkit.application.current import get_app - class FinderPluginFileRifleOpener(): def __init__(self): config_dir = user_config_dir('ranger') @@ -52,15 +50,10 @@ class FinderPluginFileRifleOpener(): def open(self, file, option = 1): # Subprocess version #process = subprocess.Popen( - # ['rifle', file], + # ['rifle', '-p', str(option), file], # stdout=subprocess.PIPE, # stderr=subprocess.PIPE, #) # API version self.rifle.execute([file], option) - - # Make sure to "invalidate" the app after Rifle returned, to ensure the - # UI is refreshed - app = get_app() - app.invalidate() |