diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/__init__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/__init__.py index 68a0396..a3de649 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/__init__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/__init__.py @@ -33,7 +33,7 @@ class Main(Builtins): settings = Settings() - settings.createWindow() + settings.create_window() controller = Controller(args, unknownargs, settings) if not controller: diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller.py index fe9ca6b..5673203 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller.py @@ -8,8 +8,8 @@ from gi.repository import Gtk, GLib # Application imports from .mixins.ui import * -from .mixins import PluginMixin -from . import ShowHideMixin, KeyboardSignalsMixin, Controller_Data +from .mixins import ShowHideMixin, KeyboardSignalsMixin +from . import Controller_Data def threaded(fn): @@ -21,13 +21,13 @@ def threaded(fn): class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \ - KeyboardSignalsMixin, PluginMixin, Controller_Data): + KeyboardSignalsMixin, Controller_Data): def __init__(self, args, unknownargs, _settings): # sys.excepthook = self.custom_except_hook self.setup_controller_data(_settings) self.window.show() self.generate_windows(self.state) - self.load_plugins() + self.plugins.launch_plugins() if not trace_debug: self.gui_event_observer() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller_Data.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller_Data.py index 83ed9d2..2fd4f62 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller_Data.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller_Data.py @@ -7,6 +7,7 @@ from gi.repository import GLib # Application imports from shellfm import WindowController from trasher.xdgtrash import XDGTrash +from . import Plugins @@ -18,6 +19,7 @@ class Controller_Data: def setup_controller_data(self, _settings): self.trashman = XDGTrash() self.window_controller = WindowController() + self.plugins = Plugins(_settings) self.state = self.window_controller.load_state() self.trashman.regenerate() @@ -91,7 +93,6 @@ class Controller_Data: self.search_iconview = None self.search_view = None - self.skip_edit = False self.cancel_edit = False self.ctrlDown = False diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Plugins.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Plugins.py new file mode 100644 index 0000000..8715aac --- /dev/null +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Plugins.py @@ -0,0 +1,41 @@ +# Python imports +import importlib + +# Lib imports +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk, Gio + +# Application imports + + + + +class Plugins: + """docstring for Plugins""" + def __init__(self, settings): + self._settings = settings + self._plugins_path = self._settings.get_plugins_path() + self._plugins_dir_watcher = None + self._socket = Gtk.Socket().new() + + def launch_plugins(self): + self._set_plugins_watcher() + self.load_plugins() + + def _set_plugins_watcher(self): + self._plugins_dir_watcher = Gio.File.new_for_path(self._plugins_path) \ + .monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, Gio.Cancellable()) + self._plugins_dir_watcher.connect("changed", self._on_plugins_changed, ()) + + def _on_plugins_changed(self, file_monitor, file, other_file=None, eve_type=None, data=None): + if eve_type in [Gio.FileMonitorEvent.CREATED, Gio.FileMonitorEvent.DELETED, + Gio.FileMonitorEvent.RENAMED, Gio.FileMonitorEvent.MOVED_IN, + Gio.FileMonitorEvent.MOVED_OUT]: + self.load_plugins(file) + + def load_plugins(self, file=None): + print(f"(Re)loading plugins...") + print(locals()) + + # importlib.reload(stl_utils) diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/__init__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/__init__.py index d59fd4f..314f976 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/__init__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/__init__.py @@ -2,8 +2,7 @@ Gtk Bound Signal Module """ from .mixins import * -from .KeyboardSignalsMixin import KeyboardSignalsMixin -from .ShowHideMixin import ShowHideMixin from .IPCServerMixin import IPCServerMixin +from .Plugins import Plugins from .Controller_Data import Controller_Data from .Controller import Controller diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/KeyboardSignalsMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/KeyboardSignalsMixin.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/KeyboardSignalsMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/KeyboardSignalsMixin.py diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/PluginMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/PluginMixin.py deleted file mode 100644 index 35a7400..0000000 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/PluginMixin.py +++ /dev/null @@ -1,17 +0,0 @@ -# Python imports - -# Lib imports -import gi -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk - -# Application imports - - - - -class PluginMixin: - """docstring for TabMixin""" - - def load_plugins(self): - pass diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/ShowHideMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ShowHideMixin.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/ShowHideMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ShowHideMixin.py diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/__init__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/__init__.py index 2b42bbb..e457cb5 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/__init__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/__init__.py @@ -1 +1,2 @@ -from .PluginMixin import PluginMixin +from .KeyboardSignalsMixin import KeyboardSignalsMixin +from .ShowHideMixin import ShowHideMixin diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/utils/Settings.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/utils/Settings.py index d312773..380210a 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/utils/Settings.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/utils/Settings.py @@ -50,12 +50,12 @@ class Settings: - def createWindow(self): + def create_window(self): # Get window and connect signals self.main_window = self.builder.get_object("Main_Window") - self.setWindowData() + self._set_window_data() - def setWindowData(self): + def _set_window_data(self): self.main_window.set_icon_from_file(self.window_icon) screen = self.main_window.get_screen() visual = screen.get_rgba_visual() @@ -63,7 +63,7 @@ class Settings: if visual != None and screen.is_composited(): self.main_window.set_visual(visual) self.main_window.set_app_paintable(True) - self.main_window.connect("draw", self.area_draw) + self.main_window.connect("draw", self._area_draw) # bind css file cssProvider = gtk.CssProvider() @@ -72,18 +72,13 @@ class Settings: styleContext = gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER) - def area_draw(self, widget, cr): + def _area_draw(self, widget, cr): cr.set_source_rgba(0, 0, 0, 0.54) cr.set_operator(cairo.OPERATOR_SOURCE) cr.paint() cr.set_operator(cairo.OPERATOR_OVER) - def get_builder(self): return self.builder - def get_logger(self): return self.logger - def get_main_window(self): return self.main_window - - - def getMonitorData(self): + def get_monitor_data(self): screen = self.builder.get_object("Main_Window").get_screen() monitors = [] for m in range(screen.get_n_monitors()): @@ -93,3 +88,8 @@ class Settings: print("{}x{}+{}+{}".format(monitor.width, monitor.height, monitor.x, monitor.y)) return monitors + + def get_builder(self): return self.builder + def get_logger(self): return self.logger + def get_main_window(self): return self.main_window + def get_plugins_path(self): return self.PLUGINS_PATH