develop #11

Merged
itdominator merged 36 commits from develop into master 2023-09-19 01:11:24 +00:00
41 changed files with 581 additions and 267 deletions
Showing only changes of commit 826b58cfc4 - Show all commits

View File

@ -52,7 +52,7 @@ class Plugin(PluginBase):
'Cache-Control': 'no-cache' 'Cache-Control': 'no-cache'
} }
self.vqd_link = "https://duckduckgo.com/" self.vqd_link = "https://duckduckgo.com/?hps=1&q=translate&ia=web"
self.vqd_data = {"q": "translate", "ia":"web"} self.vqd_data = {"q": "translate", "ia":"web"}
self.vqd_headers = { self.vqd_headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0',

View File

@ -10,8 +10,7 @@ from utils.event_system import EventSystem
from utils.endpoint_registry import EndpointRegistry from utils.endpoint_registry import EndpointRegistry
from utils.keybindings import Keybindings from utils.keybindings import Keybindings
from utils.logger import Logger from utils.logger import Logger
from utils.settings import Settings from utils.settings_manager.manager import SettingsManager
# NOTE: Threads WILL NOT die with parent's destruction. # NOTE: Threads WILL NOT die with parent's destruction.
@ -41,10 +40,11 @@ builtins.app_name = "SolarFM"
builtins.keybindings = Keybindings() builtins.keybindings = Keybindings()
builtins.event_system = EventSystem() builtins.event_system = EventSystem()
builtins.endpoint_registry = EndpointRegistry() builtins.endpoint_registry = EndpointRegistry()
builtins.settings = Settings() builtins.settings_manager = SettingsManager()
builtins.logger = Logger(settings.get_home_config_path(), \ builtins.settings = settings_manager.settings
_ch_log_lvl=settings.get_ch_log_lvl(), \ builtins.logger = Logger(settings_manager.get_home_config_path(), \
_fh_log_lvl=settings.get_fh_log_lvl()).get_logger() _ch_log_lvl=settings.debugging.ch_log_lvl, \
_fh_log_lvl=settings.debugging.fh_log_lvl).get_logger()
builtins.threaded = threaded_wrapper builtins.threaded = threaded_wrapper
builtins.daemon_threaded = daemon_threaded_wrapper builtins.daemon_threaded = daemon_threaded_wrapper

View File

@ -38,12 +38,12 @@ def run():
args, unknownargs = parser.parse_known_args() args, unknownargs = parser.parse_known_args()
if args.debug == "true": if args.debug == "true":
settings.set_debug(True) settings_manager.set_debug(True)
if args.trace_debug == "true": if args.trace_debug == "true":
settings.set_trace_debug(True) settings_manager.set_trace_debug(True)
settings.do_dirty_start_check() settings_manager.do_dirty_start_check()
Application(args, unknownargs) Application(args, unknownargs)
Gtk.main() Gtk.main()
except Exception as e: except Exception as e:

View File

@ -21,7 +21,7 @@ class Application(IPCServer):
def __init__(self, args, unknownargs): def __init__(self, args, unknownargs):
super(Application, self).__init__() super(Application, self).__init__()
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
try: try:
self.create_ipc_listener() self.create_ipc_listener()
except Exception: except Exception:

View File

@ -78,13 +78,13 @@ class Controller(UIMixin, SignalsMixins, Controller_Data):
def _load_glade_file(self): def _load_glade_file(self):
self.builder = Gtk.Builder() self.builder = Gtk.Builder()
self.builder.add_from_file(settings.get_glade_file()) self.builder.add_from_file(settings_manager.get_glade_file())
self.builder.expose_object("main_window", self.window) self.builder.expose_object("main_window", self.window)
self.core_widget = self.builder.get_object("core_widget") self.core_widget = self.builder.get_object("core_widget")
settings.set_builder(self.builder) settings_manager.set_builder(self.builder)
settings.register_signals_to_builder([self,], self.builder) settings_manager.register_signals_to_builder([self,], self.builder)
def get_core_widget(self): def get_core_widget(self):
return self.core_widget return self.core_widget

View File

@ -40,7 +40,7 @@ class Controller_Data:
__slots__ = "settings", "builder", "logger", "keybindings", "trashman", "fm_controller", "window", "window1", "window2", "window3", "window4" __slots__ = "settings", "builder", "logger", "keybindings", "trashman", "fm_controller", "window", "window1", "window2", "window3", "window4"
def _setup_controller_data(self) -> None: def _setup_controller_data(self) -> None:
self.window = settings.get_main_window() self.window = settings_manager.get_main_window()
self.builder = None self.builder = None
self.core_widget = None self.core_widget = None

View File

@ -25,7 +25,7 @@ class FileSystemActions(HandlerMixin, CRUDMixin):
self._to_copy_files = [] self._to_copy_files = []
self._to_cut_files = [] self._to_cut_files = []
self._builder = settings.get_builder() self._builder = settings_manager.get_builder()
def _setup_styling(self): def _setup_styling(self):

View File

@ -144,7 +144,7 @@ class HandlerMixin:
target = Gio.File.new_for_path(full_path) target = Gio.File.new_for_path(full_path)
start = "-copy" start = "-copy"
if settings.is_debug(): if settings_manager.is_debug():
logger.debug(f"Path: {full_path}") logger.debug(f"Path: {full_path}")
logger.debug(f"Base Path: {base_path}") logger.debug(f"Base Path: {base_path}")
logger.debug(f'Name: {file_name}') logger.debug(f'Name: {file_name}')

View File

@ -20,7 +20,7 @@ class FileActionSignalsMixin:
if tab.get_dir_watcher(): if tab.get_dir_watcher():
watcher = tab.get_dir_watcher() watcher = tab.get_dir_watcher()
watcher.cancel() watcher.cancel()
if settings.is_debug(): if settings_manager.is_debug():
logger.debug(f"Watcher Is Cancelled: {watcher.is_cancelled()}") logger.debug(f"Watcher Is Cancelled: {watcher.is_cancelled()}")
cur_dir = tab.get_current_directory() cur_dir = tab.get_current_directory()

View File

@ -72,9 +72,9 @@ class TabMixin(GridMixin):
icon_grid.destroy() icon_grid.destroy()
# icon_grid.run_dispose() # icon_grid.run_dispose()
scroll.destroy() scroll.destroy()
scroll.run_dispose() #scroll.run_dispose()
tab_box.destroy() tab_box.destroy()
tab_box.run_dispose() # tab_box.run_dispose()
del store del store
del icon_grid del icon_grid
@ -83,7 +83,7 @@ class TabMixin(GridMixin):
del watcher del watcher
del tab del tab
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
self.set_window_title() self.set_window_title()
@ -106,7 +106,7 @@ class TabMixin(GridMixin):
tab = window.get_tab_by_id(tid) tab = window.get_tab_by_id(tid)
self.set_file_watcher(tab) self.set_file_watcher(tab)
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
def on_tab_switch_update(self, notebook, content=None, index=None): def on_tab_switch_update(self, notebook, content=None, index=None):
@ -142,7 +142,7 @@ class TabMixin(GridMixin):
tab_label.set_label(tab.get_end_of_path()) tab_label.set_label(tab.get_end_of_path())
self.set_window_title() self.set_window_title()
self.set_file_watcher(tab) self.set_file_watcher(tab)
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
def do_action_from_bar_controls(self, widget, eve=None): def do_action_from_bar_controls(self, widget, eve=None):
@ -155,7 +155,7 @@ class TabMixin(GridMixin):
if action == "create_tab": if action == "create_tab":
dir = tab.get_current_directory() dir = tab.get_current_directory()
self.create_tab(wid, None, dir) self.create_tab(wid, None, dir)
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
return return

View File

@ -95,7 +95,7 @@ class WindowMixin(TabMixin):
except WindowException as e: except WindowException as e:
logger.info(repr(e)) logger.info(repr(e))
self.display_message(settings.get_error_color(), f"{repr(e)}") self.display_message(settings.theming.error_color, f"{repr(e)}")
def grid_icon_double_click(self, icons_grid, item, data=None): def grid_icon_double_click(self, icons_grid, item, data=None):
try: try:
@ -124,7 +124,7 @@ class WindowMixin(TabMixin):
event_system.emit("open_files") event_system.emit("open_files")
except WindowException as e: except WindowException as e:
traceback.print_exc() traceback.print_exc()
self.display_message(settings.get_error_color(), f"{repr(e)}") self.display_message(settings.theming.error_color, f"{repr(e)}")

View File

@ -0,0 +1,34 @@
/* Set fm to have transparent window */
* {
/* background: rgba(0, 0, 0, 0.14); */
color: rgba(255, 255, 255, 1);
border: 2px solid rgba(0, 0, 0, 0.0);
}
.base-container {
margin: 10px;
}
/* * selection {
background-color: rgba(116, 0, 0, 0.65);
color: rgba(255, 255, 255, 0.5);
} */
/* Rubberband coloring */
/* .rubberband,
rubberband,
flowbox rubberband,
treeview.view rubberband,
.content-view rubberband,
.content-view .rubberband,
XfdesktopIconView.view .rubberband {
border: 1px solid #6c6c6c;
background-color: rgba(21, 158, 167, 0.57);
}
XfdesktopIconView.view:active {
background-color: rgba(172, 102, 21, 1);
} */

View File

@ -21,7 +21,7 @@ class BottomStatusInfoWidget:
def __init__(self): def __init__(self):
super(BottomStatusInfoWidget, self).__init__() super(BottomStatusInfoWidget, self).__init__()
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/bottom_status_info_ui.glade" _GLADE_FILE = f"{settings_manager.get_ui_widgets_path()}/bottom_status_info_ui.glade"
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._builder.add_from_file(_GLADE_FILE) self._builder.add_from_file(_GLADE_FILE)
@ -41,7 +41,7 @@ class BottomStatusInfoWidget:
event_system.subscribe("set_bottom_labels", self.set_bottom_labels) event_system.subscribe("set_bottom_labels", self.set_bottom_labels)
def _load_widgets(self): def _load_widgets(self):
builder = settings.get_builder() builder = settings_manager.get_builder()
self.bottom_status_info = self._builder.get_object("bottom_status_info") self.bottom_status_info = self._builder.get_object("bottom_status_info")
self.bottom_size_label = self._builder.get_object("bottom_size_label") self.bottom_size_label = self._builder.get_object("bottom_size_label")
@ -66,7 +66,7 @@ class BottomStatusInfoWidget:
formatted_mount_size = sizeof_fmt( int(mount_file.get_attribute_as_string("filesystem::size")) ) formatted_mount_size = sizeof_fmt( int(mount_file.get_attribute_as_string("filesystem::size")) )
# NOTE: Hides empty trash and other desired buttons based on context. # NOTE: Hides empty trash and other desired buttons based on context.
if settings.get_trash_files_path() == current_directory: if settings_manager.get_trash_files_path() == current_directory:
event_system.emit("show_trash_buttons") event_system.emit("show_trash_buttons")
else: else:
event_system.emit("hide_trash_buttons") event_system.emit("hide_trash_buttons")

View File

@ -16,10 +16,10 @@ class ContextMenuWidget(Gtk.Menu):
def __init__(self): def __init__(self):
super(ContextMenuWidget, self).__init__() super(ContextMenuWidget, self).__init__()
self.builder = settings.get_builder() self.builder = settings_manager.get_builder()
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._context_menu_data = settings.get_context_menu_data() self._context_menu_data = settings_manager.get_context_menu_data()
self._window = settings.get_main_window() self._window = settings_manager.get_main_window()
self._setup_styling() self._setup_styling()
self._setup_signals() self._setup_signals()
@ -32,7 +32,7 @@ class ContextMenuWidget(Gtk.Menu):
def _setup_signals(self): def _setup_signals(self):
event_system.subscribe("show_context_menu", self.show_context_menu) event_system.subscribe("show_context_menu", self.show_context_menu)
event_system.subscribe("hide_context_menu", self.hide_context_menu) event_system.subscribe("hide_context_menu", self.hide_context_menu)
settings.register_signals_to_builder([self,], self._builder) settings_manager.register_signals_to_builder([self,], self._builder)
def _load_widgets(self): def _load_widgets(self):
self.build_context_menu() self.build_context_menu()

View File

@ -16,7 +16,7 @@ class AboutWidget:
def __init__(self): def __init__(self):
super(AboutWidget, self).__init__() super(AboutWidget, self).__init__()
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/about_ui.glade" _GLADE_FILE = f"{settings_manager.get_ui_widgets_path()}/about_ui.glade"
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._builder.add_from_file(_GLADE_FILE) self._builder.add_from_file(_GLADE_FILE)
@ -31,10 +31,10 @@ class AboutWidget:
def _setup_signals(self): def _setup_signals(self):
event_system.subscribe("show_about_page", self.show_about_page) event_system.subscribe("show_about_page", self.show_about_page)
event_system.subscribe("hide_about_page", self.hide_about_page) event_system.subscribe("hide_about_page", self.hide_about_page)
settings.register_signals_to_builder([self,], self._builder) settings_manager.register_signals_to_builder([self,], self._builder)
def _load_widgets(self): def _load_widgets(self):
builder = settings.get_builder() builder = settings_manager.get_builder()
self.about_page = self._builder.get_object("about_page") self.about_page = self._builder.get_object("about_page")
builder.expose_object(f"about_page", self.about_page) builder.expose_object(f"about_page", self.about_page)

View File

@ -16,7 +16,7 @@ class AppchooserWidget:
def __init__(self): def __init__(self):
super(AppchooserWidget, self).__init__() super(AppchooserWidget, self).__init__()
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/appchooser_ui.glade" _GLADE_FILE = f"{settings_manager.get_ui_widgets_path()}/appchooser_ui.glade"
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._builder.add_from_file(_GLADE_FILE) self._builder.add_from_file(_GLADE_FILE)
@ -32,10 +32,10 @@ class AppchooserWidget:
event_system.subscribe("show_appchooser_menu", self.show_appchooser_menu) event_system.subscribe("show_appchooser_menu", self.show_appchooser_menu)
event_system.subscribe("hide_appchooser_menu", self.hide_appchooser_menu) event_system.subscribe("hide_appchooser_menu", self.hide_appchooser_menu)
event_system.subscribe("run_appchooser_launch", self.run_appchooser_launch) event_system.subscribe("run_appchooser_launch", self.run_appchooser_launch)
settings.register_signals_to_builder([self,], self._builder) settings_manager.register_signals_to_builder([self,], self._builder)
def _load_widgets(self): def _load_widgets(self):
builder = settings.get_builder() builder = settings_manager.get_builder()
self._appchooser_menu = self._builder.get_object("appchooser_menu") self._appchooser_menu = self._builder.get_object("appchooser_menu")
self._appchooser_widget = self._builder.get_object("appchooser_widget") self._appchooser_widget = self._builder.get_object("appchooser_widget")

View File

@ -17,7 +17,7 @@ class FileExistsWidget:
def __init__(self): def __init__(self):
super(FileExistsWidget, self).__init__() super(FileExistsWidget, self).__init__()
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/file_exists_ui.glade" _GLADE_FILE = f"{settings_manager.get_ui_widgets_path()}/file_exists_ui.glade"
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._builder.add_from_file(_GLADE_FILE) self._builder.add_from_file(_GLADE_FILE)
@ -32,10 +32,10 @@ class FileExistsWidget:
def _setup_signals(self): def _setup_signals(self):
event_system.subscribe("setup_exists_data", self.setup_exists_data) event_system.subscribe("setup_exists_data", self.setup_exists_data)
event_system.subscribe("show_exists_page", self.show_exists_page) event_system.subscribe("show_exists_page", self.show_exists_page)
settings.register_signals_to_builder([self,], self._builder) settings_manager.register_signals_to_builder([self,], self._builder)
def _load_widgets(self): def _load_widgets(self):
builder = settings.get_builder() builder = settings_manager.get_builder()
self.file_exists_dialog = self._builder.get_object("file_exists_dialog") self.file_exists_dialog = self._builder.get_object("file_exists_dialog")
self._exists_file_label = self._builder.get_object("exists_file_label") self._exists_file_label = self._builder.get_object("exists_file_label")

View File

@ -18,7 +18,7 @@ class NewFileWidget:
def __init__(self): def __init__(self):
super(NewFileWidget, self).__init__() super(NewFileWidget, self).__init__()
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/new_file_ui.glade" _GLADE_FILE = f"{settings_manager.get_ui_widgets_path()}/new_file_ui.glade"
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._builder.add_from_file(_GLADE_FILE) self._builder.add_from_file(_GLADE_FILE)
@ -33,10 +33,10 @@ class NewFileWidget:
def _setup_signals(self): def _setup_signals(self):
event_system.subscribe("show_new_file_menu", self.show_new_file_menu) event_system.subscribe("show_new_file_menu", self.show_new_file_menu)
event_system.subscribe("hide_new_file_menu", self.hide_new_file_menu) event_system.subscribe("hide_new_file_menu", self.hide_new_file_menu)
settings.register_signals_to_builder([self,], self._builder) settings_manager.register_signals_to_builder([self,], self._builder)
def _load_widgets(self): def _load_widgets(self):
builder = settings.get_builder() builder = settings_manager.get_builder()
self._new_file_menu = self._builder.get_object("new_file_menu") self._new_file_menu = self._builder.get_object("new_file_menu")
self._new_fname_field = self._builder.get_object("new_fname_field") self._new_fname_field = self._builder.get_object("new_fname_field")

View File

@ -18,7 +18,7 @@ class RenameWidget:
def __init__(self): def __init__(self):
super(RenameWidget, self).__init__() super(RenameWidget, self).__init__()
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/rename_ui.glade" _GLADE_FILE = f"{settings_manager.get_ui_widgets_path()}/rename_ui.glade"
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._builder.add_from_file(_GLADE_FILE) self._builder.add_from_file(_GLADE_FILE)
@ -33,10 +33,10 @@ class RenameWidget:
def _setup_signals(self): def _setup_signals(self):
event_system.subscribe("show_rename_file_menu", self.show_rename_file_menu) event_system.subscribe("show_rename_file_menu", self.show_rename_file_menu)
event_system.subscribe("hide_rename_file_menu", self.hide_rename_file_menu) event_system.subscribe("hide_rename_file_menu", self.hide_rename_file_menu)
settings.register_signals_to_builder([self,], self._builder) settings_manager.register_signals_to_builder([self,], self._builder)
def _load_widgets(self): def _load_widgets(self):
builder = settings.get_builder() builder = settings_manager.get_builder()
self._rename_file_menu = self._builder.get_object("rename_file_menu") self._rename_file_menu = self._builder.get_object("rename_file_menu")
self._rename_fname = self._builder.get_object("rename_fname") self._rename_fname = self._builder.get_object("rename_fname")

View File

@ -20,7 +20,7 @@ class SaveLoadWidget:
def __init__(self): def __init__(self):
super(SaveLoadWidget, self).__init__() super(SaveLoadWidget, self).__init__()
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/save_load_ui.glade" _GLADE_FILE = f"{settings_manager.get_ui_widgets_path()}/save_load_ui.glade"
self._builder = Gtk.Builder() self._builder = Gtk.Builder()
self._builder.add_from_file(_GLADE_FILE) self._builder.add_from_file(_GLADE_FILE)
@ -36,7 +36,7 @@ class SaveLoadWidget:
event_system.subscribe("save_load_session", self.save_load_session) event_system.subscribe("save_load_session", self.save_load_session)
def _load_widgets(self): def _load_widgets(self):
builder = settings.get_builder() builder = settings_manager.get_builder()
self.save_load_dialog = self._builder.get_object("save_load_dialog") self.save_load_dialog = self._builder.get_object("save_load_dialog")
builder.expose_object(f"save_load_dialog", self.save_load_dialog) builder.expose_object(f"save_load_dialog", self.save_load_dialog)
@ -46,7 +46,7 @@ class SaveLoadWidget:
state = event_system.emit_and_await("get_current_state") state = event_system.emit_and_await("get_current_state")
if action == "save_session": if action == "save_session":
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
state.fm_controller.save_state() state.fm_controller.save_state()
return return
@ -74,7 +74,7 @@ class SaveLoadWidget:
self.save_load_dialog.hide() self.save_load_dialog.hide()
def load_session(self, session_json): def load_session(self, session_json):
if settings.is_debug(): if settings_manager.is_debug():
logger.debug(f"Session Data: {session_json}") logger.debug(f"Session Data: {session_json}")
state = event_system.emit_and_await("get_current_state") state = event_system.emit_and_await("get_current_state")

View File

@ -41,14 +41,14 @@ class FilesWidget(FileActionSignalsMixin, WindowMixin):
... ...
def _setup_signals(self): def _setup_signals(self):
settings.register_signals_to_builder([self,], self.builder) settings_manager.register_signals_to_builder([self,], self.builder)
def _subscribe_to_events(self): def _subscribe_to_events(self):
event_system.subscribe("load_files_view_state", self._load_files_view_state) event_system.subscribe("load_files_view_state", self._load_files_view_state)
event_system.subscribe("get_files_view_icon_grid", self._get_files_view_icon_grid) event_system.subscribe("get_files_view_icon_grid", self._get_files_view_icon_grid)
def _load_widgets(self): def _load_widgets(self):
_builder = settings.get_builder() _builder = settings_manager.get_builder()
self.files_view = _builder.get_object(f"{self.NAME}") self.files_view = _builder.get_object(f"{self.NAME}")
self.files_view.set_group_name("files_widget") self.files_view.set_group_name("files_widget")

View File

@ -70,13 +70,13 @@ class TabMixin(GridMixin):
self.get_fm_window(wid).delete_tab_by_id(tid) self.get_fm_window(wid).delete_tab_by_id(tid)
store.clear() store.clear()
store.run_dispose() # store.run_dispose()
icon_grid.destroy() icon_grid.destroy()
icon_grid.run_dispose() # icon_grid.run_dispose()
scroll.destroy() scroll.destroy()
scroll.run_dispose() #scroll.run_dispose()
tab_box.destroy() tab_box.destroy()
tab_box.run_dispose() #tab_box.run_dispose()
del store del store
del icon_grid del icon_grid
@ -85,7 +85,7 @@ class TabMixin(GridMixin):
del watcher del watcher
del tab del tab
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
self.set_window_title() self.set_window_title()
@ -108,7 +108,7 @@ class TabMixin(GridMixin):
tab = window.get_tab_by_id(tid) tab = window.get_tab_by_id(tid)
self.set_file_watcher(tab) self.set_file_watcher(tab)
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
def on_tab_switch_update(self, notebook, content=None, index=None): def on_tab_switch_update(self, notebook, content=None, index=None):
@ -144,7 +144,7 @@ class TabMixin(GridMixin):
tab_label.set_label(tab.get_end_of_path()) tab_label.set_label(tab.get_end_of_path())
self.set_window_title() self.set_window_title()
self.set_file_watcher(tab) self.set_file_watcher(tab)
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
def do_action_from_bar_controls(self, widget, eve=None): def do_action_from_bar_controls(self, widget, eve=None):
@ -157,7 +157,7 @@ class TabMixin(GridMixin):
if action == "create_tab": if action == "create_tab":
dir = tab.get_current_directory() dir = tab.get_current_directory()
self.create_tab(wid, None, dir) self.create_tab(wid, None, dir)
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self.fm_controller.save_state() self.fm_controller.save_state()
return return

View File

@ -90,7 +90,7 @@ class WindowMixin(TabMixin):
except WindowException as e: except WindowException as e:
logger.info(repr(e)) logger.info(repr(e))
self.display_message(settings.get_error_color(), f"{repr(e)}") self.display_message(settings.theming.error_color, f"{repr(e)}")
def grid_icon_double_click(self, icons_grid, item, data=None): def grid_icon_double_click(self, icons_grid, item, data=None):
try: try:
@ -119,7 +119,7 @@ class WindowMixin(TabMixin):
event_system.emit("open_files") event_system.emit("open_files")
except WindowException as e: except WindowException as e:
traceback.print_exc() traceback.print_exc()
self.display_message(settings.get_error_color(), f"{repr(e)}") self.display_message(settings.theming.error_color, f"{repr(e)}")

View File

@ -16,7 +16,7 @@ class IOPopupWidget(Gtk.Popover):
def __init__(self): def __init__(self):
super(IOPopupWidget, self).__init__() super(IOPopupWidget, self).__init__()
self._builder = settings.get_builder() self._builder = settings_manager.get_builder()
self._builder.expose_object(f"io_popup", self) self._builder.expose_object(f"io_popup", self)
self._setup_styling() self._setup_styling()

View File

@ -23,7 +23,7 @@ class MessagePopupWidget(Gtk.Popover):
def __init__(self): def __init__(self):
super(MessagePopupWidget, self).__init__() super(MessagePopupWidget, self).__init__()
self.builder = settings.get_builder() self.builder = settings_manager.get_builder()
self.builder.expose_object(f"message_popup_widget", self) self.builder.expose_object(f"message_popup_widget", self)
self._message_buffer = None self._message_buffer = None
@ -90,7 +90,7 @@ class MessagePopupWidget(Gtk.Popover):
current_time = datetime.datetime.now() current_time = datetime.datetime.now()
data = f"{current_time}\nExec Type: {exc_type} <--> Value: {exc_value}\n\n{trace}\n\n" data = f"{current_time}\nExec Type: {exc_type} <--> Value: {exc_value}\n\n{trace}\n\n"
self.display_message(settings.get_error_color(), data) self.display_message(settings.theming.error_color, data)
def display_message(self, type, text, seconds=None): def display_message(self, type, text, seconds=None):
# start_itr = self._message_buffer.get_start_iter() # start_itr = self._message_buffer.get_start_iter()
@ -110,7 +110,7 @@ class MessagePopupWidget(Gtk.Popover):
def save_debug_alerts(self, widget=None, eve=None): def save_debug_alerts(self, widget=None, eve=None):
start_itr, end_itr = self._message_buffer.get_bounds() start_itr, end_itr = self._message_buffer.get_bounds()
save_location_prompt = Gtk.FileChooserDialog("Choose Save Folder", settings.get_main_window(), \ save_location_prompt = Gtk.FileChooserDialog("Choose Save Folder", settings_manager.get_main_window(), \
action = Gtk.FileChooserAction.SAVE, \ action = Gtk.FileChooserAction.SAVE, \
buttons = (Gtk.STOCK_CANCEL, \ buttons = (Gtk.STOCK_CANCEL, \
Gtk.ResponseType.CANCEL, \ Gtk.ResponseType.CANCEL, \

View File

@ -16,7 +16,7 @@ class PathMenuPopupWidget(Gtk.Popover):
def __init__(self): def __init__(self):
super(PathMenuPopupWidget, self).__init__() super(PathMenuPopupWidget, self).__init__()
self.builder = settings.get_builder() self.builder = settings_manager.get_builder()
self.builder.expose_object(f"path_menu", self) self.builder.expose_object(f"path_menu", self)
self._setup_styling() self._setup_styling()

View File

@ -16,7 +16,7 @@ class PluginsPopupWidget(Gtk.Popover):
def __init__(self): def __init__(self):
super(PluginsPopupWidget, self).__init__() super(PluginsPopupWidget, self).__init__()
self.builder = settings.get_builder() self.builder = settings_manager.get_builder()
self.builder.expose_object(f"plugin_controls", self) self.builder.expose_object(f"plugin_controls", self)
self._setup_styling() self._setup_styling()

View File

@ -24,7 +24,7 @@ class Window(Gtk.ApplicationWindow):
super(Window, self).__init__() super(Window, self).__init__()
self._controller = None self._controller = None
settings.set_main_window(self) settings_manager.set_main_window(self)
self._set_window_data() self._set_window_data()
self._setup_styling() self._setup_styling()
@ -37,10 +37,10 @@ class Window(Gtk.ApplicationWindow):
def _setup_styling(self): def _setup_styling(self):
self.set_default_size(settings.get_main_window_width(), self.set_default_size(settings_manager.get_main_window_width(),
settings.get_main_window_height()) settings_manager.get_main_window_height())
self.set_title(f"{app_name}") self.set_title(f"{app_name}")
self.set_icon_from_file( settings.get_window_icon() ) self.set_icon_from_file( settings_manager.get_window_icon() )
self.set_gravity(5) # 5 = CENTER self.set_gravity(5) # 5 = CENTER
self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS
@ -52,7 +52,7 @@ class Window(Gtk.ApplicationWindow):
event_system.subscribe("tear_down", self._tear_down) event_system.subscribe("tear_down", self._tear_down)
def _load_widgets(self, args, unknownargs): def _load_widgets(self, args, unknownargs):
if settings.is_debug(): if settings_manager.is_debug():
self.set_interactive_debugging(True) self.set_interactive_debugging(True)
self._controller = Controller(args, unknownargs) self._controller = Controller(args, unknownargs)
@ -73,7 +73,7 @@ class Window(Gtk.ApplicationWindow):
# bind css file # bind css file
cssProvider = Gtk.CssProvider() cssProvider = Gtk.CssProvider()
cssProvider.load_from_path( settings.get_css_file() ) cssProvider.load_from_path( settings_manager.get_css_file() )
screen = Gdk.Screen.get_default() screen = Gdk.Screen.get_default()
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)
@ -86,9 +86,9 @@ class Window(Gtk.ApplicationWindow):
def _tear_down(self, widget=None, eve=None): def _tear_down(self, widget=None, eve=None):
if not settings.is_trace_debug(): if not settings_manager.is_trace_debug():
self._controller.fm_controller.save_state() self._controller.fm_controller.save_state()
settings.clear_pid() settings_manager.clear_pid()
time.sleep(event_sleep_time) time.sleep(event_sleep_time)
Gtk.main_quit() Gtk.main_quit()

View File

@ -31,8 +31,8 @@ class PluginsController:
path = os.path.dirname(os.path.realpath(__file__)) path = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, path) # NOTE: I think I'm not using this correctly... sys.path.insert(0, path) # NOTE: I think I'm not using this correctly...
self._builder = settings.get_builder() self._builder = settings_manager.get_builder()
self._plugins_path = settings.get_plugins_path() self._plugins_path = settings_manager.get_plugins_path()
self._plugins_dir_watcher = None self._plugins_dir_watcher = None
self._plugin_collection = [] self._plugin_collection = []

View File

@ -151,7 +151,7 @@ class Icon(DesktopIconMixin, VideoIconMixin, MeshsIconMixin):
gio_file = Gio.File.new_for_path(full_path) gio_file = Gio.File.new_for_path(full_path)
info = gio_file.query_info('standard::icon' , 0, None) info = gio_file.query_info('standard::icon' , 0, None)
icon = info.get_icon().get_names()[0] icon = info.get_icon().get_names()[0]
data = settings.get_icon_theme().lookup_icon(icon , size , 0) data = settings_manager.get_icon_theme().lookup_icon(icon , size , 0)
if data: if data:
icon_path = data.get_filename() icon_path = data.get_filename()

View File

@ -1,4 +0,0 @@
"""
Settings module
"""
from .settings import Settings

View File

@ -1,181 +0,0 @@
# Python imports
import os
import inspect
import json
from os import path
# Gtk imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
# Application imports
from ..singleton import Singleton
from .start_check_mixin import StartCheckMixin
class Settings(StartCheckMixin, Singleton):
def __init__(self):
self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
self._USER_HOME = path.expanduser('~')
self._USR_PATH = f"/usr/share/{app_name.lower()}"
self._USR_CONFIG_FILE = f"{self._USR_PATH}/settings.json"
self._HOME_CONFIG_PATH = f"{self._USER_HOME}/.config/{app_name.lower()}"
self._PLUGINS_PATH = f"{self._HOME_CONFIG_PATH}/plugins"
self._DEFAULT_ICONS = f"{self._HOME_CONFIG_PATH}/icons"
self._CONFIG_FILE = f"{self._HOME_CONFIG_PATH}/settings.json"
self._GLADE_FILE = f"{self._HOME_CONFIG_PATH}/Main_Window.glade"
self._CSS_FILE = f"{self._HOME_CONFIG_PATH}/stylesheet.css"
self._KEY_BINDINGS_FILE = f"{self._HOME_CONFIG_PATH}/key-bindings.json"
self._PID_FILE = f"{self._HOME_CONFIG_PATH}/{app_name.lower()}.pid"
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/icons/{app_name.lower()}.png"
self._UI_WIDEGTS_PATH = f"{self._HOME_CONFIG_PATH}/ui_widgets"
self._CONTEXT_MENU = f"{self._HOME_CONFIG_PATH}/contexct_menu.json"
self._TRASH_FILES_PATH = f"{GLib.get_user_data_dir()}/Trash/files"
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 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):
raise MissingConfigError("Unable to find the application icons directory.")
if not os.path.exists(self._GLADE_FILE):
self._GLADE_FILE = f"{self._USR_PATH}/Main_Window.glade"
if not os.path.exists(self._GLADE_FILE):
raise MissingConfigError("Unable to find the application Glade file.")
if not os.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):
raise MissingConfigError("Unable to find the application Keybindings file.")
if not os.path.exists(self._CSS_FILE):
self._CSS_FILE = f"{self._USR_PATH}/stylesheet.css"
if not os.path.exists(self._CSS_FILE):
raise MissingConfigError("Unable to find the application Stylesheet file.")
if not os.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):
raise MissingConfigError("Unable to find the application icon.")
if not os.path.exists(self._UI_WIDEGTS_PATH):
self._UI_WIDEGTS_PATH = f"{self._USR_PATH}/ui_widgets"
if not os.path.exists(self._CONTEXT_MENU):
self._CONTEXT_MENU = f"{self._USR_PATH}/contexct_menu.json"
try:
with open(self._KEY_BINDINGS_FILE) as file:
bindings = json.load(file)["keybindings"]
keybindings.configure(bindings)
except Exception as e:
print( f"Settings: {self._KEY_BINDINGS_FILE}\n\t\t{repr(e)}" )
try:
with open(self._CONTEXT_MENU) as file:
self._context_menu_data = json.load(file)
except Exception as e:
print( f"Settings: {self._CONTEXT_MENU}\n\t\t{repr(e)}" )
self._main_window = None
self._main_window_w = 1670
self._main_window_h = 830
self._builder = None
self._trace_debug = False
self._debug = False
self._dirty_start = False
self.load_settings()
def register_signals_to_builder(self, classes=None, builder=None):
handlers = {}
for c in classes:
methods = None
try:
methods = inspect.getmembers(c, predicate=inspect.ismethod)
handlers.update(methods)
except Exception as e:
print(repr(e))
builder.connect_signals(handlers)
def get_monitor_data(self) -> list:
screen = self._main_window.get_screen()
monitors = []
for m in range(screen.get_n_monitors()):
monitors.append(screen.get_monitor_geometry(m))
print("{}x{}+{}+{}".format(monitor.width, monitor.height, monitor.x, monitor.y))
return monitors
def set_builder(self, builder) -> any: self._builder = builder
def set_main_window(self, window): self._main_window = window
def get_main_window(self) -> Gtk.ApplicationWindow: return self._main_window
def get_main_window_width(self) -> Gtk.ApplicationWindow: return self._main_window_w
def get_main_window_height(self) -> Gtk.ApplicationWindow: return self._main_window_h
def get_builder(self) -> Gtk.Builder: return self._builder
def get_glade_file(self) -> str: return self._GLADE_FILE
def get_icon_theme(self) -> str: return self._ICON_THEME
def get_css_file(self) -> str: return self._CSS_FILE
def get_home_config_path(self) -> str: return self._HOME_CONFIG_PATH
def get_window_icon(self) -> str: return self._WINDOW_ICON
def get_context_menu_data(self) -> str: return self._context_menu_data
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
def get_plugins_path(self) -> str: return self._PLUGINS_PATH
# Filter returns
def get_office_filter(self) -> tuple: return tuple(self._settings["filters"]["office"])
def get_vids_filter(self) -> tuple: return tuple(self._settings["filters"]["videos"])
def get_text_filter(self) -> tuple: return tuple(self._settings["filters"]["text"])
def get_music_filter(self) -> tuple: return tuple(self._settings["filters"]["music"])
def get_images_filter(self) -> tuple: return tuple(self._settings["filters"]["images"])
def get_pdf_filter(self) -> tuple: return tuple(self._settings["filters"]["pdf"])
def get_success_color(self) -> str: return self._theming["success_color"]
def get_warning_color(self) -> str: return self._theming["warning_color"]
def get_error_color(self) -> str: return self._theming["error_color"]
def is_trace_debug(self) -> bool: return self._trace_debug
def is_debug(self) -> bool: return self._debug
def get_ch_log_lvl(self) -> str: return self._settings["debugging"]["ch_log_lvl"]
def get_fh_log_lvl(self) -> str: return self._settings["debugging"]["fh_log_lvl"]
def set_trace_debug(self, trace_debug: bool):
self._trace_debug = trace_debug
def set_debug(self, debug: bool):
self._debug = debug
def load_settings(self):
with open(self._CONFIG_FILE) as f:
self._settings = json.load(f)
self._config = self._settings["config"]
self._theming = self._settings["theming"]
def save_settings(self):
with open(self._CONFIG_FILE, 'w') as outfile:
json.dump(self._settings, outfile, separators=(',', ':'), indent=4)

