35 lines
932 B
Python
35 lines
932 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from gi.repository import Gdk, Gtk
|
|
|
|
from .main_window import MainWindow
|
|
from .thumbnailer import Thumbnailer
|
|
|
|
__all__ = ["Application"]
|
|
|
|
|
|
class Application(Gtk.Application):
|
|
def __init__(self, thumbnailer: Thumbnailer):
|
|
super().__init__()
|
|
self.thumbnailer = thumbnailer
|
|
|
|
# Load CSS
|
|
css_provider = Gtk.CssProvider()
|
|
css_file = Path(__file__).parent / "style.css"
|
|
css_provider.load_from_path(str(css_file))
|
|
|
|
display = Gdk.Display.get_default()
|
|
if display is None:
|
|
raise RuntimeError("No display available")
|
|
|
|
Gtk.StyleContext.add_provider_for_display(
|
|
display,
|
|
css_provider,
|
|
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
|
|
)
|
|
|
|
def do_activate(self):
|
|
win = MainWindow(application=self, thumbnailer=self.thumbnailer)
|
|
win.present()
|