Internalized default settings

This commit is contained in:
itdominator 2023-08-05 20:04:22 -05:00
parent 3fca6648cb
commit 9fd32b85f6
7 changed files with 129 additions and 179 deletions

View File

@ -60,13 +60,6 @@ class SettingsManager(StartCheckMixin, Singleton):
if not os.path.exists(self._PLUGINS_PATH):
os.mkdir(self._PLUGINS_PATH)
if not os.path.exists(self._CONFIG_FILE):
import shutil
try:
shutil.copyfile(self._USR_CONFIG_FILE, self._CONFIG_FILE)
except Exception as e:
raise
if not os.path.exists(self._DEFAULT_ICONS):
self._DEFAULT_ICONS = f"{self._USR_PATH}/icons"
if not os.path.exists(self._DEFAULT_ICONS):
@ -177,8 +170,13 @@ class SettingsManager(StartCheckMixin, Singleton):
def load_settings(self):
if not os.path.exists(self._CONFIG_FILE):
self.settings = Settings()
return
with open(self._CONFIG_FILE) as file:
data = json.load(file)
data["load_defaults"] = False
self.settings = Settings(**data)
def save_settings(self):

View File

@ -1,5 +1,5 @@
# Python imports
from dataclasses import dataclass
from dataclasses import dataclass, field
# Lib imports
@ -8,28 +8,28 @@ from dataclasses import dataclass
@dataclass
class Config:
base_of_home: str
hide_hidden_files: str
thumbnailer_path: str
blender_thumbnailer_path: str
go_past_home: str
lock_folder: str
locked_folders: []
mplayer_options: str
music_app: str
media_app: str
image_app: str
office_app: str
pdf_app: str
code_app: str
text_app: str
file_manager_app: str
terminal_app: str
remux_folder_max_disk_usage: str
make_transparent: int
main_window_x: int
main_window_y: int
main_window_min_width: int
main_window_min_height: int
main_window_width: int
main_window_height: int
base_of_home: str = ""
hide_hidden_files: str = "true"
thumbnailer_path: str = "ffmpegthumbnailer"
blender_thumbnailer_path: str = ""
go_past_home: str = "true"
lock_folder: str = "false"
locked_folders: list = field(default_factory=lambda: [ "venv", "flasks" ])
mplayer_options: str = "-quiet -really-quiet -xy 1600 -geometry 50%:50%",
music_app: str = "/opt/deadbeef/bin/deadbeef"
media_app: str = "mpv"
image_app: str = "mirage"
office_app: str = "libreoffice"
pdf_app: str = "evince"
code_app: str = "atom"
text_app: str = "leafpad"
file_manager_app: str = "solarfm"
terminal_app: str = "terminator"
remux_folder_max_disk_usage: str = "8589934592"
make_transparent: int = 0
main_window_x: int = 721
main_window_y: int = 465
main_window_min_width: int = 720
main_window_min_height: int = 480
main_window_width: int = 800
main_window_height: int = 600

View File

@ -8,5 +8,5 @@ from dataclasses import dataclass
@dataclass
class Debugging:
ch_log_lvl: int
fh_log_lvl: int
ch_log_lvl: int = 10
fh_log_lvl: int = 20

View File

@ -1,5 +1,5 @@
# Python imports
from dataclasses import dataclass
from dataclasses import dataclass, field
# Lib imports
@ -8,11 +8,83 @@ from dataclasses import dataclass
@dataclass
class Filters:
meshs: []
code: []
videos: []
office: []
images: []
text: []
music: []
pdf: []
meshs: list = field(default_factory=lambda: [
".blend",
".dae",
".fbx",
".gltf",
".obj",
".stl"
])
code: list = field(default_factory=lambda: [
".cpp",
".css",
".c",
".go",
".html",
".htm",
".java",
".js",
".json",
".lua",
".md",
".py",
".rs",
".toml",
".xml",
".pom"
])
videos: list = field(default_factory=lambda:[
".mkv",
".mp4",
".webm",
".avi",
".mov",
".m4v",
".mpg",
".mpeg",
".wmv",
".flv"
])
office: list = field(default_factory=lambda: [
".doc",
".docx",
".xls",
".xlsx",
".xlt",
".xltx",
".xlm",
".ppt",
".pptx",
".pps",
".ppsx",
".odt",
".rtf"
])
images: list = field(default_factory=lambda: [
".png",
".jpg",
".jpeg",
".gif",
".ico",
".tga",
".webp"
])
text: list = field(default_factory=lambda: [
".txt",
".text",
".sh",
".cfg",
".conf",
".log"
])
music: list = field(default_factory=lambda: [
".psf",
".mp3",
".ogg",
".flac",
".m4a"
])
pdf: list = field(default_factory=lambda: [
".pdf"
])

