Added setup py; buiuld system; and IPC and process detection
This commit is contained in:
parent
dc894f1245
commit
35cf150fbc
BIN
images/pic2.png
BIN
images/pic2.png
Binary file not shown.
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 456 KiB |
@ -13,6 +13,6 @@ function main() {
|
|||||||
echo "Working Dir: " $(pwd)
|
echo "Working Dir: " $(pwd)
|
||||||
|
|
||||||
source "/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/bin/activate"
|
source "/home/abaddon/Portable_Apps/py-venvs/flask-apps-venv/venv/bin/activate"
|
||||||
python .
|
python ./pyfm
|
||||||
}
|
}
|
||||||
main "$@";
|
main "$@";
|
3
src/versions/pyfm-0.0.1/PyFM/new/pyfm.toml
Normal file
3
src/versions/pyfm-0.0.1/PyFM/new/pyfm.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
@ -1,6 +1,13 @@
|
|||||||
|
# Python imports
|
||||||
import builtins
|
import builtins
|
||||||
|
|
||||||
class Builtins:
|
# Gtk imports
|
||||||
|
|
||||||
|
# Application imports
|
||||||
|
from signal_classes.DBusControllerMixin import DBusControllerMixin
|
||||||
|
|
||||||
|
|
||||||
|
class Builtins(DBusControllerMixin):
|
||||||
"""Docstring for __builtins__ extender"""
|
"""Docstring for __builtins__ extender"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -9,6 +16,8 @@ class Builtins:
|
|||||||
self._gui_events = []
|
self._gui_events = []
|
||||||
self._fm_events = []
|
self._fm_events = []
|
||||||
self.monitor_events = True
|
self.monitor_events = True
|
||||||
|
self.keep_ipc_alive = True
|
||||||
|
self.is_ipc_alive = False
|
||||||
|
|
||||||
# Makeshift fake "events" type system FIFO
|
# Makeshift fake "events" type system FIFO
|
||||||
def _pop_gui_event(self):
|
def _pop_gui_event(self):
|
||||||
@ -53,5 +62,5 @@ class Builtins:
|
|||||||
# NOTE: Just reminding myself we can add to builtins two different ways...
|
# NOTE: Just reminding myself we can add to builtins two different ways...
|
||||||
# __builtins__.update({"event_system": Builtins()})
|
# __builtins__.update({"event_system": Builtins()})
|
||||||
builtins.event_system = Builtins()
|
builtins.event_system = Builtins()
|
||||||
builtins.event_sleep_time = 0.2
|
builtins.event_sleep_time = 0.5
|
||||||
builtins.debug = False
|
builtins.debug = False
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
# Python imports
|
# Python imports
|
||||||
import inspect
|
import inspect, time
|
||||||
|
|
||||||
|
|
||||||
# Gtk imports
|
# Gtk imports
|
||||||
|
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from utils import Settings
|
from utils import Settings
|
||||||
from signal_classes import Signals
|
from signal_classes import Signals
|
||||||
@ -13,13 +11,24 @@ from __builtins__ import Builtins
|
|||||||
|
|
||||||
class Main(Builtins):
|
class Main(Builtins):
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
|
event_system.create_ipc_server()
|
||||||
|
time.sleep(0.5)
|
||||||
|
if not event_system.is_ipc_alive:
|
||||||
|
if args.new_tab:
|
||||||
|
message = f"FILE|{args.new_tab}"
|
||||||
|
event_system.send_ipc_message(message)
|
||||||
|
raise Exception("IPC Server Exists: Will send message to it and close...")
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
settings.createWindow()
|
settings.createWindow()
|
||||||
|
|
||||||
|
signals = Signals(args, settings)
|
||||||
|
if not signals:
|
||||||
|
raise Exception("Signals exited...")
|
||||||
|
|
||||||
# Gets the methods from the classes and sets to handler.
|
# Gets the methods from the classes and sets to handler.
|
||||||
# Then, builder connects to any signals it needs.
|
# Then, builder connects to any signals it needs.
|
||||||
classes = [Signals(settings)]
|
classes = [signals]
|
||||||
|
|
||||||
handlers = {}
|
handlers = {}
|
||||||
for c in classes:
|
for c in classes:
|
||||||
methods = None
|
methods = None
|
||||||
|
@ -12,7 +12,7 @@ tracemalloc.start()
|
|||||||
# Gtk imports
|
# Gtk imports
|
||||||
import gi, faulthandler, traceback
|
import gi, faulthandler, traceback
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gtk as gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from __init__ import Main
|
from __init__ import Main
|
||||||
@ -24,11 +24,14 @@ if __name__ == "__main__":
|
|||||||
faulthandler.enable() # For better debug info
|
faulthandler.enable() # For better debug info
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
# Add long and short arguments
|
# Add long and short arguments
|
||||||
parser.add_argument("--file", "-f", default="default", help="JUST SOME FILE ARG.")
|
parser.add_argument("--new-tab", "-t", help="Open a file into new tab.")
|
||||||
|
parser.add_argument("--new-window", "-w", help="Open a file into a new window.")
|
||||||
|
|
||||||
# Read arguments (If any...)
|
# Read arguments (If any...)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
main = Main(args)
|
Main(args)
|
||||||
gtk.main()
|
Gtk.main()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
event_system.keep_ipc_alive = False
|
||||||
|
if debug:
|
||||||
|
traceback.print_exc()
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
# Python imports
|
||||||
|
import threading, socket
|
||||||
|
from multiprocessing.connection import Listener, Client
|
||||||
|
|
||||||
|
# Gtk imports
|
||||||
|
|
||||||
|
# Application imports
|
||||||
|
|
||||||
|
|
||||||
|
def threaded(fn):
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
threading.Thread(target=fn, args=args, kwargs=kwargs).start()
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
class DBusControllerMixin:
|
||||||
|
|
||||||
|
@threaded
|
||||||
|
def create_ipc_server(self):
|
||||||
|
listener = Listener(('127.0.0.1', 4848), authkey=b'pyfm-ipc')
|
||||||
|
self.is_ipc_alive = True
|
||||||
|
while event_system.keep_ipc_alive:
|
||||||
|
conn = listener.accept()
|
||||||
|
print(f"New Connection: {listener.last_accepted}")
|
||||||
|
while True:
|
||||||
|
msg = conn.recv()
|
||||||
|
print(msg)
|
||||||
|
|
||||||
|
if "FILE|" in msg:
|
||||||
|
file = msg.split("FILE|")[1].strip()
|
||||||
|
event_system.push_gui_event(["create_tab_from_ipc", None, file])
|
||||||
|
conn.close()
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if msg == 'close connection':
|
||||||
|
conn.close()
|
||||||
|
break
|
||||||
|
if msg == 'close server':
|
||||||
|
conn.close()
|
||||||
|
event_system.keep_ipc_alive = False
|
||||||
|
break
|
||||||
|
listener.close()
|
||||||
|
|
||||||
|
|
||||||
|
def send_ipc_message(self, message="Empty Data..."):
|
||||||
|
try:
|
||||||
|
conn = Client(('127.0.0.1', 4848), authkey=b'pyfm-ipc')
|
||||||
|
conn.send(message)
|
||||||
|
conn.send('close connection')
|
||||||
|
except Exception as e:
|
||||||
|
print(repr(e))
|
@ -21,7 +21,7 @@ def threaded(fn):
|
|||||||
|
|
||||||
|
|
||||||
class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
|
class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
|
||||||
def __init__(self, settings):
|
def __init__(self, args, settings):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.builder = self.settings.builder
|
self.builder = self.settings.builder
|
||||||
self.logger = self.settings.logger
|
self.logger = self.settings.logger
|
||||||
@ -39,15 +39,15 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
|
|||||||
self.to_copy_files = []
|
self.to_copy_files = []
|
||||||
self.to_cut_files = []
|
self.to_cut_files = []
|
||||||
|
|
||||||
self.single_click_open = False
|
self.single_click_open = False
|
||||||
self.is_pane1_hidden = False
|
self.is_pane1_hidden = False
|
||||||
self.is_pane2_hidden = False
|
self.is_pane2_hidden = False
|
||||||
self.is_pane3_hidden = False
|
self.is_pane3_hidden = False
|
||||||
self.is_pane4_hidden = False
|
self.is_pane4_hidden = False
|
||||||
|
|
||||||
self.ctrlDown = False
|
self.ctrlDown = False
|
||||||
self.shiftDown = False
|
self.shiftDown = False
|
||||||
self.altDown = False
|
self.altDown = False
|
||||||
|
|
||||||
self.window.show()
|
self.window.show()
|
||||||
self.generate_windows(self.state)
|
self.generate_windows(self.state)
|
||||||
@ -58,7 +58,8 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
|
|||||||
|
|
||||||
def tear_down(self, widget=None, eve=None):
|
def tear_down(self, widget=None, eve=None):
|
||||||
self.window_controller.save_state()
|
self.window_controller.save_state()
|
||||||
event_system.monitor_events = False
|
event_system.send_ipc_message("close server")
|
||||||
|
event_system.monitor_events = False
|
||||||
time.sleep(event_sleep_time)
|
time.sleep(event_sleep_time)
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
@ -136,6 +137,8 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
|
|||||||
if "alt" in keyname:
|
if "alt" in keyname:
|
||||||
self.altDown = False
|
self.altDown = False
|
||||||
|
|
||||||
|
if self.ctrlDown and keyname == "q":
|
||||||
|
self.tear_down()
|
||||||
if (self.ctrlDown and keyname == "slash") or keyname == "home":
|
if (self.ctrlDown and keyname == "slash") or keyname == "home":
|
||||||
self.builder.get_object("go_home").released()
|
self.builder.get_object("go_home").released()
|
||||||
if self.ctrlDown and keyname == "r":
|
if self.ctrlDown and keyname == "r":
|
||||||
@ -159,12 +162,9 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
|
|||||||
if self.ctrlDown and keyname == "v":
|
if self.ctrlDown and keyname == "v":
|
||||||
self.paste_files()
|
self.paste_files()
|
||||||
|
|
||||||
if self.ctrlDown and keyname == "o":
|
|
||||||
pass
|
|
||||||
|
|
||||||
if keyname == "delete":
|
if keyname == "delete":
|
||||||
self.trash_files()
|
self.trash_files()
|
||||||
|
|
||||||
if keyname == "f4":
|
if keyname == "f4":
|
||||||
wid, tid = self.window_controller.get_active_data()
|
wid, tid = self.window_controller.get_active_data()
|
||||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||||
@ -217,14 +217,14 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
|
|||||||
self.create_new_view_notebook(None, i, None)
|
self.create_new_view_notebook(None, i, None)
|
||||||
|
|
||||||
|
|
||||||
def getClipboardData(self):
|
# def getClipboardData(self):
|
||||||
proc = subprocess.Popen(['xclip','-selection', 'clipboard', '-o'], stdout=subprocess.PIPE)
|
# proc = subprocess.Popen(['xclip','-selection', 'clipboard', '-o'], stdout=subprocess.PIPE)
|
||||||
retcode = proc.wait()
|
# retcode = proc.wait()
|
||||||
data = proc.stdout.read()
|
# data = proc.stdout.read()
|
||||||
return data.decode("utf-8").strip()
|
# return data.decode("utf-8").strip()
|
||||||
|
#
|
||||||
def setClipboardData(self, data):
|
# def setClipboardData(self, data):
|
||||||
proc = subprocess.Popen(['xclip','-selection','clipboard'], stdin=subprocess.PIPE)
|
# proc = subprocess.Popen(['xclip','-selection','clipboard'], stdin=subprocess.PIPE)
|
||||||
proc.stdin.write(data)
|
# proc.stdin.write(data)
|
||||||
proc.stdin.close()
|
# proc.stdin.close()
|
||||||
retcode = proc.wait()
|
# retcode = proc.wait()
|
||||||
|
@ -2,4 +2,5 @@
|
|||||||
Gtk Bound Signal Module
|
Gtk Bound Signal Module
|
||||||
"""
|
"""
|
||||||
from .mixins import *
|
from .mixins import *
|
||||||
|
from .DBusControllerMixin import DBusControllerMixin
|
||||||
from .Signals import Signals
|
from .Signals import Signals
|
||||||
|
@ -9,6 +9,12 @@ from . import WidgetMixin
|
|||||||
class TabMixin(WidgetMixin):
|
class TabMixin(WidgetMixin):
|
||||||
"""docstring for TabMixin"""
|
"""docstring for TabMixin"""
|
||||||
|
|
||||||
|
def create_tab_from_ipc(data):
|
||||||
|
self, path = data
|
||||||
|
wid, tid = self.window_controller.get_active_data()
|
||||||
|
self.create_tab(wid, path)
|
||||||
|
|
||||||
|
|
||||||
def create_tab(self, wid, path=None):
|
def create_tab(self, wid, path=None):
|
||||||
notebook = self.builder.get_object(f"window_{wid}")
|
notebook = self.builder.get_object(f"window_{wid}")
|
||||||
path_entry = self.builder.get_object(f"path_entry")
|
path_entry = self.builder.get_object(f"path_entry")
|
||||||
@ -104,6 +110,7 @@ class TabMixin(WidgetMixin):
|
|||||||
if action == "create_tab":
|
if action == "create_tab":
|
||||||
dir = view.get_current_directory()
|
dir = view.get_current_directory()
|
||||||
self.create_tab(wid, dir)
|
self.create_tab(wid, dir)
|
||||||
|
self.window_controller.save_state()
|
||||||
return
|
return
|
||||||
if action == "path_entry":
|
if action == "path_entry":
|
||||||
path = widget.get_text()
|
path = widget.get_text()
|
||||||
@ -124,6 +131,7 @@ class TabMixin(WidgetMixin):
|
|||||||
tab_label.set_label(view.get_end_of_path())
|
tab_label.set_label(view.get_end_of_path())
|
||||||
self.set_window_title()
|
self.set_window_title()
|
||||||
self.set_file_watcher(view)
|
self.set_file_watcher(view)
|
||||||
|
self.window_controller.save_state()
|
||||||
|
|
||||||
|
|
||||||
def keyboard_close_tab(self):
|
def keyboard_close_tab(self):
|
||||||
|
11
src/versions/pyfm-0.0.1/PyFM/new/setup.py
Normal file
11
src/versions/pyfm-0.0.1/PyFM/new/setup.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='pyfm',
|
||||||
|
version='0.0.1',
|
||||||
|
packages=['pyfm'],
|
||||||
|
install_requires=[
|
||||||
|
'setproctitle',
|
||||||
|
'PyGobject',
|
||||||
|
],
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user