diff --git a/plugins/README.txt b/plugins/README.txt new file mode 100644 index 0000000..4173ddd --- /dev/null +++ b/plugins/README.txt @@ -0,0 +1,2 @@ +### Note +Copy the example and rename it to your desired name. The Main class and passed in arguments are required. You don't necessarily need to use the passed in socket_id or event_system. diff --git a/plugins/example/__main__.py b/plugins/example/__main__.py new file mode 100644 index 0000000..004f660 --- /dev/null +++ b/plugins/example/__main__.py @@ -0,0 +1,37 @@ +# Python imports +import sys, traceback, threading, inspect, os, time + +# Gtk imports +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk + +# Application imports + + +def threaded(fn): + def wrapper(*args, **kwargs): + threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start() + return wrapper + + +class Main: + def __init__(self, socket_id, event_system): + 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 + + self._event_system.push_gui_event(["some_type", "display_message", ("warning", str(i), None)]) + i += 1 + + time.sleep(1) diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py index 3ac749f..42391a5 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py @@ -4,7 +4,7 @@ import builtins # Lib imports # Application imports -from signal_classes import IPCServerMixin +from controller import IPCServerMixin @@ -13,7 +13,10 @@ class Builtins(IPCServerMixin): """Docstring for __builtins__ extender""" def __init__(self): - # NOTE: The format used is list of [type, target, data] + # NOTE: The format used is list of [type, target, data] Where: + # type is useful context for control flow, + # target is the method to call, + # data is the method parameters to give # Where data may be any kind of data self._gui_events = [] self._fm_events = [] @@ -66,7 +69,7 @@ class Builtins(IPCServerMixin): # NOTE: Just reminding myself we can add to builtins two different ways... # __builtins__.update({"event_system": Builtins()}) -builtins.app_name = "SolarFM" +builtins.app_name = "SolarFM" builtins.event_system = Builtins() builtins.event_sleep_time = 0.2 builtins.debug = False 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 a3de649..cb48f8c 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/__init__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/__init__.py @@ -5,7 +5,7 @@ import os, inspect, time # Application imports from utils import Settings -from signal_classes import Controller +from controller import Controller from __builtins__ import Builtins diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller.py similarity index 92% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller.py index 5673203..ecedf6b 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller.py @@ -7,8 +7,8 @@ gi.require_version('Gtk', '3.0') from gi.repository import Gtk, GLib # Application imports -from .mixins.ui import * -from .mixins import ShowHideMixin, KeyboardSignalsMixin +from .mixins import UIMixin +from .signals import IPCSignalsMixin, KeyboardSignalsMixin from . import Controller_Data @@ -20,10 +20,9 @@ def threaded(fn): -class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \ - KeyboardSignalsMixin, Controller_Data): +class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, Controller_Data): def __init__(self, args, unknownargs, _settings): - # sys.excepthook = self.custom_except_hook + sys.excepthook = self.custom_except_hook self.setup_controller_data(_settings) self.window.show() self.generate_windows(self.state) @@ -58,8 +57,8 @@ class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \ if event: try: type, target, data = event - method = getattr(self.__class__, type) - GLib.idle_add(method, (self, data,)) + method = getattr(self.__class__, target) + GLib.idle_add(method, *(self, *data,)) except Exception as e: print(repr(e)) @@ -157,9 +156,7 @@ class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \ if action == "empty_trash": self.empty_trash() - if action == "create": self.create_files() - self.hide_new_file_menu() self.ctrlDown = False 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/controller/Controller_Data.py similarity index 99% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller_Data.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller_Data.py index 95d8008..fe97040 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Controller_Data.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/Controller_Data.py @@ -5,9 +5,9 @@ import signal from gi.repository import GLib # Application imports -from shellfm import WindowController from trasher.xdgtrash import XDGTrash -from . import Plugins +from shellfm import WindowController +from plugins import Plugins diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/IPCServerMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/IPCServerMixin.py similarity index 94% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/IPCServerMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/IPCServerMixin.py index be92ace..a689101 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/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(["create_tab_from_ipc", None, 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/signal_classes/__init__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/__init__.py similarity index 86% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/__init__.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/__init__.py index 314f976..52c4098 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/__init__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/__init__.py @@ -3,6 +3,5 @@ """ from .mixins import * 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/mixins/ShowHideMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ShowHideMixin.py similarity index 93% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ShowHideMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ShowHideMixin.py index 49b29d8..0f896fc 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ShowHideMixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ShowHideMixin.py @@ -16,7 +16,6 @@ class ShowHideMixin: def stop_file_searching(self, widget=None, eve=None): self.is_searching = False - def show_exists_page(self, widget=None, eve=None): response = self.file_exists_dialog.run() self.file_exists_dialog.hide() @@ -81,12 +80,14 @@ class ShowHideMixin: appchooser_widget = self.builder.get_object("appchooser_widget") response = appchooser_menu.run() - if response == Gtk.ResponseType.CANCEL: - self.hide_appchooser_menu() if response == Gtk.ResponseType.OK: self.open_with_files(appchooser_widget) self.hide_appchooser_menu() + if response == Gtk.ResponseType.CANCEL: + self.hide_appchooser_menu() + + def hide_appchooser_menu(self, widget=None, eve=None): self.builder.get_object("appchooser_menu").hide() @@ -103,12 +104,18 @@ class ShowHideMixin: def show_new_file_menu(self, widget=None, eve=None): - self.builder.get_object("new_file_menu").run() + self.builder.get_object("context_menu_fname").set_text("") + + new_file_menu = self.builder.get_object("new_file_menu") + response = new_file_menu.run() + if response == Gtk.ResponseType.APPLY: + self.create_files() + if response == Gtk.ResponseType.CANCEL: + self.hide_new_file_menu() def hide_new_file_menu(self, widget=None, eve=None): self.builder.get_object("new_file_menu").hide() - def show_edit_file_menu(self, widget=None, eve=None): if widget: widget.grab_focus() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/UIMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/UIMixin.py new file mode 100644 index 0000000..f6e265f --- /dev/null +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/UIMixin.py @@ -0,0 +1,11 @@ +# Python imports + +# Gtk imports + +# Application imports +from . import ShowHideMixin +from .ui import * + + +class UIMixin(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin): + pass diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/__init__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/__init__.py new file mode 100644 index 0000000..d4205b8 --- /dev/null +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/__init__.py @@ -0,0 +1,2 @@ +from .ShowHideMixin import ShowHideMixin +from .UIMixin import UIMixin diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/PaneMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/PaneMixin.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/PaneMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/PaneMixin.py diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/TabMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/TabMixin.py similarity index 92% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/TabMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/TabMixin.py index 51960dd..d6e57fb 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/TabMixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/TabMixin.py @@ -16,24 +16,6 @@ from . import WidgetMixin class TabMixin(WidgetMixin): """docstring for TabMixin""" - def create_tab_from_ipc(data): - self, path = data - wid, tid = self.window_controller.get_active_data() - notebook = self.builder.get_object(f"window_{wid}") - if notebook.is_visible(): - self.create_tab(wid, path) - return - - if not self.is_pane4_hidden: - self.create_tab(4, path) - elif not self.is_pane3_hidden: - self.create_tab(3, path) - elif not self.is_pane2_hidden: - self.create_tab(2, path) - elif not self.is_pane1_hidden: - self.create_tab(1, path) - - def create_tab(self, wid, path=None): notebook = self.builder.get_object(f"window_{wid}") path_entry = self.builder.get_object(f"path_entry") diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/WidgetFileActionMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetFileActionMixin.py similarity index 86% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/WidgetFileActionMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetFileActionMixin.py index 06ba422..1969125 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/WidgetFileActionMixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetFileActionMixin.py @@ -4,7 +4,7 @@ import os # Lib imports import gi gi.require_version('Gtk', '3.0') -from gi.repository import Gtk, GObject, Gio +from gi.repository import Gtk, GObject, GLib, Gio # Application imports @@ -239,12 +239,12 @@ class WidgetFileActionMixin: else: # Create Folder self.handle_files([path], "create_dir") - fname_field.set_text("") + self.hide_new_file_menu() def move_files(self, files, target): self.handle_files(files, "move", target) - # NOTE: Gtk recommends using fail flow than pre check existence which is more + # NOTE: Gtk recommends using fail flow than pre check which is more # race condition proof. They're right; but, they can't even delete # directories properly. So... f**k them. I'll do it my way. def handle_files(self, paths, action, _target_path=None): @@ -273,8 +273,7 @@ class WidgetFileActionMixin: if _file.query_exists(): if not overwrite_all and not rename_auto_all: - self.exists_file_label.set_label(_file.get_basename()) - self.exists_file_field.set_text(_file.get_basename()) + self.setup_exists_data(file, _file) response = self.show_exists_page() if response == "overwrite_all": @@ -344,6 +343,45 @@ class WidgetFileActionMixin: self.exists_file_rename_bttn.set_sensitive(False) + def setup_exists_data(self, from_file, to_file): + from_info = from_file.query_info("standard::*,time::modified", 0, cancellable=None) + to_info = to_file.query_info("standard::*,time::modified", 0, cancellable=None) + exists_file_diff_from = self.builder.get_object("exists_file_diff_from") + exists_file_diff_to = self.builder.get_object("exists_file_diff_to") + exists_file_from = self.builder.get_object("exists_file_from") + exists_file_to = self.builder.get_object("exists_file_to") + from_date = from_info.get_modification_date_time() + to_date = to_info.get_modification_date_time() + from_size = from_info.get_size() + to_size = to_info.get_size() + + exists_file_from.set_label(from_file.get_parent().get_path()) + exists_file_to.set_label(to_file.get_parent().get_path()) + self.exists_file_label.set_label(to_file.get_basename()) + self.exists_file_field.set_text(to_file.get_basename()) + + # Returns: -1, 0 or 1 if dt1 is less than, equal to or greater than dt2. + age = GLib.DateTime.compare(from_date, to_date) + age_text = "( same time )" + if age == -1: + age_text = "older" + if age == 1: + age_text = "newer" + + size_text = "( same size )" + if from_size < to_size: + size_text = "smaller" + if from_size > to_size: + size_text = "larger" + + from_label_text = f"{age_text} & {size_text}" + if age_text != "( same time )" or size_text != "( same size )": + from_label_text = f"{from_date.format('%F %R')} {self.sizeof_fmt(from_size)} ( {from_size} bytes ) ( {age_text} & {size_text} )" + to_label_text = f"{to_date.format('%F %R')} {self.sizeof_fmt(to_size)} ( {to_size} bytes )" + + exists_file_diff_from.set_text(from_label_text) + exists_file_diff_to.set_text(to_label_text) + def rename_proc(self, gio_file): full_path = gio_file.get_path() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/WidgetMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetMixin.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/WidgetMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WidgetMixin.py diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/WindowMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WindowMixin.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/WindowMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/WindowMixin.py diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/__init__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/__init__.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/ui/__init__.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/mixins/ui/__init__.py diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/signals/IPCSignalsMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/signals/IPCSignalsMixin.py new file mode 100644 index 0000000..74c1ea5 --- /dev/null +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/signals/IPCSignalsMixin.py @@ -0,0 +1,27 @@ +# Python imports + +# Lib imports + +# Application imports + + +class IPCSignalsMixin: + def print_to_console(self, message=None): + print(self) + print(message) + + def handle_file_from_ipc(self, path): + wid, tid = self.window_controller.get_active_data() + notebook = self.builder.get_object(f"window_{wid}") + if notebook.is_visible(): + self.create_tab(wid, path) + return + + if not self.is_pane4_hidden: + self.create_tab(4, path) + elif not self.is_pane3_hidden: + self.create_tab(3, path) + elif not self.is_pane2_hidden: + self.create_tab(2, path) + elif not self.is_pane1_hidden: + self.create_tab(1, path) diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/KeyboardSignalsMixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/signals/KeyboardSignalsMixin.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/KeyboardSignalsMixin.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/signals/KeyboardSignalsMixin.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/controller/signals/__init__.py similarity index 55% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/__init__.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/signals/__init__.py index e457cb5..f7ae310 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/mixins/__init__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/controller/signals/__init__.py @@ -1,2 +1,2 @@ from .KeyboardSignalsMixin import KeyboardSignalsMixin -from .ShowHideMixin import ShowHideMixin +from .IPCSignalsMixin import IPCSignalsMixin 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 new file mode 100644 index 0000000..6458eb1 --- /dev/null +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/Plugins.py @@ -0,0 +1,63 @@ +# Python imports +import os, importlib +from os.path import join, isdir + +# 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.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() + + + 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.reload_plugins(file) + + def load_plugins(self, file=None): + print(f"Loading plugins...") + for file in os.listdir(self._plugins_path): + path = join(self._plugins_path, file) + 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) + + def reload_plugins(self, file=None): + print(f"Reloading plugins...") + # if self._plugin_collection: + # to_unload = [] + # for dir in self._plugin_collection: + # if not os.path.isdir(os.path.join(self._plugins_path, dir)): + # to_unload.append(dir) diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/__init__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/__init__.py new file mode 100644 index 0000000..b6a753c --- /dev/null +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/plugins/__init__.py @@ -0,0 +1,4 @@ +""" + Gtk Bound Plugins Module +""" +from .Plugins import Plugins 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 deleted file mode 100644 index 8715aac..0000000 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/signal_classes/Plugins.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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/utils/Settings.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/utils/Settings.py index 380210a..d6a42ee 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 @@ -25,10 +25,10 @@ class Settings: self.PLUGINS_PATH = f"{self.CONFIG_PATH}/plugins" self.USR_SOLARFM = f"/usr/share/{app_name.lower()}" - self.cssFile = f"{self.CONFIG_PATH}/stylesheet.css" - self.windows_glade = f"{self.CONFIG_PATH}/Main_Window.glade" + self.CSS_FILE = f"{self.CONFIG_PATH}/stylesheet.css" + self.WINDOWS_GLADE = f"{self.CONFIG_PATH}/Main_Window.glade" self.DEFAULT_ICONS = f"{self.CONFIG_PATH}/icons" - self.window_icon = f"{self.DEFAULT_ICONS}/{app_name.lower()}.png" + self.WINDOW_ICON = f"{self.DEFAULT_ICONS}/{app_name.lower()}.png" self.main_window = None if not os.path.exists(self.CONFIG_PATH): @@ -36,17 +36,17 @@ class Settings: if not os.path.exists(self.PLUGINS_PATH): os.mkdir(self.PLUGINS_PATH) - if not os.path.exists(self.windows_glade): - self.windows_glade = f"{self.USR_SOLARFM}/Main_Window.glade" - if not os.path.exists(self.cssFile): - self.cssFile = f"{self.USR_SOLARFM}/stylesheet.css" - if not os.path.exists(self.window_icon): - self.window_icon = f"{self.USR_SOLARFM}/icons/{app_name.lower()}.png" + if not os.path.exists(self.WINDOWS_GLADE): + self.WINDOWS_GLADE = f"{self.USR_SOLARFM}/Main_Window.glade" + if not os.path.exists(self.CSS_FILE): + self.CSS_FILE = f"{self.USR_SOLARFM}/stylesheet.css" + if not os.path.exists(self.WINDOW_ICON): + self.WINDOW_ICON = f"{self.USR_SOLARFM}/icons/{app_name.lower()}.png" if not os.path.exists(self.DEFAULT_ICONS): self.DEFAULT_ICONS = f"{self.USR_SOLARFM}/icons" self.logger = Logger(self.CONFIG_PATH).get_logger() - self.builder.add_from_file(self.windows_glade) + self.builder.add_from_file(self.WINDOWS_GLADE) @@ -56,7 +56,7 @@ class Settings: self._set_window_data() def _set_window_data(self): - self.main_window.set_icon_from_file(self.window_icon) + self.main_window.set_icon_from_file(self.WINDOW_ICON) screen = self.main_window.get_screen() visual = screen.get_rgba_visual() @@ -67,7 +67,7 @@ class Settings: # bind css file cssProvider = gtk.CssProvider() - cssProvider.load_from_path(self.cssFile) + cssProvider.load_from_path(self.CSS_FILE) screen = gdk.Screen.get_default() styleContext = gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER) diff --git a/user_config/usr/share/solarfm/Main_Window.glade b/user_config/usr/share/solarfm/Main_Window.glade index 367ed9a..e760dc6 100644 --- a/user_config/usr/share/solarfm/Main_Window.glade +++ b/user_config/usr/share/solarfm/Main_Window.glade @@ -644,10 +644,36 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe False end - + + Create + create + True + True + True + Create File/Folder... + createImage + True + + + False + True + 0 + - + + gtk-cancel + True + True + True + True + True + + + True + True + 1 + @@ -723,7 +749,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe False - True + False 0 @@ -740,40 +766,26 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe 1 - - - Create - create - True - True - True - Create File/Folder... - createImage - True - - - - False - True - 2 - - - True + False True 1 - True + False True 1 + + button10 + button9 + True @@ -891,6 +903,103 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe True False + 15 + 10 + + + True + False + Moving From: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 0 + + + True + True + 2 + + + + + True + False + 20 + 10 + + + True + False + Moving To: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 3 + + + + + True + False + 0 + + + True + True + 4 + + + + + True + False + 20 True @@ -918,12 +1027,9 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe False True - 1 + 5 - - - True @@ -933,7 +1039,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe False True - 3 + 6 @@ -996,7 +1102,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe False True - 4 + 7 @@ -1024,60 +1130,6 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe gtk-justify-center - - 320 - False - True - bottom - - - True - False - vertical - - - gtk-save-as - True - True - True - True - - - - False - True - 0 - - - - - 600 - True - True - True - in - False - - - message_view - True - True - True - False - False - message_buffer - - - - - False - True - 1 - - - - - True False @@ -1291,7 +1343,7 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe True False - + True False @@ -1903,6 +1955,61 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe + + 320 + False + True + top_main_menubar + bottom + + + True + False + vertical + + + gtk-save-as + True + True + True + True + + + + False + True + 0 + + + + + 600 + True + True + True + in + False + + + message_view + True + True + True + False + False + message_buffer + + + + + False + True + 1 + + + + + 240 420