Cleanup of starting file collection

This commit is contained in:
itdominator 2024-02-16 20:13:22 -06:00
parent ea4324911e
commit 1245951da9
3 changed files with 25 additions and 10 deletions

View File

@ -1,5 +1,4 @@
# Python imports # Python imports
import os
# Lib imports # Lib imports
import gi import gi
@ -19,6 +18,8 @@ from .bridge_controller import BridgeController
class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerData): class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerData):
def __init__(self, args, unknownargs): def __init__(self, args, unknownargs):
self.collect_files_dirs(args, unknownargs)
self.setup_controller_data() self.setup_controller_data()
self._setup_styling() self._setup_styling()
@ -29,14 +30,8 @@ class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerData):
if args.no_plugins == "false": if args.no_plugins == "false":
self.plugins.launch_plugins() self.plugins.launch_plugins()
for arg in unknownargs + [args.new_tab,]: for file in settings_manager.get_starting_files():
if os.path.isfile(arg): event_system.emit("post_file_to_ipc", file)
message = f"FILE|{arg}"
event_system.emit("post_file_to_ipc", message)
if os.path.isdir(arg):
message = f"DIR|{arg}"
event_system.emit("post_file_to_ipc", message)
logger.info(f"Made it past {self.__class__} loading...") logger.info(f"Made it past {self.__class__} loading...")

View File

@ -25,6 +25,20 @@ class BaseControllerData:
self.setup_builder_and_container() self.setup_builder_and_container()
self.plugins = PluginsController() self.plugins = PluginsController()
def collect_files_dirs(self, args, unknownargs):
files = []
for arg in unknownargs + [args.new_tab,]:
if os.path.isdir( arg.replace("file://", "") ):
files.append( f"DIR|{arg.replace('file://', '')}" )
# NOTE: If passing line number with file split against :
if os.path.isfile( arg.replace("file://", "").split(":")[0] ):
files.append( f"FILE|{arg.replace('file://', '')}" )
if len(files) > 0:
settings_manager.set_is_starting_with_file(True)
settings_manager.set_starting_files(files)
def get_base_container(self): def get_base_container(self):
return self.base_container return self.base_container

View File

@ -110,6 +110,8 @@ class SettingsManager(StartCheckMixin, Singleton):
self._trace_debug = False self._trace_debug = False
self._debug = False self._debug = False
self._dirty_start = False self._dirty_start = False
self._passed_in_file = False
self._starting_files = []
def register_signals_to_builder(self, classes=None): def register_signals_to_builder(self, classes=None):
@ -128,7 +130,6 @@ class SettingsManager(StartCheckMixin, Singleton):
def set_main_window(self, window): self._main_window = window def set_main_window(self, window): self._main_window = window
def set_builder(self, builder) -> any: self._builder = builder def set_builder(self, builder) -> any: self._builder = builder
def get_monitor_data(self) -> list: def get_monitor_data(self) -> list:
screen = self._main_window.get_screen() screen = self._main_window.get_screen()
monitors = [] monitors = []
@ -152,9 +153,11 @@ class SettingsManager(StartCheckMixin, Singleton):
def get_home_config_path(self) -> str: return self._HOME_CONFIG_PATH def get_home_config_path(self) -> str: return self._HOME_CONFIG_PATH
def get_window_icon(self) -> str: return self._WINDOW_ICON def get_window_icon(self) -> str: return self._WINDOW_ICON
def get_home_path(self) -> str: return self._USER_HOME def get_home_path(self) -> str: return self._USER_HOME
def get_starting_files(self) -> []: return self._starting_files
def is_trace_debug(self) -> str: return self._trace_debug def is_trace_debug(self) -> str: return self._trace_debug
def is_debug(self) -> str: return self._debug def is_debug(self) -> str: return self._debug
def is_starting_with_file(self) -> bool: return self._passed_in_file
def call_method(self, target_class = None, _method_name = None, data = None): def call_method(self, target_class = None, _method_name = None, data = None):
method_name = str(_method_name) method_name = str(_method_name)
@ -167,6 +170,7 @@ class SettingsManager(StartCheckMixin, Singleton):
def set_main_window_height(self, height = 600): self.settings.config.main_window_height = height def set_main_window_height(self, height = 600): self.settings.config.main_window_height = height
def set_main_window_min_width(self, width = 720): self.settings.config.main_window_min_width = width def set_main_window_min_width(self, width = 720): self.settings.config.main_window_min_width = width
def set_main_window_min_height(self, height = 480): self.settings.config.main_window_min_height = height def set_main_window_min_height(self, height = 480): self.settings.config.main_window_min_height = height
def set_starting_files(self, files: []) -> None: self._starting_files = files
def set_trace_debug(self, trace_debug): def set_trace_debug(self, trace_debug):
self._trace_debug = trace_debug self._trace_debug = trace_debug
@ -174,6 +178,8 @@ class SettingsManager(StartCheckMixin, Singleton):
def set_debug(self, debug): def set_debug(self, debug):
self._debug = debug self._debug = debug
def set_is_starting_with_file(self, is_passed_in_file: False):
self._passed_in_file = is_passed_in_file
def load_settings(self): def load_settings(self):
if not path.exists(self._CONFIG_FILE): if not path.exists(self._CONFIG_FILE):