SolarFM/plugins/git_clone/plugin.py

51 lines
1.3 KiB
Python
Raw Normal View History

2023-01-07 20:15:06 +00:00
# Python imports
2023-02-21 01:18:45 +00:00
import os
import threading
import subprocess
import time
2023-01-07 20:15:06 +00:00
# Lib imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# Application imports
from plugins.plugin_base import PluginBase
# 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
class Plugin(PluginBase):
def __init__(self):
super().__init__()
self.name = "Git Clone" # NOTE: Need to remove after establishing private bidirectional 1-1 message bus
# where self.name should not be needed for message comms
2023-02-21 01:18:45 +00:00
self.path = os.path.dirname(os.path.realpath(__file__))
2023-01-07 20:15:06 +00:00
def generate_reference_ui_element(self):
button = Gtk.Button(label=self.name)
button.connect("button-release-event", self._do_download)
return button
def run(self):
...
def _do_download(self, widget=None, eve=None):
self._event_system.emit("get_current_state")
dir = self._fm_state.tab.get_current_directory()
self._download(dir)
@threaded
def _download(self, dir):
subprocess.Popen([f'{self.path}/download.sh', dir])