From a863dbc586d97f4fd6215c7253fb100ef489e518 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 31 Jan 2022 00:13:43 -0600 Subject: [PATCH] Plugin work on socket/plug --- plugins/example/__main__.py | 23 +++-- .../SolarFM/solarfm/controller/Controller.py | 1 - .../solarfm/controller/IPCServerMixin.py | 2 +- .../controller/mixins/ShowHideMixin.py | 6 ++ .../controller/mixins/ui/WidgetMixin.py | 2 - .../SolarFM/solarfm/plugins/Plugins.py | 17 ++-- .../usr/share/solarfm/Main_Window.glade | 84 ++++++++++++------- 7 files changed, 84 insertions(+), 51 deletions(-) diff --git a/plugins/example/__main__.py b/plugins/example/__main__.py index 004f660..b5d57b9 100644 --- a/plugins/example/__main__.py +++ b/plugins/example/__main__.py @@ -20,18 +20,17 @@ class Main: self._socket_id = socket_id self._event_system = event_system self._gtk_plug = Gtk.Plug.new(self._socket_id) - self.start_loop() - @threaded - def start_loop(self): - i = 0 - cycles = 5 - alive = True - while alive: - if i == cycles: - alive = False + button = Gtk.Button(label="Click Me!") + button.connect("button-release-event", self._do_action) + self._gtk_plug.add(button) + self._gtk_plug.show_all() - self._event_system.push_gui_event(["some_type", "display_message", ("warning", str(i), None)]) - i += 1 - time.sleep(1) + def _do_action(self, widget=None, eve=None): + message = "Hello, World!" + self._event_system.push_gui_event(["some_type", "display_message", ("warning", message, None)]) + + + def get_socket_id(self): + return self._socket_id diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller.py index ecedf6b..5b48748 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller.py @@ -62,7 +62,6 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, Controller_Data except Exception as e: print(repr(e)) - def custom_except_hook(self, exctype, value, _traceback): trace = ''.join(traceback.format_tb(_traceback)) data = f"Exectype: {exctype} <--> Value: {value}\n\n{trace}\n\n\n\n" diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/IPCServerMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/IPCServerMixin.py index a689101..7410fb8 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/IPCServerMixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/IPCServerMixin.py @@ -34,7 +34,7 @@ class IPCServerMixin: if "FILE|" in msg: file = msg.split("FILE|")[1].strip() if file: - event_system.push_gui_event([None, "handle_file_from_ipc", file]) + event_system.push_gui_event([None, "handle_file_from_ipc", (file,)]) conn.close() break diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ShowHideMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ShowHideMixin.py index 0f896fc..98ca4c6 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ShowHideMixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ShowHideMixin.py @@ -96,6 +96,12 @@ class ShowHideMixin: dialog.response(Gtk.ResponseType.OK) + def show_plugins_popup(self, widget=None, eve=None): + self.builder.get_object("plugin_list").popup() + + def hide_plugins_popup(self, widget=None, eve=None): + self.builder.get_object("plugin_list").hide() + def show_context_menu(self, widget=None, eve=None): self.builder.get_object("context_menu").run() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetMixin.py index 349cba7..b2f0648 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetMixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetMixin.py @@ -133,8 +133,6 @@ class WidgetMixin: grid.connect("button_release_event", self.grid_icon_single_click) grid.connect("item-activated", self.grid_icon_double_click) - # grid.connect("toggle-cursor-item", self.grid_cursor_toggled) - # grid.connect("notify", self.grid_cursor_toggled) grid.connect("selection-changed", self.grid_set_selected_items) grid.connect("drag-data-get", self.grid_on_drag_set) grid.connect("drag-data-received", self.grid_on_drag_data_received) diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/Plugins.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/Plugins.py index 6458eb1..d6bc67c 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/Plugins.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/Plugins.py @@ -16,15 +16,18 @@ class Plugins: """docstring for Plugins""" def __init__(self, settings): self._settings = settings + self._plugin_list_widget = self._settings.get_builder().get_object("plugin_list") + self._plugin_list_socket = self._settings.get_builder().get_object("plugin_socket") self._plugins_path = self._settings.get_plugins_path() - self.gtk_socket = Gtk.Socket().new() + self._gtk_socket = Gtk.Socket().new() self._plugins_dir_watcher = None - self.gtk_socket_id = None self._plugin_collection = [] - self._settings.get_main_window().add(self.gtk_socket) - self.gtk_socket.show() - self.gtk_socket_id = self.gtk_socket.get_id() + self._plugin_list_socket.add(self._gtk_socket) + + # NOTE: Must get ID after adding socket to window. Else issues.... + self._gtk_socket_id = self._gtk_socket.get_id() + self._plugin_list_widget.show_all() def launch_plugins(self): @@ -49,10 +52,10 @@ class Plugins: if isdir(path): spec = importlib.util.spec_from_file_location(file, join(path, "__main__.py")) module = importlib.util.module_from_spec(spec) - self._plugin_collection.append([file, module]) spec.loader.exec_module(module) - module.Main(self.gtk_socket_id, event_system) + plugin = module.Main(self._gtk_socket_id, event_system) + self._plugin_collection.append([file, plugin]) def reload_plugins(self, file=None): print(f"Reloading plugins...") diff --git a/user_config/usr/share/solarfm/Main_Window.glade b/user_config/usr/share/solarfm/Main_Window.glade index e760dc6..d15ac42 100644 --- a/user_config/usr/share/solarfm/Main_Window.glade +++ b/user_config/usr/share/solarfm/Main_Window.glade @@ -1124,7 +1124,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe - + True False gtk-justify-center @@ -1386,6 +1386,29 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe False + + + True + False + Debug + + + True + False + + + Show Errors + True + False + image3 + False + + + + + + + gtk-quit @@ -1482,29 +1505,6 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe - - - True - False - Debug - - - True - False - - - Show Errors - True - False - image1 - False - - - - - - - True @@ -1518,6 +1518,20 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe False 5 start + + + Plugins + True + True + True + + + + True + True + 0 + + tggl_notebook_1 @@ -1531,7 +1545,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe True True - 0 + 1 @@ -1547,7 +1561,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe True True - 1 + 2 @@ -1563,7 +1577,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe True True - 2 + 3 @@ -1579,7 +1593,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe True True - 3 + 4 @@ -2043,6 +2057,20 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe + + False + plugins_buttoin + + + True + False + vertical + + + + + + False 5