import gettext
import locale
import signal
from pathlib import Path

import gi

gi.require_versions({
    "Gtk": "4.0",
    "Adw": "1",
})

from gi.repository import Gio

from .config import LOCALEDIR, PKGDATADIR

_RESOURCES = ("data", "ui")

signal.signal(signal.SIGINT, signal.SIG_DFL)

locale.bindtextdomain("morphosis", LOCALEDIR)
locale.textdomain("morphosis")
gettext.bindtextdomain("morphosis", LOCALEDIR)
gettext.textdomain("morphosis")

for name in _RESOURCES:
    path = Path(PKGDATADIR, name).with_suffix(".gresource")
    resource = Gio.Resource.load(str(path))
    Gio.resources_register(resource)
