#!/usr/sbin/install-menu
# xdg desktop entry spec - applications generation
# http://www.freedesktop.org/Standards/desktop-entry-spec
# Copyright 2004 - Chris Cheney
# Licensed under the GNU General Public License, version 2.

!include /etc/menu-methods/menu.h

compat="menu-2"
outputencoding="UTF-8";

function AppEntry($terminal) =
	"[Desktop Entry]\n"
	"Type=Application\n"
	"Encoding=UTF-8\n"
	"Name=" title() "\n"
	ifnempty($generictitle,"GenericName=" $generictitle "\n")
	ifnempty($longtitle,"Comment=" $longtitle "\n")
	ifnempty($icon, "Icon=" $icon "\n") 
	forall(languages(),"lang",
                "Name[" $lang "]=" encode_translate($lang,title(),"utf-8") "\n"
		ifelse($longtitle, "Comment[" $lang "]=" encode_translate($lang,$longtitle,"utf-8") "\n", 
               		"Comment[" $lang "]=" encode_translate($lang,$title,"utf-8") "\n")
		)
	"Exec=" ifelse($kde_command, $kde_command, $command " " ifnempty($accept_url,ifeqelse(tolower($accept_url),"true",ifelse($multiple_files,ifeqelse(tolower($multiple_files),"true"," %U", " %u"), "%u"),ifelse($multiple_files,ifeq(tolower($multiple_files),"true"," %F"),"%f"))))"\n" 
	"Terminal=" $terminal "\n"
	ifnempty($mimetypes,"MimeType=" replacewith($mimetypes,",",";") "\n") 
        ifnempty($startup_notify,"StartupNotify=" $startup_notify "\n")
	ifnempty($kde_mimetype,"MimeType=" replacewith($kde_mimetype,",",";") "\n")
	ifeq(tolower($needs),"gnome","OnlyShowIn=GNOME;\n")
	ifeq(tolower($needs),"kde","OnlyShowIn=KDE;\n")
	"Categories=X-Mandrakelinux" replace(replacewith($basesection,"/","-")," ","") ";\n"
        ifnempty($kde_opt, $kde_opt "\n");


supported;
 gnome = AppEntry("false");
 kde = AppEntry("false");
 x11 = AppEntry("false");
 text = AppEntry("true");
endsupported;

startmenu = "";
endmenu = "";
submenutitle = "";

treewalk = "M";

genmenu = ifnempty($command,"Mandrakelinux" ifnempty($basesection, replace($basesection," ","")) "/" ifelse($kde_filename,$kde_filename, $title) ".desktop");

rootsection = "";

prerun=ifroot("", "/usr/bin/savekdemimetypes.pl " prefix() ";") "rm -rf " prefix() "/Mandrakelinux";

postrun="/usr/bin/removekdesysmenu-simplified.pl;" ifroot("", "/usr/bin/restorekdemimetypes.pl " prefix() ";") "/usr/bin/update-desktop-database -q " prefix();

preoutput = "";

rootprefix = "/var/lib/menu-xdg/simplified/applications";

userprefix = ".local/share/simplified/applications";
