2022-09-05 23:01:39 +00:00
|
|
|
# Python imports
|
2023-01-29 06:06:52 +00:00
|
|
|
import os
|
|
|
|
import threading
|
|
|
|
import subprocess
|
|
|
|
import time
|
2022-09-05 23:01:39 +00:00
|
|
|
|
|
|
|
# Lib imports
|
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
from gi.repository import Gtk
|
|
|
|
|
|
|
|
# Application imports
|
2022-10-14 01:58:44 +00:00
|
|
|
from plugins.plugin_base import PluginBase
|
2022-09-05 23:01:39 +00:00
|
|
|
|
|
|
|
|
2023-01-29 06:06:52 +00:00
|
|
|
|
|
|
|
|
2022-09-05 23:01:39 +00:00
|
|
|
# NOTE: Threads WILL NOT die with parent's destruction.
|
|
|
|
def threaded(fn):
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=False).start()
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
# NOTE: Threads WILL die with parent's destruction.
|
|
|
|
def daemon_threaded(fn):
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-14 01:58:44 +00:00
|
|
|
class Plugin(PluginBase):
|
2022-09-05 23:01:39 +00:00
|
|
|
def __init__(self):
|
2022-10-14 01:58:44 +00:00
|
|
|
super().__init__()
|
|
|
|
|
2022-09-05 23:01:39 +00: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
|
|
|
|
|
|
|
|
|
2022-10-14 01:58:44 +00:00
|
|
|
def generate_reference_ui_element(self):
|
2022-09-05 23:01:39 +00:00
|
|
|
button = Gtk.Button(label=self.name)
|
|
|
|
button.connect("button-release-event", self.send_message)
|
|
|
|
return button
|
|
|
|
|
|
|
|
def run(self):
|
2022-10-14 01:58:44 +00:00
|
|
|
...
|
2022-09-05 23:01:39 +00:00
|
|
|
|
|
|
|
def send_message(self, widget=None, eve=None):
|
|
|
|
message = "Hello, World!"
|
2022-10-14 01:58:44 +00:00
|
|
|
event_system.emit("display_message", ("warning", message, None))
|