"""Adwaita application entry point."""

from __future__ import annotations

import sys
import os
import gi

os.environ.setdefault("GSK_RENDERER", "cairo")
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Adw, Gio  # noqa: E402

from .window import MonitorWindow  # noqa: E402

APP_ID = "org.biglinux.DdcMonitor"


class DdcMonitorApp(Adw.Application):
    def __init__(self) -> None:
        super().__init__(application_id=APP_ID, flags=Gio.ApplicationFlags.DEFAULT_FLAGS)

    def do_activate(self) -> None:
        window = self.props.active_window
        if window is None:
            window = MonitorWindow(self)
        window.present()


def main() -> int:
    return DdcMonitorApp().run(sys.argv)


if __name__ == "__main__":
    raise SystemExit(main())
