Added ctrl+o; fixed ctrl+w, updated ipc_open logic

This commit is contained in:
itdominator 2021-11-26 00:53:20 -06:00
parent 9f1da21127
commit bff7053139
9 changed files with 81 additions and 20 deletions

View File

@ -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 "$@";

View File

@ -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)

View File

@ -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()

View File

@ -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):

View File

@ -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)

View File

@ -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("|")

View File

@ -4,7 +4,7 @@
using namespace std;
int main() {
chdir("/opt/Pytop/");
system("python3 PyTop.py");
chdir("/opt/PyFM/");
system("python3 .");
return 0;
}

View File

@ -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;

View File

@ -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