2022-01-30 20:29:57 -06:00
|
|
|
# Python imports
|
2022-11-28 22:34:13 -06:00
|
|
|
import os
|
|
|
|
import threading
|
|
|
|
import subprocess
|
2022-01-30 20:29:57 -06:00
|
|
|
|
2022-07-20 23:57:06 -05:00
|
|
|
# Lib imports
|
2022-01-30 20:29:57 -06:00
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
from gi.repository import Gtk
|
|
|
|
|
|
|
|
# Application imports
|
2022-09-05 21:21:04 -05:00
|
|
|
from plugins.plugin_base import PluginBase
|
2022-01-30 20:29:57 -06:00
|
|
|
|
|
|
|
|
2022-06-18 22:27:17 -05:00
|
|
|
# NOTE: Threads WILL NOT die with parent's destruction.
|
2022-01-30 20:29:57 -06:00
|
|
|
def threaded(fn):
|
|
|
|
def wrapper(*args, **kwargs):
|
2022-02-01 01:43:09 -06:00
|
|
|
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=False).start()
|
2022-01-30 20:29:57 -06:00
|
|
|
return wrapper
|
|
|
|
|
2022-06-18 22:27:17 -05:00
|
|
|
# NOTE: Threads WILL die with parent's destruction.
|
2022-06-14 23:03:04 -05:00
|
|
|
def daemon_threaded(fn):
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-30 20:29:57 -06:00
|
|
|
|
2022-09-05 21:21:04 -05:00
|
|
|
class Plugin(PluginBase):
|
2022-07-06 23:19:41 -05:00
|
|
|
def __init__(self):
|
2022-09-05 21:21:04 -05:00
|
|
|
super().__init__()
|
|
|
|
|
2023-02-20 19:18:45 -06:00
|
|
|
self.name = "Example Plugin" # NOTE: Need to remove after establishing private bidirectional 1-1 message bus
|
|
|
|
# where self.name should not be needed for message comms
|
|
|
|
# self.path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
# self._GLADE_FILE = f"{self.path}/glade_file.glade"
|
2022-01-30 20:29:57 -06:00
|
|
|
|
2022-02-01 01:43:09 -06:00
|
|
|
|
2022-07-06 23:19:41 -05:00
|
|
|
def run(self):
|
2023-02-20 19:18:45 -06:00
|
|
|
# self._builder = Gtk.Builder()
|
|
|
|
# self._builder.add_from_file(self._GLADE_FILE)
|
|
|
|
# self._connect_builder_signals(self, self._builder)
|
2022-09-29 17:22:33 -05:00
|
|
|
...
|
2022-02-01 01:43:09 -06:00
|
|
|
|
2023-04-29 09:44:22 -05:00
|
|
|
def generate_reference_ui_element(self):
|
|
|
|
button = Gtk.Button(label=self.name)
|
|
|
|
button.connect("button-release-event", self.send_message)
|
|
|
|
return button
|
|
|
|
|
2022-06-18 22:27:17 -05:00
|
|
|
def send_message(self, widget=None, eve=None):
|
|
|
|
message = "Hello, World!"
|
2022-09-30 23:30:38 -05:00
|
|
|
event_system.emit("display_message", ("warning", message, None))
|