mirror of
https://github.com/GradienceTeam/Gradience.git
synced 2024-06-28 23:49:56 +00:00
backend/theming: enforce hex format in Monet generated variables
Unless alpha parameter is specified.
This commit is contained in:
parent
3f9fb69437
commit
2c5f9925e1
|
@ -24,7 +24,7 @@ from pathlib import Path
|
||||||
from gi.repository import GLib, Gio
|
from gi.repository import GLib, Gio
|
||||||
|
|
||||||
from gradience.backend.models.preset import Preset
|
from gradience.backend.models.preset import Preset
|
||||||
from gradience.backend.utils.colors import rgba_from_argb
|
from gradience.backend.utils.colors import argb_to_color_code
|
||||||
|
|
||||||
from gradience.backend.globals import presets_dir, get_gtk_theme_dir
|
from gradience.backend.globals import presets_dir, get_gtk_theme_dir
|
||||||
|
|
||||||
|
@ -68,98 +68,98 @@ class PresetUtils:
|
||||||
if theme == "dark":
|
if theme == "dark":
|
||||||
dark_theme = monet_palette["schemes"]["dark"]
|
dark_theme = monet_palette["schemes"]["dark"]
|
||||||
variable = {
|
variable = {
|
||||||
"accent_color": rgba_from_argb(dark_theme.primary),
|
"accent_color": argb_to_color_code(dark_theme.primary),
|
||||||
"accent_bg_color": rgba_from_argb(dark_theme.primaryContainer),
|
"accent_bg_color": argb_to_color_code(dark_theme.primaryContainer),
|
||||||
"accent_fg_color": rgba_from_argb(dark_theme.onPrimaryContainer),
|
"accent_fg_color": argb_to_color_code(dark_theme.onPrimaryContainer),
|
||||||
"destructive_color": rgba_from_argb(dark_theme.error),
|
"destructive_color": argb_to_color_code(dark_theme.error),
|
||||||
"destructive_bg_color": rgba_from_argb(dark_theme.errorContainer),
|
"destructive_bg_color": argb_to_color_code(dark_theme.errorContainer),
|
||||||
"destructive_fg_color": rgba_from_argb(
|
"destructive_fg_color": argb_to_color_code(
|
||||||
dark_theme.onErrorContainer
|
dark_theme.onErrorContainer
|
||||||
),
|
),
|
||||||
"success_color": rgba_from_argb(dark_theme.tertiary),
|
"success_color": argb_to_color_code(dark_theme.tertiary),
|
||||||
"success_bg_color": rgba_from_argb(dark_theme.onTertiary),
|
"success_bg_color": argb_to_color_code(dark_theme.onTertiary),
|
||||||
"success_fg_color": rgba_from_argb(dark_theme.onTertiaryContainer),
|
"success_fg_color": argb_to_color_code(dark_theme.onTertiaryContainer),
|
||||||
"warning_color": rgba_from_argb(dark_theme.secondary),
|
"warning_color": argb_to_color_code(dark_theme.secondary),
|
||||||
"warning_bg_color": rgba_from_argb(dark_theme.onSecondary),
|
"warning_bg_color": argb_to_color_code(dark_theme.onSecondary),
|
||||||
"warning_fg_color": rgba_from_argb(dark_theme.primary, "0.8"),
|
"warning_fg_color": argb_to_color_code(dark_theme.primary, "0.8"),
|
||||||
"error_color": rgba_from_argb(dark_theme.error),
|
"error_color": argb_to_color_code(dark_theme.error),
|
||||||
"error_bg_color": rgba_from_argb(dark_theme.errorContainer),
|
"error_bg_color": argb_to_color_code(dark_theme.errorContainer),
|
||||||
"error_fg_color": rgba_from_argb(dark_theme.onError),
|
"error_fg_color": argb_to_color_code(dark_theme.onError),
|
||||||
"window_bg_color": rgba_from_argb(dark_theme.surface),
|
"window_bg_color": argb_to_color_code(dark_theme.surface),
|
||||||
"window_fg_color": rgba_from_argb(dark_theme.onSurface),
|
"window_fg_color": argb_to_color_code(dark_theme.onSurface),
|
||||||
"view_bg_color": rgba_from_argb(dark_theme.surface),
|
"view_bg_color": argb_to_color_code(dark_theme.surface),
|
||||||
"view_fg_color": rgba_from_argb(dark_theme.onSurface),
|
"view_fg_color": argb_to_color_code(dark_theme.onSurface),
|
||||||
"headerbar_bg_color": rgba_from_argb(dark_theme.surface),
|
"headerbar_bg_color": argb_to_color_code(dark_theme.surface),
|
||||||
"headerbar_fg_color": rgba_from_argb(dark_theme.onSurface),
|
"headerbar_fg_color": argb_to_color_code(dark_theme.onSurface),
|
||||||
"headerbar_border_color": rgba_from_argb(
|
"headerbar_border_color": argb_to_color_code(
|
||||||
dark_theme.primary, "0.8"
|
dark_theme.primary, "0.8"
|
||||||
),
|
),
|
||||||
"headerbar_backdrop_color": "@headerbar_bg_color",
|
"headerbar_backdrop_color": "@headerbar_bg_color",
|
||||||
"headerbar_shade_color": rgba_from_argb(dark_theme.shadow),
|
"headerbar_shade_color": argb_to_color_code(dark_theme.shadow),
|
||||||
"card_bg_color": rgba_from_argb(dark_theme.primary, "0.05"),
|
"card_bg_color": argb_to_color_code(dark_theme.primary, "0.05"),
|
||||||
"card_fg_color": rgba_from_argb(dark_theme.onSecondaryContainer),
|
"card_fg_color": argb_to_color_code(dark_theme.onSecondaryContainer),
|
||||||
"card_shade_color": rgba_from_argb(dark_theme.shadow),
|
"card_shade_color": argb_to_color_code(dark_theme.shadow),
|
||||||
"dialog_bg_color": rgba_from_argb(dark_theme.secondaryContainer),
|
"dialog_bg_color": argb_to_color_code(dark_theme.secondaryContainer),
|
||||||
"dialog_fg_color": rgba_from_argb(dark_theme.onSecondaryContainer),
|
"dialog_fg_color": argb_to_color_code(dark_theme.onSecondaryContainer),
|
||||||
"popover_bg_color": rgba_from_argb(dark_theme.secondaryContainer),
|
"popover_bg_color": argb_to_color_code(dark_theme.secondaryContainer),
|
||||||
"popover_fg_color": rgba_from_argb(
|
"popover_fg_color": argb_to_color_code(
|
||||||
dark_theme.onSecondaryContainer
|
dark_theme.onSecondaryContainer
|
||||||
),
|
),
|
||||||
"shade_color": rgba_from_argb(dark_theme.shadow),
|
"shade_color": argb_to_color_code(dark_theme.shadow),
|
||||||
"scrollbar_outline_color": rgba_from_argb(dark_theme.outline),
|
"scrollbar_outline_color": argb_to_color_code(dark_theme.outline),
|
||||||
}
|
}
|
||||||
elif theme == "light":
|
elif theme == "light":
|
||||||
light_theme = monet_palette["schemes"]["light"]
|
light_theme = monet_palette["schemes"]["light"]
|
||||||
variable = {
|
variable = {
|
||||||
"accent_color": rgba_from_argb(light_theme.primary),
|
"accent_color": argb_to_color_code(light_theme.primary),
|
||||||
"accent_bg_color": rgba_from_argb(light_theme.primary),
|
"accent_bg_color": argb_to_color_code(light_theme.primary),
|
||||||
"accent_fg_color": rgba_from_argb(light_theme.onPrimary),
|
"accent_fg_color": argb_to_color_code(light_theme.onPrimary),
|
||||||
"destructive_color": rgba_from_argb(light_theme.error),
|
"destructive_color": argb_to_color_code(light_theme.error),
|
||||||
"destructive_bg_color": rgba_from_argb(light_theme.errorContainer),
|
"destructive_bg_color": argb_to_color_code(light_theme.errorContainer),
|
||||||
"destructive_fg_color": rgba_from_argb(
|
"destructive_fg_color": argb_to_color_code(
|
||||||
light_theme.onErrorContainer
|
light_theme.onErrorContainer
|
||||||
),
|
),
|
||||||
"success_color": rgba_from_argb(light_theme.tertiary),
|
"success_color": argb_to_color_code(light_theme.tertiary),
|
||||||
"success_bg_color": rgba_from_argb(light_theme.tertiaryContainer),
|
"success_bg_color": argb_to_color_code(light_theme.tertiaryContainer),
|
||||||
"success_fg_color": rgba_from_argb(
|
"success_fg_color": argb_to_color_code(
|
||||||
light_theme.onTertiaryContainer
|
light_theme.onTertiaryContainer
|
||||||
),
|
),
|
||||||
"warning_color": rgba_from_argb(light_theme.secondary),
|
"warning_color": argb_to_color_code(light_theme.secondary),
|
||||||
"warning_bg_color": rgba_from_argb(light_theme.secondaryContainer),
|
"warning_bg_color": argb_to_color_code(light_theme.secondaryContainer),
|
||||||
"warning_fg_color": rgba_from_argb(
|
"warning_fg_color": argb_to_color_code(
|
||||||
light_theme.onSecondaryContainer
|
light_theme.onSecondaryContainer
|
||||||
),
|
),
|
||||||
"error_color": rgba_from_argb(light_theme.error),
|
"error_color": argb_to_color_code(light_theme.error),
|
||||||
"error_bg_color": rgba_from_argb(light_theme.errorContainer),
|
"error_bg_color": argb_to_color_code(light_theme.errorContainer),
|
||||||
"error_fg_color": rgba_from_argb(light_theme.onError),
|
"error_fg_color": argb_to_color_code(light_theme.onError),
|
||||||
"window_bg_color": rgba_from_argb(light_theme.secondaryContainer),
|
"window_bg_color": argb_to_color_code(light_theme.secondaryContainer),
|
||||||
"window_fg_color": rgba_from_argb(light_theme.onSurface),
|
"window_fg_color": argb_to_color_code(light_theme.onSurface),
|
||||||
"view_bg_color": rgba_from_argb(light_theme.secondaryContainer),
|
"view_bg_color": argb_to_color_code(light_theme.secondaryContainer),
|
||||||
"view_fg_color": rgba_from_argb(light_theme.onSurface),
|
"view_fg_color": argb_to_color_code(light_theme.onSurface),
|
||||||
"headerbar_bg_color": rgba_from_argb(
|
"headerbar_bg_color": argb_to_color_code(
|
||||||
light_theme.secondaryContainer
|
light_theme.secondaryContainer
|
||||||
),
|
),
|
||||||
"headerbar_fg_color": rgba_from_argb(light_theme.onSurface),
|
"headerbar_fg_color": argb_to_color_code(light_theme.onSurface),
|
||||||
"headerbar_border_color": rgba_from_argb(
|
"headerbar_border_color": argb_to_color_code(
|
||||||
light_theme.primary, "0.8"
|
light_theme.primary, "0.8"
|
||||||
),
|
),
|
||||||
"headerbar_backdrop_color": "@headerbar_bg_color",
|
"headerbar_backdrop_color": "@headerbar_bg_color",
|
||||||
"headerbar_shade_color": rgba_from_argb(
|
"headerbar_shade_color": argb_to_color_code(
|
||||||
light_theme.secondaryContainer
|
light_theme.secondaryContainer
|
||||||
),
|
),
|
||||||
"card_bg_color": rgba_from_argb(light_theme.primary, "0.05"),
|
"card_bg_color": argb_to_color_code(light_theme.primary, "0.05"),
|
||||||
"card_fg_color": rgba_from_argb(light_theme.onSecondaryContainer),
|
"card_fg_color": argb_to_color_code(light_theme.onSecondaryContainer),
|
||||||
"card_shade_color": rgba_from_argb(light_theme.shadow),
|
"card_shade_color": argb_to_color_code(light_theme.shadow),
|
||||||
"dialog_bg_color": rgba_from_argb(light_theme.secondaryContainer),
|
"dialog_bg_color": argb_to_color_code(light_theme.secondaryContainer),
|
||||||
"dialog_fg_color": rgba_from_argb(
|
"dialog_fg_color": argb_to_color_code(
|
||||||
light_theme.onSecondaryContainer
|
light_theme.onSecondaryContainer
|
||||||
),
|
),
|
||||||
"popover_bg_color": rgba_from_argb(light_theme.secondaryContainer),
|
"popover_bg_color": argb_to_color_code(light_theme.secondaryContainer),
|
||||||
"popover_fg_color": rgba_from_argb(
|
"popover_fg_color": argb_to_color_code(
|
||||||
light_theme.onSecondaryContainer
|
light_theme.onSecondaryContainer
|
||||||
),
|
),
|
||||||
"shade_color": rgba_from_argb(light_theme.shadow),
|
"shade_color": argb_to_color_code(light_theme.shadow),
|
||||||
"scrollbar_outline_color": rgba_from_argb(light_theme.outline),
|
"scrollbar_outline_color": argb_to_color_code(light_theme.outline),
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj_only == False and not name:
|
if obj_only == False and not name:
|
||||||
|
|
Loading…
Reference in a new issue