In addition: - moved video type detection into a separate file: videoTypes.dt out of datatypes.dt. Also, removed all actions from Antonis' dt files, as these are handled by the new actions (listed below). Image, postscript, and PDF types definitions are still located in datatypes.dt.src - supports most image files, PDFs, postscript files, and video files via dtapp now. - Added new actions: - DisplayImage - DisplayVideo - DisplayPDF - DisplayPS All of these call the dtapp_* helpers to locate an appropriate program to handle the task. - Added a camera icon - standardized the icons used to display the various types - all images use the Dtimage icon now, as an example. - moved the new *.dt files to their proper place in programs/types, rather than programs/localized/C/types (my bad). Please add any further video types into videoTypes.dt, and everything else (for now) into datatypes.dt. In the future, we should probably separate these out into type-specific .dt files. Also, something should be done about playing audio files too (maybe DisplayVideo.dt can handle all those too?)
142 lines
2.7 KiB
Plaintext
Executable File
142 lines
2.7 KiB
Plaintext
Executable File
XCOMM!/bin/ksh
|
|
XCOMM
|
|
XCOMM dtapp - provide an interface for some useful applications.
|
|
XCOMM
|
|
XCOMM #############################################################
|
|
XCOMM #set -x # uncomment for debugging
|
|
XCOMM ###############################################################
|
|
XCOMM Init
|
|
|
|
DTAPP="dtapp" # Identity crisis
|
|
APPNAME="$(basename $0)" # the app to locate/run
|
|
|
|
XCOMM apps to look for, given an action (based on APPNAME - see MAIN)
|
|
|
|
XCOMM image viewing
|
|
if [ -z "$DTAPP_VIMAGE" ]
|
|
then
|
|
VIMAGE="xv display gimp"
|
|
else
|
|
VIMAGE="$DTAPP_VIMAGE"
|
|
fi
|
|
|
|
XCOMM video viewing
|
|
if [ -z "$DTAPP_VVIDEO" ]
|
|
then
|
|
VVIDEO="vlc ffplay"
|
|
else
|
|
VVIDEO="$DTAPP_VVIDEO"
|
|
fi
|
|
|
|
XCOMM postscript viewing
|
|
if [ -z "$DTAPP_VPS" ]
|
|
then
|
|
VPS="mgv gv"
|
|
else
|
|
VPS="$DTAPP_VPS"
|
|
fi
|
|
|
|
XCOMM PDF viewing
|
|
if [ -z "$DTAPP_VPDF" ]
|
|
then
|
|
VPDF="okular xpdf"
|
|
else
|
|
VPDF="$DTAPP_VPDF"
|
|
fi
|
|
|
|
XCOMM ##############################################################
|
|
XCOMM ## Utility Functions
|
|
|
|
XCOMM ## Find the path of a program
|
|
FindProg()
|
|
{
|
|
# FindProg "program"
|
|
# - returns full path, or ""
|
|
|
|
whence $1
|
|
|
|
return 0
|
|
}
|
|
|
|
XCOMM ## Show an error message
|
|
ErrorMsg()
|
|
{
|
|
# ErrorMsg "Title "Message" ["OK"]
|
|
# use dterror.ds to display it...
|
|
|
|
if [ -z "$3" ]
|
|
then # default to 'OK'
|
|
OKM="OK"
|
|
else
|
|
OKM="$3"
|
|
fi
|
|
|
|
CDE_INSTALLATION_TOP/bin/dterror.ds "$2" "$1" "$OKM"
|
|
|
|
return 0
|
|
}
|
|
|
|
XCOMM ## do a simple command
|
|
DoSimpleCmd()
|
|
{
|
|
# DoSimpleCmd "commands" args
|
|
|
|
didone=0
|
|
cmds="$1"
|
|
shift
|
|
args="$*"
|
|
|
|
for i in $cmds
|
|
do
|
|
thecmd="$(FindProg $i)"
|
|
|
|
if [ ! -z "$thecmd" ]
|
|
then # it's there
|
|
$thecmd "$args"
|
|
didone=1
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ $didone -eq 0 ]
|
|
then # couldn't find a viewer
|
|
ErrorMsg "Helper not found" \
|
|
"${DTAPP}: Could not find any of the following\ncommands for this file type:\n\n$cmds"
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
|
|
XCOMM ##################################################################
|
|
XCOMM ## MAIN
|
|
|
|
XCOMM # We'll just look at our args and decide what to do...
|
|
|
|
XCOMM # Commands we'll recognize
|
|
|
|
COMMANDS="dtapp_vimage dtapp_vweb dtapp_vpdf dtapp_vps dtapp_vvideo"
|
|
|
|
case $APPNAME in
|
|
dtapp_vimage)
|
|
DoSimpleCmd "$VIMAGE" $*
|
|
;;
|
|
dtapp_vpdf)
|
|
DoSimpleCmd "$VPDF" $*
|
|
;;
|
|
dtapp_vps)
|
|
DoSimpleCmd "$VPS" $*
|
|
;;
|
|
dtapp_vvideo)
|
|
DoSimpleCmd "$VVIDEO" $*
|
|
;;
|
|
*)
|
|
# Unknown
|
|
ErrorMsg "${DTAPP}: Unknown Helper Application" \
|
|
"\"$APPNAME\" is not a recognized Helper Application. \nKnown Helper Applications are:\n\n$COMMANDS"
|
|
;;
|
|
esac
|
|
|
|
XCOMM # Fini
|
|
exit 0
|