2023-03-18 04:17:38 +00:00
|
|
|
# Python imports
|
2023-03-26 06:07:35 +00:00
|
|
|
import os
|
2023-03-18 04:17:38 +00:00
|
|
|
|
|
|
|
# Lib imports
|
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
gi.require_version('Gdk', '3.0')
|
|
|
|
from gi.repository import Gtk
|
|
|
|
from gi.repository import Gdk
|
|
|
|
from gi.repository import GLib
|
|
|
|
|
|
|
|
# Application imports
|
|
|
|
from .controller_data import ControllerData
|
|
|
|
from .core_widget import CoreWidget
|
2023-03-18 22:04:31 +00:00
|
|
|
from .mixins.signals_mixins import SignalsMixins
|
2023-03-18 04:17:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-18 22:04:31 +00:00
|
|
|
class Controller(SignalsMixins, ControllerData):
|
2023-03-18 04:17:38 +00:00
|
|
|
def __init__(self, args, unknownargs):
|
2023-03-18 22:04:31 +00:00
|
|
|
self.setup_controller_data()
|
|
|
|
|
2023-03-18 04:17:38 +00:00
|
|
|
self._setup_styling()
|
|
|
|
self._setup_signals()
|
|
|
|
self._subscribe_to_events()
|
|
|
|
|
2023-03-26 06:07:35 +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)
|
|
|
|
|
2023-03-18 04:17:38 +00:00
|
|
|
|
|
|
|
def _setup_styling(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def _setup_signals(self):
|
2023-03-18 22:04:31 +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)
|
2023-03-18 04:17:38 +00:00
|
|
|
|
|
|
|
def _subscribe_to_events(self):
|
|
|
|
event_system.subscribe("handle_file_from_ipc", self.handle_file_from_ipc)
|
|
|
|
|
|
|
|
def load_glade_file(self):
|
|
|
|
self.builder = Gtk.Builder()
|
|
|
|
self.builder.add_from_file(settings.get_glade_file())
|
|
|
|
self.builder.expose_object("main_window", self.window)
|
|
|
|
|
|
|
|
settings.set_builder(self.builder)
|
|
|
|
self.core_widget = CoreWidget()
|
|
|
|
|
|
|
|
settings.register_signals_to_builder([self, self.core_widget])
|
|
|
|
|
|
|
|
def get_core_widget(self):
|
|
|
|
return self.core_widget
|