Revise gresources use
authorColin Clark <colin.clark@cclark.uk>
Sun, 30 Apr 2023 14:38:23 +0000 (15:38 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sun, 30 Apr 2023 14:38:23 +0000 (15:38 +0100)
meson.build
po/locales.txt [moved from src/credits/locales.txt with 100% similarity]
po/meson.build
po/translators.gresource.xml [moved from src/credits/credits.gresource.xml with 97% similarity]
scripts/authors.sh [moved from src/credits/authors.sh with 71% similarity]
scripts/translators.sh [moved from src/credits/translators.sh with 60% similarity]
src/authors/authors.gresource.xml [new file with mode: 0644]
src/authors/meson.build [new file with mode: 0644]
src/credits/meson.build [deleted file]
src/meson.build
src/preferences.cc

index c84543a..4fdb952 100644 (file)
@@ -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,
similarity index 100%
rename from src/credits/locales.txt
rename to po/locales.txt
index 97955da..0e180e7 100644 (file)
 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
similarity index 97%
rename from src/credits/credits.gresource.xml
rename to po/translators.gresource.xml
index 2ec6df1..76873e7 100644 (file)
@@ -23,7 +23,6 @@
 
 <gresources>
   <gresource prefix="/org/geeqie/credits">
-    <file>authors</file>
     <file>translators</file>
   </gresource>
 </gresources>
similarity index 71%
rename from src/credits/authors.sh
rename to scripts/authors.sh
index 667bdca..c41ccca 100755 (executable)
 #**********************************************************************
 
 ## @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"
similarity index 60%
rename from src/credits/translators.sh
rename to scripts/translators.sh
index 2e9a253..c9d625d 100755 (executable)
 #**********************************************************************
 
 ## @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 <translator1 email> \n
+## \# translator2_name <translator2 email> \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 (file)
index 0000000..e161722
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ /*
+ * Copyright (C) 2023 The Geeqie Team
+ *
+ * Author: Colin Clark
+ *
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+-->
+
+<gresources>
+  <gresource prefix="/org/geeqie/credits">
+    <file>authors</file>
+  </gresource>
+</gresources>
diff --git a/src/authors/meson.build b/src/authors/meson.build
new file mode 100644 (file)
index 0000000..cbd3540
--- /dev/null
@@ -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 (file)
index 5d80cb0..0000000
+++ /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
index abd9efb..e381ceb 100644 (file)
@@ -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]
index df76006..ceccce1 100644 (file)
 
 #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<gchar *>(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);