View File

@ -0,0 +1,4 @@
"""
Settings module
"""
from .manager import SettingsManager

View File

@ -0,0 +1,354 @@
# Python imports
import os
import inspect
import json
from os import path
# Gtk imports
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
# Application imports
from ..singleton import Singleton
from .start_check_mixin import StartCheckMixin
from .options.settings import Settings
class MissingConfigError(Exception):
pass
class SettingsManager(StartCheckMixin, Singleton):
def __init__(self):
self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
self._USER_HOME = path.expanduser('~')
self._USR_PATH = f"/usr/share/{app_name.lower()}"
self._USR_CONFIG_FILE = f"{self._USR_PATH}/settings.json"
self._HOME_CONFIG_PATH = f"{self._USER_HOME}/.config/{app_name.lower()}"
self._PLUGINS_PATH = f"{self._HOME_CONFIG_PATH}/plugins"
self._DEFAULT_ICONS = f"{self._HOME_CONFIG_PATH}/icons"
self._CONFIG_FILE = f"{self._HOME_CONFIG_PATH}/settings.json"
self._GLADE_FILE = f"{self._HOME_CONFIG_PATH}/Main_Window.glade"
self._CSS_FILE = f"{self._HOME_CONFIG_PATH}/stylesheet.css"
self._KEY_BINDINGS_FILE = f"{self._HOME_CONFIG_PATH}/key-bindings.json"
self._PID_FILE = f"{self._HOME_CONFIG_PATH}/{app_name.lower()}.pid"
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/icons/{app_name.lower()}.png"
self._UI_WIDEGTS_PATH = f"{self._HOME_CONFIG_PATH}/ui_widgets"
self._CONTEXT_MENU = f"{self._HOME_CONFIG_PATH}/contexct_menu.json"
self._TRASH_FILES_PATH = f"{GLib.get_user_data_dir()}/Trash/files"
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 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):
raise MissingConfigError("Unable to find the application icons directory.")
if not os.path.exists(self._GLADE_FILE):
self._GLADE_FILE = f"{self._USR_PATH}/Main_Window.glade"
if not os.path.exists(self._GLADE_FILE):
raise MissingConfigError("Unable to find the application Glade file.")
if not os.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):
raise MissingConfigError("Unable to find the application Keybindings file.")
if not os.path.exists(self._CSS_FILE):
self._CSS_FILE = f"{self._USR_PATH}/stylesheet.css"
if not os.path.exists(self._CSS_FILE):
raise MissingConfigError("Unable to find the application Stylesheet file.")
if not os.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):
raise MissingConfigError("Unable to find the application icon.")
if not os.path.exists(self._UI_WIDEGTS_PATH):
self._UI_WIDEGTS_PATH = f"{self._USR_PATH}/ui_widgets"
if not os.path.exists(self._CONTEXT_MENU):
self._CONTEXT_MENU = f"{self._USR_PATH}/contexct_menu.json"
try:
with open(self._KEY_BINDINGS_FILE) as file:
bindings = json.load(file)["keybindings"]
keybindings.configure(bindings)
except Exception as e:
print( f"Settings: {self._KEY_BINDINGS_FILE}\n\t\t{repr(e)}" )
try:
with open(self._CONTEXT_MENU) as file:
self._context_menu_data = json.load(file)
except Exception as e:
print( f"Settings: {self._CONTEXT_MENU}\n\t\t{repr(e)}" )
self.settings: Settings = None
self._main_window = None
self._main_window_w = 1670
self._main_window_h = 830
self._builder = None
self._trace_debug = False
self._debug = False
self._dirty_start = False
self.load_settings()
def register_signals_to_builder(self, classes=None, builder=None):
handlers = {}
for c in classes:
methods = None
try:
methods = inspect.getmembers(c, predicate=inspect.ismethod)
handlers.update(methods)
except Exception as e:
print(repr(e))
builder.connect_signals(handlers)
def get_monitor_data(self) -> list:
screen = self._main_window.get_screen()
monitors = []
for m in range(screen.get_n_monitors()):
monitors.append(screen.get_monitor_geometry(m))
print("{}x{}+{}+{}".format(monitor.width, monitor.height, monitor.x, monitor.y))
return monitors
def set_builder(self, builder) -> any: self._builder = builder
def set_main_window(self, window): self._main_window = window
def get_main_window(self) -> Gtk.ApplicationWindow: return self._main_window
def get_main_window_width(self) -> Gtk.ApplicationWindow: return self._main_window_w
def get_main_window_height(self) -> Gtk.ApplicationWindow: return self._main_window_h
def get_builder(self) -> Gtk.Builder: return self._builder
def get_glade_file(self) -> str: return self._GLADE_FILE
def get_icon_theme(self) -> str: return self._ICON_THEME
def get_css_file(self) -> str: return self._CSS_FILE
def get_home_config_path(self) -> str: return self._HOME_CONFIG_PATH
def get_window_icon(self) -> str: return self._WINDOW_ICON
def get_context_menu_data(self) -> str: return self._context_menu_data
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
def get_plugins_path(self) -> str: return self._PLUGINS_PATH
def is_trace_debug(self) -> bool: return self._trace_debug
def is_debug(self) -> bool: return self._debug
def set_trace_debug(self, trace_debug: bool):
self._trace_debug = trace_debug
def set_debug(self, debug: bool):
self._debug = debug
def load_settings(self):
with open(self._CONFIG_FILE) as file:
data = json.load(file)
self.settings = Settings(**data)
def save_settings(self):
...
# with open(self._CONFIG_FILE, 'w') as outfile:
# json.dump(self._settings, outfile, separators=(',', ':'), indent=4)
# class Settings(StartCheckMixin, Singleton):
# def __init__(self):
# self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
# self._USER_HOME = path.expanduser('~')
# self._USR_PATH = f"/usr/share/{app_name.lower()}"
#
# self._USR_CONFIG_FILE = f"{self._USR_PATH}/settings.json"
# self._HOME_CONFIG_PATH = f"{self._USER_HOME}/.config/{app_name.lower()}"
# self._PLUGINS_PATH = f"{self._HOME_CONFIG_PATH}/plugins"
# self._DEFAULT_ICONS = f"{self._HOME_CONFIG_PATH}/icons"
# self._CONFIG_FILE = f"{self._HOME_CONFIG_PATH}/settings.json"
# self._GLADE_FILE = f"{self._HOME_CONFIG_PATH}/Main_Window.glade"
# self._CSS_FILE = f"{self._HOME_CONFIG_PATH}/stylesheet.css"
# self._KEY_BINDINGS_FILE = f"{self._HOME_CONFIG_PATH}/key-bindings.json"
# self._PID_FILE = f"{self._HOME_CONFIG_PATH}/{app_name.lower()}.pid"
# self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/icons/{app_name.lower()}.png"
# self._UI_WIDEGTS_PATH = f"{self._HOME_CONFIG_PATH}/ui_widgets"
# self._CONTEXT_MENU = f"{self._HOME_CONFIG_PATH}/contexct_menu.json"
# self._TRASH_FILES_PATH = f"{GLib.get_user_data_dir()}/Trash/files"
# 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 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):
# raise MissingConfigError("Unable to find the application icons directory.")
# if not os.path.exists(self._GLADE_FILE):
# self._GLADE_FILE = f"{self._USR_PATH}/Main_Window.glade"
# if not os.path.exists(self._GLADE_FILE):
# raise MissingConfigError("Unable to find the application Glade file.")
# if not os.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):
# raise MissingConfigError("Unable to find the application Keybindings file.")
# if not os.path.exists(self._CSS_FILE):
# self._CSS_FILE = f"{self._USR_PATH}/stylesheet.css"
# if not os.path.exists(self._CSS_FILE):
# raise MissingConfigError("Unable to find the application Stylesheet file.")
# if not os.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):
# raise MissingConfigError("Unable to find the application icon.")
# if not os.path.exists(self._UI_WIDEGTS_PATH):
# self._UI_WIDEGTS_PATH = f"{self._USR_PATH}/ui_widgets"
# if not os.path.exists(self._CONTEXT_MENU):
# self._CONTEXT_MENU = f"{self._USR_PATH}/contexct_menu.json"
#
#
# try:
# with open(self._KEY_BINDINGS_FILE) as file:
# bindings = json.load(file)["keybindings"]
# keybindings.configure(bindings)
# except Exception as e:
# print( f"Settings: {self._KEY_BINDINGS_FILE}\n\t\t{repr(e)}" )
#
# try:
# with open(self._CONTEXT_MENU) as file:
# self._context_menu_data = json.load(file)
# except Exception as e:
# print( f"Settings: {self._CONTEXT_MENU}\n\t\t{repr(e)}" )
#
#
# self._main_window = None
# self._main_window_w = 1670
# self._main_window_h = 830
# self._builder = None
#
# self._trace_debug = False
# self._debug = False
# self._dirty_start = False
#
# self.load_settings()
#
#
# def register_signals_to_builder(self, classes=None, builder=None):
# handlers = {}
#
# for c in classes:
# methods = None
# try:
# methods = inspect.getmembers(c, predicate=inspect.ismethod)
# handlers.update(methods)
# except Exception as e:
# print(repr(e))
#
# builder.connect_signals(handlers)
#
# def get_monitor_data(self) -> list:
# screen = self._main_window.get_screen()
# monitors = []
# for m in range(screen.get_n_monitors()):
# monitors.append(screen.get_monitor_geometry(m))
# print("{}x{}+{}+{}".format(monitor.width, monitor.height, monitor.x, monitor.y))
#
# return monitors
#
# def set_builder(self, builder) -> any: self._builder = builder
# def set_main_window(self, window): self._main_window = window
#
# def get_main_window(self) -> Gtk.ApplicationWindow: return self._main_window
# def get_main_window_width(self) -> Gtk.ApplicationWindow: return self._main_window_w
# def get_main_window_height(self) -> Gtk.ApplicationWindow: return self._main_window_h
# def get_builder(self) -> Gtk.Builder: return self._builder
# def get_glade_file(self) -> str: return self._GLADE_FILE
# def get_icon_theme(self) -> str: return self._ICON_THEME
# def get_css_file(self) -> str: return self._CSS_FILE
# def get_home_config_path(self) -> str: return self._HOME_CONFIG_PATH
# def get_window_icon(self) -> str: return self._WINDOW_ICON
#
# def get_context_menu_data(self) -> str: return self._context_menu_data
# 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
# def get_plugins_path(self) -> str: return self._PLUGINS_PATH
#
# # Filter returns
# def get_office_filter(self) -> tuple: return tuple(self._settings["filters"]["office"])
# def get_vids_filter(self) -> tuple: return tuple(self._settings["filters"]["videos"])
# def get_text_filter(self) -> tuple: return tuple(self._settings["filters"]["text"])
# def get_music_filter(self) -> tuple: return tuple(self._settings["filters"]["music"])
# def get_images_filter(self) -> tuple: return tuple(self._settings["filters"]["images"])
# def get_pdf_filter(self) -> tuple: return tuple(self._settings["filters"]["pdf"])
#
# def get_success_color(self) -> str: return self._theming["success_color"]
# def get_warning_color(self) -> str: return self._theming["warning_color"]
# def get_error_color(self) -> str: return self._theming["error_color"]
#
# def is_trace_debug(self) -> bool: return self._trace_debug
# def is_debug(self) -> bool: return self._debug
#
# def get_ch_log_lvl(self) -> str: return self._settings["debugging"]["ch_log_lvl"]
# def get_fh_log_lvl(self) -> str: return self._settings["debugging"]["fh_log_lvl"]
#
#
# def set_trace_debug(self, trace_debug: bool):
# self._trace_debug = trace_debug
#
# def set_debug(self, debug: bool):
# self._debug = debug
#
#
# def load_settings(self):
# with open(self._CONFIG_FILE) as f:
# self._settings = json.load(f)
# self._config = self._settings["config"]
# self._theming = self._settings["theming"]
#
# def save_settings(self):
# with open(self._CONFIG_FILE, 'w') as outfile:
# json.dump(self._settings, outfile, separators=(',', ':'), indent=4)

