2022-01-23 22:56:27 +00:00
|
|
|
# Python imports
|
2023-03-29 23:41:14 +00:00
|
|
|
import os
|
2022-01-23 22:56:27 +00:00
|
|
|
|
2023-01-29 06:06:52 +00:00
|
|
|
# Lib imports
|
2022-01-23 22:56:27 +00:00
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
2022-10-14 01:58:44 +00:00
|
|
|
from gi.repository import Gtk
|
2022-01-23 22:56:27 +00:00
|
|
|
|
|
|
|
# Application imports
|
2023-03-18 20:30:29 +00:00
|
|
|
from .mixins.signals_mixins import SignalsMixins
|
2022-02-25 23:53:58 +00:00
|
|
|
from .mixins.dummy_mixin import DummyMixin
|
2022-10-14 01:58:44 +00:00
|
|
|
from .controller_data import ControllerData
|
2023-04-23 15:57:12 +00:00
|
|
|
from .containers.base_container import BaseContainer
|
2022-01-23 22:56:27 +00:00
|
|
|
|
2022-06-15 03:30:41 +00:00
|
|
|
|
2023-01-29 06:06:52 +00:00
|
|
|
|
2023-03-18 20:30:29 +00:00
|
|
|
class Controller(DummyMixin, SignalsMixins, ControllerData):
|
2022-10-14 01:58:44 +00:00
|
|
|
def __init__(self, args, unknownargs):
|
2023-03-18 21:02:05 +00:00
|
|
|
self.setup_controller_data()
|
|
|
|
|
2022-10-14 01:58:44 +00:00
|
|
|
self._setup_styling()
|
|
|
|
self._setup_signals()
|
|
|
|
self._subscribe_to_events()
|
2022-06-15 03:30:41 +00:00
|
|
|
|
2022-01-23 22:56:27 +00:00
|
|
|
self.print_hello_world() # A mixin method from the DummyMixin file
|
|
|
|
|
2023-03-28 02:25:54 +00:00
|
|
|
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)
|
|
|
|
|
2023-02-24 00:48:37 +00:00
|
|
|
logger.info(f"Made it past {self.__class__} loading...")
|
|
|
|
|
2022-10-01 04:35:03 +00:00
|
|
|
|
2022-10-14 01:58:44 +00:00
|
|
|
def _setup_styling(self):
|
|
|
|
...
|
2022-10-01 04:35:03 +00:00
|
|
|
|
2022-10-14 01:58:44 +00:00
|
|
|
def _setup_signals(self):
|
2023-03-18 21:02:05 +00:00
|
|
|
self.window.connect("focus-out-event", self.unset_keys_and_data)
|
|
|
|
self.window.connect("key-press-event", self.on_global_key_press_controller)
|
|
|
|
self.window.connect("key-release-event", self.on_global_key_release_controller)
|
2022-01-23 22:56:27 +00:00
|
|
|
|
2022-10-14 01:58:44 +00:00
|
|
|
def _subscribe_to_events(self):
|
2023-10-19 00:00:33 +00:00
|
|
|
event_system.subscribe("shutting_down", lambda: print("Shutting down..."))
|
2022-10-14 01:58:44 +00:00
|
|
|
event_system.subscribe("handle_file_from_ipc", self.handle_file_from_ipc)
|
2023-03-28 02:25:54 +00:00
|
|
|
event_system.subscribe("handle_dir_from_ipc", self.handle_dir_from_ipc)
|
2023-03-19 20:37:43 +00:00
|
|
|
event_system.subscribe("tggl_top_main_menubar", self._tggl_top_main_menubar)
|
2022-01-23 22:56:27 +00:00
|
|
|
|
2023-04-28 04:27:53 +00:00
|
|
|
def _tggl_top_main_menubar(self):
|
2023-04-29 14:27:21 +00:00
|
|
|
logger.debug("_tggl_top_main_menubar > stub...")
|
2023-04-28 04:27:53 +00:00
|
|
|
|
2023-04-23 15:57:12 +00:00
|
|
|
def setup_builder_and_container(self):
|
2022-10-14 01:58:44 +00:00
|
|
|
self.builder = Gtk.Builder()
|
2023-07-30 05:36:52 +00:00
|
|
|
self.builder.add_from_file(settings_manager.get_glade_file())
|
2023-02-24 00:48:37 +00:00
|
|
|
self.builder.expose_object("main_window", self.window)
|
|
|
|
|
2023-07-30 05:36:52 +00:00
|
|
|
settings_manager.set_builder(self.builder)
|
2023-04-23 15:57:12 +00:00
|
|
|
self.base_container = BaseContainer()
|
2022-10-14 01:58:44 +00:00
|
|
|
|
2023-07-30 05:36:52 +00:00
|
|
|
settings_manager.register_signals_to_builder([self, self.base_container])
|
2022-10-14 01:58:44 +00:00
|
|
|
|
2023-04-23 15:57:12 +00:00
|
|
|
def get_base_container(self):
|
|
|
|
return self.base_container
|