From 88d5a5aed8d2877cc0eabc8f7fb6e321b6402ad9 Mon Sep 17 00:00:00 2001 From: Nathan Bonnemains Date: Fri, 21 Jan 2022 19:54:44 +0100 Subject: [PATCH 1/2] Improve meson build --- .editorconfig | 17 ++++++++ COPYING => LICENSE | 0 data/meson.build | 43 ++++++++++--------- meson.build | 52 ++++++++++++++++------- po/POTFILES | 6 --- po/com.manexim.codecard.pot | 55 ++++++++++++++++++++++++ po/extra/POTFILES | 2 +- po/extra/extra.pot | 83 +++++++++++++++++++++++++++++++++++++ po/extra/meson.build | 14 +++---- po/meson.build | 15 ++++--- src/Utils.vala | 2 +- src/meson.build | 29 ++++--------- 12 files changed, 242 insertions(+), 76 deletions(-) create mode 100644 .editorconfig rename COPYING => LICENSE (100%) create mode 100644 po/com.manexim.codecard.pot create mode 100644 po/extra/extra.pot diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..725d8f1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# EditorConfig +root = true + +# elementary defaults +[*] +charset = utf-8 +end_of_line = lf +indent_size = tab +indent_style = space +insert_final_newline = true +max_line_length = 80 +tab_width = 4 + +# Markup files +[{*.html,*.xml,*.xml.in,*.yml}] +tab_width = 2 +tab_width = 2 diff --git a/COPYING b/LICENSE similarity index 100% rename from COPYING rename to LICENSE diff --git a/data/meson.build b/data/meson.build index 3a2d5cc..e37ec3a 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,35 +1,38 @@ +# Install icons icon_sizes = ['16', '24', '32', '48', '64', '128'] foreach i : icon_sizes - install_data( - join_paths('icons', i, meson.project_name() + '.svg'), - install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps') + install_data ( + join_paths ('icons', i, meson.project_name () + '.svg'), + install_dir: join_paths (get_option ('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps') ) - - install_data( - join_paths('icons', i, meson.project_name() + '.svg'), - install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i + '@2', 'apps') + install_data ( + join_paths ('icons', i, meson.project_name () + '.svg'), + install_dir: join_paths (get_option ('datadir'), 'icons', 'hicolor', i + 'x' + i + '@2', 'apps') ) endforeach -i18n.merge_file( - input: meson.project_name() + '.desktop.in', - output: meson.project_name() + '.desktop', - po_dir: join_paths(meson.source_root(), 'po', 'extra'), +# Translate and install our .desktop file so the Applications Menu will see it +i18n.merge_file ( + input: meson.project_name () + '.desktop.in', + output: meson.project_name () + '.desktop', + po_dir: join_paths (meson.source_root (), 'po', 'extra'), type: 'desktop', install: true, - install_dir: join_paths(get_option('datadir'), 'applications') + install_dir: join_paths (get_option ('datadir'), 'applications') ) -i18n.merge_file( - input: meson.project_name() + '.appdata.xml.in', - output: meson.project_name() + '.appdata.xml', - po_dir: join_paths(meson.source_root(), 'po', 'extra'), +# Translate and install our .appdata.xml file so AppCenter will see it +i18n.merge_file ( + input: meson.project_name () + '.appdata.xml.in', + output: meson.project_name () + '.appdata.xml', + po_dir: join_paths (meson.source_root (), 'po', 'extra'), install: true, - install_dir: join_paths(get_option('datadir'), 'metainfo') + install_dir: join_paths (get_option ('datadir'), 'metainfo') ) -install_data( - meson.project_name() + '.gschema.xml', - install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas') +# Install gschema +install_data ( + meson.project_name () + '.gschema.xml', + install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas') ) diff --git a/meson.build b/meson.build index b0679a1..25bc5cf 100644 --- a/meson.build +++ b/meson.build @@ -1,24 +1,48 @@ -project('com.manexim.codecard', 'vala', 'c', version: '1.1.0') +# Project name, programming language and version +project ( + 'com.manexim.codecard', + 'c', 'vala', + version: '1.1.0' +) -# Include the translations module -i18n = import('i18n') +# Translation module +i18n = import ('i18n') -# Set our translation domain -add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c') +# Project arguments +add_project_arguments ( + '-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name ()), + language: 'c' +) -gtk_plus_3_dep = dependency('gtk+-3.0') -granite_dep = dependency('granite') -gtksourceview_dep = dependency('gtksourceview-4') -libhandy_dep = dependency('libhandy-1', version: '>=1.0.0') +config_data = configuration_data () +config_data.set('APP_ID', meson.project_name ()) +config_data.set('APP_VERSION', meson.project_version ()) +config_file = configure_file ( + input: 'src/Constants.vala.in', + output: '@BASENAME@', + configuration: config_data +) + +# Listing dependencies dependencies = [ - gtk_plus_3_dep, - granite_dep, - gtksourceview_dep, - libhandy_dep, + dependency ('gtk+-3.0'), + dependency ('granite'), + dependency('gtksourceview-4'), + dependency ('libhandy-1') ] -subdir('src') +subdir ('src') + +# Defining executable +executable ( + meson.project_name (), + sources, + config_file, + dependencies: dependencies, + install: true +) + subdir('data') subdir('po') diff --git a/po/POTFILES b/po/POTFILES index 31835d5..c846409 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,7 +1 @@ -src/Config/Constants.vala -src/Controllers/CodecardController.vala -src/Models/Codecard.vala -src/Services/Settings.vala -src/Views/CodecardView.vala -src/Application.vala src/MainWindow.vala diff --git a/po/com.manexim.codecard.pot b/po/com.manexim.codecard.pot new file mode 100644 index 0000000..5e28c49 --- /dev/null +++ b/po/com.manexim.codecard.pot @@ -0,0 +1,55 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the com.manexim.codecard package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: com.manexim.codecard\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-01-21 19:53+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/MainWindow.vala:105 +msgid "Save" +msgstr "" + +#: src/MainWindow.vala:112 +msgid "Language" +msgstr "" + +#: src/MainWindow.vala:132 +msgid "Zoom out" +msgstr "" + +#: src/MainWindow.vala:140 +msgid "Default zoom level" +msgstr "" + +#: src/MainWindow.vala:152 +msgid "Zoom in" +msgstr "" + +#: src/MainWindow.vala:179 +msgid "Menu" +msgstr "" + +#: src/MainWindow.vala:316 +#, c-format +msgid "Saved to %s and copied to clipboard" +msgstr "" + +#: src/MainWindow.vala:369 +msgid "Could not capture screenshot" +msgstr "" + +#: src/MainWindow.vala:370 +msgid "Codecard not saved" +msgstr "" diff --git a/po/extra/POTFILES b/po/extra/POTFILES index d1202d9..557cdcb 100644 --- a/po/extra/POTFILES +++ b/po/extra/POTFILES @@ -1,2 +1,2 @@ -data/com.manexim.codecard.appdata.xml.in data/com.manexim.codecard.desktop.in +data/com.manexim.codecard.appdata.xml.in diff --git a/po/extra/extra.pot b/po/extra/extra.pot new file mode 100644 index 0000000..83a2ef7 --- /dev/null +++ b/po/extra/extra.pot @@ -0,0 +1,83 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the extra package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: extra\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-01-21 19:53+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: data/com.manexim.codecard.desktop.in:4 +#: data/com.manexim.codecard.desktop.in:5 +#: data/com.manexim.codecard.appdata.xml.in:7 +msgid "Codecard" +msgstr "" + +#: data/com.manexim.codecard.desktop.in:6 +#: data/com.manexim.codecard.appdata.xml.in:8 +#: data/com.manexim.codecard.appdata.xml.in:10 +msgid "Share snippets of code as a pretty image, e.g. for social media." +msgstr "" + +#: data/com.manexim.codecard.desktop.in:8 +msgid "com.manexim.codecard" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:21 +#: data/com.manexim.codecard.appdata.xml.in:40 +#: data/com.manexim.codecard.appdata.xml.in:57 +msgid "New:" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:23 +msgid "Use notification instead of toast to notify user" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:24 +msgid "Use monospace font" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:26 +#: data/com.manexim.codecard.appdata.xml.in:43 +#: data/com.manexim.codecard.appdata.xml.in:60 +msgid "Improved:" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:29 +#: data/com.manexim.codecard.appdata.xml.in:46 +#: data/com.manexim.codecard.appdata.xml.in:63 +msgid "Fixed:" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:31 +#: data/com.manexim.codecard.appdata.xml.in:48 +msgid "Add stripe key" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:33 +#: data/com.manexim.codecard.appdata.xml.in:50 +#: data/com.manexim.codecard.appdata.xml.in:67 +msgid "Translations:" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:65 +msgid "Fix for autosave" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:74 +msgid "Initial release" +msgstr "" + +#: data/com.manexim.codecard.appdata.xml.in:96 +msgid "Manexim" +msgstr "" diff --git a/po/extra/meson.build b/po/extra/meson.build index c609b47..526e40f 100644 --- a/po/extra/meson.build +++ b/po/extra/meson.build @@ -1,8 +1,8 @@ -i18n.gettext('extra', - args: [ - '--directory=' + meson.source_root(), - '--from-code=UTF-8' - ], - preset: 'glib', - install: false +# Install metadata translations +i18n.gettext ('extra', + args: [ + '--directory=' + meson.source_root (), + '--from-code=UTF-8' + ], + install: false ) diff --git a/po/meson.build b/po/meson.build index e2c9b35..011a4ae 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1,8 +1,11 @@ -i18n.gettext(meson.project_name(), - args: [ - '--directory=' + meson.source_root(), - '--from-code=UTF-8' - ] +# Install main translations +i18n.gettext (meson.project_name (), + args: [ + '--directory=' + meson.source_root (), + '--from-code=UTF-8', + '-cTRANSLATORS' + ], + preset: 'glib' ) -subdir('extra') +subdir ('extra') diff --git a/src/Utils.vala b/src/Utils.vala index d149481..8d353af 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -22,7 +22,7 @@ namespace Utils { public string replace_home_with_tilde (string path) { var home_dir = Environment.get_home_dir (); if (path.has_prefix (home_dir)) { - return "~" + path[home_dir.length:]; + return "~" + path; } else { return path; } diff --git a/src/meson.build b/src/meson.build index a578aab..9f13738 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,27 +1,14 @@ -config_data = configuration_data() -config_data.set('APP_ID', meson.project_name()) -config_data.set('APP_VERSION', meson.project_version()) - -config_file = configure_file( - input: 'Constants.vala.in', - output: '@BASENAME@', - configuration: config_data -) - -sources = [ +sources = files ( 'Controllers/CodecardController.vala', - 'Models/Font.vala', + 'Models/Codecard.vala', + 'Models/Font.vala', + 'Services/Settings.vala', + 'Views/CodecardView.vala', - 'Utils.vala', - 'MainWindow.vala', -] -executable( - meson.project_name(), - sources + ['Application.vala'], - config_file, - dependencies: dependencies, - install: true + 'Application.vala', + 'MainWindow.vala', + 'Utils.vala' ) From 4157e26e7ebaa13726d3408f2f34184ad881cab6 Mon Sep 17 00:00:00 2001 From: Nathan Bonnemains Date: Fri, 21 Jan 2022 19:59:01 +0100 Subject: [PATCH 2/2] Improve post install script --- meson/post_install.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/meson/post_install.py b/meson/post_install.py index 3110c7d..281766a 100755 --- a/meson/post_install.py +++ b/meson/post_install.py @@ -1,20 +1,17 @@ #!/usr/bin/env python3 -import os -import subprocess - -prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr') -datadir = os.path.join(prefix, 'share') -# Packaging tools define DESTDIR and this isn't needed for them -if 'DESTDIR' not in os.environ: - print('Compiling gsettings schemas...') - schema_dir = os.path.join(datadir, 'glib-2.0/schemas') - subprocess.call(['glib-compile-schemas', schema_dir]) +from os import path, environ +import subprocess - print('Updating icon cache...') - icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor') - subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir]) +prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') +datadir = path.join(prefix, 'share') +schemadir = path.join(datadir, 'glib-2.0', 'schemas') +desktop_database_dir = path.join(datadir, 'applications') - print('Updating desktop database...') - desktop_database_dir = os.path.join(datadir, 'applications') +if not environ.get('DESTDIR'): + print('Compiling gsettings schemas…') + subprocess.call(['glib-compile-schemas', schemadir]) + print('Updating desktop database…') subprocess.call(['update-desktop-database', '-q', desktop_database_dir]) + print('Updating icon cache…') + subprocess.call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])