mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-16 16:28:39 -07:00
Refactor GDM module to correspond SOLID principles
- I don't know how I will support this hell ahh code; - Added some methods to gnome_shell_theme_builder.py; - Added "color" property "install" method from theme_base.py.
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
import os
|
||||
|
||||
from scripts import config
|
||||
from scripts.gdm import GlobalTheme
|
||||
from scripts.install.theme_installer import ThemeInstaller
|
||||
from scripts.utils.global_theme.gdm import GDMTheme
|
||||
from scripts.utils.global_theme.gdm_builder import GdmBuilder
|
||||
from scripts.utils.logger.console import Console, Color, Format
|
||||
from theme import SourceFolder
|
||||
|
||||
|
||||
class GlobalThemeInstaller(ThemeInstaller):
|
||||
theme: GlobalTheme
|
||||
theme: GDMTheme
|
||||
|
||||
def remove(self):
|
||||
gdm_rm_status = self.theme.remove()
|
||||
@@ -16,14 +13,10 @@ class GlobalThemeInstaller(ThemeInstaller):
|
||||
print("GDM theme removed successfully.")
|
||||
|
||||
def _define_theme(self):
|
||||
gdm_temp = os.path.join(config.temp_folder, config.gdm_folder)
|
||||
source_folder = SourceFolder().gnome_shell
|
||||
self.theme = GlobalTheme(self.colors, source_folder,
|
||||
config.global_gnome_shell_theme, config.gnome_shell_gresource,
|
||||
gdm_temp, mode=self.args.mode, is_filled=self.args.filled)
|
||||
|
||||
def _install_theme(self, hue, theme_name, sat):
|
||||
self.theme.install(hue, sat)
|
||||
gdm_builder = GdmBuilder(self.colors)
|
||||
gdm_builder.with_mode(self.args.mode)
|
||||
gdm_builder.with_filled(self.args.filled)
|
||||
self.theme = gdm_builder.build()
|
||||
|
||||
def _apply_tweaks_to_theme(self):
|
||||
for theme in self.theme.themes:
|
||||
|
@@ -18,9 +18,6 @@ class LocalThemeInstaller(ThemeInstaller):
|
||||
theme_builder.filled(self.args.filled)
|
||||
self.theme = theme_builder.build()
|
||||
|
||||
def _install_theme(self, hue, theme_name, sat):
|
||||
self.theme.install(hue, theme_name, sat)
|
||||
|
||||
def _apply_tweaks_to_theme(self):
|
||||
self._apply_tweaks(self.theme)
|
||||
|
||||
|
@@ -3,13 +3,13 @@ import concurrent.futures
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from scripts.install.colors_definer import ColorsDefiner
|
||||
from scripts.utils.theme.theme import Theme
|
||||
from scripts.types.theme_base import ThemeBase
|
||||
from scripts.tweaks_manager import TweaksManager
|
||||
|
||||
|
||||
class ThemeInstaller(ABC):
|
||||
"""Base class for theme installers"""
|
||||
theme: Theme
|
||||
theme: ThemeBase
|
||||
|
||||
def __init__(self, args: argparse.Namespace, colors: ColorsDefiner):
|
||||
self.args = args
|
||||
@@ -37,11 +37,6 @@ class ThemeInstaller(ABC):
|
||||
"""Should apply the tweaks for prepared theme"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def _install_theme(self, hue, theme_name, sat):
|
||||
"""Should say how to install the defined theme"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def _after_install(self):
|
||||
"""Method to be called after the theme is installed. Can be used for logging or other actions"""
|
||||
@@ -53,16 +48,14 @@ class ThemeInstaller(ABC):
|
||||
tweaks_manager.apply_tweaks(self.args, theme, self.colors)
|
||||
|
||||
def _apply_colors(self):
|
||||
installed_any = False
|
||||
|
||||
if self.args.hue:
|
||||
installed_any = True
|
||||
self._apply_custom_color()
|
||||
else:
|
||||
installed_any = self._apply_default_color()
|
||||
return
|
||||
|
||||
if not installed_any:
|
||||
raise Exception('No color arguments specified. Use -h or --help to see the available options.')
|
||||
if self._apply_default_color():
|
||||
return
|
||||
|
||||
raise Exception('No color arguments specified. Use -h or --help to see the available options.')
|
||||
|
||||
def _apply_custom_color(self):
|
||||
name = self.args.name
|
||||
@@ -70,7 +63,7 @@ class ThemeInstaller(ABC):
|
||||
sat = self.args.sat
|
||||
|
||||
theme_name = name if name else f'hue{hue}'
|
||||
self._install_theme(hue, theme_name, sat)
|
||||
self.theme.install(hue, theme_name, sat)
|
||||
|
||||
def _apply_default_color(self) -> bool:
|
||||
colors = self.colors.colors
|
||||
@@ -90,7 +83,7 @@ class ThemeInstaller(ABC):
|
||||
|
||||
def _run_concurrent_installation(self, colors_to_install):
|
||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||
futures = [executor.submit(self._install_theme, hue, color, sat)
|
||||
futures = [executor.submit(self.theme.install, hue, color, sat)
|
||||
for hue, color, sat in colors_to_install]
|
||||
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
|
Reference in New Issue
Block a user