Cleanup of starting file collection
This commit is contained in:
parent
ea4324911e
commit
1245951da9
|
@ -1,5 +1,4 @@
|
|||
# Python imports
|
||||
import os
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
|
@ -19,6 +18,8 @@ from .bridge_controller import BridgeController
|
|||
|
||||
class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerData):
|
||||
def __init__(self, args, unknownargs):
|
||||
self.collect_files_dirs(args, unknownargs)
|
||||
|
||||
self.setup_controller_data()
|
||||
|
||||
self._setup_styling()
|
||||
|
@ -29,14 +30,8 @@ class BaseController(IPCSignalsMixin, KeyboardSignalsMixin, BaseControllerData):
|
|||
if args.no_plugins == "false":
|
||||
self.plugins.launch_plugins()
|
||||
|
||||
for arg in unknownargs + [args.new_tab,]:
|
||||
if os.path.isfile(arg):
|
||||
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)
|
||||
for file in settings_manager.get_starting_files():
|
||||
event_system.emit("post_file_to_ipc", file)
|
||||
|
||||
logger.info(f"Made it past {self.__class__} loading...")
|
||||
|
||||
|
|
|
@ -25,6 +25,20 @@ class BaseControllerData:
|
|||
self.setup_builder_and_container()
|
||||
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):
|
||||
return self.base_container
|
||||
|
||||
|
|
|
@ -110,6 +110,8 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||
self._trace_debug = False
|
||||
self._debug = False
|
||||
self._dirty_start = False
|
||||
self._passed_in_file = False
|
||||
self._starting_files = []
|
||||
|
||||
|
||||
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_builder(self, builder) -> any: self._builder = builder
|
||||
|
||||
|
||||
def get_monitor_data(self) -> list:
|
||||
screen = self._main_window.get_screen()
|
||||
monitors = []
|
||||
|
@ -152,9 +153,11 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||
def get_home_config_path(self) -> str: return self._HOME_CONFIG_PATH
|
||||
def get_window_icon(self) -> str: return self._WINDOW_ICON
|
||||
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_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):
|
||||
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_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_starting_files(self, files: []) -> None: self._starting_files = files
|
||||
|
||||
def set_trace_debug(self, trace_debug):
|
||||
self._trace_debug = trace_debug
|
||||
|
@ -174,6 +178,8 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||
def set_debug(self, 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):
|
||||
if not path.exists(self._CONFIG_FILE):
|
||||
|
|
Loading…
Reference in New Issue