Commit a2a90cdd authored by David Boddie's avatar David Boddie

Imported meson configuration files from a GNOME Builder project and

modified them for use in this application.
Updated the application to fit in with the conventions used by the
imported files.
parent 4edead4c
Pipeline #2172 failed with stages
#!/usr/bin/env python3
from os import environ, path
from subprocess import call
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = path.join(prefix, 'share')
destdir = environ.get('DESTDIR', '')
# Package managers set this so we don't need to run
if not destdir:
print('Updating icon cache...')
call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
print('Updating desktop database...')
call(['update-desktop-database', '-q', path.join(datadir, 'applications')])
print('Compiling GSettings schemas...')
call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
gnome = import('gnome')
gnome.compile_resources('treasure',
'treasure.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)
desktop_file = i18n.merge_file(
input: 'sm.puri.treasure.desktop.in',
output: 'sm.puri.treasure.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
)
desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils,
args: [desktop_file]
)
endif
appstream_file = i18n.merge_file(
input: 'sm.puri.treasure.appdata.xml.in',
output: 'sm.puri.treasure.appdata.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'appdata')
)
appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test('Validate appstream file', appstream_util,
args: ['validate', appstream_file]
)
endif
install_data('sm.puri.treasure.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)
compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
test('Validate schema file', compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()]
)
endif
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gnome.Test-Ui-I18N.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<description>
</description>
</component>
[Desktop Entry]
Name=test-ui-i18n
Exec=test-ui-i18n
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="treasure">
<schema id="sm.puri.treasure" path="/sm/puri/treasure/">
</schema>
</schemalist>
project('treasure',
version: '0.1.0',
meson_version: '>= 0.40.0',
)
i18n = import('i18n')
subdir('data')
subdir('src')
subdir('po')
meson.add_install_script('build-aux/meson/postinstall.py')
src/main.py
data/ui/*.ui
i18n.gettext('treasure', preset: 'glib')
......@@ -16,15 +16,6 @@ gi.require_version('Handy', '0.0')
from gi.repository import Handy
Handy.init()
import config
# Enable translation to occur in the extension libraries.
locale.bindtextdomain('treasure', config.locale_dir)
locale.textdomain('treasure')
# Install a translator for Python code to use throughout the application.
gettext.install('treasure', config.locale_dir)
class Application(Gtk.Application):
def __init__(self):
......@@ -164,12 +155,7 @@ class Application(Gtk.Application):
widget.set_image(Gtk.Image(resource=res))
if __name__ == '__main__':
res = Gio.Resource.load('treasure.gresource')
# Register the resource globally within the application.
res._register()
def main(version):
app = Application()
result = app.run(sys.argv)
sys.exit(result)
return app.run(sys.argv)
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
moduledir = join_paths(pkgdatadir, 'treasure')
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)
configure_file(
input: 'treasure.in',
output: 'treasure',
configuration: conf,
install: true,
install_dir: get_option('bindir')
)
treasure_sources = [
'__init__.py',
'main.py',
]
install_data(treasure_sources, install_dir: moduledir)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Purism SPC
# SPDX-License-Identifier: GPL-3.0+
# Author: David Boddie <david.boddie@puri.sm>
import gettext, locale
import os, signal, sys
VERSION = '@VERSION@'
pkgdatadir = '@pkgdatadir@'
localedir = '@localedir@'
sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)
# Enable translation to occur in the extension libraries.
locale.bindtextdomain('treasure', localedir)
locale.textdomain('treasure')
# Install a translator for Python code to use throughout the application.
gettext.install('treasure', localedir)
if __name__ == '__main__':
import gi
from gi.repository import Gio
res = Gio.Resource.load(os.path.join(pkgdatadir, 'treasure.gresource'))
# Register the resource globally within the application.
res._register()
from treasure import main
sys.exit(main.main(VERSION))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment