develop #1

Merged
itdominator merged 11 commits from develop into master 2024-02-11 01:53:01 +00:00
4 changed files with 42 additions and 40 deletions
Showing only changes of commit 873b415f47 - Show all commits

View File

@ -10,9 +10,6 @@ import tracemalloc
tracemalloc.start() tracemalloc.start()
# Lib imports # Lib imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# Application imports # Application imports
from __builtins__ import * from __builtins__ import *
@ -47,7 +44,6 @@ if __name__ == "__main__":
settings_manager.do_dirty_start_check() settings_manager.do_dirty_start_check()
Application(args, unknownargs) Application(args, unknownargs)
Gtk.main()
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
quit() quit()

View File

@ -34,8 +34,7 @@ class Application(IPCServer):
raise AppLaunchException(f"{app_name} IPC Server Exists: Have sent path(s) to it and closing...") raise AppLaunchException(f"{app_name} IPC Server Exists: Have sent path(s) to it and closing...")
self.setup_debug_hook() self.setup_debug_hook()
Window(args, unknownargs) Window(args, unknownargs).main()
def socket_realization_check(self): def socket_realization_check(self):
try: try:

View File

@ -20,11 +20,19 @@ class KeyboardSignalsMixin:
""" KeyboardSignalsMixin keyboard hooks controller. """ """ KeyboardSignalsMixin keyboard hooks controller. """
# TODO: Need to set methods that use this to somehow check the keybindings state instead. # TODO: Need to set methods that use this to somehow check the keybindings state instead.
def unset_keys_and_data(self, widget=None, eve=None): def unset_keys_and_data(self, widget = None, eve = None):
self.ctrl_down = False self.ctrl_down = False
self.shift_down = False self.shift_down = False
self.alt_down = False self.alt_down = False
def unmap_special_keys(self, keyname):
if "control" in keyname:
self.ctrl_down = False
if "shift" in keyname:
self.shift_down = False
if "alt" in keyname:
self.alt_down = False
def on_global_key_press_controller(self, eve, user_data): def on_global_key_press_controller(self, eve, user_data):
keyname = Gdk.keyval_name(user_data.keyval).lower() keyname = Gdk.keyval_name(user_data.keyval).lower()
modifiers = Gdk.ModifierType(user_data.get_state() & ~Gdk.ModifierType.LOCK_MASK) modifiers = Gdk.ModifierType(user_data.get_state() & ~Gdk.ModifierType.LOCK_MASK)
@ -46,15 +54,8 @@ class KeyboardSignalsMixin:
if keyname.replace("_l", "").replace("_r", "") in ["control", "alt", "shift"]: if keyname.replace("_l", "").replace("_r", "") in ["control", "alt", "shift"]:
should_return = self.was_midified_key and (self.ctrl_down or self.shift_down or self.alt_down) should_return = self.was_midified_key and (self.ctrl_down or self.shift_down or self.alt_down)
self.unmap_special_keys(keyname)
if "control" in keyname:
self.ctrl_down = False
if "shift" in keyname:
self.shift_down = False
if "alt" in keyname:
self.alt_down = False
# NOTE: In effect a filter after releasing a modifier and we have a modifier mapped
if should_return: if should_return:
self.was_midified_key = False self.was_midified_key = False
return return
@ -65,30 +66,33 @@ class KeyboardSignalsMixin:
logger.debug(f"on_global_key_release_controller > mapping > {mapping}") logger.debug(f"on_global_key_release_controller > mapping > {mapping}")
if mapping: if mapping:
# See if in controller scope self.handle_mapped_key_event(mapping)
else:
self.handle_as_key_event_scope(mapping)
def handle_mapped_key_event(self, mapping):
try: try:
getattr(self, mapping)() self.handle_as_controller_scope()
return True
except Exception: except Exception:
# Must be plugins scope, event call, OR we forgot to add method to controller scope self.handle_as_plugin_scope(mapping)
def handle_as_controller_scope(self, mapping):
getattr(self, mapping)()
def handle_as_plugin_scope(self, mapping):
if "||" in mapping: if "||" in mapping:
sender, eve_type = mapping.split("||") sender, eve_type = mapping.split("||")
else: else:
sender = "" sender = ""
eve_type = mapping eve_type = mapping
self.handle_key_event_system(sender, eve_type) self.handle_as_key_event_system(sender, eve_type)
else:
def handle_as_key_event_scope(self, mapping):
logger.debug(f"on_global_key_release_controller > key > {keyname}") logger.debug(f"on_global_key_release_controller > key > {keyname}")
if self.ctrl_down: if self.ctrl_down and not keyname in ["1", "kp_1", "2", "kp_2", "3", "kp_3", "4", "kp_4"]:
if not keyname in ["1", "kp_1", "2", "kp_2", "3", "kp_3", "4", "kp_4"]:
self.handle_key_event_system(None, mapping) self.handle_key_event_system(None, mapping)
else:
...
def handle_key_event_system(self, sender, eve_type): def handle_key_event_system(self, sender, eve_type):
event_system.emit(eve_type) event_system.emit(eve_type)
def keyboard_close_tab(self):
...

View File

@ -14,12 +14,12 @@ from gi.repository import GLib
from core.controller import Controller from core.controller import Controller
class ControllerStartExceptiom(Exception): class ControllerStartExceptiom(Exception):
... ...
class Window(Gtk.ApplicationWindow): class Window(Gtk.ApplicationWindow):
""" docstring for Window. """ """ docstring for Window. """
@ -119,3 +119,6 @@ class Window(Gtk.ApplicationWindow):
settings_manager.clear_pid() settings_manager.clear_pid()
Gtk.main_quit() Gtk.main_quit()
def main(self):
Gtk.main()