blob: 06a949c5ededa09bede73fa5f572d0c150df08ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
from pathlib import Path
from gi.repository import Gdk
from gi.repository import Gtk
from gajim.common.const import CSSPriority
def get_gajim_dir() -> Path:
gajim_path = Path(__file__) / '..' / '..' / '..' / 'gajim'
return gajim_path.resolve()
def load_style(filename: str, priority: CSSPriority) -> None:
path = get_gajim_dir() / 'data' / 'style' / filename
try:
with open(str(path), 'r', encoding='utf8') as file:
css = file.read()
except Exception as exc:
print(exc)
return
provider = Gtk.CssProvider()
provider.load_from_data(bytes(css.encode('utf-8')))
screen = Gdk.Screen.get_default()
assert screen is not None
Gtk.StyleContext.add_provider_for_screen(screen,
provider,
priority)
|