View File

@ -1,5 +1,5 @@
# Python imports
from dataclasses import dataclass
from dataclasses import dataclass, field
from dataclasses import asdict
# Gtk imports
@ -13,12 +13,15 @@ from .debugging import Debugging
@dataclass
class Settings:
config: Config
filters: Filters
theming: Theming
debugging: Debugging
load_defaults: bool = True
config: Config = field(default_factory=lambda: Config())
filters: Filters = field(default_factory=lambda: Filters())
theming: Theming = field(default_factory=lambda: Theming())
debugging: Debugging = field(default_factory=lambda: Debugging())
def __post_init__(self):
if not self.load_defaults:
self.load_defaults = False
self.config = Config(**self.config)
self.filters = Filters(**self.filters)
self.theming = Theming(**self.theming)

View File

@ -8,6 +8,6 @@ from dataclasses import dataclass
@dataclass
class Theming:
success_color: str
warning_color: str
error_color: str
success_color: str = "#88cc27"
warning_color: str = "#ffa800"
error_color: str = "#ff0000"

View File

@ -1,123 +0,0 @@
{
"config":{
"base_of_home":"",
"hide_hidden_files":"true",
"thumbnailer_path":"ffmpegthumbnailer",
"blender_thumbnailer_path":"",
"go_past_home":"true",
"lock_folder":"false",
"locked_folders":[
"venv",
"flasks"
],
"mplayer_options":"-quiet -really-quiet -xy 1600 -geometry 50%:50%",
"music_app":"/opt/deadbeef/bin/deadbeef",
"media_app":"mpv",
"image_app":"mirage",
"office_app":"libreoffice",
"pdf_app":"evince",
"code_app":"atom",
"text_app":"leafpad",
"file_manager_app":"solarfm",
"terminal_app":"terminator",
"remux_folder_max_disk_usage":"8589934592",
"make_transparent":0,
"main_window_x":721,
"main_window_y":465,
"main_window_min_width":720,
"main_window_min_height":480,
"main_window_width":800,
"main_window_height":600
},
"filters":{
"meshs":[
".blend",
".dae",
".fbx",
".gltf",
".obj",
".stl"
],
"code":[
".cpp",
".css",
".c",
".go",
".html",
".htm",
".java",
".js",
".json",
".lua",
".md",
".py",
".rs",
".toml",
".xml",
".pom"
],
"videos":[
".mkv",
".mp4",
".webm",
".avi",
".mov",
".m4v",
".mpg",
".mpeg",
".wmv",
".flv"
],
"office":[
".doc",
".docx",
".xls",
".xlsx",
".xlt",
".xltx",
".xlm",
".ppt",
".pptx",
".pps",
".ppsx",
".odt",
".rtf"
],
"images":[
".png",
".jpg",
".jpeg",
".gif",
".ico",
".tga",
".webp"
],
"text":[
".txt",
".text",
".sh",
".cfg",
".conf",
".log"
],
"music":[
".psf",
".mp3",
".ogg",
".flac",
".m4a"
],
"pdf":[
".pdf"
]
},
"theming":{
"success_color":"#88cc27",
"warning_color":"#ffa800",
"error_color":"#ff0000"
},
"debugging":{
"ch_log_lvl":10,
"fh_log_lvl":20
}
}