Refactor plugin event API: rename message* to emit* and requests_ui_element to request_ui_element

This commit is contained in:
2026-02-28 19:48:41 -06:00
parent 72fcccc8a9
commit a52d5243ab
32 changed files with 208 additions and 90 deletions

View File

@@ -0,0 +1,3 @@
"""
Pligin Module
"""

View File

@@ -0,0 +1,3 @@
"""
Pligin Package
"""

View File

@@ -0,0 +1,7 @@
{
"name": "Telescope",
"author": "ITDominator",
"version": "0.0.1",
"support": "",
"requests": {}
}

View File

@@ -0,0 +1,53 @@
# Python imports
# Lib imports
# Application imports
from libs.event_factory import Event_Factory, Code_Event_Types
from plugins.plugin_types import PluginCode
from .telescope import Telescope
telescope = Telescope()
class Plugin(PluginCode):
def __init__(self):
super(Plugin, self).__init__()
def _controller_message(self, event: Code_Event_Types.CodeEvent):
if isinstance(event, Code_Event_Types.FocusedViewEvent):
...
def load(self):
window = self.request_ui_element("main-window")
telescope.set_transient_for(window)
event = Event_Factory.create_event("register_command",
command_name = "telescope",
command = Handler,
binding_mode = "released",
binding = "<Control>b"
)
self.emit_to("source_views", event)
def run(self):
...
class Handler:
@staticmethod
def execute(
view: any,
*args,
**kwargs
):
logger.debug("Command: Telescope")
telescope.hide() if telescope.is_visible() else telescope.show()

View File

@@ -0,0 +1,55 @@
# Python imports
# Lib imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
# Application imports
class Telescope(Gtk.Window):
def __init__(self):
super(Telescope, self).__init__(Gtk.WindowType.POPUP)
self._setup_styling()
self._setup_signals()
self._subscribe_to_events()
self._load_widgets()
def _setup_styling(self):
self.set_decorated(False)
self.set_modal(False)
self.set_destroy_with_parent(True)
self.set_skip_pager_hint(True)
self.set_skip_taskbar_hint(True)
self.set_size_request(620, 480)
self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
def _setup_signals(self):
# self.connect("page-added", self._page_added)
...
def _subscribe_to_events(self):
...
def _load_widgets(self):
main_box = Gtk.Box()
left_box = Gtk.Box()
list_box = Gtk.ListBox()
search_entry = Gtk.SearchEntry()
left_box.set_orientation(Gtk.Orientation.VERTICAL)
list_box.set_vexpand(True)
list_box.set_size_request(120, -1)
left_box.add(list_box)
left_box.add(search_entry)
main_box.add(left_box)
self.add(main_box)
main_box.show_all()