#!/usr/sbin/install-menu
#   -*- mode: shell-script; -*-
#I need menu-1!
#
#NOTE: the first line of this script _must_ be
# equal to "#!/usr/sbin/install-menu", otherwise update-menus
# will feed this script old-compat-mode data.
#
#More info: /usr/doc/menu/html.
#

compat="menu-1"

!include menu.h

#compat="menu-2"
treewalk="(M)"

function findicon($filename, $defaulticon)= \
    ifeqelse($filename, "", $defaulticon, \
    ifelsefile($filename, $filename, \
    ifelsefile("/usr/share/pixmaps/" $filename, "/usr/share/pixmaps/" $filename, \
    ifelsefile("/usr/share/icons/" $filename, "/usr/share/icons/" $filename, \
    ifelsefile("/usr/share/icons/hicolor/16x16/apps/" $filename, "/usr/share/icons/hicolor/16x16/apps/" $filename, \
    ifelsefile("/usr/share/icons/crystalsvg/16x16/apps/" $filename, "/usr/share/icons/crystalsvg/16x16/apps/" $filename, \
    ifelsefile("/usr/share/icons/kdeclassic/16x16/apps/" $filename, "/usr/share/icons/kdeclassic/16x16/apps/" $filename, \
    ifelsefile("/usr/share/icons/locolor/16x16/apps/" $filename, "/usr/share/icons/locolor/16x16/apps/" $filename, \
    $defaulticon))))))))\

function ttitle()=encode_translate(lang(),title(),"utf-8")
function f($com)="<app name=\"" ttitle() "\" cmd=\"" esc($com,"\"")"\" icon=\"" findicon($icon, "-") "\"/>\n"
function t($com)="<app name=\"" ttitle() "\" term=\"yes\" cmd=\"" esc($com,"\"")"\" icon=\"" findicon($icon, "-") "\"/>\n"

supported;
  x11=f($command)
  xfce4=f($command)
  text=t($command)
endsupported;

preoutput="<?xml version='1.0' encoding='UTF-8'?>\n<!DOCTYPE xfdesktop-menu>\n\n<xfdesktop-menu>\n\n"
postoutput="</xfdesktop-menu>\n"
startmenu=   "<menu name=\"" ttitle() "\" icon=\"" findicon($icon, "-") "\">\n"
endmenu=     "</menu>\n"
genmenu=      "menu2.xml"
rootprefix=   "/etc/X11/xdg/xfce4/desktop/"
rootsection= "Mandriva"
postrun= "sh /etc/X11/xdg/xfce4/desktop/menu_method_postrun.sh"
onlyrunasroot=true
