diff --git a/data/com.ranfdev.Geopard.desktop.in.in b/data/com.ranfdev.Geopard.desktop.in.in index 1ae776b..dc225af 100644 --- a/data/com.ranfdev.Geopard.desktop.in.in +++ b/data/com.ranfdev.Geopard.desktop.in.in @@ -7,7 +7,7 @@ Terminal=false Categories=GNOME;GTK;Network; Keywords=Gnome;GTK;browser;gemini;rust; # Translators: Do NOT translate or transliterate this text (this is an icon file name)! -Icon=@icon@ +Icon=@APP_ID@ StartupNotify=true MimeType=x-scheme-handler/gemini;text/gemini;text/plain; X-Purism-FormFactor=Workstation;Mobile; \ No newline at end of file diff --git a/data/com.ranfdev.Geopard.gschema.xml.in b/data/com.ranfdev.Geopard.gschema.xml.in index 31b3d68..a9b005f 100644 --- a/data/com.ranfdev.Geopard.gschema.xml.in +++ b/data/com.ranfdev.Geopard.gschema.xml.in @@ -1,6 +1,6 @@ - - + + 600 Window width diff --git a/data/com.ranfdev.Geopard.metainfo.xml.in.in b/data/com.ranfdev.Geopard.metainfo.xml.in.in index d4b45b5..0ec4f04 100644 --- a/data/com.ranfdev.Geopard.metainfo.xml.in.in +++ b/data/com.ranfdev.Geopard.metainfo.xml.in.in @@ -1,14 +1,14 @@ - @app-id@ + @APP_ID@ Geopard Browse Gemini pages Lorenzo Miglietta - @app-id@.desktop - @gettext-package@ + @APP_ID@.desktop + geopard CC0 GPL-3.0-or-later ranfdev@gmail.com @@ -51,9 +51,10 @@ - https://ranfdev.com/projects/Geopard - https://github.com/ranfdev/Geopard/issues/ - https://github.com/sponsors/ranfdev + @PROJECT_URL@ + @REPO_URL@ + @BUGTRACKER_URL@ + @DONATIONS_URL@ #deddda diff --git a/data/icons/meson.build b/data/icons/meson.build index 35e237a..ff28a5c 100644 --- a/data/icons/meson.build +++ b/data/icons/meson.build @@ -1,12 +1,12 @@ scalable_dir = join_paths('hicolor', 'scalable', 'apps') install_data( - join_paths(scalable_dir, '@0@.svg'.format(application_id)), + join_paths(scalable_dir, ('@0@.svg').format(APPLICATION_ID)), install_dir: join_paths(get_option('datadir'), 'icons', scalable_dir), ) symbolic_dir = join_paths('hicolor', 'symbolic', 'apps') install_data( - join_paths(symbolic_dir, 'com.ranfdev.Geopard-symbolic.svg'), + join_paths(symbolic_dir, ('@0@-symbolic.svg').format(PROJECT_RDNN_NAME)), install_dir: join_paths(get_option('datadir'), 'icons', symbolic_dir), - rename: '@0@-symbolic.svg'.format(application_id) + rename: '@0@-symbolic.svg'.format(APPLICATION_ID) ) diff --git a/data/meson.build b/data/meson.build index 968625d..b79d7e8 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,43 +1,42 @@ -# Desktop file -desktop_conf = configuration_data() -desktop_conf.set('icon', application_id) +# Translate and install desktop file desktop_file = i18n.merge_file( - type: 'desktop', input: configure_file( - input: '@0@.desktop.in.in'.format(base_id), + input: '@0@.desktop.in.in'.format(PROJECT_RDNN_NAME), output: '@BASENAME@', - configuration: desktop_conf + configuration: conf ), - output: '@0@.desktop'.format(application_id), - po_dir: podir, + output: '@0@.desktop'.format(APPLICATION_ID), + type: 'desktop', + po_dir: '../po', install: true, install_dir: join_paths(get_option('datadir'), 'applications') ) -# Validate Desktop file -if desktop_file_validate.found() - test( - 'validate-desktop', - desktop_file_validate, - args: [ - desktop_file.full_path() - ], - depends: desktop_file, +# Validate desktop file +desktop_utils = find_program('desktop-file-validate', required: false) +if desktop_utils.found() + test('Validate desktop file', desktop_utils, + args: [desktop_file.full_path()], + depends: desktop_file ) endif # Translate and install Metainfo file metainfo_file = i18n.merge_file( input: configure_file( - input: '@0@.metainfo.xml.in.in'.format(base_id), + input: '@0@.metainfo.xml.in.in'.format(PROJECT_RDNN_NAME), output: '@BASENAME@', configuration: configuration_data({ - 'app-id': application_id, - 'gettext-package': gettext_package + 'APP_ID': APPLICATION_ID, + 'PROJECT_URL': PROJECT_URL, + 'REPO_URL': REPO_URL, + 'BUGTRACKER_URL': BUGTRACKER_URL, + 'DONATIONS_URL': DONATIONS_URL, + #'TRANSLATE_URL': TRANSLATE_URL }) ), - output: '@0@.metainfo.xml'.format(application_id), - po_dir: podir, + output: '@0@.metainfo.xml'.format(APPLICATION_ID), + po_dir: '../po', install: true, install_dir: join_paths(get_option('datadir'), 'metainfo') ) @@ -51,26 +50,20 @@ if appstream_cli.found() ) endif -# GSchema -gschema_conf = configuration_data() -gschema_conf.set('app-id', application_id) -gschema_conf.set('gettext-package', gettext_package) - +# Install GSettings schema configure_file( - input: '@0@.gschema.xml.in'.format(base_id), - output: '@0@.gschema.xml'.format(application_id), - configuration: gschema_conf, + input: '@0@.gschema.xml.in'.format(PROJECT_RDNN_NAME), + output: '@0@.gschema.xml'.format(APPLICATION_ID), + configuration: conf, install: true, install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') ) -# Validata GSchema -if glib_compile_schemas.found() - test( - 'validate-gschema', glib_compile_schemas, - args: [ - '--strict', '--dry-run', meson.current_build_dir() - ], +# Validate GSchema file +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_build_dir()], ) endif diff --git a/data/resources/meson.build b/data/resources/meson.build index f13646b..d05afcf 100644 --- a/data/resources/meson.build +++ b/data/resources/meson.build @@ -16,7 +16,7 @@ resources = gnome.compile_resources( gresource_bundle: true, source_dir: meson.current_build_dir(), install: true, + install_dir: PKGDATA_DIR, dependencies: blueprints, - install_dir: pkgdatadir, ) diff --git a/local-build.sh b/local-build.sh index 03ca8c1..57ef2d5 100755 --- a/local-build.sh +++ b/local-build.sh @@ -6,6 +6,8 @@ if [[ "$answer" == "y" ]]; then rm -r _build fi +export RUST_LOG=debug + meson setup _build -Dprefix="$(pwd)/_build" -Dprofile=development ninja -C _build install meson devenv -C _build ./src/geopard diff --git a/meson.build b/meson.build index da347f0..5fcd2dd 100644 --- a/meson.build +++ b/meson.build @@ -1,69 +1,85 @@ -project( - 'geopard', - 'rust', - version: '1.6.0', - meson_version: '>= 0.59', - # license: MIT, +project('geopard', 'rust', + version: '1.6.0', + license: 'GPL-3.0-or-later', + meson_version: '>= 0.62.0', + default_options: ['warning_level=2', + 'werror=false', + ], ) +# Import modules i18n = import('i18n') gnome = import('gnome') -base_id = 'com.ranfdev.Geopard' +# Project information +PROJECT_URL = 'https://ranfdev.com/projects/Geopard' +REPO_URL = 'https://github.com/ranfdev/Geopard' +BUGTRACKER_URL = 'https://github.com/ranfdev/Geopard/issues' +DONATIONS_URL = 'https://github.com/sponsors/ranfdev' +#TRANSLATE_URL = 'https://hosted.weblate.org/projects/ranfdev/Geopard' -dependency('glib-2.0', version: '>= 2.66') -dependency('gio-2.0', version: '>= 2.66') -dependency('gtk4', version: '>= 4.0.0') - -glib_compile_resources = find_program('glib-compile-resources', required: true) -glib_compile_schemas = find_program('glib-compile-schemas', required: true) -desktop_file_validate = find_program('desktop-file-validate', required: false) - -cargo = find_program('cargo', required: true) +# Constants +PROJECT_RDNN_NAME = 'com.ranfdev.Geopard' +ROOT_PATH = '/com/ranfdev/Geopard' +BIN_DIR = join_paths(get_option('prefix'), get_option('bindir')) +PKGDATA_DIR = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) -version = meson.project_version() - -bindir = join_paths(get_option('prefix'), get_option('bindir')) -localedir = join_paths(get_option('prefix'), get_option('localedir')) -pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) -iconsdir = join_paths(get_option('prefix'), get_option('datadir'), 'icons') -podir = join_paths(meson.project_source_root(), 'po') - -gettext_package = meson.project_name() +# Check if cargo and git exist +cargo_bin = find_program('cargo', required: true) +git_bin = find_program('git', required: false) +# Set APPLICATION_ID and VERSION_SUFFIX if get_option('profile') == 'development' - profile = 'Devel' - vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD', check: true).stdout().strip() - if vcs_tag == '' - version_suffix = '-devel' + if git_bin.found() + VCS_TAG = run_command('git', 'rev-parse', '--short', 'HEAD', check: true).stdout().strip() + else + VCS_TAG = '' + endif + if VCS_TAG == '' + VERSION_SUFFIX = '-devel' else - version_suffix = '-@0@'.format(vcs_tag) + VERSION_SUFFIX = '-@0@'.format(VCS_TAG) endif - application_id = '@0@.@1@'.format(base_id, profile) + APPLICATION_ID = '@0@.Devel'.format(PROJECT_RDNN_NAME) else - profile = '' - version_suffix = '' - application_id = base_id + VERSION_SUFFIX = '' + APPLICATION_ID = PROJECT_RDNN_NAME endif +# Required dependencies +dependency('glib-2.0', version: '>= 2.66') +dependency('gio-2.0', version: '>= 2.66') +dependency('gtk4', version: '>= 4.12.0') +dependency('libadwaita-1', version: '>= 1.5.0') meson.add_dist_script( 'build-aux/dist-vendor.sh', - join_paths(meson.project_build_root(), 'meson-dist', meson.project_name() + '-' + version), + join_paths(meson.project_build_root(), 'meson-dist', meson.project_name() + '-' + meson.project_version()), meson.project_source_root() ) +# Setup pre-commit hook to ensure the coding style is always consistent if get_option('profile') == 'development' - # Setup pre-commit hook for ensuring coding style is always consistent - message('Setting up git pre-commit hook..') + message('Setting up git pre-commit hook...') run_command('cp', '-f', 'hooks/pre-commit.hook', '.git/hooks/pre-commit', check: false) run_command('chmod', '+x', '.git/hooks/pre-commit', check: false) endif +# Set configuration data +conf = configuration_data() +conf.set('APP_ID', APPLICATION_ID) +conf.set('ROOT_PATH', ROOT_PATH) +conf.set('PKGDATA_DIR', PKGDATA_DIR) +conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir'))) +conf.set('VERSION', meson.project_version() + VERSION_SUFFIX) +conf.set('GETTEXT_PACKAGE', meson.project_name()) + +# Subdirs subdir('data') subdir('po') subdir('src') +# Create devenv if profile is set to 'development' if get_option('profile') == 'development' devenv = environment() @@ -74,9 +90,9 @@ if get_option('profile') == 'development' meson.add_devenv(devenv) endif +# Execute post-installation GTK/GNOME scripts gnome.post_install( - gtk_update_icon_cache: true, glib_compile_schemas: true, + gtk_update_icon_cache: true, update_desktop_database: true, ) - diff --git a/po/meson.build b/po/meson.build index 57d1266..aed042c 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1 +1 @@ -i18n.gettext(gettext_package, preset: 'glib') +i18n.gettext('geopard', preset: 'glib') diff --git a/src/build_config.rs.in b/src/build_config.rs.in index 0f2600d..6803b8d 100644 --- a/src/build_config.rs.in +++ b/src/build_config.rs.in @@ -1,7 +1,15 @@ -pub const APP_ID: &str = @APP_ID@; -pub const _GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; -pub const _LOCALEDIR: &str = @LOCALEDIR@; -pub const _PKGDATADIR: &str = @PKGDATADIR@; -pub const _PROFILE: &str = @PROFILE@; -pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource"); -pub const VERSION: &str = @VERSION@; \ No newline at end of file +pub const _ROOT_PATH: &str = "@ROOT_PATH@"; +pub const _PKGDATADIR: &str = "@PKGDATA_DIR@"; +pub const _LOCALEDIR: &str = "@LOCALE_DIR@"; +pub const _GETTEXT_PACKAGE: &str = "@GETTEXT_PACKAGE@"; +pub const RESOURCES_FILE: &str = concat!("@PKGDATA_DIR@", "/resources.gresource"); + +pub const APP_ID: &str = "@APP_ID@"; +pub const _RELEASE_VER: &str = "@RELEASE_VER@"; +pub const VERSION: &str = "@VERSION@"; +pub const _PROFILE: &str = "@PROFILE@"; + +pub const PROJECT_URL: &str = "@PROJECT_URL@"; +pub const REPO_URL: &str = "@REPO_URL@"; +pub const BUGTRACKER_URL: &str = "@BUGTRACKER_URL@"; +pub const DONATIONS_URL: &str = "@DONATIONS_URL@"; diff --git a/src/meson.build b/src/meson.build index 7a14915..cfb6226 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,15 +1,22 @@ -global_conf = configuration_data() -global_conf.set_quoted('APP_ID', application_id) -global_conf.set_quoted('PKGDATADIR', pkgdatadir) -global_conf.set_quoted('PROFILE', profile) -global_conf.set_quoted('VERSION', version + version_suffix) -global_conf.set_quoted('GETTEXT_PACKAGE', gettext_package) -global_conf.set_quoted('LOCALEDIR', localedir) - -config = configure_file( +# Generate config module +configure_file( input: 'build_config.rs.in', output: 'build_config.rs', - configuration: global_conf + configuration: configuration_data({ + 'APP_ID': APPLICATION_ID, + 'ROOT_PATH': ROOT_PATH, + 'RELEASE_VER': meson.project_version(), + 'VERSION': meson.project_version() + VERSION_SUFFIX, + 'PROFILE': get_option('profile'), + 'PROJECT_URL': PROJECT_URL, + 'REPO_URL': REPO_URL, + 'BUGTRACKER_URL': BUGTRACKER_URL, + 'DONATIONS_URL': DONATIONS_URL, + #'TRANSLATE_URL': TRANSLATE_URL, + 'PKGDATA_DIR': PKGDATA_DIR, + 'LOCALE_DIR': conf.get('LOCALE_DIR'), + 'GETTEXT_PACKAGE': meson.project_name() + }) ) # Copy the config.rs output to the source directory. @@ -39,19 +46,19 @@ endif cargo_env = [ 'CARGO_HOME=' + join_paths(meson.project_build_root(), 'cargo-home') ] -cargo_build = custom_target( +custom_target( 'cargo-build', build_by_default: true, build_always_stale: true, output: meson.project_name(), console: true, install: true, - install_dir: bindir, + install_dir: BIN_DIR, depends: resources, command: [ 'env', cargo_env, - cargo, 'build', + cargo_bin, 'build', cargo_options, '&&', 'cp', join_paths('src', rust_target, meson.project_name()), '@OUTPUT@', diff --git a/src/widgets/window.rs b/src/widgets/window.rs index 992fba2..994d68a 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -5,7 +5,7 @@ use std::marker::PhantomData; use adw::prelude::*; use adw::subclass::application_window::AdwApplicationWindowImpl; use anyhow::Context; -use config::APP_ID; +use config::{APP_ID, BUGTRACKER_URL, DONATIONS_URL, PROJECT_URL, REPO_URL}; use futures::prelude::*; use glib::{clone, Properties}; use gtk::subclass::prelude::*; @@ -750,10 +750,11 @@ impl Window { .license_type(gtk::License::Gpl30) .version(build_config::VERSION) .copyright("Copyright © 2022-2024 ranfdev") - .issue_url("https://github.com/ranfdev/Geopard/issues") - .website("https://github.com/ranfdev/Geopard") + .issue_url(BUGTRACKER_URL) + .website(PROJECT_URL) .build(); - about.add_link("Donate 💝", "https://github.com/sponsors/ranfdev"); + about.add_link("Source Code", REPO_URL); + about.add_link("Donate 💝", DONATIONS_URL); about.present(Some(self)); }