briar-gtk.in 1.3 KB
Newer Older
Nico Alt's avatar
Nico Alt committed
1 2
#!@PYTHON@
#
3 4 5
# Copyright (c) 2019 Nico Alt
# SPDX-License-Identifier: AGPL-3.0-only
# License-Filename: LICENSE.md
6 7 8
#
# Initial version based on GNOME Lollypop
# https://gitlab.gnome.org/World/lollypop/blob/1.0.2/lollypop.in
Nico Alt's avatar
Nico Alt committed
9

10 11
import gettext
import locale
Nico Alt's avatar
Nico Alt committed
12 13
import os
import signal
14
import sys
Nico Alt's avatar
Nico Alt committed
15

16 17
import gi
gi.require_version('Gtk', '3.0')
18
from gi.repository import Gio
19

20 21
PACKAGE_DATA_DIR = '@PACKAGE_DATA_DIR@'
LOCALE_DIR = '@LOCALE_DIR@'
Nico Alt's avatar
Nico Alt committed
22

23 24
def add_package_to_sys_path():
    sys.path.insert(1, PACKAGE_DATA_DIR)
Nico Alt's avatar
Nico Alt committed
25

26 27 28 29 30
def handle_sigint_default_way():
    signal.signal(signal.SIGINT, signal.SIG_DFL)

def prepare_locale():
    locale.bindtextdomain('briar-gtk', LOCALE_DIR)
31
    locale.textdomain('briar-gtk')
32 33 34

def prepare_gettext():
    gettext.bindtextdomain('briar-gtk', LOCALE_DIR)
35 36
    gettext.textdomain('briar-gtk')

37 38 39
def prepare_localization():
    prepare_locale()
    prepare_gettext()
Nico Alt's avatar
Nico Alt committed
40

41 42
def prepare_resource():
    resource = Gio.Resource.load(os.path.join(PACKAGE_DATA_DIR, 'briar-gtk.gresource'))
Nico Alt's avatar
Nico Alt committed
43 44
    resource._register()

45 46 47 48 49 50 51
def prepare():
    add_package_to_sys_path()
    handle_sigint_default_way()
    prepare_localization()
    prepare_resource()

def start_application():
52
    from briar.gtk.application import Application
53
    sys.exit(Application().run(sys.argv))
54 55 56 57

if __name__ == '__main__':
    prepare()
    start_application()