mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-17 16:57:56 -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:
@@ -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