From: Colin Clark Date: Sun, 30 Apr 2023 14:38:23 +0000 (+0100) Subject: Revise gresources use X-Git-Tag: v2.1~66 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=29001d60e84a40fd2ca56f6c0ab7d960a1703538 Revise gresources use --- diff --git a/meson.build b/meson.build index c84543a4..4fdb9520 100644 --- a/meson.build +++ b/meson.build @@ -141,6 +141,7 @@ icondir = join_paths(datadir, 'pixmaps') mandir1 = join_paths(datadir, 'man', 'man1') podir = join_paths(meson.source_root(), 'po') +scriptsdir = join_paths(meson.source_root(), 'scripts') summary({'gq_appdir': gq_appdir, 'gq_bindir': gq_helpdir, diff --git a/src/credits/locales.txt b/po/locales.txt similarity index 100% rename from src/credits/locales.txt rename to po/locales.txt diff --git a/po/meson.build b/po/meson.build index 97955da9..0e180e77 100644 --- a/po/meson.build +++ b/po/meson.build @@ -14,3 +14,59 @@ add_project_arguments('-DGETTEXT_PACKAGE="geeqie"', language:'c') i18n.gettext(meson.project_name(), args : ['--keyword=N_', '--from-code=UTF-8']) + +# Create the list of translators for the About - Credits dialog +po_sources = files([ + 'ar.po', + 'be.po', + 'bg.po', + 'ca.po', + 'cs.po', + 'da.po', + 'de.po', + 'el.po', + 'en_GB.po', + 'eo.po', + 'es.po', + 'et.po', + 'eu.po', + 'fi.po', + 'fr.po', + 'hu.po', + 'id.po', + 'it.po', + 'ja.po', + 'ko.po', + 'nb.po', + 'nl.po', + 'pl.po', + 'pt_BR.po', + 'ro.po', + 'ru.po', + 'sk.po', + 'sl.po', + 'sr@latin.po', + 'sr.po', + 'sv.po', + 'th.po', + 'tlh.po', + 'tr.po', + 'uk.po', + 'vi.po', + 'zh_CN.po', + 'zh_TW.po' +]) + +po_source_list = '' +foreach name : po_sources + po_source_list = po_source_list + meson.source_root() + '/' + '@0@'.format(name) + '\n' +endforeach + +translators_sh = join_paths(scriptsdir, 'translators.sh') + +translator_resources = custom_target('translator_resources', + input : ['locales.txt', 'translators.gresource.xml'], + output : ['translators.h', 'translators.c'], + command : [translators_sh, '@PRIVATE_DIR@', po_source_list, meson.current_build_dir() , '@INPUT0@', '@INPUT1@']) + +project_sources += translator_resources diff --git a/src/credits/credits.gresource.xml b/po/translators.gresource.xml similarity index 97% rename from src/credits/credits.gresource.xml rename to po/translators.gresource.xml index 2ec6df18..76873e76 100644 --- a/src/credits/credits.gresource.xml +++ b/po/translators.gresource.xml @@ -23,7 +23,6 @@ - authors translators diff --git a/src/credits/authors.sh b/scripts/authors.sh similarity index 71% rename from src/credits/authors.sh rename to scripts/authors.sh index 667bdca8..c41ccca7 100755 --- a/src/credits/authors.sh +++ b/scripts/authors.sh @@ -20,15 +20,25 @@ #********************************************************************** ## @file -## @brief Generate a list of people who have made commits to the repository. +## @brief Generate lists of people who have made commits to the repository. ## -## This list will be displayed in the About - Credits dialog. +## The lists will be displayed in the About - Credits dialog. ## +## $1 Meson PRIVATE_DIR \n +## $2 Meson current_build_dir \n +## $3 running_from_git - "true" or "false" \n +## $4 gresource.xml \n +## + +mkdir -p "$1" -if [ "$2" = "running_from_git" ] +if [ "$3" = "true" ] then git log --pretty=format:"%an <%ae>" | sed 's/<>//' | sort | uniq --count | sort --general-numeric-sort --reverse --stable --key 1,1 | cut --characters 1-8 --complement > "$1"/authors printf "\n\0" >> "$1"/authors else printf "List of authors not available\n\0" > "$1"/authors fi + +glib-compile-resources --generate-header --sourcedir="$1" --target="$2"/authors.h "$4" +glib-compile-resources --generate-source --sourcedir="$1" --target="$2"/authors.c "$4" diff --git a/src/credits/translators.sh b/scripts/translators.sh similarity index 60% rename from src/credits/translators.sh rename to scripts/translators.sh index 2e9a2536..c9d625d6 100755 --- a/src/credits/translators.sh +++ b/scripts/translators.sh @@ -20,33 +20,46 @@ #********************************************************************** ## @file -## @brief Generate a list of people who have contributed translations. +## @brief Generate lists of people who have made commits to the repository. ## -## This list will be displayed in the About - Credits dialog. +## The lists will be displayed in the About - Credits dialog. ## -## It is expected that the .po files have a list of translators preceded -## by the line "# Translators:" and terminated by a line containing only "#" +## $1 Meson PRIVATE_DIR \n +## $2 po source list \n +## $3 Meson current_build_dir \n +## $4 locales.txt \n +## $5 gresource.xml \n ## +## It is expected that the .po files have a list of translators in the form: \n +## \# Translators: \n +## \# translator1_name \n +## \# translator2_name \n +## \# -for file in "$1"/po/*.po +mkdir -p "$1" + +printf %s "$2" | while read -r file do base=$(basename "$file") locale=${base%.po} - awk '$1 == "'"$locale"'" {print $0}' locales.txt - awk '$2 ~/Translators:/ { + + printf "\n" + awk '$1 == "'"$locale"'" {print $0}' "$4" + awk '$0 ~/Translators:/ { while (1) { getline $0 if ($0 == "#") { exit } else { - print substr($0, 3) + print $0 } } - print $0 }' "$file" - printf "\n" -done > "$2"/translators -printf "\n\0" >> "$2"/translators +done > "$1"/translators +printf "\n\0" >> "$1"/translators + +glib-compile-resources --generate-header --sourcedir="$1" --target="$3"/translators.h "$5" +glib-compile-resources --generate-source --sourcedir="$1" --target="$3"/translators.c "$5" diff --git a/src/authors/authors.gresource.xml b/src/authors/authors.gresource.xml new file mode 100644 index 00000000..e161722b --- /dev/null +++ b/src/authors/authors.gresource.xml @@ -0,0 +1,28 @@ + + + + + + authors + + diff --git a/src/authors/meson.build b/src/authors/meson.build new file mode 100644 index 00000000..cbd3540d --- /dev/null +++ b/src/authors/meson.build @@ -0,0 +1,21 @@ +# This file is a part of Geeqie project (https://www.geeqie.org/). +# Copyright (C) 2008 - 2022 The Geeqie Team +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# + +authors_sh = join_paths(scriptsdir, 'authors.sh') + +authors_resources = custom_target('authors_resources', + input : 'authors.gresource.xml', + output : ['authors.h', 'authors.c'], + command : [authors_sh, '@PRIVATE_DIR@', meson.current_build_dir() , running_from_git.to_string(), '@INPUT@']) + +project_sources += authors_resources diff --git a/src/credits/meson.build b/src/credits/meson.build deleted file mode 100644 index 5d80cb0e..00000000 --- a/src/credits/meson.build +++ /dev/null @@ -1,38 +0,0 @@ -# This file is a part of Geeqie project (https://www.geeqie.org/). -# Copyright (C) 2008 - 2022 The Geeqie Team -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# - -if running_from_git - run_command(find_program('authors.sh'), meson.current_build_dir(), 'running_from_git', check : false) -else - run_command(find_program('authors.sh'), meson.current_build_dir(), '', check : false) -endif - -run_command(find_program('translators.sh'), meson.source_root(), meson.current_build_dir(), check : false) - -message(meson.current_build_dir()) -source_string = '--sourcedir=' + meson.current_build_dir() - -target_string = '--target=' + meson.current_build_dir() + '/credits.h' -credits_resources_h = custom_target('credits_resources_h', - input : 'credits.gresource.xml', - output : 'credits.h', - command : [glib_compile_resources, '--generate-header', source_string,target_string, '@INPUT@']) - -target_string = '--target=' + meson.current_build_dir() + '/credits.c' -credits_resources_c = custom_target('credits_resources_c', - input : 'credits.gresource.xml', - output : 'credits.c', - command : [glib_compile_resources, '--generate-source', target_string, source_string, '@INPUT@']) - -project_sources += credits_resources_h -project_sources += credits_resources_c diff --git a/src/meson.build b/src/meson.build index abd9efb2..e381ceba 100644 --- a/src/meson.build +++ b/src/meson.build @@ -236,10 +236,10 @@ main_sources = files('advanced-exif.cc', project_sources += main_sources +subdir('authors') subdir('icons') subdir('pan-view') subdir('view-file') -subdir('credits') gqmarshal = gnome.genmarshal('gq-marshal', prefix : 'gq_marshal', sources : 'gq-marshal.list') project_sources += gqmarshal[0] diff --git a/src/preferences.cc b/src/preferences.cc index df760068..ceccce11 100644 --- a/src/preferences.cc +++ b/src/preferences.cc @@ -24,8 +24,10 @@ #include "bar-keywords.h" #include "cache.h" -#include "credits.h" -#include "credits.c" +//~ #include "authors.h" +//~ #include "authors.c" +//~ #include "translators.h" +//~ #include "translators.c" #include "editors.h" #include "filedata.h" #include "filefilter.h" @@ -4135,11 +4137,9 @@ void show_about_window(LayoutWindow *lw) } g_free(timezone_path); - credits_resource = credits_get_resource(); - authors_path = g_build_filename(GQ_RESOURCE_PATH_CREDITS, "authors", NULL); - in_stream_authors = g_resource_open_stream(credits_resource, authors_path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); + in_stream_authors = g_resources_open_stream(authors_path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); data_stream = g_data_input_stream_new(in_stream_authors); @@ -4156,9 +4156,9 @@ void show_about_window(LayoutWindow *lw) translators_path = g_build_filename(GQ_RESOURCE_PATH_CREDITS, "translators", NULL); - g_resource_get_info(credits_resource, translators_path, G_RESOURCE_LOOKUP_FLAGS_NONE, &size, &flags, NULL); + g_resources_get_info(translators_path, G_RESOURCE_LOOKUP_FLAGS_NONE, &size, &flags, NULL); - in_stream_translators = g_resource_open_stream(credits_resource, translators_path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); + in_stream_translators = g_resources_open_stream(translators_path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); translators = static_cast(g_malloc0(size)); g_input_stream_read_all(in_stream_translators, translators, size, &bytes_read, NULL, NULL); g_input_stream_close(in_stream_translators, NULL, NULL);