develop #1

Merged
itdominator merged 14 commits from develop into master 2022-01-30 00:22:36 +00:00
10 changed files with 62 additions and 37 deletions
Showing only changes of commit 353ee2a966 - Show all commits

View File

@ -33,7 +33,7 @@ class Main(Builtins):
settings = Settings() settings = Settings()
settings.createWindow() settings.create_window()
controller = Controller(args, unknownargs, settings) controller = Controller(args, unknownargs, settings)
if not controller: if not controller:

View File

@ -8,8 +8,8 @@ from gi.repository import Gtk, GLib
# Application imports # Application imports
from .mixins.ui import * from .mixins.ui import *
from .mixins import PluginMixin from .mixins import ShowHideMixin, KeyboardSignalsMixin
from . import ShowHideMixin, KeyboardSignalsMixin, Controller_Data from . import Controller_Data
def threaded(fn): def threaded(fn):
@ -21,13 +21,13 @@ def threaded(fn):
class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \ class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \
KeyboardSignalsMixin, PluginMixin, Controller_Data): KeyboardSignalsMixin, Controller_Data):
def __init__(self, args, unknownargs, _settings): def __init__(self, args, unknownargs, _settings):
# sys.excepthook = self.custom_except_hook # sys.excepthook = self.custom_except_hook
self.setup_controller_data(_settings) self.setup_controller_data(_settings)
self.window.show() self.window.show()
self.generate_windows(self.state) self.generate_windows(self.state)
self.load_plugins() self.plugins.launch_plugins()
if not trace_debug: if not trace_debug:
self.gui_event_observer() self.gui_event_observer()

View File

@ -7,6 +7,7 @@ from gi.repository import GLib
# Application imports # Application imports
from shellfm import WindowController from shellfm import WindowController
from trasher.xdgtrash import XDGTrash from trasher.xdgtrash import XDGTrash
from . import Plugins
@ -18,6 +19,7 @@ class Controller_Data:
def setup_controller_data(self, _settings): def setup_controller_data(self, _settings):
self.trashman = XDGTrash() self.trashman = XDGTrash()
self.window_controller = WindowController() self.window_controller = WindowController()
self.plugins = Plugins(_settings)
self.state = self.window_controller.load_state() self.state = self.window_controller.load_state()
self.trashman.regenerate() self.trashman.regenerate()
@ -91,7 +93,6 @@ class Controller_Data:
self.search_iconview = None self.search_iconview = None
self.search_view = None self.search_view = None
self.skip_edit = False self.skip_edit = False
self.cancel_edit = False self.cancel_edit = False
self.ctrlDown = False self.ctrlDown = False

View File

@ -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)

View File

@ -2,8 +2,7 @@
Gtk Bound Signal Module Gtk Bound Signal Module
""" """
from .mixins import * from .mixins import *
from .KeyboardSignalsMixin import KeyboardSignalsMixin
from .ShowHideMixin import ShowHideMixin
from .IPCServerMixin import IPCServerMixin from .IPCServerMixin import IPCServerMixin
from .Plugins import Plugins
from .Controller_Data import Controller_Data from .Controller_Data import Controller_Data
from .Controller import Controller from .Controller import Controller

View File

@ -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

View File

@ -1 +1,2 @@
from .PluginMixin import PluginMixin from .KeyboardSignalsMixin import KeyboardSignalsMixin
from .ShowHideMixin import ShowHideMixin

View File

@ -50,12 +50,12 @@ class Settings:
def createWindow(self): def create_window(self):
# Get window and connect signals # Get window and connect signals
self.main_window = self.builder.get_object("Main_Window") 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) self.main_window.set_icon_from_file(self.window_icon)
screen = self.main_window.get_screen() screen = self.main_window.get_screen()
visual = screen.get_rgba_visual() visual = screen.get_rgba_visual()
@ -63,7 +63,7 @@ class Settings:
if visual != None and screen.is_composited(): if visual != None and screen.is_composited():
self.main_window.set_visual(visual) self.main_window.set_visual(visual)
self.main_window.set_app_paintable(True) 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 # bind css file
cssProvider = gtk.CssProvider() cssProvider = gtk.CssProvider()
@ -72,18 +72,13 @@ class Settings:
styleContext = gtk.StyleContext() styleContext = gtk.StyleContext()
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER) 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_source_rgba(0, 0, 0, 0.54)
cr.set_operator(cairo.OPERATOR_SOURCE) cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint() cr.paint()
cr.set_operator(cairo.OPERATOR_OVER) cr.set_operator(cairo.OPERATOR_OVER)
def get_builder(self): return self.builder def get_monitor_data(self):
def get_logger(self): return self.logger
def get_main_window(self): return self.main_window
def getMonitorData(self):
screen = self.builder.get_object("Main_Window").get_screen() screen = self.builder.get_object("Main_Window").get_screen()
monitors = [] monitors = []
for m in range(screen.get_n_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)) print("{}x{}+{}+{}".format(monitor.width, monitor.height, monitor.x, monitor.y))
return monitors 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