Plugin sys changes, glade changes

This commit is contained in:
itdominator 2022-02-25 01:29:37 -06:00
parent 56b8ee6117
commit bddcc8e3e6
5 changed files with 47 additions and 57 deletions

View File

@ -15,19 +15,20 @@ def threaded(fn):
return wrapper return wrapper
class Main: class Plugin:
def __init__(self, socket_id, event_system): def __init__(self, builder, event_system):
self._plugin_name = "Example Plugin" self._plugin_name = "Example Plugin"
self._builder = builder
self._event_system = event_system self._event_system = event_system
self._socket_id = socket_id
self._gtk_plug = Gtk.Plug.new(self._socket_id)
button = Gtk.Button(label=self._plugin_name)
self._message = None self._message = None
self._time_out = 5 self._time_out = 5
button = Gtk.Button(label=self._plugin_name)
button.connect("button-release-event", self._do_action) button.connect("button-release-event", self._do_action)
self._gtk_plug.add(button)
self._gtk_plug.show_all() plugin_list = self._builder.get_object("plugin_socket")
plugin_list.add(button)
plugin_list.show_all()
@threaded @threaded

View File

@ -15,20 +15,22 @@ def threaded(fn):
return wrapper return wrapper
class Main: class Plugin:
def __init__(self, socket_id, event_system): def __init__(self, builder, event_system):
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
self._plugin_name = "Youtube Download" self._plugin_name = "Youtube Download"
self._builder = builder
self._event_system = event_system self._event_system = event_system
self._socket_id = socket_id
self._gtk_plug = Gtk.Plug.new(self._socket_id)
button = Gtk.Button(label=self._plugin_name)
self._message = None self._message = None
self._time_out = 5 self._time_out = 5
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
button = Gtk.Button(label=self._plugin_name)
button.connect("button-release-event", self._do_download) button.connect("button-release-event", self._do_download)
self._gtk_plug.add(button)
self._gtk_plug.show_all() plugin_list = self._builder.get_object("plugin_socket")
plugin_list.add(button)
plugin_list.show_all()
@threaded @threaded
@ -48,9 +50,6 @@ class Main:
def get_plugin_name(self): def get_plugin_name(self):
return self._plugin_name return self._plugin_name
def get_socket_id(self):
return self._socket_id
def _run_timeout(self): def _run_timeout(self):
timeout = 0 timeout = 0
while not self._message and timeout < self._time_out: while not self._message and timeout < self._time_out:

View File

@ -10,6 +10,7 @@
function main() { function main() {
cd "$(dirname "")" cd "$(dirname "")"
echo "Working Dir: " $(pwd) echo "Working Dir: " $(pwd)
source "/home/abaddon/Portable_Apps/py-venvs/yt-dlp-venv/venv/bin/activate"
LINK=`xclip -selection clipboard -o` LINK=`xclip -selection clipboard -o`
yt-dlp --write-sub --embed-sub --sub-langs en -o "${1}/%(title)s.%(ext)s" "${LINK}" yt-dlp --write-sub --embed-sub --sub-langs en -o "${1}/%(title)s.%(ext)s" "${LINK}"

View File

@ -13,8 +13,6 @@ from gi.repository import Gtk, Gio
class Plugin: class Plugin:
name = None name = None
module = None module = None
gtk_socket_id = None
gtk_socket = None
reference = None reference = None
@ -23,8 +21,7 @@ class Plugins:
def __init__(self, settings): def __init__(self, settings):
self._settings = settings self._settings = settings
self._plugin_list_widget = self._settings.get_builder().get_object("plugin_list") self._builder = self._settings.get_builder()
self._plugin_list_socket = self._settings.get_builder().get_object("plugin_socket")
self._plugins_path = self._settings.get_plugins_path() self._plugins_path = self._settings.get_plugins_path()
self._plugins_dir_watcher = None self._plugins_dir_watcher = None
self._plugin_collection = [] self._plugin_collection = []
@ -56,26 +53,18 @@ class Plugins:
if isdir(path): if isdir(path):
os.chdir(path) os.chdir(path)
gtk_socket = Gtk.Socket().new()
self._plugin_list_socket.add(gtk_socket)
# NOTE: Must get ID after adding socket to window. Else issues....
gtk_socket_id = gtk_socket.get_id()
sys.path.insert(0, path) sys.path.insert(0, path)
spec = importlib.util.spec_from_file_location(file, join(path, "__main__.py")) spec = importlib.util.spec_from_file_location(file, join(path, "__main__.py"))
module = importlib.util.module_from_spec(spec) app = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module) spec.loader.exec_module(app)
ref = module.Main(gtk_socket_id, event_system) plugin_reference = app.Plugin(self._builder, event_system)
plugin = Plugin() plugin = Plugin()
plugin.name = ref.get_plugin_name() plugin.name = plugin_reference.get_plugin_name()
plugin.module = path plugin.module = path
plugin.gtk_socket_id = gtk_socket_id plugin.reference = plugin_reference
plugin.gtk_socket = gtk_socket
plugin.reference = ref
self._plugin_collection.append(plugin) self._plugin_collection.append(plugin)
gtk_socket.show_all()
except Exception as e: except Exception as e:
print("Malformed plugin! Not loading!") print("Malformed plugin! Not loading!")
traceback.print_exc() traceback.print_exc()

View File

@ -1785,24 +1785,9 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="path_entry"> <object class="GtkButton" id="create_tab">
<property name="name">path_entry</property> <property name="label">gtk-add</property>
<property name="visible">True</property> <property name="name">create_tab</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="placeholder-text" translatable="yes">Path...</property>
<signal name="changed" handler="do_action_from_bar_controls" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="refresh_view">
<property name="label">gtk-refresh</property>
<property name="name">refresh_view</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">True</property> <property name="receives-default">True</property>
@ -1813,7 +1798,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -1830,13 +1815,28 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="path_entry">
<property name="name">path_entry</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="placeholder-text" translatable="yes">Path...</property>
<signal name="changed" handler="do_action_from_bar_controls" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="create_tab"> <object class="GtkButton" id="refresh_view">
<property name="label">gtk-add</property> <property name="label">gtk-refresh</property>
<property name="name">create_tab</property> <property name="name">refresh_view</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">True</property> <property name="receives-default">True</property>