diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py index 221fe20..102b39e 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__init__.py @@ -1,5 +1,5 @@ # Python imports -import inspect, time +import os, inspect, time # Gtk imports @@ -10,19 +10,27 @@ from __builtins__ import Builtins class Main(Builtins): - def __init__(self, args): + def __init__(self, args, unknownargs): event_system.create_ipc_server() time.sleep(0.5) if not event_system.is_ipc_alive: - if args.new_tab: + if unknownargs: + for arg in unknownargs: + if os.path.isdir(arg): + message = f"FILE|{arg}" + event_system.send_ipc_message(message) + + if args.new_tab and os.path.isdir(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...") + + raise Exception("IPC Server Exists: Will send path(s) to it and close...") + settings = Settings() settings.createWindow() - signals = Signals(args, settings) + signals = Signals(args, unknownargs, settings) if not signals: raise Exception("Signals exited...") @@ -39,4 +47,3 @@ class Main(Builtins): pass settings.builder.connect_signals(handlers) - window = settings.createWindow() diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__main__.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__main__.py index c6f940b..5f409b0 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__main__.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/__main__.py @@ -24,12 +24,13 @@ if __name__ == "__main__": faulthandler.enable() # For better debug info parser = argparse.ArgumentParser() # Add long and short arguments - 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.") + parser.add_argument("--new-tab", "-t", default="", help="Open a file into new tab.") + parser.add_argument("--new-window", "-w", default="", help="Open a file into a new window.") # Read arguments (If any...) - args = parser.parse_args() - Main(args) + args, unknownargs = parser.parse_known_args() + + Main(args, unknownargs) Gtk.main() except Exception as e: event_system.keep_ipc_alive = False diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py index 30fa2b6..ae0813f 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py @@ -24,11 +24,14 @@ class DBusControllerMixin: print(f"New Connection: {listener.last_accepted}") while True: msg = conn.recv() - print(msg) + if debug: + print(msg) if "FILE|" in msg: file = msg.split("FILE|")[1].strip() - event_system.push_gui_event(["create_tab_from_ipc", None, file]) + if file: + event_system.push_gui_event(["create_tab_from_ipc", None, file]) + conn.close() break 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 aee7517..f1204f7 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 @@ -21,7 +21,7 @@ def threaded(fn): class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin): - def __init__(self, args, settings): + def __init__(self, args, unknownargs, settings): self.settings = settings self.builder = self.settings.builder self.logger = self.settings.logger @@ -30,10 +30,10 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin): self.state = self.window_controller.load_state() self.window = self.settings.getMainWindow() - self.window1 = self.builder.get_object("window1") - self.window2 = self.builder.get_object("window2") - self.window3 = self.builder.get_object("window3") - self.window4 = self.builder.get_object("window4") + self.window1 = self.builder.get_object("window_1") + self.window2 = self.builder.get_object("window_2") + self.window3 = self.builder.get_object("window_3") + self.window4 = self.builder.get_object("window_4") self.notebooks = [self.window1, self.window2, self.window3, self.window4] self.selected_files = [] self.to_copy_files = [] @@ -56,10 +56,21 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin): GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.tear_down) self.gui_event_observer() + if unknownargs: + for arg in unknownargs: + if os.path.isdir(arg): + message = f"FILE|{arg}" + event_system.send_ipc_message(message) + + if args.new_tab and os.path.isdir(args.new_tab): + message = f"FILE|{args.new_tab}" + event_system.send_ipc_message(message) + + def tear_down(self, widget=None, eve=None): self.window_controller.save_state() - event_system.send_ipc_message("close server") event_system.monitor_events = False + event_system.send_ipc_message("close server") time.sleep(event_sleep_time) Gtk.main_quit() 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 76a6672..ea5477e 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,8 +11,14 @@ class TabMixin(WidgetMixin): def create_tab_from_ipc(data): self, path = data - wid, tid = self.window_controller.get_active_data() - self.create_tab(wid, path) + if not self.is_pane1_hidden: + self.create_tab(1, path) + elif not self.is_pane2_hidden: + self.create_tab(2, path) + elif not self.is_pane3_hidden: + self.create_tab(3, path) + elif not self.is_pane4_hidden: + self.create_tab(4, path) def create_tab(self, wid, path=None):