From d130238a5b2e297860355695a9cfa222e8489bc3 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sat, 27 Jan 2024 11:13:55 +0000 Subject: [PATCH] Check and revise .desktop files Include a .desktop file check using desktop-file-validate. Revise .desktop files - most had an incorrect Categories entry. --- meson.build | 23 ++++++++ meson_options.txt | 1 + plugins/camera-import/meson.build | 2 + .../org.geeqie.camera-import.desktop.in | 2 +- plugins/export-jpeg/meson.build | 2 + .../org.geeqie.export-jpeg.desktop.in | 2 +- plugins/image-crop/meson.build | 2 + .../org.geeqie.image-crop.desktop.in | 2 +- plugins/meson.build | 2 + plugins/open-with/meson.build | 2 + .../open-with/org.geeqie.open-with.desktop.in | 2 +- plugins/org.geeqie.template.desktop.in | 5 +- plugins/random-image/meson.build | 2 + .../org.geeqie.random-image.desktop.in | 2 +- plugins/refresh-thumbnail/meson.build | 2 + .../org.geeqie.refresh-thumbnail.desktop.in | 2 +- plugins/resize-image/meson.build | 2 + .../org.geeqie.resize-image.desktop.in | 2 +- plugins/rotate/meson.build | 2 + plugins/rotate/org.geeqie.rotate.desktop.in | 2 +- plugins/symlink/meson.build | 2 + plugins/symlink/org.geeqie.symlink.desktop.in | 2 +- plugins/tethered-photography/meson.build | 2 + ...org.geeqie.tethered-photography.desktop.in | 2 +- plugins/video-player/meson.build | 2 + .../org.geeqie.video-player.desktop.in | 2 +- scripts/desktop-file-validate.sh | 52 +++++++++++++++++++ scripts/meson.build | 1 + 28 files changed, 114 insertions(+), 14 deletions(-) create mode 100755 scripts/desktop-file-validate.sh diff --git a/meson.build b/meson.build index 153552f8..bb40d8d7 100644 --- a/meson.build +++ b/meson.build @@ -587,6 +587,9 @@ mdl_sources = [] # For gtk builder checks on .ui files ui_sources = [] +# For checks on .desktop files +desktop_sources = [] + # Process subdirs before the sources subdir('po') subdir('plugins') @@ -796,3 +799,23 @@ if not option.disabled() else summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true) endif + +# Desktop files test +option = get_option('desktop') +if not option.disabled() + desktop_exe = find_program('desktop-file-validate', required : false) + if desktop_exe.found() + desktop_sh = find_program('desktop-file-validate.sh', dirs : scriptsdir, required : true) + test_desktop_dir = join_paths(meson.current_build_dir(), 'test-desktop-files.p') + foreach desktop_file : desktop_sources + desktop_path = '@0@'.format(desktop_file) + test('Desktop_check_ ' + desktop_path, desktop_sh, args: [test_desktop_dir, desktop_file], timeout: 100) + endforeach + + summary({'Desktop files' : ['Test runs:', true]}, section : 'Testing', bool_yn : true) + else + summary({'Desktop files' : ['Test runs:', false]}, section : 'Testing', bool_yn : true) + endif +else + summary({'Desktop files' : ['Test runs:', false]}, section : 'Testing', bool_yn : true) +endif diff --git a/meson_options.txt b/meson_options.txt index 9bc8508a..eb3a9f1c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -25,6 +25,7 @@ option('gq_localedir', type : 'string', value : '', description : 'Location wher option('archive', type : 'feature', value : 'auto', description : 'archive files e.g. zip, gz') option('cms', type : 'feature', value : 'auto', description : 'color management system') +option('desktop', type : 'feature', value : 'auto', description : 'desktop file check') option('devel', type : 'feature', value : 'disabled', description : 'developer mode') option('doxygen', type : 'feature', value : 'auto', description : 'lua api help file') option('djvu', type : 'feature', value : 'auto', description : 'djvu') diff --git a/plugins/camera-import/meson.build b/plugins/camera-import/meson.build index e57bc350..a7838ac2 100644 --- a/plugins/camera-import/meson.build +++ b/plugins/camera-import/meson.build @@ -23,3 +23,5 @@ i18n.merge_file( script_sources += files('geeqie-camera-import', 'geeqie-camera-import-hook-script') + +desktop_sources += files('org.geeqie.camera-import.desktop.in') diff --git a/plugins/camera-import/org.geeqie.camera-import.desktop.in b/plugins/camera-import/org.geeqie.camera-import.desktop.in index cd9181ea..c82f65b6 100644 --- a/plugins/camera-import/org.geeqie.camera-import.desktop.in +++ b/plugins/camera-import/org.geeqie.camera-import.desktop.in @@ -11,7 +11,7 @@ Comment=Import all images from camera Exec=geeqie-camera-import # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/export-jpeg/meson.build b/plugins/export-jpeg/meson.build index 47828d8a..c9c03942 100644 --- a/plugins/export-jpeg/meson.build +++ b/plugins/export-jpeg/meson.build @@ -22,3 +22,5 @@ i18n.merge_file( install_dir : desktopdir) script_sources += files('geeqie-export-jpeg') + +desktop_sources += files('org.geeqie.export-jpeg.desktop.in') diff --git a/plugins/export-jpeg/org.geeqie.export-jpeg.desktop.in b/plugins/export-jpeg/org.geeqie.export-jpeg.desktop.in index 70ba8439..53bbe400 100644 --- a/plugins/export-jpeg/org.geeqie.export-jpeg.desktop.in +++ b/plugins/export-jpeg/org.geeqie.export-jpeg.desktop.in @@ -11,7 +11,7 @@ Exec=geeqie-export-jpeg %f #TryExec=jpgicc # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/image-crop/meson.build b/plugins/image-crop/meson.build index 13aa4334..14c056f5 100644 --- a/plugins/image-crop/meson.build +++ b/plugins/image-crop/meson.build @@ -22,3 +22,5 @@ i18n.merge_file( install_dir : desktopdir) script_sources += files('geeqie-image-crop') + +desktop_sources += files('org.geeqie.image-crop.desktop.in') diff --git a/plugins/image-crop/org.geeqie.image-crop.desktop.in b/plugins/image-crop/org.geeqie.image-crop.desktop.in index 39107ca1..104276ca 100644 --- a/plugins/image-crop/org.geeqie.image-crop.desktop.in +++ b/plugins/image-crop/org.geeqie.image-crop.desktop.in @@ -9,7 +9,7 @@ Comment=Crop image from marked rectangle Exec=geeqie-image-crop %f # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/meson.build b/plugins/meson.build index 503c94c4..76dab89c 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -31,3 +31,5 @@ i18n.merge_file( po_dir : podir, install : true, install_dir : appdir) + +desktop_sources += files('org.geeqie.template.desktop.in') diff --git a/plugins/open-with/meson.build b/plugins/open-with/meson.build index 4f533f5d..2872a299 100644 --- a/plugins/open-with/meson.build +++ b/plugins/open-with/meson.build @@ -19,3 +19,5 @@ i18n.merge_file( install : true, install_dir : desktopdir) + +desktop_sources += files('org.geeqie.open-with.desktop.in') diff --git a/plugins/open-with/org.geeqie.open-with.desktop.in b/plugins/open-with/org.geeqie.open-with.desktop.in index 5e3677c9..8d7b13f0 100644 --- a/plugins/open-with/org.geeqie.open-with.desktop.in +++ b/plugins/open-with/org.geeqie.open-with.desktop.in @@ -7,7 +7,7 @@ Comment=Call the gtk application chooser dialog Exec=geeqie --remote --action:OpenWith %f # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/org.geeqie.template.desktop.in b/plugins/org.geeqie.template.desktop.in index f1d48051..1ea0f6f6 100644 --- a/plugins/org.geeqie.template.desktop.in +++ b/plugins/org.geeqie.template.desktop.in @@ -2,9 +2,8 @@ Version=1.0 Type=Application -# The Desktop file MUST contain one or both of the following: +# The Desktop file MUST contain the following: Categories=Graphics; -Categories=X-Geeqie; # The name which appears in the menu: Name=Template @@ -13,7 +12,7 @@ Name=Template #Name[de]=Vorlage # Replace "command" with the actual command or script: -Exec=command +Exec=command param # Where may be: # omitted If no parameter is given the command will be executed in the diff --git a/plugins/random-image/meson.build b/plugins/random-image/meson.build index 4739660b..d6d4aedc 100644 --- a/plugins/random-image/meson.build +++ b/plugins/random-image/meson.build @@ -22,3 +22,5 @@ i18n.merge_file( install_dir : desktopdir) script_sources += files('geeqie-random-image') + +desktop_sources += files('org.geeqie.random-image.desktop.in') diff --git a/plugins/random-image/org.geeqie.random-image.desktop.in b/plugins/random-image/org.geeqie.random-image.desktop.in index afd3f649..51a88ea9 100644 --- a/plugins/random-image/org.geeqie.random-image.desktop.in +++ b/plugins/random-image/org.geeqie.random-image.desktop.in @@ -7,7 +7,7 @@ Comment=Display random image from Collections and current folder Exec=geeqie-random-image # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/refresh-thumbnail/meson.build b/plugins/refresh-thumbnail/meson.build index 9877a398..3b767198 100644 --- a/plugins/refresh-thumbnail/meson.build +++ b/plugins/refresh-thumbnail/meson.build @@ -20,3 +20,5 @@ i18n.merge_file( po_dir : podir, install : true, install_dir : desktopdir) + +desktop_sources += files('org.geeqie.refresh-thumbnail.desktop.in') diff --git a/plugins/refresh-thumbnail/org.geeqie.refresh-thumbnail.desktop.in b/plugins/refresh-thumbnail/org.geeqie.refresh-thumbnail.desktop.in index 14d57252..646f4152 100644 --- a/plugins/refresh-thumbnail/org.geeqie.refresh-thumbnail.desktop.in +++ b/plugins/refresh-thumbnail/org.geeqie.refresh-thumbnail.desktop.in @@ -11,7 +11,7 @@ Comment=Refresh Thumbnail Exec=geeqie-refresh-thumbnail # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/resize-image/meson.build b/plugins/resize-image/meson.build index ae750393..5259652c 100644 --- a/plugins/resize-image/meson.build +++ b/plugins/resize-image/meson.build @@ -22,3 +22,5 @@ i18n.merge_file( install_dir : desktopdir) script_sources += files('geeqie-resize-image') + +desktop_sources += files('org.geeqie.resize-image.desktop.in') diff --git a/plugins/resize-image/org.geeqie.resize-image.desktop.in b/plugins/resize-image/org.geeqie.resize-image.desktop.in index bbd12be4..48a3920b 100644 --- a/plugins/resize-image/org.geeqie.resize-image.desktop.in +++ b/plugins/resize-image/org.geeqie.resize-image.desktop.in @@ -7,7 +7,7 @@ Comment=Downsize an image Exec=geeqie-resize-image %f # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/rotate/meson.build b/plugins/rotate/meson.build index 7110e53c..8952ad2c 100644 --- a/plugins/rotate/meson.build +++ b/plugins/rotate/meson.build @@ -22,3 +22,5 @@ i18n.merge_file( install_dir : desktopdir) script_sources += files('geeqie-rotate') + +desktop_sources += files('org.geeqie.rotate.desktop.in') diff --git a/plugins/rotate/org.geeqie.rotate.desktop.in b/plugins/rotate/org.geeqie.rotate.desktop.in index 217a287d..7e007fd0 100644 --- a/plugins/rotate/org.geeqie.rotate.desktop.in +++ b/plugins/rotate/org.geeqie.rotate.desktop.in @@ -7,7 +7,7 @@ Name=Apply the orientation to image content Exec=geeqie-rotate -g %f # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # Show in menu "Edit/Orientation" diff --git a/plugins/symlink/meson.build b/plugins/symlink/meson.build index bbc3e845..992d58f3 100644 --- a/plugins/symlink/meson.build +++ b/plugins/symlink/meson.build @@ -22,3 +22,5 @@ i18n.merge_file( install_dir : desktopdir) script_sources += files('geeqie-symlink') + +desktop_sources += files('org.geeqie.symlink.desktop.in') diff --git a/plugins/symlink/org.geeqie.symlink.desktop.in b/plugins/symlink/org.geeqie.symlink.desktop.in index f82a706e..fa754a0f 100644 --- a/plugins/symlink/org.geeqie.symlink.desktop.in +++ b/plugins/symlink/org.geeqie.symlink.desktop.in @@ -7,7 +7,7 @@ Name=Symlink Exec=geeqie-symlink %f # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # Show in menu "File" diff --git a/plugins/tethered-photography/meson.build b/plugins/tethered-photography/meson.build index 5544b0ad..e8058dfb 100644 --- a/plugins/tethered-photography/meson.build +++ b/plugins/tethered-photography/meson.build @@ -23,3 +23,5 @@ i18n.merge_file( script_sources += files('geeqie-tethered-photography', 'geeqie-tethered-photography-hook-script') + +desktop_sources += files('org.geeqie.tethered-photography.desktop.in') diff --git a/plugins/tethered-photography/org.geeqie.tethered-photography.desktop.in b/plugins/tethered-photography/org.geeqie.tethered-photography.desktop.in index ef8d76b7..a3c7e6c5 100644 --- a/plugins/tethered-photography/org.geeqie.tethered-photography.desktop.in +++ b/plugins/tethered-photography/org.geeqie.tethered-photography.desktop.in @@ -6,7 +6,7 @@ Name=Tethered photography Exec=geeqie-tethered-photography # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; # It can be made verbose diff --git a/plugins/video-player/meson.build b/plugins/video-player/meson.build index 1f25ed62..d379f9d3 100644 --- a/plugins/video-player/meson.build +++ b/plugins/video-player/meson.build @@ -18,3 +18,5 @@ i18n.merge_file( po_dir : podir, install : true, install_dir : desktopdir) + +desktop_sources += files('org.geeqie.video-player.desktop.in') diff --git a/plugins/video-player/org.geeqie.video-player.desktop.in b/plugins/video-player/org.geeqie.video-player.desktop.in index 0c92c1b0..ccbe1f99 100644 --- a/plugins/video-player/org.geeqie.video-player.desktop.in +++ b/plugins/video-player/org.geeqie.video-player.desktop.in @@ -9,7 +9,7 @@ Comment=Display videos in Geeqie Exec=xdg-open %f # Desktop files that are usable only in Geeqie should be marked like this: -Categories=X-Geeqie; +Categories=Graphics; OnlyShowIn=X-Geeqie; TryExec=xdg-open diff --git a/scripts/desktop-file-validate.sh b/scripts/desktop-file-validate.sh new file mode 100755 index 00000000..56986b9c --- /dev/null +++ b/scripts/desktop-file-validate.sh @@ -0,0 +1,52 @@ +#! /bin/sh +#********************************************************************** +# Copyright (C) 2024 - 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. +#********************************************************************** + +## @file +## @brief Use desktop-file-validate on .desktop files. +## +## $1 temp directory \n +## $2 desktop file name including .in extension \n +## +## desktop-file-validate will not process a file with +## the extension ".in". Use a symlink as a workaround. + +if [ ! -d "$1" ] +then + mkdir --parents "$1" +fi + +desktop_file=$(basename "$2" ".in") + +ln --symbolic "$2" "$1/$desktop_file" + +result=$(desktop-file-validate "$1/$desktop_file") + +rm "$1/$desktop_file" + +if [ -z "$result" ] +then + exit 0 +else + printf "%s\n" "$result" + + exit 1 +fi + diff --git a/scripts/meson.build b/scripts/meson.build index 305ba369..1d47776b 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -12,6 +12,7 @@ # GNU General Public License for more details. script_sources += files('authors.sh', +'desktop-file-validate.sh', 'devel-install.sh', 'doxygen-help.sh', 'doxygen.sh', -- 2.20.1