#!@PYTHON@
# Copyright 2026, Jiri Eischmann <jiri@eischmann.cz> and the meshy contributors
# SPDX-License-Identifier: GPL-3.0-or-later

import os
import sys
import signal
import locale
import gettext

VERSION = '@VERSION@'
appdir = os.environ.get('APPDIR')
if appdir:
    prefix = os.path.join(appdir, 'usr')
    pkgdatadir = os.path.join(prefix, 'share', 'meshy')
    localedir = os.path.join(prefix, 'share', 'locale')
else:
    pkgdatadir = '@pkgdatadir@'
    localedir = '@localedir@'
QR_SCANNER_ENABLED = '@QR_SCANNER_ENABLED@' == 'true'
SHORTCUTS_DIALOG_ENABLED = '@SHORTCUTS_DIALOG_ENABLED@' == 'true'

sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)

locale.bindtextdomain('meshy', localedir)
locale.textdomain('meshy')
gettext.install('meshy', localedir)

if __name__ == '__main__':
    import gi
    gi.require_version('Gtk', '4.0')
    gi.require_version('Adw', '1')

    import meshy as _meshy_pkg
    _meshy_pkg.QR_SCANNER_ENABLED = QR_SCANNER_ENABLED
    _meshy_pkg.SHORTCUTS_DIALOG_ENABLED = SHORTCUTS_DIALOG_ENABLED

    from meshy.main import main
    sys.exit(main(VERSION))
