Refactoring verbiage, preliminary zip scan

This commit is contained in:
itdominator 2023-04-23 10:57:12 -05:00
parent c4eaa57f57
commit 23c2a99c7d
5 changed files with 22 additions and 16 deletions

View File

@ -10,9 +10,9 @@ from gi.repository import Gtk
class CoreWidget(Gtk.Box):
class BaseContainer(Gtk.Box):
def __init__(self):
super(CoreWidget, self).__init__()
super(BaseContainer, self).__init__()
self._builder = settings.get_builder()

View File

@ -13,7 +13,7 @@ from gi.repository import GLib
from .mixins.signals_mixins import SignalsMixins
from .mixins.dummy_mixin import DummyMixin
from .controller_data import ControllerData
from .containers.core_widget import CoreWidget
from .containers.base_container import BaseContainer
@ -55,18 +55,18 @@ class Controller(DummyMixin, SignalsMixins, ControllerData):
event_system.subscribe("handle_dir_from_ipc", self.handle_dir_from_ipc)
event_system.subscribe("tggl_top_main_menubar", self._tggl_top_main_menubar)
def load_glade_file(self):
def setup_builder_and_container(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(settings.get_glade_file())
self.builder.expose_object("main_window", self.window)
settings.set_builder(self.builder)
self.core_widget = CoreWidget()
self.base_container = BaseContainer()
settings.register_signals_to_builder([self, self.core_widget])
settings.register_signals_to_builder([self, self.base_container])
def get_core_widget(self):
return self.core_widget
def get_base_container(self):
return self.base_container
def _tggl_top_main_menubar(self):
print("_tggl_top_main_menubar > stub...")

View File

@ -9,20 +9,19 @@ from plugins.plugins_controller import PluginsController
class ControllerData:
''' ControllerData contains most of the state of the app at ay given time. It also has some support methods. '''
def setup_controller_data(self) -> None:
self.window = settings.get_main_window()
self.builder = None
self.core_widget = None
self.base_container = None
self.was_midified_key = False
self.ctrl_down = False
self.shift_down = False
self.alt_down = False
self.load_glade_file()
self.setup_builder_and_container()
self.plugins = PluginsController()

View File

@ -64,7 +64,7 @@ class Window(Gtk.ApplicationWindow):
if not self._controller:
raise ControllerStartException("Controller exited and doesn't exist...")
self.add( self._controller.get_core_widget() )
self.add( self._controller.get_base_container() )
def _set_window_data(self) -> None:
screen = self.get_screen()

View File

@ -1,7 +1,9 @@
# Python imports
import os
import io
import json
import inspect
import zipfile
# Lib imports
@ -19,10 +21,10 @@ class Settings(StartCheckMixin, Singleton):
def __init__(self):
self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
self._USER_HOME = os.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._USR_PATH = f"/usr/share/{app_name.lower()}"
self._USR_CONFIG_FILE = f"{self._USR_PATH}/settings.json"
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"
@ -30,9 +32,14 @@ class Settings(StartCheckMixin, Singleton):
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}/{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._WINDOW_ICON = f"{self._DEFAULT_ICONS}/{app_name.lower()}.png"
# with zipfile.ZipFile("files.zip", mode="r", allowZip64=True) as zf:
# with io.TextIOWrapper(zf.open("text1.txt"), encoding="utf-8") as f:
if not os.path.exists(self._HOME_CONFIG_PATH):
os.mkdir(self._HOME_CONFIG_PATH)