View File

@ -0,0 +1,8 @@
"""
Options module
"""
from .settings import Settings
from .config import Config
from .filters import Filters
from .theming import Theming
from .debugging import Debugging

View File

@ -0,0 +1,32 @@
# Python imports
from dataclasses import dataclass
# Lib imports
# Application imports
@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: str
mplayer_options: str
music_app: str
media_app: str
image_app: str
office_app: str
pdf_app: str
code_app: str
text_app: str
terminal_app: str
container_icon_wh: []
video_icon_wh: []
sys_icon_wh: []
file_manager_app: str
steam_cdn_url: str
remux_folder_max_disk_usage: str

View File

@ -0,0 +1,12 @@
# Python imports
from dataclasses import dataclass
# Lib imports
# Application imports
@dataclass
class Debugging:
ch_log_lvl: int
fh_log_lvl: int

View File

@ -0,0 +1,18 @@
# Python imports
from dataclasses import dataclass
# Lib imports
# Application imports
@dataclass
class Filters:
meshs: []
code: []
videos: []
office: []
images: []
text: []
music: []
pdf: []

View File

@ -0,0 +1,24 @@
# Python imports
from dataclasses import dataclass
# Gtk imports
# Application imports
from .config import Config
from .filters import Filters
from .theming import Theming
from .debugging import Debugging
@dataclass
class Settings:
config: Config
filters: Filters
theming: Theming
debugging: Debugging
def __post_init__(self):
self.config = Config(**self.config)
self.filters = Filters(**self.filters)
self.theming = Theming(**self.theming)
self.debugging = Debugging(**self.debugging)

View File

@ -0,0 +1,13 @@
# Python imports
from dataclasses import dataclass
# Lib imports
# Application imports
@dataclass
class Theming:
success_color: str
warning_color: str
error_color: str