Refactor plugin event API: rename message* to emit* and requests_ui_element to request_ui_element
This commit is contained in:
3
plugins/code/telescope/__init__.py
Normal file
3
plugins/code/telescope/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Pligin Module
|
||||
"""
|
||||
3
plugins/code/telescope/__main__.py
Normal file
3
plugins/code/telescope/__main__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Pligin Package
|
||||
"""
|
||||
7
plugins/code/telescope/manifest.json
Normal file
7
plugins/code/telescope/manifest.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Telescope",
|
||||
"author": "ITDominator",
|
||||
"version": "0.0.1",
|
||||
"support": "",
|
||||
"requests": {}
|
||||
}
|
||||
53
plugins/code/telescope/plugin.py
Normal file
53
plugins/code/telescope/plugin.py
Normal 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()
|
||||
55
plugins/code/telescope/telescope.py
Normal file
55
plugins/code/telescope/telescope.py
Normal 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()
|
||||
|
||||
Reference in New Issue
Block a user