Cleaned up imports; added config setting
This commit is contained in:
parent
df688d919e
commit
d13d23dcf0
|
@ -41,6 +41,9 @@ builtins.keybindings = Keybindings()
|
|||
builtins.event_system = EventSystem()
|
||||
builtins.endpoint_registry = EndpointRegistry()
|
||||
builtins.settings_manager = SettingsManager()
|
||||
|
||||
settings_manager.load_settings()
|
||||
|
||||
builtins.settings = settings_manager.settings
|
||||
builtins.logger = Logger(settings_manager.get_home_config_path(), \
|
||||
_ch_log_lvl=settings.debugging.ch_log_lvl, \
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
<frozen importlib._bootstrap_external>:672: size=5717 KiB, count=60317, average=97 B
|
||||
<frozen importlib._bootstrap>:241: size=534 KiB, count=5538, average=99 B
|
||||
/usr/lib/python3.10/abc.py:106: size=77.9 KiB, count=290, average=275 B
|
||||
<frozen importlib._bootstrap_external>:128: size=62.1 KiB, count=532, average=119 B
|
||||
/usr/lib/python3.10/sre_compile.py:804: size=57.7 KiB, count=110, average=537 B
|
||||
/home/abaddon/Coding/Projects/Active/Python_Projects/000_Usable/gtk/SolarFM/src/versions/solarfm-0.0.1/solarfm/./shellfm/windows/tabs/tab.py:79: size=56.4 KiB, count=875, average=66 B
|
||||
/usr/lib/python3.10/site-packages/gi/types.py:52: size=54.0 KiB, count=509, average=109 B
|
||||
/usr/lib/python3.10/site-packages/gi/module.py:207: size=49.6 KiB, count=233, average=218 B
|
||||
/usr/lib/python3.10/site-packages/gi/types.py:51: size=40.1 KiB, count=733, average=56 B
|
||||
<frozen importlib._bootstrap>:359: size=38.6 KiB, count=549, average=72 B
|
|
@ -1,8 +1,8 @@
|
|||
# Python imports
|
||||
import os
|
||||
import inspect
|
||||
import json
|
||||
from os import path
|
||||
from os import mkdir
|
||||
|
||||
# Gtk imports
|
||||
import gi
|
||||
|
@ -22,7 +22,7 @@ class MissingConfigError(Exception):
|
|||
|
||||
class SettingsManager(StartCheckMixin, Singleton):
|
||||
def __init__(self):
|
||||
self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
|
||||
self._SCRIPT_PTH = path.dirname(path.realpath(__file__))
|
||||
self._USER_HOME = path.expanduser('~')
|
||||
self._USR_PATH = f"/usr/share/{app_name.lower()}"
|
||||
|
||||
|
@ -42,34 +42,34 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||
self._TRASH_INFO_PATH = f"{GLib.get_user_data_dir()}/Trash/info"
|
||||
self._ICON_THEME = Gtk.IconTheme.get_default()
|
||||
|
||||
if not os.path.exists(self._HOME_CONFIG_PATH):
|
||||
os.mkdir(self._HOME_CONFIG_PATH)
|
||||
if not os.path.exists(self._PLUGINS_PATH):
|
||||
os.mkdir(self._PLUGINS_PATH)
|
||||
if not path.exists(self._HOME_CONFIG_PATH):
|
||||
mkdir(self._HOME_CONFIG_PATH)
|
||||
if not path.exists(self._PLUGINS_PATH):
|
||||
mkdir(self._PLUGINS_PATH)
|
||||
|
||||
if not os.path.exists(self._DEFAULT_ICONS):
|
||||
if not path.exists(self._DEFAULT_ICONS):
|
||||
self._DEFAULT_ICONS = f"{self._USR_PATH}/icons"
|
||||
if not os.path.exists(self._DEFAULT_ICONS):
|
||||
if not path.exists(self._DEFAULT_ICONS):
|
||||
raise MissingConfigError("Unable to find the application icons directory.")
|
||||
if not os.path.exists(self._GLADE_FILE):
|
||||
if not path.exists(self._GLADE_FILE):
|
||||
self._GLADE_FILE = f"{self._USR_PATH}/Main_Window.glade"
|
||||
if not os.path.exists(self._GLADE_FILE):
|
||||
if not path.exists(self._GLADE_FILE):
|
||||
raise MissingConfigError("Unable to find the application Glade file.")
|
||||
if not os.path.exists(self._KEY_BINDINGS_FILE):
|
||||
if not path.exists(self._KEY_BINDINGS_FILE):
|
||||
self._KEY_BINDINGS_FILE = f"{self._USR_PATH}/key-bindings.json"
|
||||
if not os.path.exists(self._KEY_BINDINGS_FILE):
|
||||
if not path.exists(self._KEY_BINDINGS_FILE):
|
||||
raise MissingConfigError("Unable to find the application Keybindings file.")
|
||||
if not os.path.exists(self._CSS_FILE):
|
||||
if not path.exists(self._CSS_FILE):
|
||||
self._CSS_FILE = f"{self._USR_PATH}/stylesheet.css"
|
||||
if not os.path.exists(self._CSS_FILE):
|
||||
if not path.exists(self._CSS_FILE):
|
||||
raise MissingConfigError("Unable to find the application Stylesheet file.")
|
||||
if not os.path.exists(self._WINDOW_ICON):
|
||||
if not path.exists(self._WINDOW_ICON):
|
||||
self._WINDOW_ICON = f"{self._USR_PATH}/icons/{app_name.lower()}.png"
|
||||
if not os.path.exists(self._WINDOW_ICON):
|
||||
if not path.exists(self._WINDOW_ICON):
|
||||
raise MissingConfigError("Unable to find the application icon.")
|
||||
if not os.path.exists(self._UI_WIDEGTS_PATH):
|
||||
if not path.exists(self._UI_WIDEGTS_PATH):
|
||||
self._UI_WIDEGTS_PATH = f"{self._USR_PATH}/ui_widgets"
|
||||
if not os.path.exists(self._CONTEXT_MENU):
|
||||
if not path.exists(self._CONTEXT_MENU):
|
||||
self._CONTEXT_MENU = f"{self._USR_PATH}/contexct_menu.json"
|
||||
|
||||
|
||||
|
@ -97,8 +97,6 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||
self._debug = False
|
||||
self._dirty_start = False
|
||||
|
||||
self.load_settings()
|
||||
|
||||
|
||||
def register_signals_to_builder(self, classes=None, builder=None):
|
||||
handlers = {}
|
||||
|
@ -136,6 +134,7 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||
def get_window_icon(self) -> str: return self._WINDOW_ICON
|
||||
|
||||
def get_context_menu_data(self) -> str: return self._context_menu_data
|
||||
def get_home_path(self) -> str: return self._USER_HOME
|
||||
def get_ui_widgets_path(self) -> str: return self._UI_WIDEGTS_PATH
|
||||
def get_trash_files_path(self) -> str: return self._TRASH_FILES_PATH
|
||||
def get_trash_info_path(self) -> str: return self._TRASH_INFO_PATH
|
||||
|
@ -151,7 +150,7 @@ class SettingsManager(StartCheckMixin, Singleton):
|
|||
self._debug = debug
|
||||
|
||||
def load_settings(self):
|
||||
if not os.path.exists(self._CONFIG_FILE):
|
||||
if not path.exists(self._CONFIG_FILE):
|
||||
self.settings = Settings()
|
||||
return
|
||||
|
||||
|
|
|
@ -30,3 +30,7 @@ class Config:
|
|||
sys_icon_wh: list = field(default_factory=lambda: [56, 56])
|
||||
steam_cdn_url: str = "https://steamcdn-a.akamaihd.net/steam/apps/"
|
||||
remux_folder_max_disk_usage: str = "8589934592"
|
||||
application_dirs: list = field(default_factory=lambda: [
|
||||
"/usr/share/applications",
|
||||
f"{settings_manager.get_home_path()}/.local/share/applications"
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue