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-09-10 05:24:47 +00:00
|
|
|
messages = []
|
|
|
|
for arg in unknownargs + [args.new_tab,]:
|
2023-09-13 03:14:31 +00:00
|
|
|
# NOTE: If passing line number with file split against :
|
|
|
|
if os.path.isfile(arg.replace("file://", "").split(":")[0]):
|
|
|
|
messages.append(f"FILE|{arg.replace('file://', '')}")
|
2023-09-10 05:24:47 +00:00
|
|
|
|
|
|
|
if len(messages) > 0:
|
2023-10-03 23:22:36 +00:00
|
|
|
settings_manager.set_is_starting_with_file(True)
|
2023-09-10 05:24:47 +00:00
|
|
|
|
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()
|
|
|
|
|
2023-09-10 05:24:47 +00:00
|
|
|
for message in messages:
|
|
|
|
event_system.emit("post_file_to_ipc", message)
|
2023-03-26 06:07:35 +00:00
|
|
|
|
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)
|
2023-10-10 04:07:10 +00:00
|
|
|
event_system.subscribe("set_active_src_view", self.set_active_src_view)
|
|
|
|
event_system.subscribe("get_active_src_view", self.get_active_src_view)
|
2023-03-18 04:17:38 +00:00
|
|
|
|
|
|
|
def load_glade_file(self):
|
|
|
|
self.builder = Gtk.Builder()
|
2023-10-03 23:22:36 +00:00
|
|
|
self.builder.add_from_file(settings_manager.get_glade_file())
|
2023-03-18 04:17:38 +00:00
|
|
|
self.builder.expose_object("main_window", self.window)
|
|
|
|
|
2023-10-03 23:22:36 +00:00
|
|
|
settings_manager.set_builder(self.builder)
|
2023-03-18 04:17:38 +00:00
|
|
|
self.core_widget = CoreWidget()
|
|
|
|
|
2023-10-03 23:22:36 +00:00
|
|
|
settings_manager.register_signals_to_builder([self, self.core_widget])
|
2023-03-18 04:17:38 +00:00
|
|
|
|
|
|
|
def get_core_widget(self):
|
2023-10-12 04:32:02 +00:00
|
|
|
return self.core_widget
|