From bff70531393b40238848b6f741421565d05ade27 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Fri, 26 Nov 2021 00:53:20 -0600 Subject: [PATCH] Added ctrl+o; fixed ctrl+w, updated ipc_open logic --- src/versions/pyfm-0.0.1/PyFM/new/pyfm/pyfm | 18 +++++++++++ .../shellfm/windows/view/utils/Launcher.py | 6 ++-- .../PyFM/new/pyfm/signal_classes/Signals.py | 3 +- .../pyfm/signal_classes/mixins/TabMixin.py | 31 +++++++++++++------ .../mixins/WidgetFileActionMixin.py | 14 +++++++-- .../pyfm/signal_classes/mixins/WindowMixin.py | 11 +++++-- src/versions/pyfm-0.0.1/PyFM_exec_bin.cpp | 4 +-- src/versions/pyfm-0.0.1/compileBin.sh | 2 +- src/versions/pyfm-0.0.1/pyfm.desktop | 12 +++++++ 9 files changed, 81 insertions(+), 20 deletions(-) create mode 100755 src/versions/pyfm-0.0.1/PyFM/new/pyfm/pyfm create mode 100755 src/versions/pyfm-0.0.1/pyfm.desktop diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/pyfm b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/pyfm new file mode 100755 index 0000000..fa3604b --- /dev/null +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/pyfm @@ -0,0 +1,18 @@ +#!/bin/bash + +# . CONFIG.sh + +# set -o xtrace ## To debug scripts +# set -o errexit ## To exit on error +# set -o errunset ## To exit if a variable is referenced but not set + + +function main() { + SCRIPTPATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )" + cd "${SCRIPTPATH}" + echo "Working Dir: " $(pwd) + + source "/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/bin/activate" + python ../pyfm "$@" +} +main "$@"; diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/utils/Launcher.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/utils/Launcher.py index ba50e47..92a690e 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/utils/Launcher.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/utils/Launcher.py @@ -30,10 +30,12 @@ class Launcher: command = [self.text_app, file] elif lowerName.endswith(self.fpdf): command = [self.pdf_app, file] - else: + elif lowerName.endswith("placeholder-until-i-can-get-a-use-pref-fm-flag"): command = [self.file_manager_app, file] + else: + command = ["xdg-open", file] - self.logger.debug(command) + self.logger.debug(command) DEVNULL = open(os.devnull, 'w') subprocess.Popen(command, start_new_session=True, stdout=DEVNULL, stderr=DEVNULL, close_fds=True) diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py index f1204f7..f2be994 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Signals.py @@ -172,7 +172,8 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin): self.cut_files() if self.ctrlDown and keyname == "v": self.paste_files() - + if self.ctrlDown and keyname == "o": + self.open_files() if keyname == "delete": self.trash_files() diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py index ea5477e..9ca7452 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/TabMixin.py @@ -11,14 +11,20 @@ class TabMixin(WidgetMixin): def create_tab_from_ipc(data): self, path = data - if not self.is_pane1_hidden: - self.create_tab(1, path) - elif not self.is_pane2_hidden: - self.create_tab(2, path) + wid, tid = self.window_controller.get_active_data() + notebook = self.builder.get_object(f"window_{wid}") + if notebook.is_visible(): + self.create_tab(wid, path) + return + + if not self.is_pane4_hidden: + self.create_tab(4, path) elif not self.is_pane3_hidden: self.create_tab(3, path) - elif not self.is_pane4_hidden: - self.create_tab(4, path) + elif not self.is_pane2_hidden: + self.create_tab(2, path) + elif not self.is_pane1_hidden: + self.create_tab(1, path) def create_tab(self, wid, path=None): @@ -143,9 +149,16 @@ class TabMixin(WidgetMixin): def keyboard_close_tab(self): wid, tid = self.window_controller.get_active_data() notebook = self.builder.get_object(f"window_{wid}") - iconview = self.get_tab_iconview_from_notebook(notebook) - close = self.get_tab_close(notebook, iconview) - close.released() + scroll = self.builder.get_object(f"{wid}|{tid}") + page = notebook.page_num(scroll) + view = self.get_fm_window(wid).get_view_by_id(tid) + watcher = view.get_dir_watcher() + watcher.cancel() + + self.get_fm_window(wid).delete_view_by_id(tid) + notebook.remove_page(page) + self.window_controller.save_state() + self.set_window_title() # File control events def show_hide_hidden_files(self): diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py index 79fb617..896cbe1 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py @@ -63,6 +63,16 @@ class WidgetFileActionMixin: def menu_bar_copy(self, widget, eve): self.copy_file() + def open_files(self): + wid, tid = self.window_controller.get_active_data() + view = self.get_fm_window(wid).get_view_by_id(tid) + iconview = self.builder.get_object(f"{wid}|{tid}|iconview") + store = iconview.get_model() + uris = self.format_to_uris(store, wid, tid, self.selected_files, True) + + for file in uris: + view.open_file_locally(file) + def copy_files(self): wid, tid = self.window_controller.get_active_data() iconview = self.builder.get_object(f"{wid}|{tid}|iconview") @@ -142,9 +152,9 @@ class WidgetFileActionMixin: if action == "trash": f.trash(cancellable=None) if action == "copy": - f.copy(target, flags=Gio.FileCopyFlags.OVERWRITE, cancellable=None) + f.copy(target, flags=Gio.FileCopyFlags.BACKUP, cancellable=None) if action == "move": - f.move(target, flags=Gio.FileCopyFlags.OVERWRITE, cancellable=None) + f.move(target, flags=Gio.FileCopyFlags.BACKUP, cancellable=None) except GObject.GError as e: raise OSError(e.message) diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py index caee4ef..2f20ef1 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py @@ -20,7 +20,7 @@ class WindowMixin(TabMixin): def get_fm_window(self, wid): return self.window_controller.get_window_by_nickname(f"window_{wid}") - def format_to_uris(self, store, wid, tid, treePaths): + def format_to_uris(self, store, wid, tid, treePaths, use_just_path=False): view = self.get_fm_window(wid).get_view_by_id(tid) dir = view.get_current_directory() uris = [] @@ -28,7 +28,13 @@ class WindowMixin(TabMixin): for path in treePaths: itr = store.get_iter(path) file = store.get(itr, 1)[0] - fpath = f"file://{dir}/{file}" + fpath = "" + + if not use_just_path: + fpath = f"file://{dir}/{file}" + else: + fpath = f"{dir}/{file}" + uris.append(fpath) return uris @@ -102,7 +108,6 @@ class WindowMixin(TabMixin): uris = self.format_to_uris(store, wid, tid, treePaths) data.set_uris(uris) - event_system.push_gui_event(["refresh_tab", None, action]) def grid_on_drag_motion(self, iconview, drag_context, x, y, data): wid, tid = iconview.get_name().split("|") diff --git a/src/versions/pyfm-0.0.1/PyFM_exec_bin.cpp b/src/versions/pyfm-0.0.1/PyFM_exec_bin.cpp index 93af3d7..6d3f425 100644 --- a/src/versions/pyfm-0.0.1/PyFM_exec_bin.cpp +++ b/src/versions/pyfm-0.0.1/PyFM_exec_bin.cpp @@ -4,7 +4,7 @@ using namespace std; int main() { - chdir("/opt/Pytop/"); - system("python3 PyTop.py"); + chdir("/opt/PyFM/"); + system("python3 ."); return 0; } diff --git a/src/versions/pyfm-0.0.1/compileBin.sh b/src/versions/pyfm-0.0.1/compileBin.sh index a5cbb77..7b0e7b2 100755 --- a/src/versions/pyfm-0.0.1/compileBin.sh +++ b/src/versions/pyfm-0.0.1/compileBin.sh @@ -1,6 +1,6 @@ #!/bin/bash function main() { - gcc -no-pie -s Pytop_exec_bin.cpp -o pytop + gcc -no-pie -s PyFM_exec_bin.cpp -o pyfm } main; diff --git a/src/versions/pyfm-0.0.1/pyfm.desktop b/src/versions/pyfm-0.0.1/pyfm.desktop new file mode 100755 index 0000000..72690af --- /dev/null +++ b/src/versions/pyfm-0.0.1/pyfm.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=PyFM +GenericName=File Manager +Comment=A file manager built with Python and GObject introspection. +Path=/home/abaddon/.local/share/pyfm +Exec=/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/bin/python /home/abaddon/.local/share/pyfm %F +Icon=/home/abaddon/.local/share/pyfm/resources/pyfm-64x64.png +Type=Application +StartupNotify=true +Categories=System;FileTools;Utility;Core;GTK;FileManager; +MimeType=inode/directory;inode/mount-point;x-scheme-handler/ssh;x-scheme-handler/smb;x-scheme-handler/nfs;x-scheme-handler/ftp;x-scheme-handler/ptp;x-scheme-handler/mtp;x-scheme-handler/webdav;x-scheme-handler/http;x-scheme-handler/https; +Terminal=false