36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""Load the two stylesheets as ordered CSS providers.
|
|
|
|
_colors.css (generated from ~/Dotfiles/colors.conf by apply-theme.sh) defines the
|
|
five CyberQueer @define-color names; style.css consumes them. They are loaded as
|
|
two separate providers rather than via @import, because GTK4 resolves @import
|
|
paths unreliably.
|
|
|
|
Priority is USER+1, not APPLICATION: the CyberQueer GTK theme is installed as
|
|
~/.config/gtk-4.0/gtk.css (a symlink), which GTK4 loads at PRIORITY_USER (800) —
|
|
above APPLICATION (600). Its aggressive `* { background-color: #1a1a1a }` would
|
|
otherwise beat our rules (e.g. the transparent structural containers that let the
|
|
modules float), so we must sit just above the user-level theme.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "4.0")
|
|
from gi.repository import Gdk, Gtk # noqa: E402
|
|
|
|
from paths import STYLE_DIR
|
|
|
|
|
|
def load_css() -> None:
|
|
display = Gdk.Display.get_default()
|
|
for name in ("_colors.css", "style.css"):
|
|
path = STYLE_DIR / name
|
|
if not path.exists():
|
|
continue
|
|
provider = Gtk.CssProvider()
|
|
provider.load_from_path(str(path))
|
|
Gtk.StyleContext.add_provider_for_display(
|
|
display, provider, Gtk.STYLE_PROVIDER_PRIORITY_USER + 1
|
|
)
|