develop #1

Merged
itdominator merged 14 commits from develop into master 2022-01-30 00:22:36 +00:00
13 changed files with 44 additions and 17 deletions
Showing only changes of commit 8a0057f78e - Show all commits

View File

@ -66,6 +66,7 @@ class Builtins(IPCServerMixin):
# NOTE: Just reminding myself we can add to builtins two different ways... # NOTE: Just reminding myself we can add to builtins two different ways...
# __builtins__.update({"event_system": Builtins()}) # __builtins__.update({"event_system": Builtins()})
builtins.app_name = "SolarFM"
builtins.event_system = Builtins() builtins.event_system = Builtins()
builtins.event_sleep_time = 0.2 builtins.event_sleep_time = 0.2
builtins.debug = False builtins.debug = False

View File

@ -23,7 +23,7 @@ if __name__ == "__main__":
# import web_pdb # import web_pdb
# web_pdb.set_trace() # web_pdb.set_trace()
setproctitle('solarfm') setproctitle('SolarFM')
faulthandler.enable() # For better debug info faulthandler.enable() # For better debug info
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
# Add long and short arguments # Add long and short arguments

View File

@ -7,7 +7,8 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib from gi.repository import Gtk, GLib
# Application imports # Application imports
from .mixins import * from .mixins.ui import *
from .mixins import PluginMixin
from . import ShowHideMixin, KeyboardSignalsMixin, Controller_Data from . import ShowHideMixin, KeyboardSignalsMixin, Controller_Data
@ -20,12 +21,13 @@ def threaded(fn):
class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \ class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \
KeyboardSignalsMixin, Controller_Data): KeyboardSignalsMixin, PluginMixin, 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()
if not trace_debug: if not trace_debug:
self.gui_event_observer() self.gui_event_observer()

View File

@ -0,0 +1,17 @@
# 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,5 +1 @@
from .PaneMixin import PaneMixin from .PluginMixin import PluginMixin
from .WidgetMixin import WidgetMixin
from .TabMixin import TabMixin
from .WindowMixin import WindowMixin
from .WidgetFileActionMixin import WidgetFileActionMixin

View File

@ -0,0 +1,5 @@
from .PaneMixin import PaneMixin
from .WidgetMixin import WidgetMixin
from .TabMixin import TabMixin
from .WindowMixin import WindowMixin
from .WidgetFileActionMixin import WidgetFileActionMixin

View File

@ -5,8 +5,8 @@ import os, logging
class Logger: class Logger:
def __init__(self): def __init__(self, config_path):
pass self._CONFIG_PATH = config_path
def get_logger(self, loggerName = "NO_LOGGER_NAME_PASSED", createFile = True): def get_logger(self, loggerName = "NO_LOGGER_NAME_PASSED", createFile = True):
""" """
@ -42,8 +42,8 @@ class Logger:
log.addHandler(ch) log.addHandler(ch)
if createFile: if createFile:
folder = "logs" folder = self._CONFIG_PATH
file = folder + "/application.log" file = f"{folder}/application.log"
if not os.path.exists(folder): if not os.path.exists(folder):
os.mkdir(folder) os.mkdir(folder)

View File

@ -17,29 +17,35 @@ from . import Logger
class Settings: class Settings:
def __init__(self): def __init__(self):
self.logger = Logger().get_logger()
self.builder = gtk.Builder() self.builder = gtk.Builder()
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__)) self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
self.USER_HOME = path.expanduser('~') self.USER_HOME = path.expanduser('~')
self.CONFIG_PATH = f"{self.USER_HOME}/.config/solarfm" self.CONFIG_PATH = f"{self.USER_HOME}/.config/{app_name.lower()}"
self.USR_SOLARFM = "/usr/share/solarfm" 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.cssFile = f"{self.CONFIG_PATH}/stylesheet.css"
self.windows_glade = f"{self.CONFIG_PATH}/Main_Window.glade" self.windows_glade = f"{self.CONFIG_PATH}/Main_Window.glade"
self.DEFAULT_ICONS = f"{self.CONFIG_PATH}/icons" self.DEFAULT_ICONS = f"{self.CONFIG_PATH}/icons"
self.window_icon = f"{self.DEFAULT_ICONS}/solarfm.png" self.window_icon = f"{self.DEFAULT_ICONS}/{app_name.lower()}.png"
self.main_window = None self.main_window = None
if not os.path.exists(self.CONFIG_PATH):
os.mkdir(self.CONFIG_PATH)
if not os.path.exists(self.PLUGINS_PATH):
os.mkdir(self.PLUGINS_PATH)
if not os.path.exists(self.windows_glade): if not os.path.exists(self.windows_glade):
self.windows_glade = f"{self.USR_SOLARFM}/Main_Window.glade" self.windows_glade = f"{self.USR_SOLARFM}/Main_Window.glade"
if not os.path.exists(self.cssFile): if not os.path.exists(self.cssFile):
self.cssFile = f"{self.USR_SOLARFM}/stylesheet.css" self.cssFile = f"{self.USR_SOLARFM}/stylesheet.css"
if not os.path.exists(self.window_icon): if not os.path.exists(self.window_icon):
self.window_icon = f"{self.USR_SOLARFM}/icons/solarfm.png" self.window_icon = f"{self.USR_SOLARFM}/icons/{app_name.lower()}.png"
if not os.path.exists(self.DEFAULT_ICONS): if not os.path.exists(self.DEFAULT_ICONS):
self.DEFAULT_ICONS = f"{self.USR_SOLARFM}/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)