From 53735119f211d6869e0f0da62172eae9ad5100ce Mon Sep 17 00:00:00 2001 From: Nico Alt <nicoalt@posteo.org> Date: Mon, 30 Sep 2019 00:20:42 +0200 Subject: [PATCH] Try to make first files in src/ easier to understand --- src/briar-gtk.in | 39 +++++++++++++++++++++++++++++---------- src/meson.build | 12 ++++++------ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/briar-gtk.in b/src/briar-gtk.in index 1f3930d..0bd3f8e 100755 --- a/src/briar-gtk.in +++ b/src/briar-gtk.in @@ -15,24 +15,43 @@ import sys import gi gi.require_version('Gtk', '3.0') +from gi.repository import Gio -pkgdatadir = '@pkgdatadir@' -localedir = '@localedir@' +PACKAGE_DATA_DIR = '@PACKAGE_DATA_DIR@' +LOCALE_DIR = '@LOCALE_DIR@' -sys.path.insert(1, pkgdatadir) -signal.signal(signal.SIGINT, signal.SIG_DFL) +def add_package_to_sys_path(): + sys.path.insert(1, PACKAGE_DATA_DIR) -if __name__ == '__main__': - locale.bindtextdomain('briar-gtk', localedir) +def handle_sigint_default_way(): + signal.signal(signal.SIGINT, signal.SIG_DFL) + +def prepare_locale(): + locale.bindtextdomain('briar-gtk', LOCALE_DIR) locale.textdomain('briar-gtk') - gettext.bindtextdomain('briar-gtk', localedir) + +def prepare_gettext(): + gettext.bindtextdomain('briar-gtk', LOCALE_DIR) gettext.textdomain('briar-gtk') - import gi +def prepare_localization(): + prepare_locale() + prepare_gettext() - from gi.repository import Gio - resource = Gio.Resource.load(os.path.join(pkgdatadir, 'briar-gtk.gresource')) +def prepare_resource(): + resource = Gio.Resource.load(os.path.join(PACKAGE_DATA_DIR, 'briar-gtk.gresource')) resource._register() +def prepare(): + add_package_to_sys_path() + handle_sigint_default_way() + prepare_localization() + prepare_resource() + +def start_application(): from briar.gtk.application import Application sys.exit(Application("@VERSION@").run(sys.argv)) + +if __name__ == '__main__': + prepare() + start_application() diff --git a/src/meson.build b/src/meson.build index a1afe42..744ca3a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -2,16 +2,16 @@ # SPDX-License-Identifier: AGPL-3.0-only # License-Filename: LICENSE.md -pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) -moduledir = join_paths(pkgdatadir, 'briar') +PACKAGE_DATA_DIR = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) +MODULE_DIR = join_paths(PACKAGE_DATA_DIR, 'briar') python3 = import('python3') conf = configuration_data() conf.set('PYTHON', python3.find_python().path()) conf.set('VERSION', meson.project_version()) -conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir'))) -conf.set('pkgdatadir', pkgdatadir) +conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir'))) +conf.set('PACKAGE_DATA_DIR', PACKAGE_DATA_DIR) configure_file( input: 'briar-gtk.in', @@ -21,5 +21,5 @@ configure_file( install_dir: get_option('bindir') ) -install_subdir('briar/api', install_dir: moduledir) -install_subdir('briar/gtk', install_dir: moduledir) +install_subdir('briar/api', install_dir: MODULE_DIR) +install_subdir('briar/gtk', install_dir: MODULE_DIR) -- GitLab