From ab2341d3c3f1af804857cac7c6fd35d09dc4cabd Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Mon, 27 Apr 2020 08:06:21 +0100 Subject: [PATCH] Update desktop.template documentation Also include a script to automatically update the menu "Valid sections" of the template. This needs to be run only when the menus have changed. --- plugins/template.desktop.in | 17 ++++++-- scripts/template-desktop.sh | 83 +++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 4 deletions(-) create mode 100755 scripts/template-desktop.sh diff --git a/plugins/template.desktop.in b/plugins/template.desktop.in index d43690cd..7af3121b 100644 --- a/plugins/template.desktop.in +++ b/plugins/template.desktop.in @@ -9,8 +9,13 @@ _Name=Template #Name[de]=Vorlage # Replace "command" with the actual command or script: -Exec=command %f +Exec=command +# Where may be: +# omitted If no parameter is given the command will be executed in the +# current folder. If a parameter is given but the current folder +# does not contain any files, the command will not be run. +# # %f A single file name, even if multiple files are selected. The # system reading the desktop entry should recognize that the program in # question cannot handle multiple file arguments, and it should should @@ -42,8 +47,8 @@ Icon=gtk-file Categories=X-Geeqie; OnlyShowIn=X-Geeqie; -# Uncomment the following line to include in a Geeqie menu, -# other than in the default path of EditMenu/ExternalMenu +# Uncomment the following line to include in a Geeqie menu +# other than in the default path of PluginsMenu #X-Geeqie-Menu-Path= # e.g. @@ -83,12 +88,16 @@ OnlyShowIn=X-Geeqie; # ViewMenu/ViewSection # ViewMenu/ToolsSection # ViewMenu/SlideShowSection +# WindowsMenu +# WindowsMenu/NewWindow # HelpMenu # HelpMenu/HelpSection # This is a filter - see symlink.desktop and geeqie-symlink for an example -# how to use this feature +# of how to use this feature, or the Plugins section of the Help file. #X-Geeqie-Filter=true # It can be made verbose #X-Geeqie-Verbose=true + +# For other keys such as MimeType see https://developer.gnome.org/desktop-entry-spec/ diff --git a/scripts/template-desktop.sh b/scripts/template-desktop.sh new file mode 100755 index 00000000..c42a2794 --- /dev/null +++ b/scripts/template-desktop.sh @@ -0,0 +1,83 @@ +#! /bin/bash + +# Insert updated menu "Valid sections" list into the desktop template file. +# This needs to be run only when the menus have changed. + +tmp_file=$(mktemp) +path=$(dirname $(realpath $0)) +srcpath=$(dirname $path)"/src/layout_util.c" +templatepath=$(dirname $path)"/plugins/template.desktop.in" + +awk -v src_path=$srcpath 'BEGIN { +menu_flag = 0 +template_flag = 0 +i = 0 +} + +function get_menus() +{ + {while ((getline line < src_path) > 0 ) + { + if (line == "\"\"") + { + menu_flag = 1 + } + if (line == "\"<\057ui>\";") + { + menu_flag = 0 + } + if (menu_flag >= 1) + { + gsub(/\047|"|\/|<|>/, "", line) + split(line, lineArr, "=") + + if (index(lineArr[1], "menu action") > 0) + { + i = i + 1 + menu[i] = lineArr[2] + if ( i == 3) + { + print "# " menu[1] "/" menu[2] "/" lineArr[2] + } + if ( i == 2) + { + print "# " menu[1] "/" lineArr[2] + } + if (i == 1) + { + print "# " lineArr[2] + } + } + if (index(lineArr[1], "placeholder name")) + { + if ( i == 2) + { + print "# " menu[1] "/" menu[2] "/" lineArr[2] + } + else + { + print "# " menu[1] "/" lineArr[2] + } + } + gsub(" ", "", line) + if (line == "menu") + { + i = i - 1 + } + } + } + } +} + +/Valid sections/ {template_flag = 1; print; get_menus()} +/This is a filter/ {template_flag = 0; print ""} +(template_flag == 0) {print} +' $templatepath > $tmp_file + +zenity --text-info < $tmp_file +if [ $? == 0 ] +then + mv $tmp_file $templatepath +else + rm $tmp_file +fi -- 2.20.1