Fixed multi file ipc load speeds
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
from contextlib import suppress
|
||||
import signal
|
||||
import os
|
||||
import json
|
||||
|
||||
# Lib imports
|
||||
|
||||
@@ -44,15 +45,19 @@ class Application:
|
||||
return True
|
||||
|
||||
logger.warning(f"{APP_NAME} IPC Server Exists: Have sent path(s) to it and closing...")
|
||||
files: list = []
|
||||
for arg in unknownargs + [args.new_tab,]:
|
||||
if os.path.isfile(arg):
|
||||
message = f"FILE|{arg}"
|
||||
ipc_server.send_ipc_message(message)
|
||||
files.append(f"file://{arg}")
|
||||
|
||||
if os.path.isdir(arg):
|
||||
message = f"DIR|{arg}"
|
||||
ipc_server.send_ipc_message(message)
|
||||
|
||||
if files:
|
||||
message = f"FILES|{json.dumps(files)}"
|
||||
ipc_server.send_ipc_message(message)
|
||||
|
||||
return False
|
||||
|
||||
def ipc_realization_check(self, ipc_server):
|
||||
|
||||
@@ -26,12 +26,12 @@ class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerMixin)
|
||||
|
||||
self._setup_controller_data()
|
||||
|
||||
self._load_plugins_and_files(is_pre = True)
|
||||
self._load_plugins(is_pre = True)
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._subscribe_to_events()
|
||||
self._load_controllers()
|
||||
self._load_plugins_and_files(is_pre = False)
|
||||
self._load_plugins(is_pre = False)
|
||||
|
||||
logger.info(f"Made it past {self.__class__} loading...")
|
||||
settings_manager.set_end_load_time()
|
||||
@@ -60,13 +60,14 @@ class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerMixin)
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("shutting-down", lambda: print("Shutting down..."))
|
||||
event_system.subscribe("handle-file-from-ipc", self.handle_file_from_ipc)
|
||||
event_system.subscribe("handle-files-from-ipc", self.handle_files_from_ipc)
|
||||
event_system.subscribe("handle-dir-from-ipc", self.handle_dir_from_ipc)
|
||||
event_system.subscribe("tggl-top-main-menubar", self._tggl_top_main_menubar)
|
||||
|
||||
def _load_controllers(self):
|
||||
BridgeController()
|
||||
|
||||
def _load_plugins_and_files(self, is_pre: bool):
|
||||
def _load_plugins(self, is_pre: bool):
|
||||
args, unknownargs = settings_manager.get_starting_args()
|
||||
if args.no_plugins == "true": return
|
||||
|
||||
@@ -78,9 +79,5 @@ class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerMixin)
|
||||
self.plugins_controller.post_launch_plugins()
|
||||
return
|
||||
|
||||
def _load_files(self):
|
||||
for file in settings_manager.get_starting_files():
|
||||
event_system.emit("post-file-to-ipc", file)
|
||||
|
||||
def _tggl_top_main_menubar(self):
|
||||
logger.debug("_tggl_top_main_menubar > stub...")
|
||||
|
||||
@@ -27,6 +27,7 @@ class CodeBase:
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("handle-file", self._load_ipc_file)
|
||||
event_system.subscribe("handle-files", self._load_ipc_files)
|
||||
|
||||
def _load_controllers(self):
|
||||
files_controller = FilesController()
|
||||
@@ -62,3 +63,7 @@ class CodeBase:
|
||||
active_view = self.controller_manager["source_views"].signal_mapper.active_view
|
||||
uris = [ f"file://{fpath}" ]
|
||||
active_view._on_uri_data_received(uris)
|
||||
|
||||
def _load_ipc_files(self, uris: list):
|
||||
active_view = self.controller_manager["source_views"].signal_mapper.active_view
|
||||
active_view._on_uri_data_received(uris)
|
||||
|
||||
@@ -33,6 +33,7 @@ class SourceViewDnDMixin:
|
||||
|
||||
def _on_uri_data_received(self, uris: []):
|
||||
uri = uris.pop(0)
|
||||
|
||||
self.command.exec_with_args("dnd_load_file_to_buffer", self, uri)
|
||||
|
||||
if not uris: return
|
||||
|
||||
@@ -87,6 +87,16 @@ class IPCServer(Singleton):
|
||||
conn.close()
|
||||
break
|
||||
|
||||
if "FILES|" in msg:
|
||||
import json
|
||||
data = msg.split("FILES|")[1].strip()
|
||||
files = json.loads(data)
|
||||
if files:
|
||||
event_system.emit("handle-files-from-ipc", (files,))
|
||||
|
||||
conn.close()
|
||||
break
|
||||
|
||||
if "DIR|" in msg:
|
||||
file = msg.split("DIR|")[1].strip()
|
||||
if file:
|
||||
|
||||
@@ -21,6 +21,12 @@ class IPCSignalsMixin:
|
||||
self.broadcast_message, "handle-file", (fpath,)
|
||||
)
|
||||
|
||||
def handle_files_from_ipc(self, uris: list) -> None:
|
||||
logger.debug(f"Files From IPC: {uris}")
|
||||
GLib.idle_add(
|
||||
self.broadcast_message, "handle-files", (uris,)
|
||||
)
|
||||
|
||||
def handle_dir_from_ipc(self, fpath: str) -> None:
|
||||
logger.debug(f"Dir From IPC: {fpath}")
|
||||
GLib.idle_add(
|
||||
|
||||
Reference in New Issue
Block a user