OSDN Git Service

* timidity/common.c
authorKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Tue, 1 Apr 2008 02:35:08 +0000 (02:35 +0000)
committerKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Tue, 1 Apr 2008 02:35:08 +0000 (02:35 +0000)
  common.makefile.in
  configure.in
  doc/C/README.xaw
  interface/arrow.xbm
  interface/bitmaps/arrow.xbm
  interface/bitmaps/check.xbm
  interface/bitmaps/fast.xbm
  interface/bitmaps/keydown.xbm
  interface/bitmaps/keyup.xbm
  interface/bitmaps/off.xbm
  interface/bitmaps/on.xbm
  interface/bitmaps/slow.xbm
  interface/check.xbm
  interface/Makefile.am
  interface/off.xbm
  interface/on.xbm
  interface/xaw_c.c
  interface/xaw.h
  interface/xaw_i.c
  interface/xdnd.c
  interface/xdnd.h
  interface/x_trace.c
  interface/x_trace.h
  Makefile.am
  Makefile.in
  script/unix2dos.sh
  timidity/aiff_a.c
  timidity/au_a.c
  timidity/common.c
  timidity/flac_a.c
  timidity/gogo_a.c
  timidity/m2m.c
  timidity/midi_a.c
  timidity/modmid_a.c
  timidity/output.h
  timidity/playmidi.c
  file timidity/raw_a.c
  file timidity/speex_a.c
  file timidity/vorbis_a.c
  timidity/wave_a.c
  TiMidity.ad
  TiMidity.ad.in
  TiMidity-uj.ad
  TiMidity-uj.ad.in  some improvements of XAW interface.

42 files changed:
ChangeLog
Makefile.am
Makefile.in
autoconf/Makefile.in
common.makefile.in
config.h.in
configs/Makefile.in
configure
configure.in
doc/C/Makefile.in
doc/C/README.xaw
doc/Makefile.in
doc/ja_JP.eucJP/Makefile.in
interface/Makefile.am
interface/Makefile.in
interface/bitmaps/Makefile.in
interface/motif_bitmaps/Makefile.in
interface/pixmaps/Makefile.in
interface/xaw.h
interface/xaw_c.c
interface/xaw_i.c
libarc/Makefile.in
libunimod/Makefile.in
script/Makefile.in
script/unix2dos.sh
timidity/Makefile.in
timidity/aiff_a.c
timidity/au_a.c
timidity/common.c
timidity/flac_a.c
timidity/gogo_a.c
timidity/m2m.c
timidity/midi_a.c
timidity/modmid_a.c
timidity/output.h
timidity/playmidi.c
timidity/raw_a.c
timidity/speex_a.c
timidity/vorbis_a.c
timidity/wave_a.c
utils/Makefile.in
windrv/Makefile.in

index 927104d..894bb38 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,52 @@
 2008-4-1  Keishi Suenaga <skeishi@yahoo.co.jp>
+               patchs by Yair K.
+       * timidity/common.c
+         common.makefile.in
+         configure.in
+         doc/C/README.xaw
+         interface/arrow.xbm
+         interface/bitmaps/arrow.xbm
+         interface/bitmaps/check.xbm
+         interface/bitmaps/fast.xbm
+         interface/bitmaps/keydown.xbm
+         interface/bitmaps/keyup.xbm
+         interface/bitmaps/off.xbm
+         interface/bitmaps/on.xbm
+         interface/bitmaps/slow.xbm
+         interface/check.xbm
+         interface/Makefile.am
+         interface/off.xbm
+         interface/on.xbm
+         interface/xaw_c.c
+         interface/xaw.h
+         interface/xaw_i.c
+         interface/xdnd.c
+         interface/xdnd.h
+         interface/x_trace.c
+         interface/x_trace.h
+         Makefile.am
+         Makefile.in
+         script/unix2dos.sh
+         timidity/aiff_a.c
+         timidity/au_a.c
+         timidity/common.c
+         timidity/flac_a.c
+         timidity/gogo_a.c
+         timidity/m2m.c
+         timidity/midi_a.c
+         timidity/modmid_a.c
+         timidity/output.h
+         timidity/playmidi.c
+         file timidity/raw_a.c
+         file timidity/speex_a.c
+         file timidity/vorbis_a.c
+         timidity/wave_a.c
+         TiMidity.ad
+         TiMidity.ad.in
+         TiMidity-uj.ad
+         TiMidity-uj.ad.in  some improvements of XAW interface.
+
+2008-4-1  Keishi Suenaga <skeishi@yahoo.co.jp>
                a patch by Milan Zamazal
        * timidity/playmidi.c
          timidity/playmidi.h
        * windrv/timiditydrv.c
        * windrv/timiwp_timidity.c: fix for WindowsMediaPlayer.
 
-\r2007-01-28  Keishi Suenaga <skeishi@yahoo.co.jp>
+2007-01-28  Keishi Suenaga <skeishi@yahoo.co.jp>
 
        * interface/rtsyn_common.c: fix sysex check 
        * timidity/portaudio_a.c    small fix for compiling
        * timidity/timidity.c       w32 cfg file sequence changed
                                    option > exe dir > win dir
-\r                                  w32 set stdin&out binarymode
+                                   w32 set stdin&out binarymode
        * timidity/w32_a.c          small fix for compiling
        * windrv/Makefile.am        re-add add timidity.idl
        * windrv/timiditydrv.c      re-add MIDIOUTCAPS2A(W)
index 810fbe4..8f65aa2 100644 (file)
@@ -36,9 +36,7 @@ EXTRA_DIST = \
        ChangeLog.1 \
        ChangeLog.2 \
        INSTALL.ja \
-       README.ja \
-       TiMidity-uj.ad.in \
-       TiMidity.ad.in
+       README.ja
 
 TOOLSDIR = timidity-tools
 UMPDIR = ump
index d03d967..2ac5549 100644 (file)
@@ -135,6 +135,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -215,6 +217,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -280,6 +284,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 
 ACLOCAL_AMFLAGS = -I autoconf
 M4DIR = autoconf
@@ -300,9 +305,7 @@ EXTRA_DIST = \
        ChangeLog.1 \
        ChangeLog.2 \
        INSTALL.ja \
-       README.ja \
-       TiMidity-uj.ad.in \
-       TiMidity.ad.in
+       README.ja
 
 
 TOOLSDIR = timidity-tools
@@ -311,7 +314,7 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/autoconf/mkinstalldirs
 CONFIG_HEADER = config.h interface.h
-CONFIG_CLEAN_FILES = common.makefile TiMidity.ad TiMidity-uj.ad
+CONFIG_CLEAN_FILES = common.makefile
 DIST_SOURCES =
 
 RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
@@ -320,9 +323,9 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
        installdirs-recursive install-recursive uninstall-recursive \
        check-recursive installcheck-recursive
 DIST_COMMON = README $(srcdir)/Makefile.in $(srcdir)/configure AUTHORS \
-       COPYING ChangeLog INSTALL Makefile.am NEWS TODO \
-       TiMidity-uj.ad.in TiMidity.ad.in aclocal.m4 common.makefile.in \
-       config.h.in configure configure.in interface.h.in
+       COPYING ChangeLog INSTALL Makefile.am NEWS TODO aclocal.m4 \
+       common.makefile.in config.h.in configure configure.in \
+       interface.h.in
 DIST_SUBDIRS = $(SUBDIRS)
 all: config.h interface.h
        $(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -377,10 +380,6 @@ distclean-hdr:
        -rm -f config.h stamp-h1 interface.h stamp-h2
 common.makefile: $(top_builddir)/config.status common.makefile.in
        cd $(top_builddir) && $(SHELL) ./config.status $@
-TiMidity.ad: $(top_builddir)/config.status TiMidity.ad.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
-TiMidity-uj.ad: $(top_builddir)/config.status TiMidity-uj.ad.in
-       cd $(top_builddir) && $(SHELL) ./config.status $@
 uninstall-info-am:
 
 # This directory's subdirectories are mostly independent; you can cd
index 6378d5c..c6db3bd 100644 (file)
@@ -134,6 +134,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -214,6 +216,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -279,6 +283,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 
 EXTRA_DIST = \
   alsa.m4 \
index ee07eb0..a6f4b44 100644 (file)
@@ -68,6 +68,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index e00cf07..331275f 100644 (file)
@@ -76,6 +76,9 @@
 /* Define to 1 if you have the `getpagesize' function. */
 #undef HAVE_GETPAGESIZE
 
+/* Define to 1 if you have the `getpid' function. */
+#undef HAVE_GETPID
+
 /* Define to 1 if you have the `gettimeofday' function. */
 #undef HAVE_GETTIMEOFDAY
 
 /* Define to 1 if you have the `xpg4' library (-lxpg4). */
 #undef HAVE_LIBXPG4
 
+/* Define to 1 if you have the `Xpm' library (-lXpm). */
+#undef HAVE_LIBXPM
+
 /* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 
 /* Define to 1 if you have the <X11/Xmu/ExtAgent.h> header file. */
 #undef HAVE_X11_XMU_EXTAGENT_H
 
+/* Define to 1 if you have the <X11/Xaw3d/Tip.h> header file. */
+#undef HAVE_XAW3D_TIP
+
 /* Define to 1 if you have the `XmuRegisterExternalAgent' function. */
 #undef HAVE_XMUREGISTEREXTERNALAGENT
 
 /* Define to 1 if you are NOT in debug mode */
 #undef NDEBUG
 
+/* Define to 1 if you use libneXtaw. */
+#undef NEXTAW
+
 /* Define to 1 if you do not have <string.h>. */
 #undef NO_STRING_H
 
 /* Define to 1 if you have libXaw3d. */
 #undef XAW3D
 
+/* Define to 1 if you use libXawPlus. */
+#undef XAWPLUS
+
+/* Define to 1 if you want xdnd support. */
+#undef XDND
+
 /* Define to 1 if the X Window System is missing or not being used. */
 #undef X_DISPLAY_MISSING
 
index 4d05c7a..92d6b28 100644 (file)
@@ -134,6 +134,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -214,6 +216,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -279,6 +283,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 
 EXTRA_DIST = \
   msc6-project.zip \
index 5c56c00..e1973f8 100755 (executable)
--- a/configure
+++ b/configure
@@ -685,6 +685,9 @@ am__leading_dot
 MAINTAINER_MODE_TRUE
 MAINTAINER_MODE_FALSE
 MAINT
+XAW_INSTALL_RESOURCE_FILES_TRUE
+XAW_INSTALL_RESOURCE_FILES_FALSE
+xawresdir
 EMACS
 lispdir
 CC
@@ -738,6 +741,8 @@ LIBOGGFLAC_CFLAGS
 LIBOGGFLAC_LIBS
 NEEDDLOPEN_TRUE
 NEEDDLOPEN_FALSE
+ENABLE_XDND_TRUE
+ENABLE_XDND_FALSE
 ENABLE_NCURSES_TRUE
 ENABLE_NCURSES_FALSE
 n_so_libs
@@ -1477,6 +1482,7 @@ Optional Features:
   --enable-dynamic        Enable dynamic link interface   (default is no)
   --enable-dynamic=dynamic_list
                           Comma separated dynamic interface list
+  --enable-xdnd           Enable xdnd support             (default is no)
   --enable-ncurses        Enable ncurses interface        (default is no)
   --enable-slang          Enable slang interface          (default is no)
   --enable-motif          Enable motif interface          (default is no)
@@ -1517,9 +1523,18 @@ Optional Packages:
   --with-libraries=DIR    Specify library directories (colon separated)
   --with-default-path=DIR Where timidity.cfg is  (PREFIX/share/timidity)
   --with-module-dir=DIR   Where to install interfaces (PREFIX/lib/timidity)
+  --with-xaw-resource-prefix=DIR What prefix to install XAW's resource files to
+     (optinal)
   --with-lispdir          Override the default lisp directory
   --with-elf              create ELF shared object instead of AOUT
   --with-x                use the X Window System
+  --with-xawlib=lib      Try to link to these xaw widget libraries by the
+                            order specified by the comma separated value list:
+                             xaw: X11's libXaw
+                             xaw3d: Xaw3d
+                             neXtaw: neXtaw
+                             XawPlus: XawPlus
+                             default is --with-xawlib=xaw3d,xaw
   --with-tcl-includes=DIR Tcl include file path
   --with-tcl-libs=DIR     Tcl library file path
   --with-tk-includes=DIR  Tk include file path
@@ -2733,6 +2748,23 @@ _ACEOF
 
 
 
+# Check whether --with-xaw-resource-prefix was given.
+if test "${with_xaw_resource_prefix+set}" = set; then
+  withval=$with_xaw_resource_prefix; xawresdir=$withval
+fi
+
+
+
+if test "x$xawresdir" != "x"; then
+  XAW_INSTALL_RESOURCE_FILES_TRUE=
+  XAW_INSTALL_RESOURCE_FILES_FALSE='#'
+else
+  XAW_INSTALL_RESOURCE_FILES_TRUE='#'
+  XAW_INSTALL_RESOURCE_FILES_FALSE=
+fi
+
+
+
 # Checks for programs.
 
 # Check whether --with-lispdir was given.
@@ -6614,6 +6646,15 @@ fi
 fi
 
 
+
+# Check whether --with-xawlib was given.
+if test "${with_xawlib+set}" = set; then
+  withval=$with_xawlib;  with_xawlib="$withval"
+else
+   with_xawlib="xaw3d,xaw"
+fi
+
+
 # Checks for X
 if test "x$with_x" = xyes; then
   if test "x$have_x" = xno; then
@@ -7080,67 +7121,668 @@ case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_Xmu_XmuInternAtom=yes
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_Xmu_XmuInternAtom=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_lib_Xmu_XmuInternAtom=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xmu_XmuInternAtom" >&5
+echo "${ECHO_T}$ac_cv_lib_Xmu_XmuInternAtom" >&6; }
+if test $ac_cv_lib_Xmu_XmuInternAtom = yes; then
+  LIBS="-lXmu $LIBS"
+fi
+
+
+for ac_func in XmuRegisterExternalAgent
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  for i in `echo $with_xawlib | sed 's/,/ /g'`; do
+  case "$i" in
+  "xaw")
+    { echo "$as_me:$LINENO: checking for XawInitializeWidgetSet in -lXaw" >&5
+echo $ECHO_N "checking for XawInitializeWidgetSet in -lXaw... $ECHO_C" >&6; }
+if test "${ac_cv_lib_Xaw_XawInitializeWidgetSet+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXaw  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char XawInitializeWidgetSet ();
+int
+main ()
+{
+return XawInitializeWidgetSet ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_Xaw_XawInitializeWidgetSet=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_lib_Xaw_XawInitializeWidgetSet=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xaw_XawInitializeWidgetSet" >&5
+echo "${ECHO_T}$ac_cv_lib_Xaw_XawInitializeWidgetSet" >&6; }
+if test $ac_cv_lib_Xaw_XawInitializeWidgetSet = yes; then
+  have_xaw=yes
+else
+  have_xaw=no
+fi
+
+    ;;
+  "xaw3d")
+    { echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+{ echo "$as_me:$LINENO: checking for XawInitializeWidgetSet in -lXaw3d" >&5
+echo $ECHO_N "checking for XawInitializeWidgetSet in -lXaw3d... $ECHO_C" >&6; }
+if test "${ac_cv_lib_Xaw3d_XawInitializeWidgetSet+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXaw3d  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char XawInitializeWidgetSet ();
+int
+main ()
+{
+return XawInitializeWidgetSet ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_Xaw3d_XawInitializeWidgetSet=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_cv_lib_Xaw3d_XawInitializeWidgetSet=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xaw3d_XawInitializeWidgetSet" >&5
+echo "${ECHO_T}$ac_cv_lib_Xaw3d_XawInitializeWidgetSet" >&6; }
+if test $ac_cv_lib_Xaw3d_XawInitializeWidgetSet = yes; then
+   have_xaw=3d;
+          if test "${ac_cv_header_X11_Xaw3d_Tip_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for X11/Xaw3d/Tip.h" >&5
+echo $ECHO_N "checking for X11/Xaw3d/Tip.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_X11_Xaw3d_Tip_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_X11_Xaw3d_Tip_h" >&5
+echo "${ECHO_T}$ac_cv_header_X11_Xaw3d_Tip_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking X11/Xaw3d/Tip.h usability" >&5
+echo $ECHO_N "checking X11/Xaw3d/Tip.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <X11/Xaw3d/Tip.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking X11/Xaw3d/Tip.h presence" >&5
+echo $ECHO_N "checking X11/Xaw3d/Tip.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <X11/Xaw3d/Tip.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: X11/Xaw3d/Tip.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: X11/Xaw3d/Tip.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to root@mput.dip.jp ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for X11/Xaw3d/Tip.h" >&5
+echo $ECHO_N "checking for X11/Xaw3d/Tip.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_X11_Xaw3d_Tip_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_cv_lib_Xmu_XmuInternAtom=no
+  ac_cv_header_X11_Xaw3d_Tip_h=$ac_header_preproc
 fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_X11_Xaw3d_Tip_h" >&5
+echo "${ECHO_T}$ac_cv_header_X11_Xaw3d_Tip_h" >&6; }
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xmu_XmuInternAtom" >&5
-echo "${ECHO_T}$ac_cv_lib_Xmu_XmuInternAtom" >&6; }
-if test $ac_cv_lib_Xmu_XmuInternAtom = yes; then
-  LIBS="-lXmu $LIBS"
+if test $ac_cv_header_X11_Xaw3d_Tip_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XAW3D_TIP 1
+_ACEOF
+
 fi
 
 
-for ac_func in XmuRegisterExternalAgent
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+
+else
+  have_xaw=no
+
+fi
+
+    ;;
+  "neXtaw")
+    { echo "$as_me:$LINENO: checking for XawInitializeWidgetSet in -lneXtaw" >&5
+echo $ECHO_N "checking for XawInitializeWidgetSet in -lneXtaw... $ECHO_C" >&6; }
+if test "${ac_cv_lib_neXtaw_XawInitializeWidgetSet+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lneXtaw  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
@@ -7148,18 +7790,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char $ac_func ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_$ac_func || defined __stub___$ac_func
-choke me
-#endif
-
+char XawInitializeWidgetSet ();
 int
 main ()
 {
-return $ac_func ();
+return XawInitializeWidgetSet ();
   ;
   return 0;
 }
@@ -7182,35 +7817,36 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  eval "$as_ac_var=yes"
+  ac_cv_lib_neXtaw_XawInitializeWidgetSet=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       eval "$as_ac_var=no"
+       ac_cv_lib_neXtaw_XawInitializeWidgetSet=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-ac_res=`eval echo '${'$as_ac_var'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_neXtaw_XawInitializeWidgetSet" >&5
+echo "${ECHO_T}$ac_cv_lib_neXtaw_XawInitializeWidgetSet" >&6; }
+if test $ac_cv_lib_neXtaw_XawInitializeWidgetSet = yes; then
+  have_xaw=next
+else
+  have_xaw=no
 fi
-done
 
-  { echo "$as_me:$LINENO: checking for XawInitializeWidgetSet in -lXaw3d" >&5
-echo $ECHO_N "checking for XawInitializeWidgetSet in -lXaw3d... $ECHO_C" >&6; }
-if test "${ac_cv_lib_Xaw3d_XawInitializeWidgetSet+set}" = set; then
+    ;;
+  "XawPlus")
+
+{ echo "$as_me:$LINENO: checking for XpmCreatePixmapFromData in -lXpm" >&5
+echo $ECHO_N "checking for XpmCreatePixmapFromData in -lXpm... $ECHO_C" >&6; }
+if test "${ac_cv_lib_Xpm_XpmCreatePixmapFromData+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXaw3d  $LIBS"
+LIBS="-lXpm  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -7224,11 +7860,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char XawInitializeWidgetSet ();
+char XpmCreatePixmapFromData ();
 int
 main ()
 {
-return XawInitializeWidgetSet ();
+return XpmCreatePixmapFromData ();
   ;
   return 0;
 }
@@ -7251,30 +7887,36 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_Xaw3d_XawInitializeWidgetSet=yes
+  ac_cv_lib_Xpm_XpmCreatePixmapFromData=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_Xaw3d_XawInitializeWidgetSet=no
+       ac_cv_lib_Xpm_XpmCreatePixmapFromData=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xaw3d_XawInitializeWidgetSet" >&5
-echo "${ECHO_T}$ac_cv_lib_Xaw3d_XawInitializeWidgetSet" >&6; }
-if test $ac_cv_lib_Xaw3d_XawInitializeWidgetSet = yes; then
-  have_xaw=3d
-else
-   { echo "$as_me:$LINENO: checking for XawInitializeWidgetSet in -lXaw" >&5
-echo $ECHO_N "checking for XawInitializeWidgetSet in -lXaw... $ECHO_C" >&6; }
-if test "${ac_cv_lib_Xaw_XawInitializeWidgetSet+set}" = set; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&5
+echo "${ECHO_T}$ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&6; }
+if test $ac_cv_lib_Xpm_XpmCreatePixmapFromData = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBXPM 1
+_ACEOF
+
+  LIBS="-lXpm $LIBS"
+
+fi
+
+    { echo "$as_me:$LINENO: checking for XawInitializeWidgetSet in -lXawPlus" >&5
+echo $ECHO_N "checking for XawInitializeWidgetSet in -lXawPlus... $ECHO_C" >&6; }
+if test "${ac_cv_lib_XawPlus_XawInitializeWidgetSet+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXaw  $LIBS"
+LIBS="-lXawPlus  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -7315,28 +7957,33 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
         test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_Xaw_XawInitializeWidgetSet=yes
+  ac_cv_lib_XawPlus_XawInitializeWidgetSet=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_lib_Xaw_XawInitializeWidgetSet=no
+       ac_cv_lib_XawPlus_XawInitializeWidgetSet=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xaw_XawInitializeWidgetSet" >&5
-echo "${ECHO_T}$ac_cv_lib_Xaw_XawInitializeWidgetSet" >&6; }
-if test $ac_cv_lib_Xaw_XawInitializeWidgetSet = yes; then
-  have_xaw=yes
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_XawPlus_XawInitializeWidgetSet" >&5
+echo "${ECHO_T}$ac_cv_lib_XawPlus_XawInitializeWidgetSet" >&6; }
+if test $ac_cv_lib_XawPlus_XawInitializeWidgetSet = yes; then
+  have_xaw=plus
 else
   have_xaw=no
 fi
 
-fi
-
+    ;;
+  *)
+    have_xaw=no
+    ;;
+  esac
+  if test "x$have_xaw" != "xno"; then break; fi
+  done
   { echo "$as_me:$LINENO: checking for XmCreateForm in -lXm" >&5
 echo $ECHO_N "checking for XmCreateForm in -lXm... $ECHO_C" >&6; }
 if test "${ac_cv_lib_Xm_XmCreateForm+set}" = set; then
@@ -8048,75 +8695,6 @@ fi
 
 fi
 
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-                 inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
-if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       eval "$as_ac_Header=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-ac_res=`eval echo '${'$as_ac_Header'}'`
-              { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
 
 
 
 
 
 
+
 for ac_func in \
   alarm \
   dup2 \
   floor \
   getcwd \
-  getopt \
   gethostbyname \
+  getopt \
+  getpid \
   gettimeofday \
   getwd \
   isatty \
@@ -16167,6 +16747,31 @@ else
 fi
 
 
+# Check whether --enable-xdnd was given.
+if test "${enable_xdnd+set}" = set; then
+  enableval=$enable_xdnd;  if test "$enableval" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define XDND 1
+_ACEOF
+
+    XDND_SRCS="xdnd.c"
+    enable_xdnd=yes
+    fi
+
+fi
+
+
+
+if test "x$enable_xdnd" = "xyes"; then
+  ENABLE_XDND_TRUE=
+  ENABLE_XDND_FALSE='#'
+else
+  ENABLE_XDND_TRUE='#'
+  ENABLE_XDND_FALSE=
+fi
+
+
 
 
 
@@ -17499,7 +18104,7 @@ if test "${enable_xaw+set}" = set; then
 echo "$as_me: error: xaw: --with-x option must be specified" >&2;}
    { (exit 1); exit 1; }; }
     fi
-    if test "x$have_xaw" != "xyes" -a "x$have_xaw" != "x3d"; then
+    if test "x$have_xaw" = "xno"; then
       { echo "$as_me:$LINENO: WARNING: X Athena Widget library is not found." >&5
 echo "$as_me: WARNING: X Athena Widget library is not found." >&2;}
       enable_xaw=no
     fi
     lib_xmu_opt=-lXmu
     lib_xt_opt=-lXt
-    if test "x$have_xaw" = x3d; then
+    case "$have_xaw" in
+      "yes")
+        lib_xaw_opt=-lXaw
+       ;;
+      "3d")
 
 cat >>confdefs.h <<\_ACEOF
 #define XAW3D 1
 _ACEOF
 
-      lib_xaw_opt=-lXaw3d
-    else
-      lib_xaw_opt=-lXaw
-    fi
-    INTERFACE_SRCS="$INTERFACE_SRCS xaw_c.c xaw_i.c"
+        lib_xaw_opt=-lXaw3d
+       ;;
+      "plus")
+
+cat >>confdefs.h <<\_ACEOF
+#define XAWPLUS 1
+_ACEOF
+
+        lib_xaw_opt="-lXpm -lXawPlus"
+       ;;
+      "next")
+
+cat >>confdefs.h <<\_ACEOF
+#define NEXTAW 1
+_ACEOF
+
+        lib_xaw_opt=-lneXtaw
+       ;;
+    esac
+    INTERFACE_SRCS="$INTERFACE_SRCS xaw_c.c xaw_i.c x_trace.c $XDND_SRCS"
 
   ;;
 xdynamic)
@@ -20206,7 +20830,7 @@ SHLD="$SHLD $SHLDFLAGS"
 
 
 
-ac_config_files="$ac_config_files Makefile autoconf/Makefile common.makefile configs/Makefile doc/Makefile doc/C/Makefile doc/ja_JP.eucJP/Makefile interface/Makefile interface/motif_bitmaps/Makefile interface/bitmaps/Makefile interface/pixmaps/Makefile libarc/Makefile libunimod/Makefile timidity/Makefile windrv/Makefile utils/Makefile script/Makefile TiMidity.ad TiMidity-uj.ad"
+ac_config_files="$ac_config_files Makefile autoconf/Makefile common.makefile configs/Makefile doc/Makefile doc/C/Makefile doc/ja_JP.eucJP/Makefile interface/Makefile interface/motif_bitmaps/Makefile interface/bitmaps/Makefile interface/pixmaps/Makefile libarc/Makefile libunimod/Makefile timidity/Makefile windrv/Makefile utils/Makefile script/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -20311,6 +20935,13 @@ echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${XAW_INSTALL_RESOURCE_FILES_TRUE}" && test -z "${XAW_INSTALL_RESOURCE_FILES_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"XAW_INSTALL_RESOURCE_FILES\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"XAW_INSTALL_RESOURCE_FILES\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -20339,6 +20970,13 @@ echo "$as_me: error: conditional \"NEEDDLOPEN\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${ENABLE_XDND_TRUE}" && test -z "${ENABLE_XDND_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"ENABLE_XDND\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"ENABLE_XDND\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${ENABLE_NCURSES_TRUE}" && test -z "${ENABLE_NCURSES_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"ENABLE_NCURSES\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -21168,8 +21806,6 @@ do
     "windrv/Makefile") CONFIG_FILES="$CONFIG_FILES windrv/Makefile" ;;
     "utils/Makefile") CONFIG_FILES="$CONFIG_FILES utils/Makefile" ;;
     "script/Makefile") CONFIG_FILES="$CONFIG_FILES script/Makefile" ;;
-    "TiMidity.ad") CONFIG_FILES="$CONFIG_FILES TiMidity.ad" ;;
-    "TiMidity-uj.ad") CONFIG_FILES="$CONFIG_FILES TiMidity-uj.ad" ;;
 
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -21302,6 +21938,9 @@ am__leading_dot!$am__leading_dot$ac_delim
 MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim
 MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim
 MAINT!$MAINT$ac_delim
+XAW_INSTALL_RESOURCE_FILES_TRUE!$XAW_INSTALL_RESOURCE_FILES_TRUE$ac_delim
+XAW_INSTALL_RESOURCE_FILES_FALSE!$XAW_INSTALL_RESOURCE_FILES_FALSE$ac_delim
+xawresdir!$xawresdir$ac_delim
 EMACS!$EMACS$ac_delim
 lispdir!$lispdir$ac_delim
 CC!$CC$ac_delim
@@ -21326,9 +21965,6 @@ EGREP!$EGREP$ac_delim
 RANLIB!$RANLIB$ac_delim
 LN_S!$LN_S$ac_delim
 XMKMF!$XMKMF$ac_delim
-X_CFLAGS!$X_CFLAGS$ac_delim
-X_PRE_LIBS!$X_PRE_LIBS$ac_delim
-X_LIBS!$X_LIBS$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -21370,6 +22006,9 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+X_CFLAGS!$X_CFLAGS$ac_delim
+X_PRE_LIBS!$X_PRE_LIBS$ac_delim
+X_LIBS!$X_LIBS$ac_delim
 X_EXTRA_LIBS!$X_EXTRA_LIBS$ac_delim
 LIBOBJS!$LIBOBJS$ac_delim
 NEEDGETOPT_TRUE!$NEEDGETOPT_TRUE$ac_delim
@@ -21396,6 +22035,8 @@ LIBOGGFLAC_CFLAGS!$LIBOGGFLAC_CFLAGS$ac_delim
 LIBOGGFLAC_LIBS!$LIBOGGFLAC_LIBS$ac_delim
 NEEDDLOPEN_TRUE!$NEEDDLOPEN_TRUE$ac_delim
 NEEDDLOPEN_FALSE!$NEEDDLOPEN_FALSE$ac_delim
+ENABLE_XDND_TRUE!$ENABLE_XDND_TRUE$ac_delim
+ENABLE_XDND_FALSE!$ENABLE_XDND_FALSE$ac_delim
 ENABLE_NCURSES_TRUE!$ENABLE_NCURSES_TRUE$ac_delim
 ENABLE_NCURSES_FALSE!$ENABLE_NCURSES_FALSE$ac_delim
 n_so_libs!$n_so_libs$ac_delim
@@ -21462,11 +22103,6 @@ ENABLE_WRD_FALSE!$ENABLE_WRD_FALSE$ac_delim
 W32G_GUI_TRUE!$W32G_GUI_TRUE$ac_delim
 W32G_GUI_FALSE!$W32G_GUI_FALSE$ac_delim
 WINDRV_TRUE!$WINDRV_TRUE$ac_delim
-WINDRV_FALSE!$WINDRV_FALSE$ac_delim
-MSYS_TRUE!$MSYS_TRUE$ac_delim
-MSYS_FALSE!$MSYS_FALSE$ac_delim
-VCPP_TRUE!$VCPP_TRUE$ac_delim
-VCPP_FALSE!$VCPP_FALSE$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -21508,6 +22144,11 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+WINDRV_FALSE!$WINDRV_FALSE$ac_delim
+MSYS_TRUE!$MSYS_TRUE$ac_delim
+MSYS_FALSE!$MSYS_FALSE$ac_delim
+VCPP_TRUE!$VCPP_TRUE$ac_delim
+VCPP_FALSE!$VCPP_FALSE$ac_delim
 POCC_TRUE!$POCC_TRUE$ac_delim
 POCC_FALSE!$POCC_FALSE$ac_delim
 BORLANDC_TRUE!$BORLANDC_TRUE$ac_delim
@@ -21543,7 +22184,7 @@ pkglibdir!$pkglibdir$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 33; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 38; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
index 0e0c138..729058d 100644 (file)
@@ -155,6 +155,11 @@ AC_ARG_WITH(module-dir,
 tmplibdir="`eval \"echo ${pkglibdir}\"`"
 AC_DEFINE_UNQUOTED(PKGLIBDIR,"$tmplibdir",place to install modules)
 
+AC_ARG_WITH(xaw-resource-prefix,
+  [  --with-xaw-resource-prefix=DIR What prefix to install XAW's resource files to
+     (optinal)], [xawresdir=$withval], [])
+AM_CONDITIONAL(XAW_INSTALL_RESOURCE_FILES, test "x$xawresdir" != "x")
+AC_SUBST(xawresdir)
 
 # Checks for programs.
 AM_PATH_LISPDIR
@@ -337,6 +342,16 @@ fi
 AC_CHECK_FUNCS(gethostbyname,,[ AC_CHECK_LIB(nsl,gethostbyname) ])
 AC_PATH_XTRA
 
+AC_ARG_WITH(xawlib,
+  [  --with-xawlib=lib      Try to link to these xaw widget libraries by the
+                            order specified by the comma separated value list:
+                             xaw: X11's libXaw
+                             xaw3d: Xaw3d
+                             neXtaw: neXtaw
+                             XawPlus: XawPlus
+                             default is --with-xawlib=xaw3d,xaw],
+  [ with_xawlib="$withval" ], [ with_xawlib="xaw3d,xaw" ])
+
 # Checks for X
 if test "x$with_x" = xyes; then
   if test "x$have_x" = xno; then
@@ -382,8 +397,34 @@ fail;
   AC_CHECK_LIB(Xt,XtVaAppInitialize,have_xt=yes; LIBS="-lXt $LIBS",have_xt=no)
   AC_CHECK_LIB(Xmu,XmuInternAtom,LIBS="-lXmu $LIBS")
   AC_CHECK_FUNCS(XmuRegisterExternalAgent)
-  AC_CHECK_LIB(Xaw3d,XawInitializeWidgetSet,have_xaw=3d,
-   [ AC_CHECK_LIB(Xaw,XawInitializeWidgetSet,have_xaw=yes,have_xaw=no) ])
+  for i in `echo $with_xawlib | sed 's/,/ /g'`; do
+  case "$i" in
+  "xaw")
+    AC_CHECK_LIB(Xaw,XawInitializeWidgetSet,have_xaw=yes,have_xaw=no)
+    ;;
+  "xaw3d") 
+    AC_CHECK_LIB(Xaw3d,XawInitializeWidgetSet,
+      [ have_xaw=3d;
+          AC_CHECK_HEADER(X11/Xaw3d/Tip.h,
+          AC_DEFINE(HAVE_XAW3D_TIP,1,Define to 1 if you have the <X11/Xaw3d/Tip.h> header file.),
+          )
+      ],
+      have_xaw=no
+    )
+    ;;
+  "neXtaw")
+    AC_CHECK_LIB(neXtaw,XawInitializeWidgetSet,have_xaw=next,have_xaw=no)
+    ;;
+  "XawPlus")
+    AC_CHECK_LIB(Xpm,XpmCreatePixmapFromData)
+    AC_CHECK_LIB(XawPlus,XawInitializeWidgetSet,have_xaw=plus,have_xaw=no)
+    ;;
+  *)
+    have_xaw=no
+    ;;
+  esac
+  if test "x$have_xaw" != "xno"; then break; fi
+  done
   AC_CHECK_LIB(Xm,XmCreateForm,have_xm=yes,have_xm=no)
   AC_CHECK_FUNCS(XShmCreatePixmap)
   LIBS=$KEEPLIBS
@@ -544,8 +585,9 @@ AC_CHECK_FUNCS( \
   dup2 \
   floor \
   getcwd \
-  getopt \
   gethostbyname \
+  getopt \
+  getpid \
   gettimeofday \
   getwd \
   isatty \
@@ -1551,6 +1593,17 @@ fi
 
 AM_CONDITIONAL(NEEDDLOPEN, test "$NEEDDLOPEN" = "yes")
 
+dnl xdnd support
+AC_ARG_ENABLE(xdnd,
+  [  --enable-xdnd           Enable xdnd support             (default is no)],
+  [ if test "$enableval" = "yes"; then
+    AC_DEFINE(XDND,1,Define to 1 if you want xdnd support.)
+    XDND_SRCS="xdnd.c"
+    enable_xdnd=yes
+    fi
+  ])
+AM_CONDITIONAL(ENABLE_XDND, test "x$enable_xdnd" = "xyes")
+
 dnl
 dnl Each interface section
 dnl
@@ -1764,7 +1817,7 @@ CONFIG_INTERFACE(xaw,XAW,a,
   [ if test "x$with_x" != xyes; then
        AC_MSG_ERROR(xaw: --with-x option must be specified)
     fi
-    if test "x$have_xaw" != "xyes" -a "x$have_xaw" != "x3d"; then
+    if test "x$have_xaw" = "xno"; then
       AC_MSG_WARN(X Athena Widget library is not found.)
       enable_xaw=no
     fi ],
@@ -1777,13 +1830,24 @@ CONFIG_INTERFACE(xaw,XAW,a,
     fi
     lib_xmu_opt=-lXmu
     lib_xt_opt=-lXt
-    if test "x$have_xaw" = x3d; then
-      AC_DEFINE(XAW3D,1,Define to 1 if you have libXaw3d.)
-      lib_xaw_opt=-lXaw3d
-    else
-      lib_xaw_opt=-lXaw
-    fi
-    INTERFACE_SRCS="$INTERFACE_SRCS xaw_c.c xaw_i.c"
+    case "$have_xaw" in
+      "yes")
+        lib_xaw_opt=-lXaw
+       ;;
+      "3d")
+        AC_DEFINE(XAW3D,1,Define to 1 if you use libXaw3d.)
+        lib_xaw_opt=-lXaw3d
+       ;;
+      "plus")
+        AC_DEFINE(XAWPLUS,1,Define to 1 if you use libXawPlus.)
+        lib_xaw_opt="-lXpm -lXawPlus"
+       ;;
+      "next")
+        AC_DEFINE(NEXTAW,1,Define to 1 if you use libneXtaw.)
+        lib_xaw_opt=-lneXtaw
+       ;;
+    esac
+    INTERFACE_SRCS="$INTERFACE_SRCS xaw_c.c xaw_i.c x_trace.c $XDND_SRCS"
   ],
   [ if test "x$have_xext" = xyes; then
       a_so_libs="-lXext -lX11"
@@ -2181,7 +2245,5 @@ AC_CONFIG_FILES([
   windrv/Makefile
   utils/Makefile
   script/Makefile
-  TiMidity.ad
-  TiMidity-uj.ad
 ])
 AC_OUTPUT
index f5937ae..b7b5350 100644 (file)
@@ -133,6 +133,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -213,6 +215,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -278,6 +282,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 
 EXTRA_DIST = \
        timidity.1 \
index f547d1f..63e06af 100644 (file)
@@ -5,35 +5,109 @@ Xaw interface of TiMidity prepares a GUI only with Athena Widget sets
 and Xt libraries that are standard toolkits of X Window System.
 
 
-* WHAT'S NEW int 1.3
+* WHAT'S NEW in 2.0
+
+- Support for loading and saving playlists.
+- Vastly improved file dialog (Separate file/directory panes, filtering, etc.).
+- Scroll wheel support.
+- Supports Drag and Drop via the XDND protocol.
+- Tooltips for buttons are implemented.
+- Can mute individual channels in trace mode.
+- Fixed time thumb. Now it can also be used to change the position in the midi.
+- Support displaying more than 16 channels.
+- Many many bugs fixed and other small improvments.
 
-- Imported shortcut key translations 
-- Added Trace window including keyboard displaying
-- Enabled to configure resources of X
-- Supported Drag and Drop used on OffiX application
-- Added function to load and/or delete MIDI file entries
-- Enabled to modify some of extended option settings
-- Enabled to save the current playing lists into ~/.xtimidity
-- Menu and dialog messages were Internationalized 
-- Resource files were attached
+* INSTALLATION
+
+The xaw interface is compiled by passing either "--enable-interface=xaw"
+or "--enable-dynamic=xaw" as parameters for the configure script.
+TiMidity++ ordianary install will than contain the xaw interface.
+
+The are several ways to configure the xaw interface before compilation:
+
+A) Some parameters can be passed to GNU configure to modify the xaw
+interface. Namely:
+
+--with-xawlib=<comma delimetered list of toolkit names>
+--with-xaw-resource-prefix=<prefix to resource dir>
+--enable-xdnd, --disable-xdnd
+--enable-offix, --disable-offix
+
+--with-xawlib:
+
+TiMidity++ supports multiple Xaw toolkits. By default it searches for them
+in this order: xaw3d, xaw. If you wish to force compilation
+with a specific toolkit, provide the --with-xawlib=<name> parameter to
+configure, e.g.:
+
+  ./configure --enable-interface=xaw --with-xawlib=xaw
+
+or even:
+
+  ./configure --enable-interface=xaw --with-xawlib=neXtaw,xaw3d,XawPlus,xaw
+
+  to force a different search order.
+
+--enable-xdnd, --enable-offix, --disable-xdnd, --disable-offix
+
+Enable/Disable support for XDND/Offix drag and drop protocols. By default
+both are disabled.
+
+--with-xaw-resource-prefix=<prefix>
+
+Optional parameter. If passed, timidity will try to install the resource files
+to <prefix>/app-defaults/ and <prefix>/ja_JP.EUCJP/app-defaults.
+
+B) The xaw.h and x_trace.h files can be edited as well to change some options:
+
+If you want to use Label Widget for lyrics as in version 1.1,
+remove /* */ so that this line is visible:
+
+  #define WIDGET_IS_LABEL_WIDGET
+
+Although $(HOME)/.xtimidity will be regarded as an initial personal
+configuration file, you can rename it by changing the line;
 
+  #define INITIAL_CONFIG ".xtimidity"
+
+If you'd like to see more/less than 16 channels in one screen when in
+trace mode, change
+
+  #define D_VISIBLE_CHANNELS 16
+
+in x_trace.h.
+
+(There's a way to change that after compilation: changing the traceHeight
+resource will change the number of visible channels in one screen.)
+
+!!! NOTE !!!
+Don't forget to make clean before build if these files are edited.
 
 * USAGE
 
-New Xaw interface has following file menu;
+Xaw interface shows the following file menu:
 
   LOAD
     Load a new MIDI file.
 
+  SAVE
+    Save the currently shown MIDI file.
+
+  LOAD PLAYLIST
+    Loads a playlist.
+
+  SAVE PLAYLIST
+    Saves a playlist.
+
   SAVE CONFIG
     Save the current settings and modes e.g. shuffle,
     repeat, auto-start and auto-exit flags to ~/.xtimidity .
 
   HIDE/UNHIDE MESSAGES
-    Toggles displaying status text widget showing messages.
+    Toggles displaying text widget showing messages and lyrics.
 
   HIDE/UNHIDE TRACE
-    Toggles displaying status of trace canvas.
+    Toggles trace canvas.
 
   SHUFFLE
     Toggles shuffle flag.
@@ -68,18 +142,32 @@ The shortcut key actions on each window are as follows:
 <Main Window>
        [Enter] or [r]  : Start Playing
        [Space]         : Pause / Start Again
+       [a]             : Show about window
+       [l]             : Show file list
        [s]             : Stop Playing
        [q]             : Quit TiMidity++
        [p] or [Left]   : Previous File
        [n] or [Right]  : Next File
        [v] or [Down]   : Volume Down (10%)
        [V] or [Up]     : Volume Up (10%)
+       [<]             : Slower tempo
+       [>]             : Faster tempo
+       [-]             : Lower pitch
+       [+]             : Raise pitch
+       [Alt + F], [z]  : Show main menu
        [Alt + N]       : Load Files
+       [Ctrl + V]      : Save File
+       [Alt + L]       : Load Playlist
+       [Alt + P]       : Save Playlist
        [Alt + S]       : Save settings to ~/.xtimidity
        [Ctrl + M]      : Hide/Show Messages
        [Ctrl + T]      : Hide/Show Trace canvas
        [Ctrl + S]      : Toggles Shuffle state
        [Ctrl + R]      : Toggles Repeat state
+       [Ctrl + D]      : Toggles Tooltips
+       [Ctrl + O]      : Show options window
+       [g]             : Turns on/off spectrogram (if timidity was compiled
+                         with --enable-spectrogram)
 
 <File List Window>
        [p] or [Up]     : Move the cursor to the previous file
@@ -90,74 +178,44 @@ The shortcut key actions on each window are as follows:
        [V]             : Volume Up (10%)
        [Enter] or [R]  : Start Playing the selected file
        [d]             : Delete the selected file entry
+       [A]             : Delete all entries
        [Space]         : Pause / Start Again
        [s]             : Stop Playing
        [q]             : Quit TiMidity++
        [c]             : Close the window
+       [ESC]           : Close the window
 
 <Extend Mode Window>
        [c]             : Close the window
+       [ESC]           : Close the window
        [q]             : Quit TiMidity++
 
 <Dialog in Load File Window>
-       [Tab]           : File or directory completion
-       [Enter]         : Select the directory entries.
-       [Escape] or [CTRL]+[g] : Cancel and close the window
-       [Ctrl-a]        : Move the cursor to the top
-       [Ctrl-e]        : Move the cursor to the line-end
-       [Ctrl-k]        : Delete strings after the cursor
-
-From version 1.1, trace canvas is realized and renewed overall in
-1.3.  Specify the interface option flag 't' in command line like as
-'timidity -iat' when you execute TiMidity(see timidity man page).
+       [Tab]                   : File or directory completion
+       [Enter]                 : Select the directory entries
+       [Alt-Enter]             : Selects all visible files
+       [Escape] or [CTRL]+[g]  : Cancel and close the window
+       [Ctrl-a]                : Move the cursor to the top
+       [Ctrl-e]                : Move the cursor to the line-end
+       [Ctrl-k]                : Delete strings after the cursor
+       [Ctrl-`]                : Turn on filter
+By entering a string containing a wildcard in the dialog, the filter will
+be turned on, only displaying the matching files (case-insensitive). e.g.
+*.mid shows all filenames ending in '.mid', '.MID', etc.
+[AB]* shows all filenames beginning with 'a','A','b' or 'B'.
+[!c]* shows all filenames not starting with 'c'.
+
+* TRACE MODE
+Specify the interface option flag 't' in command line like as
+'timidity -iat' when you execute TiMidity (see timidity man page).
 You can see a funny movements of volume, expression, panning,
 pitchbending, reverb, chorus and voices et cetera of each channel on the
 trace canvas.  Click left mouse button on the trace screen and you can
 toggle trace screen between 'pitchbend and instrument' or 'tonebank,
-reverb and chorus'.
-
-
-* INSTALLATION
-
-TiMidity++ uses Xaw3d by default while compiling when it exists on your
-system because GNU configure is employed.  If you feel like to use Xaw,
-edit common.makefile manually to delete all of '-DXAW3D' definitions
-from CPPFLAGS and/or CFLAGS and correct -lXaw3d to -lXaw after
-configure.
-If you want to use Label Widget as before, make the following line
-enable at interface/xaw.h to remove /* */.
-
- #define WIDGET_IS_LABEL_WIDGET
-
-And make clean before build.  If you are using X servers compiled
-without X_LOCALE on the system that doesn't support locale, rewrite
-the folloing line;
-
- #define I18N
-
-to '#undef I18N' before compiling TiMidity++.
-Although $(HOME)/.xtimidity will be regarded as an initial personal
-configuration file, you can rename it by correcting the line;
-
- #define INITIAL_CONFIG ".xtimidity"
-
-in xaw.h manually.
-
-!!! NOTE !!!
-Some resource files were attached to TiMidity++1.3.6 or later.
-If you create a resource file of another locale except English or 
-Japanese, please mail it to Yoshishige Arai <ryo2@on.rim.or.jp> or
-to Masanao Izumo <mo@goice.co.jp>.
-After building TiMidity++, put TiMidity.ad into the resources directory
-such as;
- $(X11R6)/lib/X11/app-defaults
-And put TiMidity-uj.ad, which is the Japanese-EUC resource file into;
- $(X11R6)/lib/X11/$(LANG)/app-defaults
-For example, those are as follows if the Japanese-EUC locale of your
-system is ja_JP.EUC as FreeBSD;
- # cp TiMidity.ad /usr/X11R6/lib/X11/app-defaults/TiMidity 
- # cp TiMidity-uj.ad /usr/X11R6/lib/X11/app-defaults/ja_JP.EUC/TiMidity
-
+reverb and chorus'. Click right mouse button and you can (un)mute a channel.
+Wheel or 'j' key can scroll the trace to see more channels than the usual
+16 channels. If the trace is too tall for your resolution, simply set
+the traceHeight resource to a lower value.
 
 * RESOURCES
 
@@ -170,12 +228,10 @@ Application class name is 'TiMidity', so specity resources in
   TiMidity*buttonbackground: gold
   TiMidity*labelfont: -adobe-helvetica-bold-o-*-*-14-*-75-75-*-*-*-*
 
-typical resources are listed below.
+Application specific resources supported by TiMidity are listed below:
 
 Name                Class                   Default
 ----------------------------------------------------------
-bitmapDir           BitmapDir               "DEFAULT_PATH/bitmaps"
-  directory bitmaps is put.
 arrangeTitle        ArrangeTitle            False
   Show MIDI titles on the title bar of the main window.
 background          Background              gray65
@@ -184,34 +240,150 @@ menubutton          MenuButtonBackground    #CCFF33
   Menu button color.
 textbackground      TextBackground          gray85
   Background color of Text Widget.
-togglebackground    ToggleBackground        MediumBlue
-  Background color of toggle buttons.
+toggleforeground    ToggleForeground        MediumBlue
+  Foreground color of toggle buttons.
+buttonforeground    ButtonForeground        blue
+  Foreground color of command buttons and other transient windows. 
 buttonbackground    ButtonBackground        gray76
   Background color of command buttons and other transient windows. 
-tracebackground     TraceBackground         gray90
-  Background color of trace canvas.
-labelfont           LabelFont       -adobe-helvetica-bold-r-*-*-14-*-75-75-*-*-*-*
+text2background     Text2Background         gray80
+  Background color of labels in file dialogs.
+
+labelfont           FontSet      -adobe-helvetica-bold-r-*-*-14-*-75-75-*-*-*-*
   Label widget font.
-volumefont          VolumeFont      -adobe-helvetica-bold-r-*-*-12-*-75-75-*-*-*-*
+volumefont          FontSet      -adobe-helvetica-bold-r-*-*-12-*-75-75-*-*-*-*
   Volume Label font.
-tracefont           TraceFont       -*-*-medium-r-normal--14-*-*-*-*-*-*-*
-  Trace window font.
-textfontset         TextFontSet     -*-*-medium-r-normal--14-*-*-*-*-*-*-*
+textfontset         FontSet      -*-*-medium-r-normal--14-*-*-*-*-*-*-*
   Text font for message box and so on.
-ttitlefont          TtitleFont      -*-fixed-medium-r-normal--14-*-*-*-*-*-*-*
+ttitlefont          FontSet      -*-fixed-medium-r-normal--14-*-*-*-*-*-*-*
   MIDI title font at the bottom of trace window.
+textHeight          TextHeight   120
+  Height of the lyric widget (is 30 if WIDGET_IS_LABEL_WIDGET is defined).
+menuWidth           MenuWidth    200
+  Width of popup menu.
+moreString          String       More...
+  Label of submenus on the pop-up menu.
+labelfile           LabelFile    file...
+  Title of main menu.
+noplaying           String       [ No Playing File ]
+  String appended to title when no file is being played.
+popup_confirm_title String       Dialog
+  Title of confirm boxes.
+
+These resources are used only in trace mode:
+
+Name                Class                   Default
+----------------------------------------------------------
+tracefont           FontSet      -*-*-medium-r-normal--14-*-*-*-*-*-*-*
+  Trace window font.
+traceWidth          TraceWidth     627
+  Width of trace widget.
+traceHeight         TraceHeight    332
+  Height of trace widget.
+tracebackground     TraceBackground         gray90
+  Background color of trace canvas.
+velforeground       VelForeground           orange
+  Color of bar in 'vel' (velocity) column for 'normal' channels.
+veldrumforeground   VelDrumForeground       red
+  Color of bar in 'vel' column, when the channel is a drum channel.
+volforeground       VolForeground           LightPink
+  Color of bar in 'vol' column.
+expforeground       ExpForeground           aquamarine
+  Color of bar in 'expr' column.
+panforeground       PanForeground           blue
+  Color of triangle in pan column. 
+rimcolor            RimColor                gray20
+  Color of the border between channel bars.
+boxcolor            BoxColor                gray76
+  Color of the channel bars.
+captioncolor        CaptionColor            DarkSlateGrey
+  Color of text in the trace widget.
+whitekeycolor       WhiteKeyColor           white
+  Color of white keys in keyboard.
+blackkeycolor       BlackKeyColor           black
+  Color of black keys in keyboard.
+playingkeycolor     PlayingKeyColor         maroon1
+  Color of played key in keyboard.
+sustainedkeycolor   SustainedKeyColor       red4
+  Color of sustained key in keyboard.
+reverbcolor         ReverbColor             PaleGoldenrod
+  Color of bar in reverb column.
+choruscolor         ChorusColor             yellow
+  Color of bar in chorus column.
+untitled            String       <No title>
+  String used in foot when no file is being played.
+
+Note that all font resource are of type FontSet.
+Also traceWidth setting does not work yet.
+
+!!! NOTE !!!
+Some resource files were attached to TiMidity++1.3.6 or later.
+If you create a resource file of another locale except English or 
+Japanese, please mail it to the timidity mailing list
+<timidity-talk@lists.sourceforge.net>.
+After building TiMidity++, put TiMidity.ad into the resources directory
+such as;
+ $(X11R6)/lib/X11/app-defaults
+And put TiMidity-uj.ad, which is the Japanese-EUC resource file into;
+ $(X11R6)/lib/X11/$(LANG)/app-defaults
+For example, those are as follows if the Japanese-EUC locale of your
+system is ja_JP.EUC as FreeBSD;
+ # cp TiMidity.ad /usr/X11R6/lib/X11/app-defaults/TiMidity 
+ # cp TiMidity-uj.ad /usr/X11R6/lib/X11/app-defaults/ja_JP.EUC/TiMidity
 
-Note that you have to specify FontSet style for font resources 
-of TiMdifity*textfontset and/or TiMidity*ttitlefont if you are using
-executables compiled with -DI18N on the internationalized X server.
+* SETTINGS FILE
+ ~/.xtimidity contains settings which are used by the xaw interface.
+ When "SAVE CONFIG" is selected, timidity will save the current configuration
+ to the file.
 
+ The file has a simple format. Each line begins with "set", than an option name,
+ followed by the option's value.
+ The options are:
+
+Name                Allowed Values          Default
+----------------------------------------------------------
+RepeatPlay           0/1                    0
+  Repeat playing the playlist after the last file was played.
+ShufflePlay          0/1                    0
+  Play the playlist in a random order.
+ExtOptions           0-63                   Depends on compliation options.
+  Enable various sequencer extensional modes (see options window for list).
+ChorusOption         0/1                    Depends on compliation options.
+  Enable chorus.
+CurVol               0-800                  70
+  Initial value of volume.
+Showdotfiles         0/1                    0
+  Show files and directories beginning with '.' in the file dialog.
+DefaultDir           a valid dir name.      The user's home directory.
+  The directory first displayed in the file dialog.
+Disp:trace           0/1                    0
+  Always start in trace mode.
+Disp:text            0/1                    1
+  Display the lyrics/messages widget at startup.
+Tooltips             0/1                    1 [1]
+  Display tooltips for buttons.
+Autostart            0/1                    1
+  Start playing immediately when the interface is started.
+AutoExit             0/1                    0
+  Exit after playing has stopped.
+ConfirmExit          0/1                    0
+  Confirm exit from interface if user tries to close it.
+SaveList             0/1                    1
+  Save playing list to ~/.xtimidity when quiting. If Autostart is 1,
+  it will begin playing immediately when timidity is next started.
+File                 a valid file name.     None
+  This file will be loaded at next start. If SaveList is 1, the previous
+  playlist will be saved using this option. This option may occur multiple
+  times in ~/.xtimidity.
+
+[1] When timidity is compiled with xaw3d, tooltips are by default off.
+    Tooltips can not be enabled when the neXtaw toolkit is used.
 
 * REPORTS
 
 Please send problems concerning Xaw interface, feature requests,
-bug reports or comments to either Yoshishige Arai <ryo2@on.rim.or.jp>
-or to the TiMidity mailing list <timidity@goice.co.jp>.
-
+bug reports or comments to the TiMidity mailing list
+<timidity-talk@lists.sourceforge.net>.
 
   Regards,
 
index 27c3476..3f8be42 100644 (file)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index cff2433..ebafbda 100644 (file)
@@ -133,6 +133,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -213,6 +215,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -278,6 +282,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 
 EXTRA_DIST = \
        timidity.1 \
index 21752aa..e7462e1 100644 (file)
@@ -50,10 +50,14 @@ EXTRA_libinterface_a_SOURCES = \
        vt100.h \
        vt100.c \
        vt100_c.c \
+       x_trace.c \
+       x_trace.h \
        xaw.h \
        xaw_c.c \
        xaw_i.c \
        xaw_redef.c \
+       xdnd.c \
+       xdnd.h \
        xskin.h \
        xskin_c.c \
        xskin_i.c \
@@ -142,6 +146,10 @@ WRD_OBJS = \
        x_sherry.$(OBJEXT)
 endif
 
+if ENABLE_XDND
+XDND_SO = xdnd.${so}
+endif
+
 if MSYS
 if W32G_GUI
 else
@@ -276,7 +284,13 @@ install.tk: $(ALLTCLF) install.bitmaps
        test -d $(DESTDIR)$(TCL_DIR) || mkdir -p $(DESTDIR)$(TCL_DIR)
        for f in $(ALLTCLF) ''; do case ".$$f" in .);; *) $(INSTALL_DATA) $$f $(DESTDIR)$(TCL_DIR);; esac; done
 
-install.xaw: install.bitmaps
+install.xaw:
+if XAW_INSTALL_RESOURCE_FILES
+       test -d ${DESTDIR}${XAWRES} || mkdir -p ${DESTDIR}${XAWRES}
+       test -d ${DESTDIR}${XAWRES_JA} || mkdir -p ${DESTDIR}${XAWRES_JA}
+       cp ${top_srcdir}/TiMidity.ad ${DESTDIR}${XAWRES}/TiMidity
+       cp ${top_srcdir}/TiMidity-uj.ad ${DESTDIR}${XAWRES_JA}/TiMidity
+endif
 
 install.bitmaps:
        cd bitmaps; $(MAKE) install.bitmaps
@@ -401,8 +415,8 @@ if_emacs.$(so): emacs_c.$(so) support.$(so)
 if_vt100.$(so): vt100_c.$(so) support.$(so) vt100.$(so) bitset.$(so) timer.$(so)
        $(SHLD) -o $@ vt100_c.$(so) support.$(so) vt100.$(so) bitset.$(so) timer.$(so) $(T_so_libs)
 
-if_xaw.$(so): xaw_c.$(so) support.$(so) xaw_i.$(so) timer.$(so)
-       $(SHLD) -o $@ xaw_c.$(so) support.$(so) xaw_i.$(so) timer.$(so) $(a_so_libs)
+if_xaw.$(so): xaw_c.$(so) support.$(so) xaw_i.$(so) x_trace.${so} timer.$(so) ${XDND_SO}
+       $(SHLD) -o $@ xaw_c.$(so) support.$(so) xaw_i.$(so) x_trace.${so} timer.$(so) ${XDND_SO} $(a_so_libs)
 
 if_xskin.$(so): xskin_c.$(so) support.$(so) xskin_i.$(so) xskin_loadBMP.$(so) xskin_spectrum.$(so) url_buff.$(so)
        $(SHLD) -o $@ xskin_c.$(so) support.$(so) xskin_i.$(so) xskin_loadBMP.$(so) xskin_spectrum.$(so) url_buff.$(so) $(i_so_libs)
index 8c4b259..b26eaaf 100644 (file)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
@@ -363,10 +372,14 @@ EXTRA_libinterface_a_SOURCES = \
        vt100.h \
        vt100.c \
        vt100_c.c \
+       x_trace.c \
+       x_trace.h \
        xaw.h \
        xaw_c.c \
        xaw_i.c \
        xaw_redef.c \
+       xdnd.c \
+       xdnd.h \
        xskin.h \
        xskin_c.c \
        xskin_i.c \
@@ -455,6 +468,8 @@ EXTRA_libinterface_a_SOURCES = \
 @ENABLE_WRD_TRUE@      x_sherry.$(OBJEXT)
 
 
+@ENABLE_XDND_TRUE@XDND_SO = xdnd.${so}
+
 @MSYS_TRUE@@W32G_GUI_FALSE@WRD_WINCON_OBJS = wrdt_wcon.$(OBJEXT)
 
 @NEEDDLOPEN_TRUE@DYNAMIC_OBJS = dynamic_c.$(OBJEXT)
@@ -752,9 +767,10 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE@   ./$(DEPDIR)/wrdt_mac.Po ./$(DEPDIR)/wrdt_tty.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/wrdt_w32g.Po ./$(DEPDIR)/wrdt_wcon.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/wrdt_x.Po ./$(DEPDIR)/x_mag.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/x_sherry.Po ./$(DEPDIR)/x_wrdwindow.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/xaw_c.Po ./$(DEPDIR)/xaw_i.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/xaw_redef.Po ./$(DEPDIR)/xskin_c.Po \
+@AMDEP_TRUE@   ./$(DEPDIR)/x_sherry.Po ./$(DEPDIR)/x_trace.Po \
+@AMDEP_TRUE@   ./$(DEPDIR)/x_wrdwindow.Po ./$(DEPDIR)/xaw_c.Po \
+@AMDEP_TRUE@   ./$(DEPDIR)/xaw_i.Po ./$(DEPDIR)/xaw_redef.Po \
+@AMDEP_TRUE@   ./$(DEPDIR)/xdnd.Po ./$(DEPDIR)/xskin_c.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/xskin_i.Po ./$(DEPDIR)/xskin_loadBMP.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/xskin_spectrum.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -845,10 +861,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrdt_x.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x_mag.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x_sherry.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x_trace.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x_wrdwindow.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaw_c.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaw_i.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xaw_redef.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdnd.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xskin_c.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xskin_i.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xskin_loadBMP.Po@am__quote@
@@ -1192,7 +1210,11 @@ install.tk: $(ALLTCLF) install.bitmaps
        test -d $(DESTDIR)$(TCL_DIR) || mkdir -p $(DESTDIR)$(TCL_DIR)
        for f in $(ALLTCLF) ''; do case ".$$f" in .);; *) $(INSTALL_DATA) $$f $(DESTDIR)$(TCL_DIR);; esac; done
 
-install.xaw: install.bitmaps
+install.xaw:
+@XAW_INSTALL_RESOURCE_FILES_TRUE@      test -d ${DESTDIR}${XAWRES} || mkdir -p ${DESTDIR}${XAWRES}
+@XAW_INSTALL_RESOURCE_FILES_TRUE@      test -d ${DESTDIR}${XAWRES_JA} || mkdir -p ${DESTDIR}${XAWRES_JA}
+@XAW_INSTALL_RESOURCE_FILES_TRUE@      cp ${top_srcdir}/TiMidity.ad ${DESTDIR}${XAWRES}/TiMidity
+@XAW_INSTALL_RESOURCE_FILES_TRUE@      cp ${top_srcdir}/TiMidity-uj.ad ${DESTDIR}${XAWRES_JA}/TiMidity
 
 install.bitmaps:
        cd bitmaps; $(MAKE) install.bitmaps
@@ -1281,8 +1303,8 @@ install.el: $(ELFILES)
 @NEEDDLOPEN_TRUE@if_vt100.$(so): vt100_c.$(so) support.$(so) vt100.$(so) bitset.$(so) timer.$(so)
 @NEEDDLOPEN_TRUE@      $(SHLD) -o $@ vt100_c.$(so) support.$(so) vt100.$(so) bitset.$(so) timer.$(so) $(T_so_libs)
 
-@NEEDDLOPEN_TRUE@if_xaw.$(so): xaw_c.$(so) support.$(so) xaw_i.$(so) timer.$(so)
-@NEEDDLOPEN_TRUE@      $(SHLD) -o $@ xaw_c.$(so) support.$(so) xaw_i.$(so) timer.$(so) $(a_so_libs)
+@NEEDDLOPEN_TRUE@if_xaw.$(so): xaw_c.$(so) support.$(so) xaw_i.$(so) x_trace.${so} timer.$(so) ${XDND_SO}
+@NEEDDLOPEN_TRUE@      $(SHLD) -o $@ xaw_c.$(so) support.$(so) xaw_i.$(so) x_trace.${so} timer.$(so) ${XDND_SO} $(a_so_libs)
 
 @NEEDDLOPEN_TRUE@if_xskin.$(so): xskin_c.$(so) support.$(so) xskin_i.$(so) xskin_loadBMP.$(so) xskin_spectrum.$(so) url_buff.$(so)
 @NEEDDLOPEN_TRUE@      $(SHLD) -o $@ xskin_c.$(so) support.$(so) xskin_i.$(so) xskin_loadBMP.$(so) xskin_spectrum.$(so) url_buff.$(so) $(i_so_libs)
index 4ea9fa4..d63618c 100644 (file)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index 68cb947..10daa48 100644 (file)
@@ -139,6 +139,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -220,6 +222,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -285,6 +289,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -300,6 +305,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index 3a36f4d..38455fe 100644 (file)
@@ -139,6 +139,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -220,6 +222,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -285,6 +289,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -300,6 +305,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index f7ff380..216c694 100644 (file)
 
     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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 
     xaw.h: written by Yoshishige Arai (ryo2@on.rim.or.jp) 12/8/98
-
+           modified by Yair Kalvariski (cesium2@gmail.com)
     */
 #ifndef _XAW_H_
 #define _XAW_H_
 #if HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
+#include "timidity.h"
 
-/* Define to use libXaw3d */
+/* Define to use Xaw3d */
 /* #define XAW3D */
 
-/* Define to use Japanese and so on */
-#define I18N
+/* Define to use libXaw3d's tip widget (requires version 1.5E) */
+/* #define HAVE_XAW3D_TIP */
+
+/* Define to use neXtaw */
+/* #define NEXTAW */
+
+/* Define to use XawPlus */
+/* #define XAWPLUS */
+
+/* Define to use code for old xaw versions (Xaw6 and such) */
+/* #define OLDXAW */
+
+/* Define to use Timidity's implmentation of submenus */
+/* #define TimNmenu */
 
 /* Define to use scrollable Text widget instead of Label widget */
 /* #define WIDGET_IS_LABEL_WIDGET */
 /*** Initial dot file name at home directory ***/
 #define INITIAL_CONFIG ".xtimidity"
 
+/*
+ * SET CORRECT PATHS AND CAPABILITIES.
+ */
+
+#ifdef XAW3D
+#define XAWINCDIR(x) <X11/Xaw3d/x>
+#include XAWINCDIR(Xaw3dP.h)
+#elif defined(NEXTAW)
+#define XAWINCDIR(x) <X11/neXtaw/x>
+#include XAWINCDIR(XawVersion.h)
+#elif defined(XAWPLUS)
+#define XAWINCDIR(x) <X11/XawPlus/x>
+#else
+#define XAWINCDIR(x) <X11/Xaw/x>
+#include <X11/Xmu/Converters.h>
+#include XAWINCDIR(XawInit.h)
+#ifndef XawVersion
+#define OLDXAW
+#else
+#if XawVersion < 7000L
+#define OLDXAW
+#endif /* XawVersion < 7000L */
+#endif /* !XawVersion */
+#ifndef OLDXAW
+#define XAW
+#endif /* !OLDXAW */
+#endif
+
+#if (defined (XAW3D) && !defined(HAVE_XAW3D_TIP)) || defined(OLDXAW) || \
+     defined(XAWPLUS) || defined(NEXTAW)
+/*
+ * XtNmenuItem in SmeBSBObject Widgets is not supported in
+ * Xaw3d v1.5, Xaw6, XawPlus and neXtaw.
+ */
+#define TimNmenu
+#endif /* (XAW3D && !HAVE_XAW3D_TIP) || OLDXAW || XAWPLUS || NEXTAW */
+
+#if (defined(XAW3D) && defined(HAVE_XAW3D_TIP)) \
+      || (defined(XAW) && !(defined(OLDXAW))) || defined(XAWPLUS)
+/* Tooltips support exists only in Xaw7 (and above), Xaw3d 1.5E and XawPlus */
+#define HAVE_TIP
+#endif /* (XAW3D && HAVE_XAW3D_TIP) || (XAW && !OLDXAW) || XAWPLUS */
+
+#if defined(NEXTAW) || defined(XAWPLUS) \
+      || (defined(XAW3D) && defined(XAW_ARROW_SCROLLBARS))
+/*
+ * StartScroll does not exist when Xaw3d is compiled with XAW_ARROW_SCROLLBARS,
+ * or when neXtaw or XawPlus is used. A replacement is defined to avoid
+ * warnings, and to allow for scrolling with the wheel buttons.
+ */
+#define USEOWNSTARTSCROLL
+#endif /* NEXTAW || XAWPLUS || (XAW3D && XAW_ARROW_SCROLLBARS) */
+
+#if defined(XAW3D) || defined(XAWPLUS)
+  /*
+   * Xaw3D 1.5/1.5E crashes on XtVaSetValues to XtNvalue in Dialogwidget,
+   * where the string is used in place, internationalization is on,
+   * and a new string is set - it tries to free the wrong pointer.
+   * The Fedora package includes a one-line patch for this problem, but
+   * we can't rely on the user's Xaw3D package being patched.
+   * XawPlus has the same bug.
+   */
+#define CLEARVALUE
+#endif /* XAW3D || XAWPLUS */
+
+#if defined(NEXTAW) || defined(XAW3D) || defined(XAWPLUS)
+  /*
+   * These toolkits crash on XtDestroyWidget(w), when
+   * w == popup_sformat if this hack isn't used.
+   */
+#define RECFMTGROUPDESTHACK
+#endif /* NEXTAW || XAW3D || XAWPLUS */
+
+#if defined(NEXTAW) || defined(XAWPLUS)
+#define DONTUSEOVALTOGGLES
+#endif /* NEXTAW || XAWPLUS */
+
+#if defined(XAW) || defined(OLDXAW)
+  /*
+   * libXaw has a bug: it doesn't set length=width-minimumThumb, but
+   * length=width so the thumb may become invisible when it reaches the
+   * end of the scrollbar. (Other toolkits always substracts minimumThumb
+   * from length, so we can't use the same codepath).
+   */
+#define SCROLLBARLENGTHBUG
+#endif /* XAW || OLDXAW */
+
+#if defined(NEXTAW) || defined(XAWPLUS) || defined(XAW3D)
+ /*
+  * These toolkits won't scroll textarea when sentence is wrapped.
+  * We'll redraw to get it to scroll.
+  */
+#define BYPASSTEXTSCROLLBUG
+#endif /* NEXTAW || XAW3D || XAWPLUS */
 
 /*
  * CONSTANTS FOR XAW MENUS
  */
 #define MAXVOLUME MAX_AMPLIFICATION
-#define MAX_XAW_MIDI_CHANNELS 16
+#define MAX_XAW_MIDI_CHANNELS MAX_CHANNELS
 
 #define APP_CLASS "TiMidity"
 #define APP_NAME "timidity"
 
+#define PIPE_LENGTH 300
 #ifndef PATH_MAX
 #define PATH_MAX 512
 #endif
 #define MAX_DIRECTORY_ENTRY BUFSIZ
-#define LF 0x0a
-#define SPACE 0x20
-#define TAB 0x09
 
 #define MODUL_N 0
 #define PORTA_N 1
 #define OVERLAPV_BIT (1<<OVERLAPV_N)
 #define TXTMETA_BIT (1<<TXTMETA_N)
 
-#include "timidity.h"
-
 #ifdef MODULATION_WHEEL_ALLOW
 #define INIT_OPTIONS0 MODUL_BIT
 #else
 
 #ifdef REVERB_CONTROL_ALLOW
 #define INIT_OPTIONS3 REVERB_BIT
+#define DEFAULT_REVERB 1
+#else
+#ifdef FREEVERB_CONTROL_ALLOW
+#define INIT_OPTIONS3 REVERB_BIT
+#define DEFAULT_REVERB 3
 #else
 #define INIT_OPTIONS3 0
-#endif
+#define DEFAULT_REVERB 1
+#endif /* FREEVERB_CONTROL_ALLOW */
+#endif /* REVERB_CONTROL_ALLOW */
 
 #ifdef GM_CHANNEL_PRESSURE_ALLOW
 #define INIT_OPTIONS4 CHPRESSURE_BIT
 
 #define XAW_UPDATE_TIME 0.1
 
+#ifndef XawFmt8Bit
+#define XawFmt8Bit FMT8BIT
+#endif
+/* Only defined since X11R6 */
+
 #endif /* _XAW_H_ */
index cdeb53e..5ab58d5 100644 (file)
 
     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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 
     xaw_c.c - XAW Interface from
         Tomokazu Harada <harada@prince.pe.u-tokyo.ac.jp>
         Yoshishige Arai <ryo2@on.rim.or.jp>
+        Yair Kalvariski <cesium2@gmail.com>
 */
 
 #ifdef HAVE_CONFIG_H
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#if defined(TIME_WITH_SYS_TIME)
 #include <sys/time.h>
+#include <time.h>
+#elif defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif /* TIME_WITH_SYS_TIME */
 #ifndef NO_STRING_H
 #include <string.h>
 #else
 #include <strings.h>
-#endif
-
+#endif /* NO_STRING_H */
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif /* HAVE_UNISTD_H */
 #include "miditrace.h"
 #include "timer.h"
 #include "xaw.h"
-static void ctl_current_time(int secs, int v);
-static void ctl_lyric(int lyricid);
-static int ctl_open(int using_stdin, int using_stdout);
+
+static int cmsg(int, int, char *, ...);
+static int ctl_blocking_read(int32 *);
 static void ctl_close(void);
-static int ctl_read(int32 *valp);
-static int cmsg(int type, int verbosity_level, char *fmt, ...);
-static int ctl_pass_playing_list(int number_of_files, char *list_of_files[]);
-static void ctl_event(CtlEvent *e);
+static void ctl_event(CtlEvent *);
+static int ctl_read(int32 *);
+static int ctl_open(int, int);
+static int ctl_pass_playing_list(int, char **);
+ControlMode *interface_a_loader(void);
 
 static void a_pipe_open(void);
 static int a_pipe_ready(void);
+int a_pipe_read(char *, size_t);
+int a_pipe_nread(char *, size_t);
+void a_pipe_sync(void);
+void a_pipe_write(const char *, ...);
+static void a_pipe_write_buf(char *, int);
+static void a_pipe_write_msg(char *);
+static void a_pipe_write_msg_nobr(char *);
+extern void a_start_interface(int);
+
+static void ctl_current_time(int, int);
+static void ctl_drumpart(int, int);
+static void ctl_event(CtlEvent *);
+static void ctl_expression(int, int);
+static void ctl_keysig(int);
+static void ctl_key_offset(int);
+static void ctl_lyric(int);
 static void ctl_master_volume(int);
+static void ctl_mute(int, int);
+static void ctl_note(int, int, int, int);
+static void ctl_panning(int, int);
+static void ctl_pitch_bend(int, int);
+static void ctl_program(int, int, void *);
+static void ctl_reset(void);
+static void ctl_sustain(int, int);
+static void ctl_tempo(int);
+static void ctl_timeratio(int);
 static void ctl_total_time(int);
-void a_pipe_write(char *);
-int a_pipe_read(char *,int);
-static void a_pipe_write_msg(char *msg);
-
-static void ctl_event(CtlEvent *e);
 static void ctl_refresh(void);
-static void ctl_total_time(int tt);
-static void ctl_note(int status, int ch, int note, int velocity);
-static void ctl_program(int ch, int val, void *vp);
-static void ctl_drumpart(int ch, int is_drum);
-static void ctl_volume(int ch, int val);
-static void ctl_expression(int ch, int val);
-static void ctl_panning(int ch, int val);
-static void ctl_sustain(int ch, int val);
-static void ctl_pitch_bend(int ch, int val);
-static void ctl_reset(void);
+static void ctl_volume(int, int);
+static void set_otherinfo(int, int, char);
+static void shuffle(int, int *);
+static void query_outputs(void);
 static void update_indicator(void);
-static void set_otherinfo(int ch, int val, char c);
-static void xaw_add_midi_file(char *additional_path);
-static void xaw_delete_midi_file(int delete_num);
-static void xaw_output_flist(void);
-static int ctl_blocking_read(int32 *valp);
-static void shuffle(int n,int *a);
+static void xaw_add_midi_file(char *);
+static void xaw_delete_midi_file(int);
+static void xaw_output_flist(char *);
 
 static double indicator_last_update = 0;
 #define EXITFLG_QUIT 1
 #define EXITFLG_AUTOQUIT 2
-static int exitflag=0,randomflag=0,repeatflag=0,selectflag=0;
-static int xaw_ready=0;
-static int number_of_files;
-static char **list_of_files;
-static char **titles;
-static int *file_table;
+static int reverb_type;
+/*
+ * Unfortunate hack, forced because opt_reverb_control has been overloaded,
+ * and is no longer 0 or 1. Now it's in the range 0..3, so when reenabling
+ * reverb and disabling it, we need to know the original value.
+ */
+static int exitflag = 0, randomflag = 0, repeatflag = 0, selectflag = 0,
+           current_no = 0, xaw_ready = 0, number_of_files, *file_table;
+static int pipe_in_fd, pipe_out_fd;
+static char **list_of_files, **titles;
+static int active[MAX_XAW_MIDI_CHANNELS];
+/*
+ * When a midi channel has played a note, this is set to 1. Otherwise, it's 0.
+ * This is used to screen out channels which are not used from the GUI.
+ */
 extern int amplitude;
+extern PlayMode *play_mode, *target_play_mode;
+static PlayMode *olddpm = NULL;
 
 /**********************************************/
 /* export the interface functions */
 
 #define ctl xaw_control_mode
 
-ControlMode ctl=
-{
+ControlMode ctl = {
     "XAW interface", 'a',
     "xaw",
     1,0,0,
@@ -117,7 +146,7 @@ ControlMode ctl=
     ctl_event
 };
 
-static char local_buf[300];
+static char local_buf[PIPE_LENGTH];
 
 /***********************************************************************/
 /* Put controls on the pipe                                            */
@@ -129,13 +158,13 @@ static int cmsg(int type, int verbosity_level, char *fmt, ...) {
   char *buff;
   MBlockList pool;
 
-  if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
-      ctl.verbosity<verbosity_level)
+  if (((type == CMSG_TEXT) || (type == CMSG_INFO) || (type == CMSG_WARNING)) &&
+      (ctl.verbosity<verbosity_level))
     return 0;
 
   va_start(ap, fmt);
 
-  if(!xaw_ready) {
+  if (!xaw_ready) {
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, NLS);
     va_end(ap);
@@ -155,138 +184,145 @@ static int cmsg(int type, int verbosity_level, char *fmt, ...) {
 /*ARGSUSED*/
 static int tt_i;
 
-static void ctl_current_time(int sec, int v) {
+static void
+ctl_current_time(int sec, int v) {
 
-  static int previous_sec=-1,last_voices=-1;
-  static int last_v=-1, last_time=-1;
+  static int previous_sec = -1, last_voices = -1, last_v = -1, last_time = -1;
 
-  if (sec!=previous_sec) {
-    previous_sec=sec;
-    snprintf(local_buf,sizeof(local_buf),"t %d",sec);
-    a_pipe_write(local_buf);
+  if (sec != previous_sec) {
+    previous_sec = sec;
+    a_pipe_write("t %d", sec);
   }
-  if (last_time!=tt_i) {
-    last_time=tt_i;
-    sprintf(local_buf, "T %d", tt_i);
-    a_pipe_write(local_buf);
+  if (last_time != tt_i) {
+    last_time = tt_i;
+    a_pipe_write("T %d", tt_i);
   }
-  if(!ctl.trace_playing || midi_trace.flush_flag) return;
-  if(last_voices!=voices) {
-    last_voices=voices;
-    snprintf(local_buf,sizeof(local_buf),"vL%d",voices);
-    a_pipe_write(local_buf);
+  if (!ctl.trace_playing || midi_trace.flush_flag) return;
+  if (last_voices != voices) {
+    last_voices = voices;
+    a_pipe_write("vL%d", voices);
   }
-  if(last_v!=v) {
-    last_v=v;
-    snprintf(local_buf,sizeof(local_buf),"vl%d",v);
-    a_pipe_write(local_buf);
+  if (last_v != v) {
+    last_v = v;
+    a_pipe_write("vl%d", v);
   }
-  
 }
 
-static void ctl_total_time(int tt)
-{
+static void
+ctl_total_time(int tt) {
     tt_i = tt / play_mode->rate;
     ctl_current_time(0, 0);
-    sprintf(local_buf,"m%d",play_system_mode);
-    a_pipe_write(local_buf);
+    a_pipe_write("m%d", play_system_mode);
 }
 
-static void ctl_master_volume(int mv)
-{
-  sprintf(local_buf,"V %03d", mv);
-  amplitude=atoi(local_buf+2);
+static void
+ctl_master_volume(int mv) {
+  amplitude = atoi(local_buf + 2);
   if (amplitude < 0) amplitude = 0;
   if (amplitude > MAXVOLUME) amplitude = MAXVOLUME;
-  a_pipe_write(local_buf);
-}
-
-static void ctl_volume(int ch, int val)
-{
-  if(!ctl.trace_playing) return;
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  sprintf(local_buf, "PV%c%d", ch+'A', val);
-  a_pipe_write(local_buf);
-}
-
-static void ctl_expression(int ch, int val)
-{
-  if(!ctl.trace_playing) return;
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  sprintf(local_buf, "PE%c%d", ch+'A', val);
-  a_pipe_write(local_buf);
-}
-
-static void ctl_panning(int ch, int val)
-{
-  if(!ctl.trace_playing) return;
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  sprintf(local_buf, "PA%c%d", ch+'A', val);
-  a_pipe_write(local_buf);
-}
-
-static void ctl_sustain(int ch, int val)
-{
-  if(!ctl.trace_playing) return;
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  sprintf(local_buf, "PS%c%d", ch+'A', val);
-  a_pipe_write(local_buf);
-}
-
-static void ctl_pitch_bend(int ch, int val)
-{
-  if(!ctl.trace_playing) return;
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  sprintf(local_buf, "PB%c%d", ch+'A', val);
-  a_pipe_write(local_buf);
-}
-
-static void ctl_lyric(int lyricid)
-{
-    char *lyric;
-    static int lyric_col = 0;
-    static char lyric_buf[300];
-
-    lyric = event2string(lyricid);
-    if(lyric != NULL)
-    {
-        if(lyric[0] == ME_KARAOKE_LYRIC)
-        {
-            if(lyric[1] == '/' || lyric[1] == '\\')
-            {
-                strncpy(lyric_buf, lyric + 2, sizeof(lyric_buf) - 1);
-                a_pipe_write_msg(lyric_buf);
-                lyric_col = strlen(lyric_buf);
-            }
-            else if(lyric[1] == '@')
-            {
-                if(lyric[2] == 'L')
-                    snprintf(lyric_buf, sizeof(lyric_buf), "Language: %s", lyric + 3);
-                else if(lyric[2] == 'T')
-                    snprintf(lyric_buf, sizeof(lyric_buf), "Title: %s", lyric + 3);
-                else
-                    strncpy(lyric_buf, lyric + 1, sizeof(lyric_buf) - 1);
-                a_pipe_write_msg(lyric_buf);
-                lyric_col = 0;
-            }
-            else
-            {
-                strncpy(lyric_buf + lyric_col, lyric + 1, sizeof(lyric_buf) - lyric_col - 1);
-                a_pipe_write_msg(lyric_buf);
-                lyric_col += strlen(lyric + 1);
-            }
-        }
+  a_pipe_write("V %03d", mv);
+}
+
+static void
+ctl_volume(int ch, int val) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+  a_pipe_write("PV%c%d", ch+'A', val);
+}
+
+static void
+ctl_expression(int ch, int val) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+  a_pipe_write("PE%c%d", ch+'A', val);
+}
+
+static void
+ctl_panning(int ch, int val) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+  a_pipe_write("PA%c%d", ch+'A', val);
+}
+
+static void
+ctl_sustain(int ch, int val) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+  a_pipe_write("PS%c%d", ch+'A', val);
+}
+
+static void
+ctl_pitch_bend(int ch, int val) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+  a_pipe_write("PB%c%d", ch+'A', val);
+}
+
+#ifdef WIDGET_IS_LABEL_WIDGET
+static void
+ctl_lyric(int lyricid) {
+  char *lyric;
+  static int lyric_col = 0;
+  static char lyric_buf[PIPE_LENGTH];
+
+  lyric = event2string(lyricid);
+  if (lyric != NULL) {
+    if (lyric[0] == ME_KARAOKE_LYRIC) {
+      if ((lyric[1] == '/') || (lyric[1] == '\\')) {
+        strlcpy(lyric_buf, lyric + 2, sizeof(lyric_buf));
+        a_pipe_write_msg(lyric_buf);
+        lyric_col = strlen(lyric_buf);
+      }
+      else if (lyric[1] == '@') {
+        if (lyric[2] == 'L')
+          snprintf(lyric_buf, sizeof(lyric_buf), "Language: %s", lyric + 3);
+        else if (lyric[2] == 'T')
+          snprintf(lyric_buf, sizeof(lyric_buf), "Title: %s", lyric + 3);
         else
-        {
-            lyric_col = 0;
-            a_pipe_write_msg(lyric + 1);
-        }
+          strlcpy(lyric_buf, lyric + 1, sizeof(lyric_buf));
+        a_pipe_write_msg(lyric_buf);
+        lyric_col = 0;
+      }
+      else {
+        strlcpy(lyric_buf + lyric_col, lyric + 1,
+                  sizeof(lyric_buf) - lyric_col);
+        a_pipe_write_msg(lyric_buf);
+        lyric_col += strlen(lyric + 1);
+      }
+    }
+    else {
+      lyric_col = 0;
+      a_pipe_write_msg_nobr(lyric + 1);
     }
+  }
 }
+#else
+static void
+ctl_lyric(int lyricid) {
+  char *lyric;
+
+  lyric = event2string(lyricid);
+  if (lyric != NULL) {
+    if (lyric[0] == ME_KARAOKE_LYRIC) {
+      if ((lyric[1] == '/') || (lyric[1] == '\\')) { 
+        lyric[1] = '\n';
+        a_pipe_write_msg_nobr(lyric + 1);
+      }
+      else if (lyric[1] == '@') {
+        if (lyric[2] == 'L')
+          snprintf(local_buf, sizeof(local_buf), "Language: %s", lyric + 3);
+        else if (lyric[2] == 'T')
+          snprintf(local_buf, sizeof(local_buf), "Title: %s", lyric + 3);
+        else
+          strlcpy(local_buf, lyric + 1, sizeof(local_buf));
+        a_pipe_write_msg(local_buf);
+      }
+      else a_pipe_write_msg_nobr(lyric + 1);
+    }
+    else a_pipe_write_msg_nobr(lyric + 1);
+  }
+}
+#endif /* WIDGET_IS_LABEL_WIDGET */
 
 /*ARGSUSED*/
-static int ctl_open(int using_stdin, int using_stdout) {
-  ctl.opened=1;
+static int
+ctl_open(int using_stdin, int using_stdout) {
+  ctl.opened = 1;
 
   set_trace_loop_hook(update_indicator);
 
@@ -296,396 +332,515 @@ static int ctl_open(int using_stdin, int using_stdout) {
   return 0;
 }
 
-static void ctl_close(void)
-{
+static void
+ctl_close(void) {
   if (ctl.opened) {
     a_pipe_write("Q");
-    ctl.opened=0;
-    xaw_ready=0;
+    ctl.opened = 0;
+    xaw_ready = 0;
   }
 }
 
-static void xaw_add_midi_file(char *additional_path) {
-    char *files[1],**ret,**tmp;
-    int i,nfiles,nfit;
-    char *p;
+static void
+xaw_add_midi_file(char *additional_path) {
+  char *files[1], **ret;
+  int i, nfiles, nfit, *local_len = NULL;
+  char *p;
 
-    files[0] = additional_path;
-    nfiles = 1;
-    ret = expand_file_archives(files, &nfiles);
-    if(ret == NULL)
-      return;
-    tmp = list_of_files;
-    titles=(char **)safe_realloc(titles,(number_of_files+nfiles)*sizeof(char *));
-    list_of_files=(char **)safe_malloc((number_of_files+nfiles)*sizeof(char *));
-    for (i=0;i<number_of_files;i++)
-        list_of_files[i]=safe_strdup(tmp[i]);
-    for (i=0,nfit=0;i<nfiles;i++) {
-        if(check_midi_file(ret[i]) >= 0) {
-            p=strrchr(ret[i],'/');
-            if (p==NULL) p=ret[i]; else p++;      
-            titles[number_of_files+nfit]=(char *)safe_malloc(sizeof(char)*(strlen(p)+ 9));
-            list_of_files[number_of_files+nfit]=safe_strdup(ret[i]);
-            sprintf(titles[number_of_files+nfit],"%d. %s",number_of_files+nfit+1,p);
-            nfit++;
-        }
-    }
-    if(nfit>0) {
-        file_table=(int *)safe_realloc(file_table,
-                                       (number_of_files+nfit)*sizeof(int));
-        for(i = number_of_files; i < number_of_files + nfit; i++)
-            file_table[i] = i;
-        number_of_files+=nfit;
-        sprintf(local_buf, "X %d", nfit);
-        a_pipe_write(local_buf);
-        for (i=0;i<nfit;i++)
-            a_pipe_write(titles[number_of_files-nfit+i]);
-    }
-    free(ret[0]);
-    free(ret);
+  files[0] = additional_path;
+  nfiles = 1;
+  ret = expand_file_archives(files, &nfiles);
+  if (ret == NULL) return;
+  titles = (char **)safe_realloc(titles,
+             (number_of_files + nfiles) * sizeof(char *));
+  list_of_files = (char **)safe_realloc(list_of_files,
+                   (number_of_files + nfiles) * sizeof(char *));
+  if (nfiles > 0) local_len = (int *)safe_malloc(nfiles * sizeof(int));
+  for (i=0, nfit=0;i<nfiles;i++) {
+      if (check_midi_file(ret[i]) >= 0) {
+          p = strrchr(ret[i], '/');
+          if (p == NULL) p = ret[i]; else p++;
+          titles[number_of_files+nfit] =
+            (char *)safe_malloc(sizeof(char) * (strlen(p) +  9));
+          list_of_files[number_of_files + nfit] = safe_strdup(ret[i]);
+          local_len[nfit] = sprintf(titles[number_of_files + nfit],
+                                  "%d. %s", number_of_files + nfit + 1, p);
+          nfit++;
+      }
+  }
+  if (nfit > 0) {
+      file_table = (int *)safe_realloc(file_table,
+                                     (number_of_files + nfit) * sizeof(int));
+      for(i = number_of_files; i < number_of_files + nfit; i++)
+          file_table[i] = i;
+      number_of_files += nfit;
+      a_pipe_write("X %d", nfit);
+      for (i=0;i<nfit;i++)
+          a_pipe_write_buf(titles[number_of_files - nfit + i], local_len[i]);
+  }
+  free(local_len);
+  free(ret[0]);
+  free(ret);
 }
 
-static void xaw_delete_midi_file(int delete_num) {
+static void
+xaw_delete_midi_file(int delete_num) {
     int i;
     char *p;
 
-    if(delete_num<0) {
+    if (delete_num < 0) {
         for(i=0;i<number_of_files;i++){
             free(list_of_files[i]);
             free(titles[i]);
         }
         list_of_files = NULL; titles = NULL;
-        file_table=(int *)safe_realloc(file_table,1*sizeof(int));
+        file_table = (int *)safe_realloc(file_table, 1*sizeof(int));
         file_table[0] = 0;
         number_of_files = 0;
+        current_no = 0;
     } else {
-        free(titles[delete_num]);
-        for(i=delete_num;i<number_of_files-1;i++){
-            list_of_files[i]= list_of_files[i+1];
-            p= strchr(titles[i+1],'.');
-            titles[i]= (char *)safe_malloc(strlen(titles[i+1])*sizeof(char *));
-            sprintf(titles[i],"%d%s",i+1,p);
+        free(titles[delete_num]); titles[delete_num] = NULL;
+        for(i=delete_num; i<number_of_files-1; i++) {
+            list_of_files[i] = list_of_files[i+1];
+            p = strchr(titles[i+1], '.');
+            titles[i] = (char *)safe_realloc(titles[i],
+                                  strlen(titles[i+1]) * sizeof(char));
+            sprintf(titles[i], "%d%s", i+1, p);
         }
-        if(number_of_files>0) number_of_files -= 1;
+        if (number_of_files > 0) number_of_files--;
+        if ((current_no >= delete_num) && (delete_num)) current_no--;
     }
 }
 
-static void xaw_output_flist(void) {
-    int i;
+static void
+xaw_output_flist(char *filename) {
+  int i;
+  char *temp = safe_strdup(filename);
 
-    sprintf(local_buf, "s%d",number_of_files);
-    a_pipe_write(local_buf);
-    for(i=0;i<number_of_files;i++){
-        sprintf(local_buf, "%s",list_of_files[i]);
-        a_pipe_write(local_buf);
-    }
+  a_pipe_write("s%d %s", number_of_files, temp);
+  free(temp);
+  for(i=0;i<number_of_files;i++) {
+    a_pipe_write("%s", list_of_files[i]);
+  }
 }
 
 /*ARGSUSED*/
-static int ctl_blocking_read(int32 *valp) {
+static int
+ctl_blocking_read(int32 *valp) {
   int n;
 
-  a_pipe_read(local_buf,sizeof(local_buf));
+  a_pipe_read(local_buf, sizeof(local_buf));
   for (;;) {
     switch (local_buf[0]) {
-      case 'P' : return RC_LOAD_FILE;
-      case 'U' : return RC_TOGGLE_PAUSE;
-      case 'f': *valp=(int32)(play_mode->rate * 10);
-        return RC_FORWARD;
-      case 'b': *valp=(int32)(play_mode->rate * 10);
-        return RC_BACK;
-      case 'S' : return RC_QUIT;
-      case 'N' : return RC_NEXT;
-      case 'B' : return RC_REALLY_PREVIOUS;
-      case 'R' : repeatflag=atoi(local_buf+2);return RC_NONE;
-      case 'D' : randomflag=atoi(local_buf+2);return RC_QUIT;
-      case 'd' : n=atoi(local_buf+2);
-        xaw_delete_midi_file(atoi(local_buf+2));
-        return RC_QUIT;
+      case 'X':
+        xaw_add_midi_file(local_buf + 2);
+        return RC_NONE;
       case 'A' : xaw_delete_midi_file(-1);
         return RC_QUIT;
-      case 'C' : n=atoi(local_buf+2);
+      case 'B' : return RC_REALLY_PREVIOUS;
+      case 'b': *valp = (int32)(play_mode->rate * 10);
+        return RC_BACK;
+      case 'C': n = atoi(local_buf + 2);
         opt_chorus_control = n;
         return RC_QUIT;
-      case 'E' : n=atoi(local_buf+2);
+      case 'D': randomflag = atoi(local_buf + 2); return RC_QUIT;
+      case 'd': n = atoi(local_buf + 2);
+        xaw_delete_midi_file(atoi(local_buf + 2));
+        return RC_NONE;
+      case 'E': n = atoi(local_buf + 2);
         opt_modulation_wheel = n & MODUL_BIT;
         opt_portamento = n & PORTA_BIT;
         opt_nrpn_vibrato = n & NRPNV_BIT;
-        opt_reverb_control = !!(n & REVERB_BIT);
+        opt_reverb_control = !!(n & REVERB_BIT) * reverb_type;
         opt_channel_pressure = n & CHPRESSURE_BIT;
         opt_overlap_voice_allow = n & OVERLAPV_BIT;
         opt_trace_text_meta_event = n & TXTMETA_BIT;
         return RC_QUIT;
-      case 'F' : 
-      case 'L' : selectflag=atoi(local_buf+2);return RC_QUIT;
-      case 'T' : a_pipe_read(local_buf,sizeof(local_buf));
-        n=atoi(local_buf+2); *valp= n * play_mode->rate;
+      case 'F': 
+      case 'L': selectflag = atoi(local_buf + 2); return RC_QUIT;
+      case 'f': *valp = (int32)(play_mode->rate * 10);
+        return RC_FORWARD;
+      case 'g': return RC_TOGGLE_SNDSPEC;
+      case 'P': return RC_LOAD_FILE;
+      case 'U': return RC_TOGGLE_PAUSE;
+      case 'S': return RC_QUIT;
+      case 'N': return RC_NEXT;
+      case 'R': repeatflag = atoi(local_buf + 2); return RC_NONE;
+      case 'T':
+        n = atoi(local_buf + 2); *valp = n * play_mode->rate;
         return RC_JUMP;
-      case 'V' : a_pipe_read(local_buf,sizeof(local_buf));
-        amplification=atoi(local_buf+2); *valp=(int32)0;
+      case 'M':
+        n = atoi(local_buf + 2);
+        *valp = (int32)n;
+        return RC_TOGGLE_MUTE;
+      case 'O': *valp = (int32)1; return RC_VOICEDECR;
+      case 'o': *valp = (int32)1; return RC_VOICEINCR;
+      case 'q': exitflag ^= EXITFLG_AUTOQUIT; return RC_NONE;
+      case 's':
+        xaw_output_flist(local_buf + 2); return RC_NONE;
+      case 't':
+        ctl.trace_playing = 1;
+        if (local_buf[1] == 'R') ctl_reset();
+        return RC_NONE;
+      case 'V': 
+        amplification = atoi(local_buf + 2); *valp = (int32)0;
         return RC_CHANGE_VOLUME;
-      case '+': a_pipe_read(local_buf,sizeof(local_buf));
-        *valp = (int32)1; return RC_KEYUP;
-      case '-': a_pipe_read(local_buf,sizeof(local_buf));
-        *valp = (int32)-1; return RC_KEYDOWN;
-      case '>': a_pipe_read(local_buf,sizeof(local_buf));
-        *valp = (int32)1; return RC_SPEEDUP;
-      case '<': a_pipe_read(local_buf,sizeof(local_buf));
-        *valp = (int32)1; return RC_SPEEDDOWN;
-      case 'o': a_pipe_read(local_buf,sizeof(local_buf));
-        *valp = (int32)1; return RC_VOICEINCR;
-      case 'O': a_pipe_read(local_buf,sizeof(local_buf));
-        *valp = (int32)1; return RC_VOICEDECR;
-      case 'X': a_pipe_read(local_buf,sizeof(local_buf));
-        xaw_add_midi_file(local_buf + 2);
+      case '+': *valp = (int32)1; return RC_KEYUP;
+      case '-': *valp = (int32)-1; return RC_KEYDOWN;
+      case '>': *valp = (int32)1; return RC_SPEEDUP;
+      case '<': *valp = (int32)1; return RC_SPEEDDOWN;
+      case 'W':
+        if (olddpm == NULL) {
+          PlayMode **ii;
+          char id = *(local_buf + 1), *p;
+
+          target_play_mode = NULL;
+          for (ii = play_mode_list; *ii != NULL; ii++)
+            if ((*ii)->id_character == id) 
+              target_play_mode = *ii;
+          if (target_play_mode == NULL) goto z1error;
+          p = strchr(local_buf, ' ');
+          target_play_mode->name = safe_strdup(p + 1);
+          target_play_mode->rate = atoi(local_buf + 2);
+          if (target_play_mode->open_output() == -1) {
+            free(target_play_mode->name);
+            goto z1error;
+          }
+          play_mode->close_output();
+          olddpm = play_mode;
+          play_mode = target_play_mode;
+          /* playmidi.c won't change play_mode when a file is not played,
+           * so to be certain, we do this ourselves.
+           */
+          a_pipe_write("Z1");
+          return RC_OUTPUT_CHANGED;
+        }
+z1error:
+        a_pipe_write("Z1E");
         return RC_NONE;
-      case 's':
-        xaw_output_flist();return RC_NONE;
-      case 'g': return RC_TOGGLE_SNDSPEC;
-      case 'q' : exitflag ^= EXITFLG_AUTOQUIT;return RC_NONE;
-      case 'Q' :
-      default  : exitflag |= EXITFLG_QUIT;return RC_QUIT;
+      case 'w':
+        if (olddpm != NULL) {
+          play_mode->close_output();
+          if (*(local_buf + 1) == 'S') a_pipe_write("Z2S");
+          target_play_mode = olddpm;
+          if (target_play_mode->open_output() == -1) return RC_NONE;
+          free(play_mode->name);
+          play_mode = target_play_mode;
+          olddpm = NULL;
+          return RC_OUTPUT_CHANGED;
+        }
+        return RC_NONE;
+      case 'p':
+       {
+          PlayMode **ii;
+          char id = *(local_buf + 1);
+
+          if (play_mode->id_character == id) goto z3error;
+          if (olddpm != NULL) goto z3error;
+
+          target_play_mode = NULL;
+          for (ii = play_mode_list; *ii != NULL; ii++)
+            if ((*ii)->id_character == id)
+              target_play_mode = *ii;
+          if (target_play_mode == NULL) goto z3error;
+          play_mode->close_output();
+          if (target_play_mode->open_output() == -1) {
+            play_mode->open_output();
+            goto z3error;
+          }
+          play_mode = target_play_mode;
+          a_pipe_write("Z3");
+          return RC_OUTPUT_CHANGED;
+       }
+z3error:
+       a_pipe_write("Z3E");
+       return RC_NONE;
+      case 'Q':
+        free(file_table);
+        for (n=0; n<number_of_files; n++) {
+          free(titles[n]); free(list_of_files[n]);
+        }
+      default : exitflag |= EXITFLG_QUIT; return RC_QUIT;
     }
   }
 }
 
-static int ctl_read(int32 *valp) {
-  if (a_pipe_ready()<=0) return RC_NONE;
+static int
+ctl_read(int32 *valp) {
+  if (a_pipe_ready() <= 0) return RC_NONE;
   return ctl_blocking_read(valp);
 }
 
-static void shuffle(int n,int *a) {
-  int i,j,tmp;
+static void
+shuffle(int n, int *a) {
+  int i, j, tmp;
 
   for (i=0;i<n;i++) {
-    j=int_rand(n);
-    tmp=a[i];
-    a[i]=a[j];
-    a[j]=tmp;
+    j = int_rand(n);
+    tmp = a[i];
+    a[i] = a[j];
+    a[j] = tmp;
   }
 }
 
-static int ctl_pass_playing_list(int init_number_of_files,
-                  char *init_list_of_files[]) {
-  int current_no,command=RC_NONE,i,j;
+static void
+query_outputs(void) {
+  PlayMode **ii; unsigned char c;
+
+  for (ii = play_mode_list; *ii != NULL; ii++) {
+    if ((*ii)->flag & PF_FILE_OUTPUT) c = 'F';
+    else c = 'O';
+    if (*ii == play_mode) c += 32;
+    a_pipe_write("%c%c %s", c, (*ii)->id_character, (*ii)->id_name);
+  }
+  a_pipe_write("Z0");
+}
+
+static int
+ctl_pass_playing_list(int init_number_of_files, char **init_list_of_files) {
+  int command = RC_NONE, i, j;
   int32 val;
   char *p;
 
+  for (i=0; i<MAX_XAW_MIDI_CHANNELS; i++) active[i] = 0;
+  reverb_type = opt_reverb_control?opt_reverb_control:DEFAULT_REVERB;
   /* Wait prepare 'interface' */
-  a_pipe_read(local_buf,sizeof(local_buf));
-  if (strcmp("READY",local_buf)) return;
-  xaw_ready=1;
+  a_pipe_read(local_buf, sizeof(local_buf));
+  if (strcmp("READY", local_buf)) return 0;
+  xaw_ready = 1;
 
-  sprintf(local_buf,"%d",
+  a_pipe_write("%d",
   (opt_modulation_wheel<<MODUL_N)
      | (opt_portamento<<PORTA_N)
      | (opt_nrpn_vibrato<<NRPNV_N)
-     | (opt_reverb_control<<REVERB_N)
+     | (!!(opt_reverb_control)<<REVERB_N)
      | (opt_channel_pressure<<CHPRESSURE_N)
      | (opt_overlap_voice_allow<<OVERLAPV_N)
      | (opt_trace_text_meta_event<<TXTMETA_N));
-  a_pipe_write(local_buf);
-  sprintf(local_buf,"%d",opt_chorus_control);
-  a_pipe_write(local_buf);
+  a_pipe_write("%d", opt_chorus_control);
+
+  query_outputs();
 
   /* Make title string */
-  titles=(char **)safe_malloc(init_number_of_files*sizeof(char *));
-  list_of_files=(char **)safe_malloc(init_number_of_files*sizeof(char *));
-  for (i=0,j=0;i<init_number_of_files;i++) {
-    if(check_midi_file(init_list_of_files[i]) >= 0) {
-      p=strrchr(init_list_of_files[i],'/');
-      if (p==NULL) {
-        p=safe_strdup(init_list_of_files[i]);
-      } else p++;
-      list_of_files[j]= safe_strdup(init_list_of_files[i]);
-      titles[j]=(char *)safe_malloc(sizeof(char)*(strlen(p)+ 9));
-      sprintf(titles[j],"%d. %s",j+1,p);
-      j++; number_of_files = j;
+  titles = (char **)safe_malloc(init_number_of_files * sizeof(char *));
+  list_of_files = (char **)safe_malloc(init_number_of_files * sizeof(char *));
+  for (i=0, j=0;i<init_number_of_files;i++) {
+    if (check_midi_file(init_list_of_files[i]) >= 0) {
+      p = strrchr(init_list_of_files[i], '/');
+      if (p == NULL) p = safe_strdup(init_list_of_files[i]);
+      else p++;
+      list_of_files[j] = safe_strdup(init_list_of_files[i]);
+      titles[j] = (char *)safe_malloc(sizeof(char) * (strlen(p) +  9));
+      sprintf(titles[j], "%d. %s", j+1, p);
+      j++;
     }
   }
-  titles=(char **)safe_realloc(titles,init_number_of_files*sizeof(char *));
-  list_of_files=(char **)safe_realloc(list_of_files,init_number_of_files*sizeof(char *));
+  number_of_files = j;
+  titles = (char **)safe_realloc(titles, number_of_files * sizeof(char *));
+  list_of_files = (char **)safe_realloc(list_of_files,
+                                         number_of_files * sizeof(char *));
 
   /* Send title string */
-  sprintf(local_buf,"%d",number_of_files);
-  a_pipe_write(local_buf);
+  a_pipe_write("%d", number_of_files);
   for (i=0;i<number_of_files;i++)
-    a_pipe_write(titles[i]);
+    a_pipe_write("%s", titles[i]);
 
   /* Make the table of play sequence */
-  file_table=(int *)safe_malloc(number_of_files*sizeof(int));
-  for (i=0;i<number_of_files;i++) file_table[i]=i;
+  file_table = (int *)safe_malloc(number_of_files * sizeof(int));
+  for (i=0;i<number_of_files;i++) file_table[i] = i;
 
   /* Draw the title of the first file */
-  current_no=0;
-  if(number_of_files!=0){
-    snprintf(local_buf,sizeof(local_buf),"E %s",titles[file_table[0]]);
-    a_pipe_write(local_buf);
-    command=ctl_blocking_read(&val);
+  current_no = 0;
+  if (number_of_files != 0) {
+    a_pipe_write("E %s", titles[file_table[0]]);
+    command = ctl_blocking_read(&val);
   }
 
   /* Main loop */
   for (;;) {
     /* Play file */
-    if (command==RC_LOAD_FILE&&number_of_files!=0) {
+    if ((command == RC_LOAD_FILE) && (number_of_files != 0)) {
       char *title;
-      snprintf(local_buf,sizeof(local_buf),"E %s",titles[file_table[current_no]]);
-      a_pipe_write(local_buf);
-      if((title = get_midi_title(list_of_files[file_table[current_no]])) == NULL)
+      a_pipe_write("E %s", titles[file_table[current_no]]);
+      if ((title = get_midi_title(list_of_files[file_table[current_no]]))
+            == NULL)
       title = list_of_files[file_table[current_no]];
-      snprintf(local_buf,sizeof(local_buf),"e %s", title);
-      a_pipe_write(local_buf);
-      command=play_midi_file(list_of_files[file_table[current_no]]);
+      a_pipe_write("e %s", title);
+      command = play_midi_file(list_of_files[file_table[current_no]]);
     } else {
-      if (command==RC_CHANGE_VOLUME) amplitude+=val;
-      if (command==RC_JUMP) ;
-      if (command==RC_TOGGLE_SNDSPEC) ;
+      if (command == RC_CHANGE_VOLUME) amplitude += val;
+      if (command == RC_JUMP) ;
+      if (command == RC_TOGGLE_SNDSPEC) ;
       /* Quit timidity*/
-      if (exitflag & EXITFLG_QUIT) return;
+      if (exitflag & EXITFLG_QUIT) return 0;
       /* Stop playing */
-      if (command==RC_QUIT) {
-        sprintf(local_buf,"T 00:00");
-        a_pipe_write(local_buf);
+      if (command == RC_QUIT) {
+        a_pipe_write("T 00:00");
         /* Shuffle the table */
         if (randomflag) {
-          if(number_of_files == 0) {
-            randomflag=0;
+          if (number_of_files == 0) {
+            randomflag = 0;
             continue;
           }
-          current_no=0;
-          if (randomflag==1) {
-            shuffle(number_of_files,file_table);
-            randomflag=0;
-            command=RC_LOAD_FILE;
+          current_no = 0;
+          if (randomflag == 1) {
+            shuffle(number_of_files, file_table);
+            randomflag = 0;
+            command = RC_LOAD_FILE;
             continue;
           }
-          randomflag=0;
-          for (i=0;i<number_of_files;i++) file_table[i]=i;
-          snprintf(local_buf,sizeof(local_buf),"E %s",titles[file_table[current_no]]);
-          a_pipe_write(local_buf);
+          randomflag = 0;
+          for (i=0;i<number_of_files;i++) file_table[i] = i;
+          a_pipe_write("E %s", titles[file_table[current_no]]);
         }
         /* Play the selected file */
         if (selectflag) {
           for (i=0;i<number_of_files;i++)
-            if (file_table[i]==selectflag-1) break;
-          if (i!=number_of_files) current_no=i;
-          selectflag=0;
-          command=RC_LOAD_FILE;
+            if (file_table[i] == selectflag-1) break;
+          if (i != number_of_files) current_no = i;
+          selectflag = 0;
+          command = RC_LOAD_FILE;
           continue;
         }
         /* After the all file played */
-      } else if (command==RC_TUNE_END || command==RC_ERROR) {
-        if (current_no+1<number_of_files) {
-          current_no++;
-          command=RC_LOAD_FILE;
-          continue;
+      } else if ((command == RC_TUNE_END) || (command == RC_ERROR)) {
+        if (current_no+1 < number_of_files) {
+          if (olddpm != NULL) {
+            command = RC_QUIT;
+            a_pipe_write("Z2");
+          } else {
+            current_no++;
+            command = RC_LOAD_FILE;
+            continue;
+          }
         } else if (exitflag & EXITFLG_AUTOQUIT) {
-          return;
+          return 0;
           /* Repeat */
         } else if (repeatflag) {
-          current_no=0;
-          command=RC_LOAD_FILE;
+          current_no = 0;
+          command = RC_LOAD_FILE;
           continue;
           /* Off the play button */
         } else {
+          if (olddpm != NULL) a_pipe_write("Z2");
           a_pipe_write("O");
         }
         /* Play the next */
-      } else if (command==RC_NEXT) {
-        if (current_no+1<number_of_files) current_no++;
-        command=RC_LOAD_FILE;
+      } else if (command == RC_NEXT) {
+        if (current_no+1 < number_of_files) current_no++;
+        command = RC_LOAD_FILE;
         continue;
         /* Play the previous */
-      } else if (command==RC_REALLY_PREVIOUS) {
-        if (current_no>0) current_no--;
-        command=RC_LOAD_FILE;
+      } else if (command == RC_REALLY_PREVIOUS) {
+        if (current_no > 0) current_no--;
+        command = RC_LOAD_FILE;
         continue;
       }
-      command=ctl_blocking_read(&val);
+      command = ctl_blocking_read(&val);
     }
   }
 }
 
 /* ------ Pipe handlers ----- */
 
-static int pipe_in_fd,pipe_out_fd;
-
-extern void a_start_interface(int);
-
-static void a_pipe_open(void) {
-  int cont_inter[2],inter_cont[2];
+static void
+a_pipe_open(void) {
+  int cont_inter[2], inter_cont[2];
 
-  if (pipe(cont_inter)<0 || pipe(inter_cont)<0) exit(1);
+  if ((pipe(cont_inter) < 0) || (pipe(inter_cont) < 0)) exit(1);
 
-  if (fork()==0) {
+  if (fork() == 0) {
     close(cont_inter[1]);
     close(inter_cont[0]);
-    pipe_in_fd=cont_inter[0];
-    pipe_out_fd=inter_cont[1];
+    pipe_in_fd = cont_inter[0];
+    pipe_out_fd = inter_cont[1];
     a_start_interface(pipe_in_fd);
   }
   close(cont_inter[0]);
   close(inter_cont[1]);
-  pipe_in_fd=inter_cont[0];
-  pipe_out_fd=cont_inter[1];
+  pipe_in_fd = inter_cont[0];
+  pipe_out_fd = cont_inter[1];
 }
 
-void a_pipe_write(char *buf) {
-  write(pipe_out_fd,buf,strlen(buf));
-  write(pipe_out_fd,"\n",1);
+void
+a_pipe_write(const char *fmt, ...) {
+  /* char local_buf[PIPE_LENGTH]; */
+  int len;
+  va_list ap;
+
+  va_start(ap, fmt);
+  len = vsnprintf(local_buf, sizeof(local_buf), fmt, ap);
+  if ((len < 0) || (len > PIPE_LENGTH))
+    write(pipe_out_fd, local_buf, PIPE_LENGTH);
+  else write(pipe_out_fd, local_buf, len);
+  write(pipe_out_fd, "\n", 1);
+  va_end(ap);
 }
 
-static int a_pipe_ready(void) {
+static void
+a_pipe_write_buf(char *buf, int len) {
+  if ((len < 0) || (len > PIPE_LENGTH)) write(pipe_out_fd, buf, PIPE_LENGTH);
+  else write(pipe_out_fd, buf, len);
+  write(pipe_out_fd, "\n", 1);
+}
+
+static int
+a_pipe_ready(void) {
   fd_set fds;
   static struct timeval tv;
   int cnt;
 
   FD_ZERO(&fds);
-  FD_SET(pipe_in_fd,&fds);
-  tv.tv_sec=0;
-  tv.tv_usec=0;
-  if((cnt=select(pipe_in_fd+1,&fds,NULL,NULL,&tv))<0)
-    return -1;
-  return cnt > 0 && FD_ISSET(pipe_in_fd, &fds) != 0;
+  FD_SET(pipe_in_fd, &fds);
+  tv.tv_sec = 0;
+  tv.tv_usec = 0;
+  if ((cnt = select(pipe_in_fd+1, &fds, NULL, NULL, &tv)) < 0) return -1;
+  return (cnt > 0) && (FD_ISSET(pipe_in_fd, &fds) != 0);
 }
 
-int a_pipe_read(char *buf,int bufsize) {
+int
+a_pipe_read(char *buf, size_t bufsize) {
   int i;
 
   bufsize--;
   for (i=0;i<bufsize;i++) {
-    ssize_t len = read(pipe_in_fd,buf+i,1);
+    ssize_t len = read(pipe_in_fd, buf+i, 1);
     if (len != 1) {
       perror("CONNECTION PROBLEM WITH XAW PROCESS");
       exit(1);
     }
-    if (buf[i]=='\n') break;
+    if (buf[i] == '\n') break;
   }
-  buf[i]=0;
+  buf[i] = '\0';
   return 0;
 }
 
-int a_pipe_nread(char *buf, int n)
-{
-    int i, j;
+int
+a_pipe_nread(char *buf, size_t n) {
+    ssize_t i, j = 0;
 
-    j = 0;
-    while(n > 0 && (i = read(pipe_in_fd, buf + j, n - j)) > 0)
-    j += i;
+    if (n <= 0) return 0;
+    while ((i = read(pipe_in_fd, buf + j, n - j)) > 0) j += i;
     return j;
 }
 
-static void a_pipe_write_msg(char *msg)
-{
-    int msglen;
-    char buf[2 + sizeof(int)], *p, *q;
+void
+a_pipe_sync(void) {
+  fsync(pipe_out_fd);
+  fsync(pipe_in_fd);
+  usleep(100000);
+}
+
+static void
+a_pipe_write_msg(char *msg) {
+    size_t msglen;
+    char buf[2 + sizeof(size_t)], *p, *q;
 
-    /* strip '\r' */
+    /* convert '\r' to '\n', but strip '\r' from '\r\n' */
     p = q = msg;
-    while(*q) {
-    if(*q != '\r')
-        *p++ = *q;
-    q++;
+    while (*q != '\0') {
+      if (*q != '\r') *p++ = *q++;
+      else if (*(++q) != '\n') *p++ = '\n';
     }
     *p = '\0';
 
@@ -693,68 +848,88 @@ static void a_pipe_write_msg(char *msg)
     buf[0] = 'L';
     buf[1] = '\n';
 
-    memcpy(buf + 2, &msglen, sizeof(int));
+    memcpy(buf + 2, &msglen, sizeof(size_t));
     write(pipe_out_fd, buf, sizeof(buf));
     write(pipe_out_fd, msg, msglen - 1);
     write(pipe_out_fd, "\n", 1);
 }
 
 static void
-ctl_note(int status, int ch, int note, int velocity)
-{
+a_pipe_write_msg_nobr(char *msg) {
+    size_t msglen;
+    char buf[2 + sizeof(size_t)], *p, *q;
+
+    /* convert '\r' to '\n', but strip '\r' from '\r\n' */
+    p = q = msg;
+    while (*q != '\0') {
+      if (*q != '\r') *p++ = *q++;
+      else if (*(++q) != '\n') *p++ = '\n';
+    }
+    *p = '\0';
+
+    msglen = strlen(msg);
+    buf[0] = 'L';
+    buf[1] = '\n';
+
+    memcpy(buf + 2, &msglen, sizeof(size_t));
+    write(pipe_out_fd, buf, sizeof(buf));
+    write(pipe_out_fd, msg, msglen);
+}
+
+static void
+ctl_note(int status, int ch, int note, int velocity) {
   char c;
 
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
+  if (ch >= MAX_XAW_MIDI_CHANNELS) return;
   if(!ctl.trace_playing || midi_trace.flush_flag) return;
-    
+
+  switch (status) {
+  case VOICE_ON:
+    c = '*';
+    break;
+  case VOICE_SUSTAINED:
+    c = '&';
+    break;
+  case VOICE_FREE:
+  case VOICE_DIE:
+  case VOICE_OFF:
+  default:
     c = '.';
-    switch(status) {
-    case VOICE_ON:
-      c = '*';
-      break;
-    case VOICE_SUSTAINED:
-      c = '&';
-      break;
-    case VOICE_FREE:
-    case VOICE_DIE:
-    case VOICE_OFF:
-    default:
-      break;
-    }
-    snprintf(local_buf,sizeof(local_buf),"Y%c%c%03d%d",ch+'A',c,(unsigned char)note,velocity);
-    a_pipe_write(local_buf);
-}
+    break;
+  }
+  a_pipe_write("Y%c%c%03d%d", ch+'A', c, (unsigned char)note, velocity);
 
-static void ctl_program(int ch, int val, void *comm)
-{
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  if(!ctl.trace_playing) return;
+  if (active[ch] == 0) {
+    active[ch] = 1;
+    ctl_program(ch, channel[ch].program, channel_instrum_name(ch));
+  }
+}
 
-  if(!IS_CURRENT_MOD_FILE)
-    val += progbase;
-  sprintf(local_buf, "PP%c%d", ch+'A', val);
-  a_pipe_write(local_buf);
+static void
+ctl_program(int ch, int val, void *comm) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+
+  if ((channel[ch].program == DEFAULT_PROGRAM) && (active[ch] == 0) &&
+      (!ISDRUMCHANNEL(ch))) return;
+  active[ch] = 1;
+  if (!IS_CURRENT_MOD_FILE) val += progbase;
+  a_pipe_write("PP%c%d", ch+'A', val);
   if (comm != NULL) {
-    sprintf(local_buf, "I%c%s", ch+'A', (char *)comm);
-    if (ISDRUMCHANNEL(ch))
-      sprintf(local_buf, "I%c%s", ch+'A',
-              (!strlen((char *)comm))? "<drum>":(char *)comm);
-    a_pipe_write(local_buf);
+    a_pipe_write("I%c%s", ch+'A', (!strlen((char *)comm) &&
+                 (ISDRUMCHANNEL(ch)))? "<drum>":(char *)comm);
   }
 }
-static void ctl_drumpart(int ch, int is_drum)
-{
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  if(!ctl.trace_playing) return;
 
-  sprintf(local_buf, "i%c%c", ch+'A', is_drum+'A');;
-  a_pipe_write(local_buf);
+static void
+ctl_drumpart(int ch, int is_drum) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+
+  a_pipe_write("i%c%c", ch+'A', is_drum+'A');
 }
 
-static void ctl_event(CtlEvent *e)
-{
-    switch(e->type)
-    {
+static void
+ctl_event(CtlEvent *e) {
+  switch(e->type) {
     case CTLE_LOADING_DONE:
       break;
     case CTLE_CURRENT_TIME:
@@ -766,6 +941,10 @@ static void ctl_event(CtlEvent *e)
     case CTLE_PLAY_END:
       break;
     case CTLE_TEMPO:
+      ctl_tempo((int)e->v1);
+      break;
+    case CTLE_TIME_RATIO:
+      ctl_timeratio((int)e->v1);
       break;
     case CTLE_METRONOME:
       break;
@@ -814,84 +993,109 @@ static void ctl_event(CtlEvent *e)
     case CTLE_RESET:
       ctl_reset();
       break;
-
-    }
+    case CTLE_MUTE:
+      ctl_mute((int)e->v1, (int)e->v2);
+      break;
+    case CTLE_KEYSIG:
+      ctl_keysig((int)e->v1);
+      break;
+    case CTLE_KEY_OFFSET:
+      ctl_key_offset((int)e->v1);
+      break;
+  }
 }
 
-static void ctl_refresh(void)
-{
-}
+static void
+ctl_refresh(void) { }
 
-static void set_otherinfo(int ch, int val, char c) {
-  if(!ctl.trace_playing) return;
-  if(ch >= MAX_XAW_MIDI_CHANNELS) return;
-  sprintf(local_buf, "P%c%c%d", c, ch+'A', val);
-  a_pipe_write(local_buf);
+static void
+set_otherinfo(int ch, int val, char c) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+  a_pipe_write("P%c%c%d", c, ch+'A', val);
 }
 
-static void ctl_reset(void)
-{
+static void
+ctl_reset(void) {
   int i;
 
-  if(!ctl.trace_playing) return;
+  if (!ctl.trace_playing) return;
 
   indicator_last_update = get_current_calender_time();
+  ctl_tempo((int)current_play_tempo);
+  ctl_timeratio((int)(100 / midi_time_ratio + 0.5));
+  ctl_keysig((int)current_keysig);
+  ctl_key_offset(note_key_offset);
   for (i=0; i<MAX_XAW_MIDI_CHANNELS; i++) {
-    if(ISDRUMCHANNEL(i)) {
-      ctl_program(i, channel[i].bank, channel_instrum_name(i));
-      if (opt_reverb_control)
-        set_otherinfo(i, get_reverb_level(i), 'r');
+    active[i] = 0;
+    if (ISDRUMCHANNEL(i)) {
+      if (opt_reverb_control) set_otherinfo(i, get_reverb_level(i), 'r');
     } else {
-      ToneBank *bank;
-      int b;
-
-      ctl_program(i, channel[i].program, channel_instrum_name(i));
-      b = channel[i].bank;
-      if((bank = tonebank[b]) == NULL
-         || bank->tone[channel[i].program].instrument == NULL)  {
-          b = 0;
-          bank = tonebank[0];
-      }
       set_otherinfo(i, channel[i].bank, 'b');
-      if (opt_reverb_control)
-        set_otherinfo(i, get_reverb_level(i), 'r');
-
-      if(opt_chorus_control)
-        set_otherinfo(i, get_chorus_level(i), 'c');
+      if (opt_reverb_control) set_otherinfo(i, get_reverb_level(i), 'r');
+      if (opt_chorus_control) set_otherinfo(i, get_chorus_level(i), 'c');
     }
+    ctl_program(i, channel[i].bank, channel_instrum_name(i));
     ctl_volume(i, channel[i].volume);
     ctl_expression(i, channel[i].expression);
     ctl_panning(i, channel[i].panning);
     ctl_sustain(i, channel[i].sustain);
-    if(channel[i].pitchbend == 0x2000 && channel[i].mod.val > 0)
+    if ((channel[i].pitchbend == 0x2000) && (channel[i].mod.val > 0))
       ctl_pitch_bend(i, -1);
     else
       ctl_pitch_bend(i, channel[i].pitchbend);
   }
-  sprintf(local_buf, "R");
-  a_pipe_write(local_buf);  
-}
-
-static void update_indicator(void)
-{
-    double t, diff;
-
-    if(!ctl.trace_playing)
-        return;
-    t = get_current_calender_time();
-    diff = t - indicator_last_update;
-    if(diff > XAW_UPDATE_TIME)
-    {
-       sprintf(local_buf, "U");
-       a_pipe_write(local_buf);
-       indicator_last_update = t;
-    }
+  a_pipe_write("R");
+}
+
+static void
+update_indicator(void) {
+  double t, diff;
+
+  if (!ctl.trace_playing) return;
+  t = get_current_calender_time();
+  diff = t - indicator_last_update;
+  if (diff > XAW_UPDATE_TIME) {
+     a_pipe_write("U");
+     indicator_last_update = t;
+  }
+}
+
+static void
+ctl_mute(int ch, int mute) {
+  if ((!ctl.trace_playing) || (ch >= MAX_XAW_MIDI_CHANNELS)) return;
+  a_pipe_write("M%c%d", ch+'A', mute);
+  return;
+}
+
+static void
+ctl_tempo(int tempo) {
+  a_pipe_write("r%d", tempo);
+  return;
+}
+
+
+static void
+ctl_timeratio(int ratio) {
+  a_pipe_write("q%d", ratio);
+  return;
+}
+
+static void
+ctl_keysig(int keysig) {
+  a_pipe_write("p %d", keysig);
+  return;
+}
+
+static void
+ctl_key_offset(int offset) {
+  a_pipe_write("o %d", offset);
+  return;
 }
 
 /*
  * interface_<id>_loader();
  */
-ControlMode *interface_a_loader(void)
-{
+ControlMode *
+interface_a_loader(void) {
     return &ctl;
 }
index 2e11dc9..b74cf86 100644 (file)
 
     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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 
     xaw_i.c - XAW Interface
         from Tomokazu Harada <harada@prince.pe.u-tokyo.ac.jp>
         modified by Yoshishige Arai <ryo2@on.rim.or.jp>
+        modified by Yair Kalvariski <cesium2@gmail.com>
 */
 
 #ifdef HAVE_CONFIG_H
 #include <math.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
+#endif /* HAVE_UNISTD_H */
 #ifndef NO_STRING_H
 #include <string.h>
 #else
 #include <strings.h>
-#endif
+#endif /* NO_STRING_H */
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
 #include <pwd.h>
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
-#include "xaw.h"
-#include <X11/IntrinsicP.h>
-#include <X11/StringDefs.h>
-#include <X11/Xaw/Form.h>
-#include <X11/Xaw/Box.h>
-#include <X11/Xaw/Label.h>
-#include <X11/Xaw/Dialog.h>
-#include <X11/Xaw/AsciiText.h>
+#endif /* HAVE_SYS_STAT_H */
 
-#ifdef OFFIX
-#include <OffiX/DragAndDrop.h>
-#include <OffiX/DragAndDropTypes.h>
-#endif
-#include <X11/Xaw/Toggle.h>
-#include <X11/Xaw/MenuButton.h>
-#include <X11/Xaw/SimpleMenu.h>
-#include <X11/Xaw/SmeLine.h>
-#include <X11/Xaw/SmeBSB.h>
-#include <X11/Xaw/Scrollbar.h>
-#include <X11/Xaw/Cardinals.h>
-#include <X11/Xaw/Simple.h>
-#include <X11/Xaw/List.h>
-#include <X11/Xaw/Viewport.h>
-
-#include "check.xbm"
-#include "arrow.xbm"
-#include "on.xbm"
-#include "off.xbm"
+#include "xaw.h"
+#include "x_trace.h"
 #include "timidity.h"
 #include "common.h"
 #include "instrum.h"
 #include "playmidi.h"
 #include "readmidi.h"
 #include "controls.h"
-#include "timer.h"
 #include "strtab.h"
+#include "arc.h"
 
-#ifndef S_ISDIR
-#define S_ISDIR(mode)   (((mode)&0xF000) == 0x4000)
-#endif /* S_ISDIR */
-
-#define TRACE_WIDTH 627                        /* default height of trace_vport */
-#define TRACEVPORT_WIDTH (TRACE_WIDTH+12)
-#define TRACE_WIDTH_SHORT 388
-#define TRACEV_OFS 22
-#define TRACE_FOOT 16
-#define TRACEH_OFS 0
-#define BAR_SPACE 20
-#define BAR_HEIGHT 16
-static int VOLUME_LABEL_WIDTH = 80;
-#define MAX_TRACE_HEIGHT 560
-#if (MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACE_FOOT+14 > MAX_TRACE_HEIGHT)
-#define TRACE_HEIGHT MAX_TRACE_HEIGHT
-#else
-#define TRACE_HEIGHT (MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACE_FOOT+14)
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#ifdef HAVE_GETPID
+#include <X11/Xatom.h>
 #endif
-#define VOICES_NUM_OFS 6
-#define TTITLE_OFS 120
-#define FILEVPORT_HEIGHT 336
-#define FILEVPORT_WIDTH 272
-
-#define BARSCALE2 0.31111      /* velocity scale   (60-4)/180 */
-#define BARSCALE3 0.28125      /* volume scale     (40-4)/128 */
-#define BARSCALE4 0.25         /* expression scale (36-4)/128 */
-#define BARSCALE5 0.385827     /* expression scale (53-4)/128 */
-static int currwidth = 2;
-static Dimension rotatewidth[] = {TRACE_WIDTH_SHORT, 592, TRACE_WIDTH+8};
-
-typedef struct {
-  int                  col;    /* column number */
-  char                 **cap;  /* caption strings array */
-  int                  *w;     /* column width array */
-  int                  *ofs;   /* column offset array */
-} Tplane;
-static int plane = 0;
-
-#define TCOLUMN 9
-#define T2COLUMN 10
-static char *caption[TCOLUMN] =
-{"ch","  vel"," vol","expr","prog","pan","pit"," instrument",
- "          keyboard"};
-static char *caption2[T2COLUMN] =
-{"ch","  vel"," vol","expr","prog","pan","bnk","reverb","chorus",
- "          keyboard"};
-
-static int BARH_SPACE[TCOLUMN]= {22,60,40,36,36,36,30,106,304};
-#define BARH_OFS0      (TRACEH_OFS)
-#define BARH_OFS1      (BARH_OFS0+22)
-#define BARH_OFS2      (BARH_OFS1+60)
-#define BARH_OFS3      (BARH_OFS2+40)
-#define BARH_OFS4      (BARH_OFS3+36)
-#define BARH_OFS5      (BARH_OFS4+36)
-#define BARH_OFS6      (BARH_OFS5+36)
-#define BARH_OFS7      (BARH_OFS6+30)
-#define BARH_OFS8      (BARH_OFS7+106)
-static int bar0ofs[] = {BARH_OFS0,BARH_OFS1,BARH_OFS2,BARH_OFS3,
-         BARH_OFS4,BARH_OFS5,BARH_OFS6,BARH_OFS7,BARH_OFS8};
-
-static int BARH2_SPACE[T2COLUMN]= {22,60,40,36,36,36,30,53,53,304};
-#define BARH2_OFS0     (TRACEH_OFS)
-#define BARH2_OFS1     (BARH2_OFS0+22)
-#define BARH2_OFS2     (BARH2_OFS1+60)
-#define BARH2_OFS3     (BARH2_OFS2+40)
-#define BARH2_OFS4     (BARH2_OFS3+36)
-#define BARH2_OFS5     (BARH2_OFS4+36)
-#define BARH2_OFS6     (BARH2_OFS5+36)
-#define BARH2_OFS7     (BARH2_OFS6+30)
-#define BARH2_OFS8     (BARH2_OFS7+53)
-#define BARH2_OFS9     (BARH2_OFS8+53)
-static int bar1ofs[] = {BARH2_OFS0,BARH2_OFS1,BARH2_OFS2,BARH2_OFS3,
-         BARH2_OFS4,BARH2_OFS5,BARH2_OFS6,BARH2_OFS7,BARH2_OFS8,BARH2_OFS9};
-
-static Tplane pl[] = {
-  {TCOLUMN, caption, BARH_SPACE, bar0ofs},
-  {T2COLUMN, caption2, BARH2_SPACE, bar1ofs},
-};
 
-#define CL_C 0 /* column 0 = channel */
-#define CL_VE 1        /* column 1 = velocity */
-#define CL_VO 2        /* column 2 = volume */
-#define CL_EX 3        /* column 3 = expression */
-#define CL_PR 4        /* column 4 = program */
-#define CL_PA 5        /* column 5 = panning */
-#define CL_PI 6        /* column 6 = pitch bend */
-#define CL_IN 7        /* column 7 = instrument name */
+#include XAWINCDIR(AsciiText.h)
+#include XAWINCDIR(Box.h)
+#include XAWINCDIR(Cardinals.h)
+#include XAWINCDIR(Dialog.h)
+#include XAWINCDIR(Form.h)
+#include XAWINCDIR(Label.h)
+#include XAWINCDIR(List.h)
+#include XAWINCDIR(MenuButton.h)
+#include XAWINCDIR(Paned.h)
+#include XAWINCDIR(Scrollbar.h)
+#include XAWINCDIR(Simple.h)
+#include XAWINCDIR(SimpleMenu.h)
+#include XAWINCDIR(SmeBSB.h)
+#include XAWINCDIR(SmeLine.h)
+#if defined(HAVE_TIP) && !defined(XAWPLUS)
+#include XAWINCDIR(Tip.h)
+#endif /* HAVE_TIP && !XAWPLUS */
+#include XAWINCDIR(Toggle.h)
+#ifdef XawTraversal
+#include XAWINCDIR(Traversal.h)
+#endif /* XawTraversal */
+#include XAWINCDIR(Viewport.h)
 
-#define CL_BA  6       /* column 6 = bank */
-#define CL_RE  7       /* column 7 = reverb */
-#define CL_CH  8       /* column 8 = chorus */
+#ifdef OFFIX
+#include <OffiX/DragAndDrop.h>
+#include <OffiX/DragAndDropTypes.h>
+#endif /* OFFIX */
+#ifdef XDND
+#include "xdnd.h"
+#endif /* XDND */
+
+#include "bitmaps/arrow.xbm"
+#include "bitmaps/back.xbm"
+#include "bitmaps/check.xbm"
+#include "bitmaps/fast.xbm"
+#include "bitmaps/fwrd.xbm"
+#include "bitmaps/keyup.xbm"
+#include "bitmaps/keydown.xbm"
+#include "bitmaps/next.xbm"
+#include "bitmaps/on.xbm"
+#include "bitmaps/off.xbm"
+#include "bitmaps/pause.xbm"
+#include "bitmaps/play.xbm"
+#include "bitmaps/prev.xbm"
+#include "bitmaps/quit.xbm"
+#include "bitmaps/random.xbm"
+#include "bitmaps/repeat.xbm"
+#include "bitmaps/slow.xbm"
+#include "bitmaps/stop.xbm"
+#include "bitmaps/timidity.xbm"
 
-#define INST_NAME_SIZE 16
-#define INIT_FLISTNUM MAX_DIRECTORY_ENTRY
-static char *inst_name[MAX_XAW_MIDI_CHANNELS];
-static int disp_inst_name_len = 13;
-#define UNTITLED_STR "<No Title>"
+#ifndef S_ISDIR
+#define S_ISDIR(mode)   (((mode)&0xF000) == 0x4000)
+#endif /* S_ISDIR */
 
-typedef struct {
-  int                  id;
-  String               name;
-  Boolean              trap;
-  Boolean              bmflag;
-  Widget               widget;
-} ButtonRec;
+#define DEFAULT_REG_WIDTH      400 /* default width when not in trace mode */
 
-typedef struct {
-  int                  id;
-  int                  bit;
-  Widget               widget;
-} OptionRec;
+#define INIT_FLISTNUM MAX_DIRECTORY_ENTRY
 
+#define MAX_POPUPNAME 15
+#define MAX_FILTER 20
+#define POPUP_HEIGHT 400
+#define PANE_HEIGHT 200
+#define INFO_HEIGHT 20
+#define ran() (int) (51.0 * (rand() / (RAND_MAX + 1.0))) - 25;
 
 typedef struct {
   char *dirname;
   char *basename;
 } DirPath;
 
-void a_print_text(Widget,char *);
-static void drawProg(int,int,int,int,Boolean),drawPan(int,int,Boolean),
-  draw1Chan(int,int,char),drawVol(int,int),drawExp(int,int),drawPitch(int,int),
-  drawInstname(int,char *),drawDrumPart(int,int),drawBank(int,int),
-  drawReverb(int,int),drawChorus(int,int),drawVoices(void),drawTitle(char *),
-  quitCB(),playCB(),pauseCB(),stopCB(),prevCB(),nextCB(),
-  optionsCB(),optionspopupCB(),optionscloseCB(),chorusCB(),optionsdestroyCB(),
-  flistpopupCB(),flistcloseCB(),
-  forwardCB(),backCB(),repeatCB(),randomCB(),menuCB(),sndspecCB(),
-  volsetCB(),volupdownCB(),tuneslideCB(),filemenuCB(),
-  fselectCB(),fdeleteCB(),fdelallCB(),backspaceCB(),aboutCB(),aboutcloseCB(),
-#ifndef WIDGET_IS_LABEL_WIDGET
-  deleteTextCB(),
-#endif
-  toggleMark(),popupLoad(),popdownLoad(),volupdownAction(),tuneslideAction(),
-  tunesetAction(),a_readconfig(),a_saveconfig(),filemenuAction(),
-  setDirAction(),setDirList(),
-  drawBar(),redrawTrace(Boolean),completeDir(),ctl_channel_note(),
-  drawKeyboardAll(),draw1Note(),redrawAction(),redrawCaption(),
-  exchgWidth(),toggletrace(),
-  checkRightAndPopupSubmenu(),popdownSubmenuCB(),popdownSubmenu(),leaveSubmenu(),
-  addOneFile(int,int,char *,Boolean),
-  flistMove(),closeParent(),createOptions(),createFlist();
-static char *expandDir(),*strmatch();
-static int configcmp();
-static void pauseAction(),soundkeyAction(),speedAction(),voiceAction();
-static Boolean IsTracePlaying(),IsEffectiveFile();
-extern void a_pipe_write(char *);
-extern int a_pipe_read(char *,int);
-extern int a_pipe_nread(char *buf, int n);
-static void initStatus(void);
-static void xaw_vendor_setup(void);
-static void safe_getcwd(char *cwd, int maxlen);
-
-static Widget title_mb,title_sm,time_l,popup_load,popup_load_f,load_d,load_t;
-static Widget load_vport,load_flist,cwd_l,load_info, lyric_t;
-static Dimension lyric_height, base_height, text_height;
-static GC gc,gcs,gct,gc_xcopy;
-static Pixel bgcolor,menubcolor,textcolor,textbgcolor,text2bgcolor,buttonbgcolor,
-  buttoncolor,togglecolor,tracecolor,volcolor,expcolor,pancolor,capcolor,rimcolor,
-  boxcolor,suscolor,playcolor,revcolor,chocolor;
-static Pixel black,white;
-static Pixel barcol[MAX_XAW_MIDI_CHANNELS];
-
-static Widget toplevel,m_box,base_f,file_mb,file_sm,bsb,
-  quit_b,play_b,pause_b,stop_b,prev_b,next_b,fwd_b,back_b,
-  random_b,repeat_b,b_box,v_box,t_box,vol_l0,vol_l,vol_bar,tune_l0,tune_l,tune_bar,
-  trace_vport,trace,pbox,popup_opt,popup_optbox,popup_oclose,
-  popup_about,popup_abox,popup_aok,about_lbl[5],
-  file_vport,file_list,popup_file,popup_fbox,flist_cmdbox,
-  popup_fplay,popup_fdelete,popup_fdelall,popup_fclose,
-  modul_b,porta_b,nrpnv_b,chpressure_b,txtmeta_b,overlapv_b,reverb_b,chorus_b,
-  modul_l,porta_l,nrpnv_l,chpressure_l,txtmeta_l,overlapv_l,reverb_l,chorus_l,
-  modul_bb,porta_bb,nrpnv_bb,chpressure_bb,txtmeta_bb,overlapv_bb,reverb_bb,chorus_bb;
+typedef struct {
+  String *StringArray;
+  unsigned int number;
+} StringList;
+
+typedef struct {
+ char ld_basepath[PATH_MAX];
+ char ld_popupname[MAX_POPUPNAME];
+ Widget ld_popup_load;
+ Widget ld_load_d;
+ Widget ld_load_b;
+ Widget ld_load_ok;
+ Widget ld_load_pane;
+ Widget ld_load_vport;
+ Widget ld_load_vportdir;
+ Widget ld_load_flist;
+ Widget ld_load_dlist;
+ Widget ld_cwd_l;
+ Widget ld_load_info;
+ Dimension ld_ldwidth;
+ Dimension ld_ldheight;
+ StringList ld_fdirlist;
+ StringList ld_fulldirlist;
+ StringList ld_ddirlist;
+ char ld_filter[MAX_FILTER];
+ char ld_cur_filter[MAX_FILTER];
+} load_dialog;
+
+typedef load_dialog *ldPointer;
+
+typedef struct {
+ ldPointer ld;
+ char *name; 
+ struct ldStore *next;
+} ldStore;
+
+typedef ldStore *ldStorePointer;
+
+static ldStorePointer ldSstart;
+static ldPointer ld;
+
+#define basepath ld->ld_basepath
+#define popupname ld->ld_popupname
+#define popup_load ld->ld_popup_load
+#define load_d ld->ld_load_d
+#define load_b ld->ld_load_b
+#define load_ok ld->ld_load_ok
+#define load_pane ld->ld_load_pane
+#define load_vport ld->ld_load_vport
+#define load_vportdir ld->ld_load_vportdir
+#define load_flist ld->ld_load_flist
+#define load_dlist ld->ld_load_dlist
+#define cwd_l ld->ld_cwd_l
+#define load_info ld->ld_load_info
+#define ldwidth ld->ld_ldwidth
+#define ldheight ld->ld_ldheight
+#define fdirlist ld->ld_fdirlist.StringArray
+#define filenum ld->ld_fdirlist.number
+#define fulldirlist ld->ld_fulldirlist.StringArray
+#define fullfilenum ld->ld_fulldirlist.number
+#define ddirlist ld->ld_ddirlist.StringArray
+#define dirnum ld->ld_ddirlist.number
+#define filter ld->ld_filter
+#define cur_filter ld->ld_cur_filter
+
+#define LISTDIALOGBASENAME "dialog_list"
+
+static Widget toplevel, m_box, base_f, file_mb, file_sm, bsb, quit_b, play_b,
+  pause_b, stop_b, prev_b, next_b, fwd_b, back_b, random_b, repeat_b,
+  fast_b, slow_b, keyup_b, keydown_b, b_box, v_box, t_box, vol_l0,
+  vol_l, vol_bar, tune_l0, tune_l, tune_bar, trace_vport, trace, file_vport,
+  file_list, title_mb, title_sm, time_l, lyric_t, chorus_b,
+  popup_file = NULL, popup_opt = NULL;
 static Widget *psmenu = NULL;
-static char local_buf[300];
-static char window_title[300], *w_title;
+#ifndef TimNmenu
+/* We'll be using XAWs implementation of submenus (XtNmenuName).
+ * If its parameter isn't constantly available, it will fail to work.
+ */
+static String *sb;
+#endif /* !TimNmenu */
+static char local_buf[PIPE_LENGTH];
+static char window_title[300];
+static char *home;
 int amplitude = DEFAULT_AMPLIFICATION;
 
-#ifndef XAW_BITMAP_DIR
-#define XAW_BITMAP_DIR PKGLIBDIR "/bitmaps"
-#endif /* XAW_BITMAP_DIR */
+static int maxentry_on_a_menu = 0, current_n_displayed = 0;
+static long submenu_n = 0;
+#define IsRealized(w) (((w) != NULL) && (XtIsRealized(w)))
 
-String bitmapdir = XAW_BITMAP_DIR;
-Boolean arrangetitle,savelist;
-static char **current_flist = NULL;
-static int xaw_i_voices = 0, last_voice = 0, voices_num_width;
-static int maxentry_on_a_menu = 0,submenu_n = 0;
-#define OPTIONS_WINDOW 1
-#define FLIST_WINDOW 2
-#define ABOUT_WINDOW 4
-static int popup_shell_exist = 0;
+static Boolean lockevents = False;
+/*
+ * There's a race condition, where after writing a request to the pipe
+ * which changes the current song (like "N" for next song) events from
+ * the (then current) song still pass through, but are counted
+ * as events from the next song. This variable is used for rudimentary
+ * locking to prevent such events from influencing the trace display.
+ */
 
 typedef struct {
-  Boolean              confirmexit;
-  Boolean              repeat;
-  Boolean              autostart;
-  Boolean              autoexit;
-  Boolean              hidetext;
-  Boolean              shuffle;
-  Boolean              disptrace;
-  int                  amplitude;
-  int                  extendopt;
-  int                  chorusopt;
+  Boolean      confirmexit;
+  Boolean      repeat;
+  Boolean      autostart;
+  Boolean      autoexit;
+  Boolean      disptext;
+  Boolean      shuffle;
+  Boolean      disptrace;
+  int          amplitude;
+  int          extendopt;
+  int          chorusopt;
+  Boolean      tooltips;
+  Boolean      showdotfiles;
+  char         *DefaultDir;
+  Boolean      save_list;
 } Config;
 
-#define FLAG_NOTE_OFF   1
-#define FLAG_NOTE_ON    2
-#define FLAG_BANK       1
-#define FLAG_PROG       2
-#define FLAG_PROG_ON    4
-#define FLAG_PAN        8
-#define FLAG_SUST       16
-#define FLAG_BENDT             32
-typedef struct {
-  int reset_panel;
-  int multi_part;
-  char v_flags[MAX_XAW_MIDI_CHANNELS];
-  int16 cnote[MAX_XAW_MIDI_CHANNELS];
-  int16 cvel[MAX_XAW_MIDI_CHANNELS];
-  int16 ctotal[MAX_XAW_MIDI_CHANNELS];
-  int16 bank[MAX_XAW_MIDI_CHANNELS];
-  int16 reverb[MAX_XAW_MIDI_CHANNELS];  
-  char c_flags[MAX_XAW_MIDI_CHANNELS];
-  Channel channel[MAX_XAW_MIDI_CHANNELS];
-  int is_drum[MAX_XAW_MIDI_CHANNELS];
-} PanelInfo;
-
-/* Default configuration to execute Xaw interface */
-/* (confirmexit repeat autostart autoexit hidetext shuffle disptrace amplitude) */
-Config Cfg = { False, False, True, False, False, False, True,
-               DEFAULT_AMPLIFICATION, DEFAULT_OPTIONS, DEFAULT_CHORUS };
-static PanelInfo *Panel;
+/* Default configuration for Xaw interface */
+/* (confirmexit repeat autostart autoexit disptext shuffle disptrace amplitude
+    options chorus tooltips showdotfiles defaultdir savelist) */
+static Config Cfg = {
+  False, False, True, False, True, False, False,
+  DEFAULT_AMPLIFICATION, DEFAULT_OPTIONS, DEFAULT_CHORUS,
+#ifndef XAW3D
+  True,
+#else
+/* The Xaw3d v1.5E tooltip function is surprisingly slow. */
+  False,
+#endif /* !XAW3D */
+  False, NULL, True
+};
 
-typedef struct {
-  int y;
-  int l;
-} KeyL;
+enum {
+  S_ConfirmExit = 0,
+  S_RepeatPlay,
+  S_AutoStart,
+  S_DispText,
+  S_DispTrace,
+  S_CurVol,
+  S_ShufflePlay,
+  S_AutoExit,
+  S_ExtOptions,
+  S_ChorusOption,
+  S_Tooltips,
+  S_Showdotfiles,
+  S_DefaultDirectory,
+  S_SaveList,
+  S_MidiFile,
+  CFGITEMSNUMBER
+};
 
-typedef struct {
-  KeyL k[3];
-  int xofs;
-  Pixel col;
-} ThreeL;
-static ThreeL *keyG;
-#define KEY_NUM 111
-
-#define MAXBITMAP 10
-static char *bmfname[] = {
-  "back.xbm","fwrd.xbm","next.xbm","pause.xbm","play.xbm","prev.xbm",
-  "quit.xbm","stop.xbm","random.xbm","repeat.xbm",(char *)NULL
+static const char *cfg_items[CFGITEMSNUMBER] = {
+  "ConfirmExit", "RepeatPlay", "AutoStart", "Disp:text", "Disp:trace",
+  "CurVol", "ShufflePlay", "AutoExit", "ExtOptions", "ChorusOption",
+  "Tooltips", "Showdotfiles", "DefaultDir", "SaveList", "File",
 };
-static char *iconname = "timidity.xbm";
-#define BM_BACK                        0
-#define BM_FWRD                        1
-#define BM_NEXT                        2
-#define BM_PAUSE               3
-#define BM_PLAY                        4
-#define BM_PREV                        5
-#define BM_QUIT                        6
-#define BM_STOP                        7
-#define BM_RANDOM              8
-#define BM_REPEAT              9
-static char *dotfile = NULL;
 
-char *cfg_items[]= {"Tracing", "ConfirmExit", "Disp:file", "Disp:volume",
-               "Disp:button", "RepeatPlay", "AutoStart", "Disp:text",
-               "Disp:time", "Disp:trace", "CurVol", "ShufflePlay",
-               "AutoExit", "CurFileMode", "ExtOptions", "ChorusOption","File"};
-#define S_Tracing 0
-#define S_ConfirmExit 1
-#define S_DispFile 2
-#define S_DispVolume 3 
-#define S_DispButton 4
-#define S_RepeatPlay 5
-#define S_AutoStart 6
-#define S_DispText 7
-#define S_DispTime 8
-#define S_DispTrace 9
-#define S_CurVol 10
-#define S_ShufflePlay 11
-#define S_AutoExit 12
-#define S_CurFileMode 13
-#define S_ExtOptions 14
-#define S_ChorusOption 15
-#define S_MidiFile 16
-#define CFGITEMSNUMBER 17
-
-#define COMMON_BGCOLOR "gray67"
-#define COMMANDBUTTON_COLOR "gray78"
-#define TEXTBG_COLOR "gray82"
+#define COMMON_BGCOLOR         "gray67"
+#define COMMANDBUTTON_COLOR    "gray78"
+#define TEXTBG_COLOR           "gray82"
+
+typedef struct {
+  char id_char;
+  char *id_name;
+} id_list;
+
+typedef struct {
+  id_list *output_list;
+  unsigned short max;
+  unsigned short current;
+  unsigned short def;
+  char *lbuf;
+  Widget formatGroup;
+  Widget *toggleGroup;
+} outputs;
 
 static Display *disp;
-static int screen;
-static Pixmap check_mark, arrow_mark, on_mark, off_mark, layer[2];
-
-static int bm_height[MAXBITMAP], bm_width[MAXBITMAP],
-  x_hot,y_hot, root_height, root_width;
-static Pixmap bm_Pixmap[MAXBITMAP];
-static int max_files, init_options = 0, init_chorus = 0;
-static char basepath[PATH_MAX];
-static String *dirlist = NULL, dirlist_top, *flist = NULL;
-static Dimension trace_width, trace_height, menu_width;
-static int total_time = 0, curr_time;
-static float thumbj;
-static XFontStruct *labelfont,*volumefont,*tracefont;
-#ifdef I18N
-static XFontSet ttitlefont;
-static XFontStruct *ttitlefont0;
-static char **ml;
-static XFontStruct **fs_list;
-#else
-static XFontStruct *ttitlefont;
-#define ttitlefont0 ttitlefont
-#endif
+static Atom wm_delete_window;
+#ifdef HAVE_GETPID
+static Atom net_wm_pid;
+static pid_t pid;
+#endif /* HAVE_GETPID */
+static XtAppContext app_con;
+static Pixmap check_mark, arrow_mark, on_mark, off_mark;
+
+#define GET_BITMAP(Pix) XCreateBitmapFromData(disp, \
+                        RootWindowOfScreen(XtScreen(toplevel)), \
+                        (char *)Pix##_bits, Pix##_width, Pix##_height)
+
+#ifdef XDND
+static DndClass _DND;
+static DndClass *dnd = &_DND;
+#endif /* XDND */
+
+static int root_height, root_width;
+static Dimension curr_width, curr_height, base_height, lyric_height,
+       trace_v_height;
+static int max_files = 0,
+           init_options = DEFAULT_OPTIONS, init_chorus = DEFAULT_CHORUS;
+static outputs *record, *play;
+static Boolean recording = False;
+static String *flist = NULL;
+static int max_num = INIT_FLISTNUM;
+static int total_time = 0, curr_time, halt = 0;
+
+typedef enum {
+  NORESPONSE = -1,
+  OK,
+  CANCEL
+} resvalues;
+typedef struct {
+  resvalues val;
+  Widget widget;
+} resvar;
+static resvar response = {NORESPONSE, NULL};
 
 static struct _app_resources {
-  String bitmap_dir;
-  Boolean arrange_title,save_list,gradient_bar;
-  Dimension text_height,trace_width,trace_height,menu_width;
-  Pixel common_fgcolor,common_bgcolor,menub_bgcolor,text_bgcolor,text2_bgcolor,
-       toggle_fgcolor,button_fgcolor,button_bgcolor,
-       velocity_color,drumvelocity_color,volume_color,expr_color,pan_color,
-       trace_bgcolor,rim_color,box_color,caption_color,sus_color,white_key_color,black_key_color,play_color,
-       rev_color,cho_color;
-  XFontStruct *label_font,*volume_font,*trace_font;
-  String more_text,file_text;
-#ifdef I18N
-  XFontSet text_font, ttitle_font;
-#else
-  XFontStruct *text_font, *ttitle_font;
-#endif
+  tconfig tracecfg;
+  Boolean arrange_title;
+  Dimension text_height, menu_width;
+  Pixel common_bgcolor, menub_bgcolor, text2_bgcolor, toggle_fgcolor,
+        button_fgcolor, button_bgcolor;
+  String more_text, file_text, no_playing;
+  XFontSet label_font, volume_font, text_font;
+  String labelfile, popup_confirm, load_LISTDIALOGBASENAME_title,
+         save_LISTDIALOGBASENAME_title;
 } app_resources;
 
-static XtResource xaw_resources[] ={
-#define offset(entry) XtOffset(struct _app_resources*, entry)
-  {"bitmapDir", "BitmapDir", XtRString, sizeof(String),
-   offset(bitmap_dir), XtRString, XAW_BITMAP_DIR },
-  {"arrangeTitle", "ArrangeTitle", XtRBoolean, sizeof(Boolean),
-   offset(arrange_title), XtRImmediate, (XtPointer)False},
-  {"saveList", "SaveList", XtRBoolean, sizeof(Boolean),
-   offset(save_list), XtRImmediate, (XtPointer)True},
-  {"gradientBar", "GradientBar", XtRBoolean, sizeof(Boolean),
-   offset(gradient_bar), XtRImmediate, (XtPointer)False},
-#ifdef WIDGET_IS_LABEL_WIDGET
-  {"textLHeight", "TextLHeight", XtRShort, sizeof(short),
-   offset(text_height), XtRImmediate, (XtPointer)30},
-#else
-  {"textHeight", "TextHeight", XtRShort, sizeof(short),
-   offset(text_height), XtRImmediate, (XtPointer)120},
-#endif
-  {"traceWidth", "TraceWidth", XtRShort, sizeof(short),
-   offset(trace_width), XtRImmediate, (XtPointer)TRACE_WIDTH},
-  {"traceHeight", "TraceHeight", XtRShort, sizeof(short),
-   offset(trace_height), XtRImmediate, (XtPointer)TRACE_HEIGHT},
-  {"menuWidth", "MenuWidth", XtRShort, sizeof(Dimension),
-   offset(menu_width), XtRImmediate, (XtPointer)200},
-  {"foreground", XtCForeground, XtRPixel, sizeof(Pixel),
-   offset(common_fgcolor), XtRString, "black"},
-  {"background", XtCBackground, XtRPixel, sizeof(Pixel),
-   offset(common_bgcolor), XtRString, COMMON_BGCOLOR},
-  {"menubutton", "MenuButtonBackground", XtRPixel, sizeof(Pixel),
-   offset(menub_bgcolor), XtRString, "#CCFF33"},
-  {"textbackground", "TextBackground", XtRPixel, sizeof(Pixel),
-   offset(text_bgcolor), XtRString, TEXTBG_COLOR},
-  {"text2background", "Text2Background", XtRPixel, sizeof(Pixel),
-   offset(text2_bgcolor), XtRString, "gray80"},
-  {"toggleforeground", "ToggleForeground", XtRPixel, sizeof(Pixel),
-   offset(toggle_fgcolor), XtRString, "MediumBlue"},
-  {"buttonforeground", "ButtonForeground", XtRPixel, sizeof(Pixel),
-   offset(button_fgcolor), XtRString, "blue"},
-  {"buttonbackground", "ButtonBackground", XtRPixel, sizeof(Pixel),
-   offset(button_bgcolor), XtRString, COMMANDBUTTON_COLOR},
-  {"velforeground", "VelForeground", XtRPixel, sizeof(Pixel),
-   offset(velocity_color), XtRString, "orange"},
-  {"veldrumforeground", "VelDrumForeground", XtRPixel, sizeof(Pixel),
-   offset(drumvelocity_color), XtRString, "red"},
-  {"volforeground", "VolForeground", XtRPixel, sizeof(Pixel),
-   offset(volume_color), XtRString, "LightPink"},
-  {"expforeground", "ExpForeground", XtRPixel, sizeof(Pixel),
-   offset(expr_color), XtRString, "aquamarine"},
-  {"panforeground", "PanForeground", XtRPixel, sizeof(Pixel),
-   offset(pan_color), XtRString, "blue"},
-  {"tracebackground", "TraceBackground", XtRPixel, sizeof(Pixel),
-   offset(trace_bgcolor), XtRString, "gray90"},
-  {"rimcolor", "RimColor", XtRPixel, sizeof(Pixel),
-   offset(rim_color), XtRString, "gray20"},
-  {"boxcolor", "BoxColor", XtRPixel, sizeof(Pixel),
-   offset(box_color), XtRString, "gray76"},
-  {"captioncolor", "CaptionColor", XtRPixel, sizeof(Pixel),
-   offset(caption_color), XtRString, "DarkSlateGrey"},
-  {"sustainedkeycolor", "SustainedKeyColor", XtRPixel, sizeof(Pixel),
-   offset(sus_color), XtRString, "red4"},
-  {"whitekeycolor", "WhiteKeyColor", XtRPixel, sizeof(Pixel),
-   offset(white_key_color), XtRString, "white"},
-  {"blackkeycolor", "BlackKeyColor", XtRPixel, sizeof(Pixel),
-   offset(black_key_color), XtRString, "black"},
-  {"playingkeycolor", "PlayingKeyColor", XtRPixel, sizeof(Pixel),
-   offset(play_color), XtRString, "maroon1"},
-  {"reverbcolor", "ReverbColor", XtRPixel, sizeof(Pixel),
-   offset(rev_color), XtRString, "PaleGoldenrod"},
-  {"choruscolor", "ChorusColor", XtRPixel, sizeof(Pixel),
-   offset(cho_color), XtRString, "yellow"},
-  {"labelfont", "LabelFont", XtRFontStruct, sizeof(XFontStruct *),
-   offset(label_font), XtRString, "-adobe-helvetica-bold-r-*-*-14-*-75-75-*-*-*-*"},
-  {"volumefont", "VolumeFont", XtRFontStruct, sizeof(XFontStruct *),
-   offset(volume_font), XtRString, "-adobe-helvetica-bold-r-*-*-12-*-75-75-*-*-*-*"},
-#ifdef I18N
-  {"textfontset", "TextFontSet", XtRFontSet, sizeof(XFontSet),
-   offset(text_font), XtRString, "-*-*-medium-r-normal--14-*-*-*-*-*-*-*"},
-  {"ttitlefont", "TtitleFont", XtRFontSet, sizeof(XFontSet),
-   offset(ttitle_font), XtRString, "-*-fixed-medium-r-normal--14-*-*-*-*-*-*-*"},
-#else
-  {"textfont", XtCFont, XtRFontStruct, sizeof(XFontStruct *),
-   offset(text_font), XtRString, "-*-fixed-medium-r-normal--14-*-*-*-*-*-*-*"},
-  {"ttitlefont", "Ttitlefont", XtRFontStruct, sizeof(XFontStruct *),
-   offset(ttitle_font), XtRString, "-adobe-helvetica-bold-o-*-*-14-*-75-75-*-*-*-*"},
-#endif
-  {"tracefont", "TraceFont", XtRFontStruct, sizeof(XFontStruct *),
-   offset(trace_font), XtRString, "7x14"},
-  {"labelfile", "LabelFile", XtRString, sizeof(String),
-   offset(file_text), XtRString, "file..."},
-#undef offset
-};
-
-enum {
-    ID_LOAD = 100,
-    ID_SAVECONFIG,
-    ID_HIDETXT,
-    ID_HIDETRACE,
-    ID_SHUFFLE,
-    ID_REPEAT,
-    ID_AUTOSTART,
-    ID_AUTOQUIT,
-    ID_LINE,
-    ID_FILELIST,
-    ID_OPTIONS,
-    ID_LINE2,
-    ID_ABOUT,
-    ID_QUIT,
-};
-#define IDS_SAVECONFIG  "101"
-#define IDS_HIDETXT     "102"
-#define IDS_HIDETRACE   "103"
-#define IDS_SHUFFLE     "104"
-#define IDS_REPEAT      "105"
-#define IDS_AUTOSTART   "106"
-#define IDS_AUTOQUIT    "107"
-#define IDS_FILELIST    "109"
-#define IDS_OPTIONS     "110"
-#define IDS_ABOUT       "112"
+#define capcolor       app_resources.tracecfg.caption_color
+#define bgcolor                app_resources.common_bgcolor
+#define buttonbgcolor  app_resources.button_bgcolor
+#define buttoncolor    app_resources.button_fgcolor
+#define menubcolor     app_resources.menub_bgcolor
+#define textcolor      app_resources.tracecfg.common_fgcolor
+#define textbgcolor    app_resources.tracecfg.text_bgcolor
+#define text2bgcolor   app_resources.text2_bgcolor
+#define togglecolor    app_resources.toggle_fgcolor
+
+#define ID_LOAD                        100
+#define ID_SAVE                        101
+#define ID_LOAD_PLAYLIST       102
+#define ID_SAVE_PLAYLIST       103
+#define ID_SAVECONFIG          104
+#define ID_HIDETXT             105
+#define ID_HIDETRACE           106
+#define ID_SHUFFLE             107
+#define ID_REPEAT              108
+#define ID_AUTOSTART           109
+#define ID_AUTOQUIT            110
+#define ID_LINE                        111
+#define ID_FILELIST            112
+#define ID_OPTIONS             113
+#define ID_LINE2               114
+#define ID_ABOUT               115
+#define ID_QUIT                        116
+
+#define R(x) #x
+#define S(x) R(x)
 
+typedef struct {
+  const int    id;
+  const String name;
+  WidgetClass  *class;
+  Widget       widget;
+} ButtonRec;
 
 static ButtonRec file_menu[] = {
-  {ID_LOAD, "load", True, False},
-  {ID_SAVECONFIG, "saveconfig", True, False},
-  {ID_HIDETXT, "hidetext", True, False},
-  {ID_HIDETRACE, "hidetrace", True, False},
-  {ID_SHUFFLE, "shuffle", True, False},
-  {ID_REPEAT, "repeat", True, False},
-  {ID_AUTOSTART, "autostart", True, False},
-  {ID_AUTOQUIT, "autoquit", True, False},
-  {ID_LINE, "line", False, False},
-  {ID_FILELIST, "filelist", True, False},
-  {ID_OPTIONS, "modes", True, False},
-  {ID_LINE2, "line2", False, False},
-  {ID_ABOUT, "about", True, False},
-  {ID_QUIT, "quit", True, False},
+  {ID_LOAD, "load", &smeBSBObjectClass},
+  {ID_SAVE, "save", &smeBSBObjectClass},
+  {ID_LOAD_PLAYLIST, "load_playlist", &smeBSBObjectClass},
+  {ID_SAVE_PLAYLIST, "save_playlist", &smeBSBObjectClass},
+  {ID_SAVECONFIG, "saveconfig", &smeBSBObjectClass},
+  {ID_HIDETXT, "hidetext", &smeBSBObjectClass},
+  {ID_HIDETRACE, "hidetrace", &smeBSBObjectClass},
+  {ID_SHUFFLE, "shuffle", &smeBSBObjectClass},
+  {ID_REPEAT, "repeat", &smeBSBObjectClass},
+  {ID_AUTOSTART, "autostart", &smeBSBObjectClass},
+  {ID_AUTOQUIT, "autoquit", &smeBSBObjectClass},
+  {ID_LINE, "line", &smeLineObjectClass},
+  {ID_FILELIST, "filelist", &smeBSBObjectClass},
+  {ID_OPTIONS, "modes", &smeBSBObjectClass},
+  {ID_LINE2, "line2", &smeLineObjectClass},
+  {ID_ABOUT, "about", &smeBSBObjectClass},
+  {ID_QUIT, "quit", &smeBSBObjectClass},
 };
 
+typedef struct {
+  const int    bit;
+  Widget       widget;
+} OptionRec;
+
 static OptionRec option_num[] = {
-  {MODUL_N, MODUL_BIT},
-  {PORTA_N, PORTA_BIT},
-  {NRPNV_N, NRPNV_BIT},
-  {REVERB_N, REVERB_BIT},
-  {CHPRESSURE_N, CHPRESSURE_BIT},
-  {OVERLAPV_N, OVERLAPV_BIT},
-  {TXTMETA_N, TXTMETA_BIT},
+  {MODUL_BIT, NULL},
+  {PORTA_BIT, NULL},
+  {NRPNV_BIT, NULL},
+  {REVERB_BIT, NULL},
+  {CHPRESSURE_BIT, NULL},
+  {OVERLAPV_BIT, NULL},
+  {TXTMETA_BIT, NULL},
 };
 
-static void offPauseButton(void) {
+typedef union {
+  float f;
+  XtArgVal x;
+} barfloat;
+
+static char *dotfile = NULL;
+static char **dotfile_flist;
+static int dot_nfile = 0;
+#define SPREFIX "set "
+#define SPLEN 4
+#define SLINELEN PATH_MAX+SPLEN+20
+
+static void a_init_interface(int);
+void a_start_interface(int);
+extern void a_pipe_write(const char *, ...);
+extern int a_pipe_read(char *, size_t);
+extern int a_pipe_nread(char *, size_t);
+extern void a_pipe_sync(void);
+static void a_print_text(Widget, char *);
+static void a_print_msg(Widget);
+static void handle_input(XtPointer, int *, XtInputId *);
+
+static void a_readconfig(Config *, char **);
+static void a_saveconfig(char *, Boolean);
+static void aboutACT(Widget, XEvent *, String *, Cardinal *);
+static void addOneFile(int, long, char *);
+static void addFlist(char *, long);
+static void backspaceACT(Widget, XEvent *, String *, Cardinal *);
+static void backCB(Widget, XtPointer, XtPointer);
+static void callFilterDirList(Widget, XtPointer, XtPointer);
+static void callRedrawTrace(Boolean);
+static void callInitTrace(void);
+static void cancelACT(Widget, XEvent *, String *, Cardinal *);
+static void cancelCB(Widget, XtPointer, XtPointer);
+static char *canonicalize_path(char *);
+#ifdef TimNmenu
+static void checkRightAndPopupSubmenuACT(Widget, XEvent *, String *,Cardinal *);
+#endif /* TimNmenu */
+#ifdef CLEARVALUE
+static void clearValue(Widget);
+#endif /* CLEARVALUE */
+static void closeParentACT(Widget, XEvent *, String *, Cardinal *);
+static void closeWidgetCB(Widget, XtPointer, XtPointer);
+static int configcmp(char *, int *);
+static int confirmCB(Widget, char *, Boolean);
+static void completeDirACT(Widget , XEvent *, String *, Cardinal *);
+static void createBars(void);
+static void createButtons(void);
+static void createDialog(Widget, ldPointer);
+static void createFlist(void);
+static void createOptions(void);
+static void createTraceWidgets(void);
+static Widget
+  createOutputSelectionWidgets(Widget, Widget, Widget, outputs *, Boolean);
+#ifndef WIDGET_IS_LABEL_WIDGET
+static void deleteTextACT(Widget, XEvent *, String *, Cardinal *);
+#endif /* !WIDGET_IS_LABEL_WIDGET */
+static void destroyWidgetCB(Widget, XtPointer, XtPointer);
+static void downACT(Widget, XEvent *, String *, Cardinal *);
+static void exchgWidthACT(Widget, XEvent *, String *, Cardinal *);
+static char *expandDir(char *, DirPath *, char *);
+static void fdelallCB(Widget, XtPointer, XtPointer);
+static void fdeleteCB(Widget, XtPointer, XtPointer);
+#ifdef OFFIX
+static void FileDropedHandler(Widget, XtPointer, XEvent *, Boolean *);
+#endif /* OFFIX */
+static void filemenuACT(Widget, XEvent *, String *, Cardinal *);
+static void filemenuCB(Widget, XtPointer, XtPointer);
+static void filterDirList(Widget, ldPointer, Boolean);
+static void flistMoveACT(Widget, XEvent *, String *, Cardinal *);
+static void flistpopupACT(Widget, XEvent *, String *, Cardinal *);
+static void forwardCB(Widget, XtPointer, XtPointer);
+static void fselectCB(Widget, XtPointer, XtPointer);
+#if 0
+static void free_ldS(ldStorePointer ldS);
+#endif
+static void freevarCB(Widget, XtPointer, XtPointer);
+static char *get_user_home_dir(void);
+static ldStorePointer getldsPointer(ldStorePointer lds, char *Popname);
+static ldStorePointer init_ldS(void);
+static void init_output_lists(void);
+static Boolean IsTracePlaying(void);
+static Boolean IsEffectiveFile(char *);
+static void leaveSubmenuACT(Widget, XEvent *, String *, Cardinal *);
+static void menuCB(Widget, XtPointer, XtPointer);
+static void muteChanACT(Widget, XEvent *, String *, Cardinal *);
+static void nextCB(Widget, XtPointer, XtPointer);
+static void offPauseButton(void);
+static void offPlayButton(void);
+static Boolean onPlayOffPause(void);
+static void okCB(Widget, XtPointer, XtPointer);
+static void okACT(Widget, XEvent *, String *, Cardinal *);
+static void optionsCB(Widget, XtPointer, XtPointer);
+static void optionscloseCB(Widget, XtPointer, XtPointer);
+static void optionspopupACT(Widget, XEvent *, String *, Cardinal *);
+static void pauseACT(Widget, XEvent *, String *, Cardinal *);
+static void pauseCB(Widget, XtPointer, XtPointer);
+static void pitchCB(Widget, XtPointer, XtPointer);
+static void playCB(Widget, XtPointer, XtPointer);
+static void popdownAddALL(Widget, XtPointer, XtPointer);
+static void popdownAddALLACT(Widget, XEvent *, String *, Cardinal *);
+static void popdownCB(Widget, XtPointer, XtPointer);
+static void popdownLoadfile(Widget, XtPointer, XtPointer);
+static void popdownLoadPL(Widget, XtPointer, XtPointer);
+static void popdownSavefile(Widget, XtPointer, XtPointer);
+static void popdownSavePL(Widget, XtPointer, XtPointer);
+static void popdownSubmenuACT(Widget, XEvent *, String *, Cardinal *);
+static void popdownSubmenuCB(Widget, XtPointer, XtPointer);
+static void popdownfilemenuACT(Widget, XEvent *, String *, Cardinal *);
+static void popupfilemenuACT(Widget, XEvent *, String *, Cardinal *);
+static void popupDialog(Widget, char *, String *, XtCallbackProc,
+                        ldStorePointer);
+static void prevCB(Widget, XtPointer, XtPointer);
+static void quitCB(Widget, XtPointer, XtPointer);
+static void randomCB(Widget, XtPointer, XtPointer);
+static int readPlaylist(char *);
+static void recordCB(Widget, XtPointer, XtPointer);
+static void recordACT(Widget, XEvent *, String *, Cardinal *);
+static void redrawACT(Widget, XEvent *, String *, Cardinal *);
+static void redrawCaptionACT(Widget, XEvent *, String *, Cardinal *);
+static void repeatCB(Widget, XtPointer, XtPointer);
+static void resizeToplevelACT(Widget, XEvent *, String *, Cardinal *);
+static void restoreDefaultOSelectionCB(Widget, XtPointer, XtPointer);
+static void restoreLDPointer(Widget, XtPointer, XEvent *, Boolean *);
+static void savePlaylist(char *);
+static void saveformatDialog(Widget, char *, ldPointer);
+static void setupWindow(Widget, String, Boolean, Boolean);
+static int setDirList(ldPointer, char *);
+static void setSizeHints(Dimension);
+static void scrollTextACT(Widget, XEvent *, String *, Cardinal *);
+static void scrollTraceACT(Widget, XEvent *, String *, Cardinal *);
+static void scrollListACT(Widget, XEvent *, String *, Cardinal *);
+static void setDirACT(Widget, XEvent *, String *, Cardinal *);
+static void setDirLoadCB(Widget, XtPointer, XawListReturnStruct *);
+static void setFileLoadCB(Widget, XtPointer, XawListReturnStruct *);
+static void setThumb(Widget, barfloat);
+static Widget seekTransientShell(Widget);
+static void sndspecACT(Widget, XEvent *, String *, Cardinal *);
+static void soundkeyACT(Widget, XEvent *, String *, Cardinal *);
+static void speedACT(Widget, XEvent *, String *, Cardinal *);
+#ifdef USEOWNSTARTSCROLL
+static void simulateArrowsCB(Widget, XtPointer, XtPointer);
+static void StartScrollACT(Widget, XEvent *, String *, Cardinal *);
+#endif /* USEOWNSTARTSCROLL */
+static void stopCB(Widget, XtPointer, XtPointer);
+static char *strmatch(char *, char *);
+static void tempoCB(Widget, XtPointer, XtPointer);
+#ifdef HAVE_TIP
+static void TipEnable(Widget, String);
+static void TipDisable(Widget);
+static void xawTipSet(Boolean);
+#endif /* HAVE_TIP */
+static void tnotifyCB(Widget, XtPointer, XtPointer);
+static void toggleMark(Widget, Boolean);
+static void toggleTraceACT(Widget, XEvent *, String *, Cardinal *);
+static void tunesetACT(Widget, XEvent *, String *, Cardinal *);
+static void tuneslideCB(Widget, XtPointer, XtPointer);
+static void upACT(Widget, XEvent *, String *, Cardinal *);
+static void voiceACT(Widget, XEvent *, String *, Cardinal *);
+static void volsetCB(Widget, XtPointer, XtPointer);
+static void volupdownACT(Widget, XEvent *, String *, Cardinal *);
+static Widget warnCB(Widget, char *, Boolean);
+static void xaw_vendor_setup(void);
+static void xawtipsetACT(Widget, XEvent *, String *, Cardinal *);
+#ifdef XDND
+static void a_dnd_init(void);
+static void enable_dnd_for_widget(DndClass *, Widget, dnd_callback_t);
+static void xdnd_file_drop_handler(char *);
+static void xdnd_listener(Widget, XtPointer, XEvent *, Boolean *);
+#endif /* XDND */
+
+static void
+offPauseButton(void) {
   Boolean s;
 
-  XtVaGetValues(pause_b,XtNstate,&s,NULL);
+  XtVaGetValues(pause_b, XtNstate,&s, NULL);
   if (s == True) {
-    s=False;
-    XtVaSetValues(pause_b,XtNstate,&s,NULL);
+    XtVaSetValues(pause_b, XtNstate,False, NULL);
     a_pipe_write("U");
   }
 }
 
-static void offPlayButton(void) {
+static void
+offPlayButton(void) {
   Boolean s;
 
-  XtVaGetValues(play_b,XtNstate,&s,NULL);
+  XtVaGetValues(play_b, XtNstate,&s, NULL);
   if (s == True) {
-    s=False;
-    XtVaSetValues(play_b,XtNstate,&s,NULL);
-    a_pipe_write("T 0\n");
+    XtVaSetValues(play_b, XtNstate,False, NULL);
+    a_pipe_write("T 0");
   }
 }
 
-static Boolean IsTracePlaying(void) {
+static Boolean
+IsTracePlaying(void) {
   Boolean s;
 
-  if (!ctl->trace_playing) return False;
-  XtVaGetValues(play_b,XtNstate,&s,NULL);
-  return(s);
+  if ((!ctl->trace_playing) || (lockevents == True)) return False;
+  XtVaGetValues(play_b, XtNstate,&s, NULL);
+  return s;
 }
 
-static Boolean IsEffectiveFile(char *file) {
+static Boolean
+IsEffectiveFile(char *file) {
   char *p2;
   struct stat st;
 
-  if((p2 = strrchr(file,'#')) != NULL)
-    *p2 = '\0';
-  if(stat(file, &st) != -1)
+  if ((p2 = strrchr(file, '#')) != NULL) *p2 = '\0';
+  if (stat(file, &st) != -1)
     if (st.st_mode & S_IFMT & (S_IFDIR|S_IFREG|S_IFLNK)) {
-      if(p2) *p2 = '#';
-      return(True);
+      if (p2 != NULL) *p2 = '#';
+      return True;
     }
-  return(False);
+  return False;
 }
 
-static Boolean onPlayOffPause(void) {
-  Boolean s;
-  Boolean play_on;
+static Boolean
+onPlayOffPause(void) {
+  Boolean s, play_on = False;
 
-  play_on = False;
-  XtVaGetValues(play_b,XtNstate,&s,NULL);
+  XtVaGetValues(play_b, XtNstate,&s, NULL);
   if (s == False) {
-    s=True;
-    XtVaSetValues(play_b,XtNstate,&s,NULL);
+    XtVaSetValues(play_b, XtNstate,True, NULL);
     play_on = True;
   }
   offPauseButton();
-  return(play_on);
+  return play_on;
 }
 
-/*ARGSUSED*/
-static void chorusCB(Widget w,XtPointer id_data, XtPointer data) {
+static void
+optionsCB(Widget w, XtPointer id_data, XtPointer data) {
   Boolean s;
-  char str[16];
 
-  stopCB(NULL,NULL,NULL);
-  XtVaGetValues(w,XtNstate,&s,NULL);
-  XtVaSetValues(w,XtNbitmap,(s)? on_mark:off_mark,NULL);
-  if(!s)
-    sprintf(str, "C 0");
-  else
-    sprintf(str, "C %03d", (init_chorus)? init_chorus:1);
-  a_pipe_write(str);
+  XtVaGetValues(w, XtNstate,&s, NULL);
+  XtVaSetValues(w, XtNbitmap,s?on_mark:off_mark, NULL);
 }
 
-/*ARGSUSED*/
-static void optionsCB(Widget w,XtPointer id_data, XtPointer data) {
-  Boolean s;
-  int i,flags;
-  char str[16];
-
-  stopCB(NULL,NULL,NULL);
-  XtVaGetValues(w,XtNstate,&s,NULL);
-  XtVaSetValues(w,XtNbitmap,(s)? on_mark:off_mark,NULL);
-  flags = 0;
-  for(i=0; i<MAX_OPTION_N; i++) {
-    XtVaGetValues(option_num[i].widget,XtNstate,&s,NULL);
-    flags |= ((s)? option_num[i].bit:0);
-  }
-  sprintf(str, "E %03d", flags);
-  init_options = flags;
-  a_pipe_write(str);
+static void
+optionspopupACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  if (popup_opt == NULL) createOptions();
+  setupWindow(popup_opt, "do-optionsclose()", False, False);
 }
 
-/*ARGSUSED*/
-static void optionspopupCB(Widget w,XtPointer data,XtPointer dummy) {
-  Dimension x,y;
+static void
+flistpopupACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  Dimension x, y;
 
-  createOptions();
-  XtVaGetValues(toplevel,XtNx,&x,XtNy,&y,NULL);
-  XtVaSetValues(popup_opt,XtNx,x+TRACE_WIDTH_SHORT,XtNy,y,NULL);
-  XtPopup(popup_opt,(XtGrabKind)XtGrabNone);
+  createFlist();
+  XtVaGetValues(toplevel, XtNx,&x, XtNy,&y, NULL);
+  XtVaSetValues(popup_file, XtNx,x+DEFAULT_REG_WIDTH, XtNy,y, NULL);
+  setupWindow(popup_file, "do-closeparent()", True, False);
 }
 
-static void flistpopupCB(Widget w,XtPointer data,XtPointer dummy) {
-  Dimension x,y,w1,h1;
+static void
+aboutACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  char s[12], *p;
+  char lbuf[30];
+  int i;
+  Widget popup_about, popup_abox, popup_aok, about_lbl[5];
 
-  createFlist();
-  XtVaGetValues(toplevel,XtNx,&x,XtNy,&y,NULL);
-  XtVaSetValues(popup_file,XtNx,x+TRACE_WIDTH_SHORT,XtNy,y,NULL);
-  XtPopup(popup_file,(XtGrabKind)XtGrabNone);
-  XtVaGetValues(file_vport,XtNwidth,&w1,XtNheight,&h1,NULL);
-  XtVaSetValues(file_vport,XtNheight,((h1>FILEVPORT_HEIGHT)? h1:FILEVPORT_HEIGHT),NULL);
+  char *info[] = {"TiMidity++ %s%s - Xaw interface",
+                  "- MIDI to WAVE converter and player -",
+                  "by Masanao Izumo and Tomokazu Harada",
+                  "modified by Yoshishige Arai", " ", NULL};
+
+  if ((popup_about = XtNameToWidget(toplevel, "popup_about")) != NULL) {
+    XtPopup(popup_about, XtGrabNone);
+    XSetInputFocus(disp, XtWindow(popup_about), RevertToParent, CurrentTime);
+    return;
+  }
+  popup_about = XtVaCreatePopupShell("popup_about",transientShellWidgetClass,
+                                toplevel,NULL);
+  popup_abox = XtVaCreateManagedWidget("popup_abox",boxWidgetClass,
+                                popup_about, XtNwidth,320, XtNheight,120,
+                                XtNorientation,XtorientVertical,
+                                XtNbackground,bgcolor, NULL);
+  for(i=0, p=info[0]; p; p=info[++i]) {
+    snprintf(s, sizeof(s), "about_lbl%d", i);
+    snprintf(lbuf, sizeof(lbuf), p,
+               (strcmp(timidity_version, "current")) ? "version " : "",
+               timidity_version);
+    about_lbl[i] = XtVaCreateManagedWidget(s,labelWidgetClass,popup_abox,
+                                XtNlabel,lbuf, XtNwidth,320, XtNresize,False,
+                                XtNfontSet,app_resources.label_font,
+                                XtNforeground,textcolor, XtNborderWidth,0,
+                                XtNbackground,bgcolor, NULL);
+  }
+  popup_aok = XtVaCreateManagedWidget("OK",commandWidgetClass,popup_abox,
+                                XtNwidth,320, XtNresize,False, NULL);
+  XtAddCallback(popup_aok, XtNcallback,closeWidgetCB, (XtPointer)popup_about);
+  XtVaSetValues(popup_about, XtNx,root_width/2 - 160,
+                  XtNy,root_height/2 - 60, NULL);
+  setupWindow(popup_about, "do-closeparent()", False, True);
+  XtSetKeyboardFocus(popup_about, popup_abox);
 }
 
-static void aboutCB(Widget w,XtPointer data,XtPointer dummy) {
-  char s[12],*p;
-  int i;
+static void
+optionscloseCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  Boolean s1;
+  id_list *result = NULL;
+  int flags = 0, cflag = 0, i;
+
+  if (play != NULL) result = (id_list *)XawToggleGetCurrent(play->formatGroup);
+  for(i=0; i<MAX_OPTION_N; i++) {
+    XtVaGetValues(option_num[i].widget, XtNstate,&s1, NULL);
+    flags |= s1?option_num[i].bit:0;
+  }
+  XtVaGetValues(chorus_b, XtNstate,&s1, NULL);
+  if (s1 == True) cflag = Cfg.chorusopt?Cfg.chorusopt:DEFAULT_CHORUS;
+  if ((init_options != flags) || (init_chorus != cflag) ||
+      (recording == True)) {
+    stopCB(NULL, NULL, NULL);
+  }
+  if (init_options != flags) {
+    init_options = flags;
+    a_pipe_write("E %03d", init_options);
+  }
+  if (init_chorus != cflag) {
+    init_chorus = cflag;
+    if (s1 == False) a_pipe_write("C 0");
+    else a_pipe_write("C %03d", init_chorus);
+  }
 
-  static char *info[]= {"TiMidity++ %s%s - Xaw interface",
-                      "- MIDI to WAVE converter and player -",
-                      "by Masanao Izumo and Tomokazu Harada",
-                      "modified by Yoshishige Arai"," ",NULL};
-
-  if(!(popup_shell_exist & ABOUT_WINDOW)) {
-    popup_about= XtVaCreatePopupShell("popup_about",transientShellWidgetClass,
-                                  toplevel,NULL);
-    popup_abox= XtVaCreateManagedWidget("popup_abox",boxWidgetClass,popup_about,
-                                  XtNwidth,320,XtNheight,120,
-                                  XtNorientation,XtorientVertical,
-                                  XtNbackground,bgcolor,NULL);
-    for(i=0,p=info[0]; p!=NULL; p=info[++i]) {
-      snprintf(s,sizeof(s),"about_lbl%d",i);
-      snprintf(local_buf, sizeof(local_buf), p,
-               (strcmp(timidity_version, "current")) ? "version " : "",
-               timidity_version);
-      about_lbl[i]= XtVaCreateManagedWidget(s,labelWidgetClass,popup_abox,
-                                  XtNlabel,local_buf,XtNfont,((i)? labelfont:labelfont),
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNwidth,320,XtNresize,False,
-                                  XtNborderWidth,0,NULL);
+  if (result != NULL) {
+    a_pipe_write("p%c", result->id_char);
+    while (strncmp(local_buf, "Z3", 2)) {
+      XtAppProcessEvent(app_con, XtIMAll);
     }
-    popup_aok= XtVaCreateManagedWidget("OK",
-                    commandWidgetClass,popup_abox,
-                    XtNwidth,320,XtNresize,False,NULL);
-    XtAddCallback(popup_aok,XtNcallback,aboutcloseCB,NULL);
-    XtSetKeyboardFocus(popup_about, popup_abox);
-    popup_shell_exist |= ABOUT_WINDOW;
+    if (*(local_buf + 2) == 'E') goto popdownopt;
+    play->def = play->current;
   }
-  XtVaSetValues(popup_about,XtNx,root_width/2 -160,XtNy,root_height/2 -60,NULL);
-  XtPopup(popup_about,(XtGrabKind)XtGrabNonexclusive);
+popdownopt:
+  XtPopdown(popup_opt);
 }
 
-static void aboutcloseCB(Widget w,XtPointer data,XtPointer dummy) {
-  XtPopdown(popup_about);
+static Widget
+warnCB(Widget w, char *mesname, Boolean destroy) {
+  Widget popup_warning, popup_wbox, popup_message, popup_wok;
+
+  if (mesname == NULL) return None;
+  popup_warning = XtVaCreatePopupShell("popup_warning",
+            transientShellWidgetClass,toplevel, NULL);
+  popup_wbox = XtVaCreateManagedWidget("popup_wbox", boxWidgetClass,
+                                 popup_warning, XtNbackground,bgcolor,
+                                  XtNorientation,XtorientVertical, NULL);
+  popup_message = XtVaCreateManagedWidget(mesname, labelWidgetClass,
+                                          popup_wbox,
+                                          XtNfontSet,app_resources.label_font,
+                                          XtNforeground,textcolor,
+                                          XtNbackground,bgcolor,
+                                          XtNresize,False,
+                                          XtNborderWidth,0, NULL);
+  popup_wok = XtVaCreateManagedWidget("OK",commandWidgetClass,
+                    popup_wbox, XtNbackground,buttonbgcolor,
+                    XtNresize,False, NULL);
+  XtAddCallback(popup_wok, XtNcallback,closeWidgetCB, (XtPointer)popup_warning);
+  XtSetKeyboardFocus(popup_warning, popup_wbox);
+  setupWindow(popup_warning, "do-closeparent()", False, destroy);
+  return popup_warning;
 }
 
-static void flistcloseCB(Widget w,XtPointer data,XtPointer dummy) {
-  XtPopdown(popup_file);
+static void
+closeWidgetCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  XtPopdown((Widget)client_data);
 }
 
-/*ARGSUSED*/
-static void optionscloseCB(Widget w,XtPointer data,XtPointer dummy) {
-  XtPopdown(popup_opt);
+static int
+confirmCB(Widget w, char *mesname, Boolean multiple) {
+  Widget popup_confirm, popup_cform, popup_message, popup_ccancel, popup_cok;
+  char s[21];
+  Dimension mw, ow, cw;
+
+  if (mesname == NULL) return NORESPONSE;
+  snprintf(s, sizeof(s), "confirm_%s", mesname);
+  if ((multiple == False) && ((popup_confirm = XtNameToWidget(w, s)) != NULL)) {
+    XtPopup(popup_confirm, XtGrabNone);
+    XSetInputFocus(disp, XtWindow(popup_confirm), RevertToParent, CurrentTime);
+    return CANCEL;
+  }
+  popup_confirm = XtVaCreatePopupShell(s,transientShellWidgetClass,w,
+                                       XtNtitle,app_resources.popup_confirm,
+                                       NULL);
+  popup_cform = XtVaCreateManagedWidget("popup_cform",formWidgetClass,
+                                  popup_confirm, XtNbackground,bgcolor,
+                                  XtNorientation,XtorientVertical, NULL);
+  popup_message = XtVaCreateManagedWidget(mesname,labelWidgetClass,
+                                          popup_cform, XtNresize,False,
+                                          XtNfontSet,app_resources.label_font,
+                                          XtNforeground,textcolor,
+                                          XtNbackground,bgcolor,
+                                          XtNborderWidth,0, NULL);
+  popup_cok = XtVaCreateManagedWidget("OK",commandWidgetClass,
+                    popup_cform, XtNbackground,buttonbgcolor,
+                    XtNresize,False, XtNfromVert,popup_message, NULL);
+  popup_ccancel = XtVaCreateManagedWidget("Cancel",commandWidgetClass,
+                    popup_cform, XtNbackground,buttonbgcolor,
+                    XtNresize,False, XtNfromVert,popup_message, 
+                    XtNfromHoriz,popup_cok, NULL);
+  XtVaGetValues(popup_message, XtNwidth,&mw, NULL);
+  XtVaGetValues(popup_cok, XtNwidth,&ow, NULL);
+  XtVaGetValues(popup_ccancel, XtNwidth,&cw, NULL);
+  if (mw > ow+cw) XtVaSetValues(popup_cok, XtNhorizDistance,(mw-ow-cw)/2, NULL);
+
+  XtAddCallback(popup_cok, XtNcallback,okCB, (XtPointer)popup_confirm);
+  XtAddCallback(popup_ccancel, XtNcallback,cancelCB, (XtPointer)popup_confirm);
+  XtSetKeyboardFocus(popup_confirm, popup_cform);
+  setupWindow(popup_confirm, "do-cancel()", False, True);
+  response.val = NORESPONSE;
+  while ((response.val == NORESPONSE) || (response.widget != popup_confirm)) {
+    XtAppProcessEvent(app_con, XtIMAll);
+  }
+  XtPopdown(popup_confirm);
+  return response.val;
 }
 
-/*ARGSUSED*/
-static void optionsdestroyCB(Widget w,XtPointer data,XtPointer dummy) {
-  popup_shell_exist &= (! OPTIONS_WINDOW);
+static void
+okCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  response.widget = (Widget)client_data;
+  response.val = OK;
 }
 
-/*ARGSUSED*/
-static void quitCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+okACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  response.widget = seekTransientShell(w);
+  response.val = OK;
+}
+
+static void
+cancelCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  response.widget = (Widget)client_data;
+  response.val = CANCEL;
+}
+
+static void
+cancelACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  response.widget = seekTransientShell(w);
+  response.val = CANCEL;
+}
+
+static void
+quitCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  if (Cfg.confirmexit == True) {
+#ifdef XAW3D
+      XtPopdown(file_sm); 
+     /* Otherwise, when selecting "Quit" from the file menu, the menu
+      * may obscure the confirm dialog on XAW3D v1.5.
+      */
+#endif
+     if (confirmCB(toplevel, "confirmexit", False) != OK) return;
+  }
   a_pipe_write("Q");
 }
 
-/*ARGSUSED*/
-static void sndspecCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+sndspecACT(Widget w, XEvent *e, String *v, Cardinal *n) {
 #ifdef SUPPORT_SOUNDSPEC
   a_pipe_write("g");
 #endif
 }
 
-/*ARGSUSED*/
-static void playCB(Widget w,XtPointer data,XtPointer dummy) {
-  if(!max_files) return;
+static void
+playCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  float thumb;
+
+  if (max_files == 0) return;
   onPlayOffPause();
-  XtVaGetValues(title_mb,XtNlabel,&local_buf+2,NULL);
-  a_pipe_write("P");
+  XtVaGetValues(tune_bar, XtNtopOfThumb,&thumb, NULL);
+  if (thumb != 0) {
+    a_pipe_write("P");
+    a_pipe_write("U");
+    a_pipe_sync();
+    a_pipe_write("T %d", (int)(total_time * thumb));
+    a_pipe_write("U");
+  }
+  else a_pipe_write("P");
 }
 
-/*ARGSUSED*/
-static void pauseAction(Widget w,XEvent *e,String *v,Cardinal *n) {
+static void
+pauseACT(Widget w, XEvent *e, String *v, Cardinal *n) {
   Boolean s;
 
-  XtVaGetValues(play_b,XtNstate,&s,NULL);
-  if (e->type == KeyPress && s == True) {
-    XtVaGetValues(pause_b,XtNstate,&s,NULL);
+  XtVaGetValues(play_b, XtNstate,&s, NULL);
+  if ((e->type == KeyPress) && (s == True)) {
+    XtVaGetValues(pause_b, XtNstate,&s, NULL);
     s ^= True;
-    XtVaSetValues(pause_b,XtNstate,&s,NULL);
+    XtVaSetValues(pause_b, XtNstate,s, NULL);
+    halt = s?1:0;
     a_pipe_write("U");
   }
 }
 
-static void soundkeyAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  a_pipe_write(*(int *)n == 0 ? "+\n":"-\n");
-}
-
-static void speedAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  a_pipe_write(*(int *)n == 0 ? ">\n":"<\n");
-}
-
-static void voiceAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  a_pipe_write(*(int *)n == 0 ? "O\n":"o\n");
+static void
+soundkeyACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  if (*(int *)n == 0) {
+    if (IsTracePlaying())
+      XtCallActionProc(keyup_b, (String)"set", NULL, NULL, ZERO);
+    a_pipe_write("+");
+  } else {
+    if (IsTracePlaying())
+      XtCallActionProc(keydown_b, (String)"set", NULL, NULL, ZERO);
+    a_pipe_write("-");
+  }
 }
 
-static void randomAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  Boolean s;
-  XtVaGetValues(random_b,XtNstate,&s,NULL);
-  s ^= True;
-  if(!s) XtVaSetValues(random_b,XtNstate,s,NULL);
-    randomCB(NULL,&s,NULL);
+static void
+speedACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  if (*(int *)n == 0) {
+    if (IsTracePlaying())
+      XtCallActionProc(fast_b, (String)"set", NULL, NULL, ZERO);
+    a_pipe_write(">");
+  } else {
+    if (IsTracePlaying())
+      XtCallActionProc(slow_b, (String)"set", NULL, NULL, ZERO);
+    a_pipe_write("<");
+  }
 }
 
-static void repeatAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  Boolean s;
-  XtVaGetValues(repeat_b,XtNstate,&s,NULL);
-  s ^= True;
-  if(!s) XtVaSetValues(repeat_b,XtNstate,s,NULL);
-  repeatCB(NULL,&s,NULL);
+static void
+voiceACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  a_pipe_write(*(int *)n == 0 ? "O":"o");
 }
 
-/*ARGSUSED*/
-static void pauseCB() {
+static void
+pauseCB(Widget w, XtPointer client_data, XtPointer call_data) {
   Boolean s;
 
-  XtVaGetValues(play_b,XtNstate,&s,NULL);
+  XtVaGetValues(play_b, XtNstate,&s, NULL);
   if (s == True) {
+    halt = 1;
     a_pipe_write("U");
-  } else {
-    s = True;
-    XtVaSetValues(pause_b,XtNstate,&s,NULL);
   }
+  XtVaGetValues(pause_b, XtNstate,&s, NULL);
+  if (s == False) halt = 0;
 }
 
-/*ARGSUSED*/
-static void stopCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+stopCB(Widget w, XtPointer client_data, XtPointer call_data) {
   offPlayButton();
   offPauseButton();
   a_pipe_write("S");
-  initStatus();
-  window_title[0]='\0';
-  redrawTrace(False);
+  lockevents = True;
+  if (recording == True) a_pipe_write("wS");
+  if (ctl->trace_playing) initStatus();
+  XtVaSetValues(tune_l0, XtNlabel,"0:00", NULL);
+  XawScrollbarSetThumb(tune_bar, 0.0, -1.0);
+  snprintf(window_title, sizeof(window_title), "%s : %s",
+           APP_CLASS, app_resources.no_playing);
+  XtVaSetValues(toplevel, XtNtitle,window_title, NULL);
+  callRedrawTrace(False);
 }
 
-/*ARGSUSED*/
-static void nextCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+nextCB(Widget w, XtPointer client_data, XtPointer call_data) {
   onPlayOffPause();
   a_pipe_write("N");
-  initStatus();
-  redrawTrace(True);
+  lockevents = True;
+  if (ctl->trace_playing) initStatus();
 }
 
-/*ARGSUSED*/
-static void prevCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+prevCB(Widget w, XtPointer client_data, XtPointer call_data) {
   onPlayOffPause();
   a_pipe_write("B");
-  initStatus();
-  redrawTrace(True);
+  lockevents = True;
+  if (ctl->trace_playing) initStatus();
 }
 
-/*ARGSUSED*/
-static void forwardCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+forwardCB(Widget w, XtPointer client_data, XtPointer call_data) {
   if (onPlayOffPause()) a_pipe_write("P");
   a_pipe_write("f");
-  initStatus();
+  if (ctl->trace_playing) initStatus();
 }
 
-/*ARGSUSED*/
-static void backCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+backCB(Widget w, XtPointer client_data, XtPointer call_data) {
   if (onPlayOffPause()) a_pipe_write("P");
   a_pipe_write("b");
-  initStatus();
+  if (ctl->trace_playing) initStatus();
 }
 
-/*ARGSUSED*/
-static void repeatCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+repeatCB(Widget w, XtPointer client_data, XtPointer call_data) {
   Boolean s;
-  Boolean *set= (Boolean *)data;
+  Boolean *set = (Boolean *)client_data;
 
-  if (set != NULL && *set) {
+  if (set != NULL) {
     s = *set;
-    XtVaSetValues(repeat_b,XtNstate,set,NULL);
+    XtVaSetValues(repeat_b, XtNstate,s, NULL);
+    toggleMark(file_menu[ID_REPEAT-100].widget, s);
   } else {
-    XtVaGetValues(repeat_b,XtNstate,&s,NULL);
+    XtVaGetValues(repeat_b, XtNstate,&s, NULL);
+    toggleMark(file_menu[ID_REPEAT-100].widget, s);
+    Cfg.repeat = s;
   }
-  if (s == True) {
-    a_pipe_write("R 1");
-  } else a_pipe_write("R 0");
-  toggleMark(file_menu[ID_REPEAT-100].widget, file_menu[ID_REPEAT-100].id);
+  if (s == True) a_pipe_write("R 1");
+  else a_pipe_write("R 0");
 }
 
-/*ARGSUSED*/
-static void randomCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+randomCB(Widget w, XtPointer client_data, XtPointer call_data) {
   Boolean s;
-  Boolean *set= (Boolean *)data;
+  Boolean *set = (Boolean *)client_data;
 
   onPlayOffPause();
-  if (set != NULL && *set) {
+  if (set != NULL) {
     s = *set;
-    XtVaSetValues(random_b,XtNstate,set,NULL);
+    XtVaSetValues(random_b, XtNstate,s, NULL);
+    toggleMark(file_menu[ID_SHUFFLE-100].widget, s);
   } else {
-    XtVaGetValues(random_b,XtNstate,&s,NULL);
+    XtVaGetValues(random_b, XtNstate,&s, NULL);
+    toggleMark(file_menu[ID_SHUFFLE-100].widget, s);
+    Cfg.shuffle = s;
   }
   if (s == True) {
     onPlayOffPause();
@@ -876,153 +1054,153 @@ static void randomCB(Widget w,XtPointer data,XtPointer dummy) {
     offPauseButton();
     a_pipe_write("D 2");
   }
-  toggleMark(file_menu[ID_SHUFFLE-100].widget, file_menu[ID_SHUFFLE-100].id);
 }
 
-static void menuCB(Widget w,XtPointer data,XtPointer dummy) {
+static void
+tempoCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  a_pipe_write( (client_data == (XtPointer)TRUE) ? ">":"<");
+}
+
+static void
+pitchCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  a_pipe_write( (client_data == (XtPointer)TRUE) ? "+":"-");
+}
+
+static void
+menuCB(Widget w, XtPointer client_data, XtPointer call_data) {
   onPlayOffPause();
-  sprintf(local_buf,"L %d",((int)data)+1);
-  a_pipe_write(local_buf);
+  lockevents = True;
+  if (ctl->trace_playing) initStatus();
+  a_pipe_write("L %ld", ((long)client_data)+1);
 }
 
-static void setVolbar(int val) {
+static void
+setVolbar(int val) {
   char s[8];
-  float thumb;
-
-  amplitude = (val > MAXVOLUME)? MAXVOLUME:val;
-  sprintf(s, "%d", val);
-  XtVaSetValues(vol_l, XtNlabel, s, NULL);
-  sprintf(s, "V %03d\n", val);
-  a_pipe_write(s);
-  thumb = (float)val / (float)MAXVOLUME;
-  sprintf(s, "%d", val);
-  XtVaSetValues(vol_l, XtNlabel, s, NULL);
-  if (sizeof(thumb) > sizeof(XtArgVal)) {
-    XtVaSetValues(vol_bar, XtNtopOfThumb, &thumb, NULL);
-  } else {
-    XtArgVal *l_thumb = (XtArgVal *) &thumb;
-    XtVaSetValues(vol_bar, XtNtopOfThumb,*l_thumb, NULL);
-  }
+  barfloat thumb;
+
+  amplitude = (val > MAXVOLUME)? MAXVOLUME : val;
+  a_pipe_write("V %03d", amplitude);
+  snprintf(s, sizeof(s), "%d", amplitude);
+  XtVaSetValues(vol_l, XtNlabel,s, NULL);
+  thumb.f = (float)amplitude / (float)MAXVOLUME;
+  setThumb(vol_bar, thumb);
 }
 
-static void volsetCB(Widget w,XtPointer data,XtPointer call_data) {
-  float percent = *(float*)call_data;
-  int val = (float)(MAXVOLUME * percent);
+static void
+volsetCB(Widget w, XtPointer client_data, XtPointer percent_ptr) {
+  float percent = *(float *)percent_ptr;
+  int val = MAXVOLUME * percent;
 
   if (amplitude == val) return;
   setVolbar(val);
 }
 
-static void volupdownCB(Widget w,XtPointer data,XtPointer diff) {
-  int i = ((int)diff > 0)? (-10):10;
-
-  i += amplitude;
-  setVolbar(i);
-}
-
-static void volupdownAction(Widget w,XEvent *e,String *v,Cardinal *n) {
+static void
+volupdownACT(Widget w, XEvent *e, String *v, Cardinal *n) {
   int i = atoi(*v);
 
   i += amplitude;
   setVolbar(i);
 }
 
-#if 0 /* Not used */
-static void tunesetCB(Widget w,XtPointer data,XtPointer call_data)
-{
-  static int tmpval;
-  char s[16];
-  float percent = *(float*)call_data;
-  int value = (float)(total_time * percent);
-  float thumb, l_thumb;
-
-  if (tmpval == value) return;
-  if (curr_time > total_time) curr_time = total_time;
-  curr_time = tmpval = value;
-  l_thumb = thumb = (float)curr_time / (float)total_time;
-  snprintf(s,sizeof(s), "%2d:%02d", tmpval / 60, tmpval % 60);
-  XtVaSetValues(tune_l0, XtNlabel, s, NULL);
-  sprintf(s, "T %d\n", tmpval);
-  a_pipe_write(s);
+static void
+tunesetACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  int click_y;
+  Dimension h;
+  barfloat thumb;
+
+  if (!halt) return;
+  halt = 0;
+  XtVaGetValues(tune_bar, XtNtopOfThumb,&thumb.f, XtNheight,&h, NULL);
+  click_y = e->xbutton.y;
+  if ((click_y > h) || (click_y < 0)) {
+    char s[10];
+
+    snprintf(s, sizeof(s), "%d:%02d", curr_time / 60, curr_time % 60);
+    XtVaSetValues(tune_l0, XtNlabel,s, NULL);
+    thumb.f = (float)curr_time / (float)total_time;
+    setThumb(tune_bar, thumb);
+    return;
+  }
+  a_pipe_write("T %d", (int)(total_time * thumb.f));
+  /*  local_buf[0] = '\0';
+  a_print_text(lyric_t, local_buf);*/
 }
-#endif
 
-static void tunesetAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  static float tmpval;
+static void
+tuneslideCB(Widget w, XtPointer client_data, XtPointer percent_ptr) {
   char s[16];
   int value;
-  float l_thumb;
+  float l_thumb = *(float *)percent_ptr;
 
-  XtVaGetValues(tune_bar, XtNtopOfThumb, &l_thumb, NULL);
-  if (tmpval == l_thumb) return;
-  tmpval = l_thumb;
-  value = (int)(l_thumb * total_time);
-  snprintf(s,sizeof(s), "%2d:%02d", curr_time / 60, curr_time % 60);
-  XtVaSetValues(tune_l0, XtNlabel, s, NULL);
-  XtVaSetValues(tune_bar, XtNtopOfThumb, &l_thumb, NULL);
-  sprintf(s, "T %d\n", value);
-  a_pipe_write(s);
+  halt = 1;
+  value = l_thumb * total_time;
+  snprintf(s, sizeof(s), "%d:%02d", value / 60, value % 60);
+  XtVaSetValues(tune_l0, XtNlabel,s, NULL);
 }
 
-static void tuneslideCB(Widget w,XtPointer data,XtPointer diff) {
-  char s[16];
+static void
+setSizeHints(Dimension height) {
+  XSizeHints *xsh;
 
-  sprintf(s, "T %d\n", curr_time+ (int)diff);
-  a_pipe_write(s);
+  xsh = XAllocSizeHints();
+  if (xsh != NULL) {
+    xsh->flags = PMaxSize/* | PMinSize*/;
+    if (Cfg.disptrace == False) {
+      xsh->max_width = root_width;
+      xsh->min_height = base_height;
+    } else {
+      xsh->max_width = TRACE_WIDTH+8;
+      xsh->min_height = base_height + trace_v_height;
+    }
+    xsh->min_width = DEFAULT_REG_WIDTH;
+    if (XtIsManaged(lyric_t)) xsh->max_height = root_height;
+    else xsh->max_height = height;
+    XSetWMNormalHints(disp, XtWindow(toplevel), xsh);
+    XFree(xsh);
+  }
+ return;
 }
 
-static void tuneslideAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  char s[16];
-  float l_thumb;
-
-  XtVaGetValues(tune_bar, XtNtopOfThumb, &l_thumb, NULL);
-  sprintf(s, "T %d\n", (int)(total_time * l_thumb));
-  a_pipe_write(s);
-}
-
-/*ARGSUSED*/
-static void resizeAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  Dimension w1,w2,h1,h2;
-  Position y1;
-  int i,tmp,tmp2,tmp3;
-
-  XtVaGetValues(toplevel,XtNwidth,&w1,XtNheight,&h1,NULL);
-  w2 = w1 -8;
-  if(w2>TRACEVPORT_WIDTH) w2 = TRACEVPORT_WIDTH;
-  XtVaGetValues(lyric_t,XtNheight,&h2,NULL);
-  XtResizeWidget(lyric_t,w2-2,h2,0);
-  i= 0; tmp = 10;
-  while (tmp > 0) {
-    i++; tmp -= (int)(w2) / 36;
-  }
-  XtVaSetValues(lyric_t,XtNborderWidth,1,NULL);
-  XtVaSetValues(b_box,XtNheight,i*40,NULL);
-  XtResizeWidget(b_box,w2,i*40,0);
-
-  if(ctl->trace_playing) {
-    XtVaGetValues(trace_vport,XtNy,&y1,NULL);
-    XtResizeWidget(trace_vport,w2,((h1-y1>TRACE_HEIGHT+12)? TRACE_HEIGHT+12:h1-y1),0);
-  }
-  XtVaGetValues(v_box,XtNheight,&h2,NULL);
-  w2 = ((w1 < TRACE_WIDTH_SHORT)? w1:TRACE_WIDTH_SHORT);    /* new v_box width */
-  tmp = XTextWidth(app_resources.volume_font,"Volume ",7)+8; /* vol_l width */
-  XtVaSetValues(vol_l0,XtNwidth,tmp,NULL);
-  XtVaSetValues(v_box,XtNwidth,w2,NULL);
-  tmp2 = w2 -tmp - XTextWidth(app_resources.volume_font,"000",3) -38;
-  tmp3 = w2 -XTextWidth(app_resources.volume_font,"/ 99:59",7)
-    - XTextWidth(app_resources.volume_font,"000",3) -45;
-  XtResizeWidget(v_box,w2,h2,0);
-  XtVaGetValues(vol_bar,XtNheight,&h2,NULL);
-  XtVaSetValues(vol_bar,XtNwidth,tmp2,NULL);
-  XtVaSetValues(tune_bar,XtNwidth,tmp3,NULL);
-  XtResizeWidget(vol_bar,tmp2,h2,0);
-  XtResizeWidget(tune_bar,tmp3,h2,0);
+static void
+resizeToplevelACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  XConfigureEvent *xce = (XConfigureEvent *)e;
+
+  if (xce != NULL) {
+    if ((xce->width == curr_width) && (xce->height == curr_height))
+      return;
+    curr_width = xce->width;
+    curr_height = xce->height;
+  }
+
+  XawFormDoLayout(base_f, False);
+  setSizeHints(curr_height);
+
+  if (XtIsManaged(lyric_t)) {
+    if (Cfg.disptrace == True) {
+      if (base_height + trace_v_height + 4 > curr_height) lyric_height = 4;
+      else lyric_height = curr_height - base_height - trace_v_height;
+    } else {
+      if (base_height + 4 > curr_height) lyric_height = 4;
+      else lyric_height = curr_height - base_height;
+    }
+    XtResizeWidget(lyric_t, curr_width-10,lyric_height, 1);
+    XtVaGetValues(lyric_t, XtNheight,&lyric_height, NULL);
+  }
+
+  if (Cfg.disptrace == True) {
+    XtManageChild(trace_vport);
+    XtVaSetValues(trace_vport, XtNtop,XawChainBottom, NULL);
+  }
+
+  XawFormDoLayout(base_f, True);
   XSync(disp, False);
-  usleep(10000);
 }
 
 #ifndef WIDGET_IS_LABEL_WIDGET
-void a_print_text(Widget w, char *st) {
+static void
+a_print_text(Widget w, char *st) {
   XawTextPosition pos;
   XawTextBlock tb;
 
@@ -1031,1304 +1209,1432 @@ void a_print_text(Widget w, char *st) {
   tb.firstPos = 0;
   tb.length = strlen(st);
   tb.ptr = st;
-  tb.format = FMT8BIT;
+  tb.format = XawFmt8Bit;
   XawTextReplace(w, pos, pos, &tb);
   XawTextSetInsertionPoint(w, pos + tb.length);
 }
 #else
-void a_print_text(Widget w, char *st) {
-  XtVaSetValues(w,XtNlabel,st,NULL);
+static void
+a_print_text(Widget w, char *st) {
+  XtVaSetValues(w, XtNlabel,st, NULL);
 }
 #endif /* !WIDGET_IS_LABEL_WIDGET */
 
-/*ARGSUSED*/
-static void popupLoad(Widget w,XtPointer client_data,XtPointer call_data) {
-#define DIALOG_HEIGHT 400
-  Position popup_x, popup_y, top_x, top_y;
-  Dimension top_width;
-
-  XtVaGetValues(toplevel, XtNx,&top_x,XtNy,&top_y,XtNwidth,&top_width,NULL);
-  popup_x=top_x+ 20;
-  popup_y=top_y+ 72;
-  top_width += 100;
-  if(popup_x+top_width > root_width) popup_x = root_width -top_width -20;
-  if(popup_y+DIALOG_HEIGHT > root_height) popup_y = root_height -DIALOG_HEIGHT -20;
+static ldStorePointer
+init_ldS(void) {
+  ldStorePointer p;
+  p = (ldStorePointer)safe_malloc(sizeof(ldStore));
+  p->name = NULL;
+  return p;
+}
 
-  XtVaSetValues(popup_load, XtNx,popup_x,XtNy,popup_y,XtNwidth,top_width,
-                XtNheight,DIALOG_HEIGHT,NULL);
-  XtRealizeWidget(popup_load);
-  XtPopup(popup_load,(XtGrabKind)XtGrabNone);
-  top_width -= 4;
-  XtVaSetValues(load_vport,XtNwidth,top_width,NULL);
-  XawTextSetInsertionPoint(load_t,(XawTextPosition)(strlen(basepath)));
+#if 0
+static void
+free_ldS(ldStorePointer ldS) {
+  if (ldS == NULL) return;
+  if (ldS->name == NULL) free(ldS);
+  else {
+    free_ldS( (ldStorePointer)ldS->next);
+    free(ldS->fdirlist); free(ldS->ddirlist); free(ldS->fulldirlist);
+    free(ldS->ld);
+    free(ldS->name);
+    free(ldS);
+  }
+  return;
 }
+#endif
 
-static void popdownLoad(Widget w,XtPointer s,XtPointer data) {
-  char *p, *p2;
-  DirPath full;
-  char local_buf[300],tmp[PATH_MAX];
-#ifndef        ORIGINAL
-  int  Aflag = 0; /* RAKK/HIOENS: adding All files in directory */
-#endif /*RAKK/HIOENS*/
-
-  /* tricky way for both use of action and callback */
-  if (s != NULL && data == NULL){
-    if(*(char *)s == 'A') {
-      snprintf(tmp,sizeof(tmp),"%s%c",basepath,'/');
-      p = tmp;
-#ifndef        ORIGINAL
-      Aflag = 1;
-#endif /*RAKK/HIOENS*/
-    } else {
-      p = XawDialogGetValueString(load_d);
-    }
-    if (NULL != (p2 = expandDir(p, &full)))
-      p = p2;
-    if(IsEffectiveFile(p)) {
-#ifndef        ORIGINAL
-      if(Aflag == 1) strcat(p,"/");
-#endif /*RAKK/HIOENS*/
-      snprintf(local_buf,sizeof(local_buf),"X %s\n",p);
-      a_pipe_write(local_buf);
-    }
+static ldStorePointer
+getldsPointer(ldStorePointer lds, char *Popname) {
+  if ((lds == NULL) || (Popname == NULL)) {
+    fprintf(stderr, "getldPointer received NULL parameter!\n");
+    exit(1);
   }
-  XtPopdown(popup_load);
+  if (lds->name == NULL) {
+    lds->name = safe_strdup(Popname);
+    lds->ld = (ldPointer)safe_malloc(sizeof(load_dialog));
+    strlcpy(lds->ld->ld_popupname, Popname, MAX_POPUPNAME);
+    strlcpy(lds->ld->ld_basepath, Cfg.DefaultDir, sizeof(lds->ld->ld_basepath));
+    lds->ld->ld_cur_filter[0] = '\0';
+    if (strcmp(LISTDIALOGBASENAME, Popname))
+      strlcpy(lds->ld->ld_filter, "*.mid", 6);
+    else strlcpy(lds->ld->ld_filter, "*.tpl", 6);
+    lds->ld->ld_popup_load = NULL;
+    lds->ld->ld_fdirlist.StringArray = NULL;
+    lds->ld->ld_ddirlist.StringArray = NULL;
+    lds->ld->ld_fulldirlist.StringArray = NULL;
+    lds->next = (struct ldStore *)init_ldS();
+    return lds;
+  }
+  if (!strncmp(lds->name, Popname, MAX_POPUPNAME)) return lds;
+  return getldsPointer( (ldStorePointer)lds->next, Popname);
 }
 
-static void toggleMark(Widget w,int id) {
-  file_menu[id-100].bmflag ^= True;
-  XtVaSetValues(w,XtNleftBitmap,
-                ((file_menu[id-100].bmflag)? check_mark:None),NULL);
+static void
+restoreLDPointer(Widget w, XtPointer client_data, XEvent *ev, Boolean *bool) {
+  if (ev->xany.type == FocusIn) ld = (ldPointer)client_data;
+  return;
 }
 
-static void filemenuAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  int i;
+static void
+createDialog(Widget w, ldPointer ld) {
+  Position popup_x, popup_y, top_x, top_y;
+  Widget load_l,load_t;
+
+  XtVaGetValues(toplevel, XtNx,&top_x, XtNy,&top_y, XtNwidth,&ldwidth, NULL);
+  ldheight = POPUP_HEIGHT;
+  popup_x = top_x + 20 + ran();
+  popup_y = top_y + 72 + ran();
+  if (popup_x+ldwidth > root_width)
+        popup_x = root_width - ldwidth - 20;
+  if (popup_y+ldheight > root_height)
+        popup_y = root_height - POPUP_HEIGHT - 20;
+  ldwidth += 100-4;
+
+  popup_load = XtVaCreatePopupShell(popupname, transientShellWidgetClass,
+               toplevel, XtNx,popup_x, XtNy,popup_y, XtNheight,ldheight, NULL);
+  load_d = XtVaCreateManagedWidget("load_dialog",dialogWidgetClass,
+           popup_load, XtNbackground,bgcolor, XtNresize,True,
+           XtNvalue,"", NULL);
+          /* We set XtNvalue because we need load_t to exist now so it
+           * can be given the correct size.
+           */
+  load_t = XtNameToWidget(load_d, "value");
+  load_l = XtNameToWidget(load_d, "label");
+  load_ok = XtVaCreateManagedWidget("OK",commandWidgetClass,load_d, NULL);
+  XawDialogAddButton(load_d, "add", popdownAddALL, (XtPointer)ld);
+  XawDialogAddButton(load_d, "Cancel", popdownCB, (XtPointer)ld);
+  load_b = XtVaCreateManagedWidget("load_button",toggleWidgetClass,load_d,
+          XtNforeground,togglecolor, XtNbackground,buttonbgcolor, NULL);
+
+  cwd_l = XtVaCreateManagedWidget("cwd_label",labelWidgetClass,
+             load_d, XtNlabel,basepath, XtNborderWidth,0,
+             XtNfromVert,load_b, XtNwidth,ldwidth, XtNheight,INFO_HEIGHT,
+             XtNbackground,text2bgcolor, XtNresize,False, NULL);
+  load_pane = XtVaCreateManagedWidget("pane",panedWidgetClass,load_d,
+             XtNfromVert,cwd_l, XtNwidth,ldwidth, XtNheight,PANE_HEIGHT,
+             XtNorientation,XtorientHorizontal, NULL);
+  load_vportdir = XtVaCreateManagedWidget("vdport",viewportWidgetClass,
+             load_pane, XtNallowHoriz,True, XtNallowVert,True,
+             XtNbackground,textbgcolor, XtNuseBottom,True,
+             XtNpreferredPaneSize,ldwidth/5, NULL);
+  load_vport = XtVaCreateManagedWidget("vport",viewportWidgetClass,
+             load_pane, XtNallowHoriz,True, XtNallowVert,True,
+             XtNbackground,textbgcolor, XtNuseBottom,True,
+             XtNpreferredPaneSize,ldwidth*4/5, NULL);
+  load_dlist = XtVaCreateManagedWidget("dirs",listWidgetClass,load_vportdir,
+             XtNverticalList,True, XtNforceColumns,True,
+             XtNbackground,textbgcolor, XtNdefaultColumns,1, NULL);
+  load_flist = XtVaCreateManagedWidget("files",listWidgetClass,load_vport,
+             XtNverticalList,True, XtNforceColumns,False,
+             XtNbackground,textbgcolor, XtNdefaultColumns,3, NULL);
+  load_info = XtVaCreateManagedWidget("cwd_info",labelWidgetClass,
+             load_d, XtNborderWidth,0, XtNwidth,ldwidth,
+             XtNheight,INFO_HEIGHT, XtNresize,False,
+             XtNbackground,text2bgcolor, XtNfromVert,load_pane, NULL);
+  XtVaSetValues(load_t, XtNwidth,(int)(ldwidth/1.5), NULL);
+  XtVaSetValues(load_l, XtNwidth,(int)(ldwidth/1.5), NULL);
+
+  XtAddCallback(load_flist, XtNcallback,
+                 (XtCallbackProc)setFileLoadCB, (XtPointer)ld); 
+  XtAddCallback(load_dlist, XtNcallback,
+                 (XtCallbackProc)setDirLoadCB, (XtPointer)ld); 
+  XtAddCallback(load_b, XtNcallback,callFilterDirList, (XtPointer)ld);
+  XtInstallAccelerators(load_t, load_b);
+  XtAddEventHandler(popup_load, FocusChangeMask, False,
+                    restoreLDPointer, (XtPointer)ld);
+}
 
-  if(e == NULL)
-    i= ID_HIDETXT;
-  else
-    i= atoi(*v);
-  if(!(ctl->trace_playing) && i == ID_HIDETRACE) i= ID_HIDETXT;
-  filemenuCB(file_menu[i-100].widget,&file_menu[i-100].id,NULL);
+static void
+popupDialog(Widget w, char *Popname, String *title,
+            XtCallbackProc OKfunc, ldStorePointer ldS) {
+  ldPointer ldlocal;
+
+  ldlocal = getldsPointer(ldS, Popname)->ld;
+  ld = ldlocal;
+  if (popup_load == NULL) createDialog(w, ldlocal);
+
+  XtRemoveAllCallbacks(load_ok,XtNcallback);
+  XtAddCallback(load_ok, XtNcallback,OKfunc, (XtPointer)ldlocal);
+  if (title != NULL) XtVaSetValues(popup_load, XtNtitle,*title, NULL);
+
+  setDirList(ldlocal, basepath);
+  XtVaSetValues(cwd_l, XtNlabel,basepath, NULL);
+
+  setupWindow(popup_load, "MenuPopdown()", False, False);
+  /* uses MenuPopdown() (see intrinsics p.88) becuase FocusIn events
+   * are not always recieved on pressing the X button so ld can be
+   * incorrect for do-popdown().
+   */
+
+  XtVaSetValues(load_flist, XtNwidth,0, XtNheight,0, NULL);
+  XtVaSetValues(load_dlist, XtNwidth,0, XtNheight,0, NULL);
+  /* Neccesary to bypass Xaw8 bug: The listwidget will always inherit
+   * width and height regardless of original setting. This should be
+   * harmless on other implementations.
+   */
 }
 
-static void filemenuCB(Widget w,XtPointer id_data, XtPointer data) {
-  int *id = (int *)id_data;
-  Dimension w1,h1,w2,h2,tmp;
+static void
+popdownCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  XtPopdown(popup_load); /* uses global ld */
+}
 
-  switch (*id) {
-    case ID_LOAD:
-      popupLoad(w,NULL,NULL);
-      break;
-    case ID_AUTOSTART:
-      toggleMark(w,*id);
-      break;
-    case ID_AUTOQUIT:
-      toggleMark(w,*id);
-      a_pipe_write("q");
-      break;
-    case ID_HIDETRACE:
-      if(ctl->trace_playing) {
-        XtVaGetValues(toplevel,XtNheight,&h1,XtNwidth,&w1,NULL);
-        if(XtIsManaged(trace_vport)) {
-          tmp = trace_height + (XtIsManaged(lyric_t) ? 0:lyric_height);
-          XtUnmanageChild(trace_vport);
-          XtMakeResizeRequest(toplevel,w1,base_height-tmp,&w2,&h2);
-        } else {
-          XtManageChild(trace_vport);
-          XtVaSetValues(trace_vport,XtNfromVert,
-                        (XtIsManaged(lyric_t) ? lyric_t:t_box),NULL);
-          XtMakeResizeRequest(toplevel,w1,h1+trace_height,&w2,&h2);
-          XtVaSetValues(trace_vport,XtNheight,trace_height,NULL);
-        }
-        toggleMark(w,*id);
-      }
-      break;
-    case ID_HIDETXT:
-      XtVaGetValues(toplevel,XtNheight,&h1,XtNwidth,&w1,NULL);
-      if(XtIsManaged(lyric_t)) {
-        if(ctl->trace_playing) {
-          tmp = lyric_height + (XtIsManaged(trace_vport) ? 0:trace_height);
-        } else {
-          tmp = lyric_height;
-        }
-        XtUnmanageChild(lyric_t);
-        if(ctl->trace_playing && XtIsManaged(trace_vport))
-          XtVaSetValues(trace_vport,XtNfromVert,t_box,NULL);
-        XtMakeResizeRequest(toplevel,w1,base_height-tmp,&w2,&h2);
-      } else {
-        XtManageChild(lyric_t);
-        if(ctl->trace_playing && XtIsManaged(trace_vport)) {
-          XtVaSetValues(trace_vport,XtNfromVert,lyric_t,NULL);
-        }
-        XtVaSetValues(lyric_t,XtNheight,lyric_height,NULL);
-        XtMakeResizeRequest(toplevel,w1,h1+lyric_height,&w2,&h2);
+static void
+popdownAddALLACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  popdownAddALL(w, ld, NULL); /* uses global ld */
+}
+
+static void
+popdownAddALL(Widget w, XtPointer client_data, XtPointer call_data) {
+  char *p;
+  ldPointer ld = (ldPointer)client_data;
+  String *filelist = fdirlist;
+  Boolean toggle;
+
+  XtVaGetValues(load_b, XtNstate,&toggle, NULL);
+  if ((toggle == False) || (filelist == NULL)) {
+    a_pipe_write("X %s/", basepath);
+    /*
+     * Speed shortcut - timidity internals can get a directory name, and
+     * get the midi files from it. Otherwise, all the filenames in the
+     * directory would have been passed through the pipe which
+     * can be slow for a very large amount of files. The alternative would
+     * involve something like:
+     * filelist = fulldirlist; (but the case of filelist == NULL can be more
+     * complicated).
+     */
+    goto addallpopdown;
+  }
+  while ((p = *(filelist++)) != NULL) {
+    a_pipe_write("X %s/%s", basepath, p);
+  }
+addallpopdown:
+  XtPopdown(popup_load);
+}
+
+static void
+popdownLoadfile(Widget w, XtPointer client_data, XtPointer call_data) {
+  char *p, *p2;
+  ldPointer ld = (ldPointer)client_data;
+
+  p = XawDialogGetValueString(load_d);
+  if ((p2 = expandDir(p, NULL, basepath)) != NULL) p = p2;
+  if (IsEffectiveFile(p)) {
+    a_pipe_write("X %s", p);
+#ifdef CLEARVALUE
+    clearValue(load_d);
+#endif /* CLEARVALUE */
+    XtVaSetValues(load_d, XtNvalue,"", NULL);
+    XtPopdown(popup_load);
+  } else {
+    char *s = strrchr(p, '/');
+
+    if (s == NULL) return;
+    else s++;
+    p2 = s;
+    while ((*s) != '\0') {
+      if ((*s == '*') || (*s == '?')) {
+        strlcpy(filter, p2, sizeof(filter));
+        XtVaSetValues(load_b, XtNstate,True, NULL);
+        filterDirList(w, ld, True);
+        return;
+      }
+      s++;
+    }
+  }
+}
+
+static void
+popdownSavefile(Widget w, XtPointer client_data, XtPointer call_data) {
+  char *p;
+  char lbuf[PIPE_LENGTH];
+  struct stat st;
+  ldPointer ld = (ldPointer)client_data;
+
+  p = XawDialogGetValueString(XtParent(w));
+  snprintf(lbuf, sizeof(lbuf), "%s/%s", basepath, p);
+  if (stat(lbuf, &st) != -1) {
+    if (st.st_mode & S_IFMT & (S_IFREG|S_IFLNK)) {
+      if (confirmCB(popup_load, "warnoverwrite", True) != OK) return;
+    }
+    else return;
+  }
+
+  saveformatDialog(popup_load, lbuf, ld);
+}
+
+static void
+popdownLoadPL(Widget w, XtPointer client_data, XtPointer call_data) {
+  char *p, *p2;
+  ldPointer ld = (ldPointer)client_data;
+
+  p = XawDialogGetValueString(load_d);
+  if ((p2 = expandDir(p, NULL, basepath)) != NULL) p = p2;
+  if ( (IsEffectiveFile(p)) && (!readPlaylist(p)) ) {
+#ifdef CLEARVALUE
+    clearValue(load_d);
+#endif /* CLEARVALUE */
+    XtVaSetValues(load_d, XtNvalue,"", NULL);
+    XtPopdown(popup_load);
+  } else {
+    char *s = strrchr(p, '/');
+
+    if (s == NULL) return;
+    else s++;
+    p2 = s;
+    while ((*s) != '\0') {
+      if ((*s == '*') || (*s == '?')) {
+        strlcpy(filter, p2, sizeof(filter));
+        XtVaSetValues(load_b, XtNstate,True, NULL);
+        filterDirList(w, ld, True);
+        return;
+      }
+      s++;
+    }
+  }
+}
+
+static void
+popdownSavePL(Widget w, XtPointer client_data, XtPointer call_data) {
+  char *p;
+  char lbuf[PIPE_LENGTH];
+  struct stat st;
+  ldPointer ld = (ldPointer)client_data;
+
+  p = XawDialogGetValueString(XtParent(w));
+  snprintf(lbuf, sizeof(lbuf), "%s/%s", basepath, p);
+  if (stat(lbuf, &st) != -1) {
+    if (st.st_mode & S_IFMT & (S_IFREG|S_IFLNK)) {
+      if (confirmCB(popup_load, "warnoverwrite", True) != OK) return;
+    }
+    else return;
+  }
+  a_pipe_write("s %s", lbuf);
+#ifdef CLEARVALUE
+  clearValue(XtParent(w));
+#endif /* CLEARVALUE */
+  XtVaSetValues(XtParent(w), XtNvalue,"", NULL);
+  XtPopdown(popup_load);
+}
+
+static void
+saveformatDialog(Widget parent, char *lbuf, ldPointer ld) {
+  Widget popup_sform, popup_sformat, popup_slabel, sbox_rbox, sbox_ratelabel,
+         sbox_ratetext, popup_sbuttons, popup_sok, popup_scancel, lowBox;
+
+  if ((recording == True) ||
+      ((popup_sformat = XtNameToWidget(parent, "popup_sformat")) != NULL)) {
+    warnCB(parent, "warnrecording", True);
+    return;
+  }
+
+  popup_sformat = XtVaCreatePopupShell("popup_sformat",
+            transientShellWidgetClass,parent, NULL);
+  popup_sform = XtVaCreateManagedWidget("popup_sform",formWidgetClass,
+            popup_sformat, XtNbackground,bgcolor, XtNwidth,200, NULL);
+  popup_slabel = XtVaCreateManagedWidget("popup_slabel",labelWidgetClass,
+            popup_sform, XtNbackground,menubcolor, NULL);
+
+  lowBox = createOutputSelectionWidgets(popup_sformat, popup_sform,
+                                             popup_slabel, record, False);
+
+  sbox_rbox = XtVaCreateManagedWidget("sbox_rbox",boxWidgetClass,popup_sform,
+                                           XtNorientation,XtorientVertical,
+                                           XtNbackground,bgcolor,
+                                           XtNfromVert,lowBox,
+                                           XtNborderWidth,0, NULL);
+  sbox_ratelabel = XtVaCreateManagedWidget("sbox_ratelabel",labelWidgetClass,
+                                              sbox_rbox, XtNborderWidth,0,
+                                              XtNforeground,textcolor,
+                                              XtNbackground,bgcolor, NULL);
+  sbox_ratetext = XtVaCreateManagedWidget("sbox_ratetext",asciiTextWidgetClass,
+                                              sbox_rbox,
+                                              XtNdisplayNonprinting,False,
+                                              XtNfromHoriz,sbox_ratelabel,
+                                              XtNstring,(String)S(DEFAULT_RATE),
+                                              XtNbackground,textbgcolor,
+                                              XtNforeground,textcolor,
+                                              XtNeditType,XawtextEdit, NULL);
+  XtCallActionProc(sbox_ratetext, (String)"end-of-line", NULL, NULL, ZERO);
+  XtInstallAccelerators(sbox_ratetext, record->formatGroup);
+
+  popup_sbuttons = XtVaCreateManagedWidget("popup_sbuttons",boxWidgetClass,
+                                           popup_sform, XtNbackground,bgcolor,
+                                           XtNorientation,XtorientHorizontal,
+                                           XtNfromVert,sbox_rbox,
+                                           XtNborderWidth,0, NULL);
+  popup_sok = XtVaCreateManagedWidget("OK",commandWidgetClass,popup_sbuttons,
+                    XtNbackground,buttonbgcolor, XtNresize,False,
+                    XtNfromVert,sbox_rbox, XtNwidth,90, NULL);
+  popup_scancel = XtVaCreateManagedWidget("Cancel",commandWidgetClass,
+                    popup_sbuttons, XtNbackground,buttonbgcolor,
+                    XtNresize,False, XtNfromVert,sbox_rbox,
+                    XtNfromHoriz,popup_sok, XtNwidth,90, NULL);
+
+  record->lbuf = safe_strdup(lbuf);
+  XtAddCallback(popup_sok, XtNcallback,recordCB, (XtPointer)sbox_ratetext);
+  XtAddCallback(popup_scancel, XtNcallback,closeWidgetCB,
+                (XtPointer)popup_sformat);
+
+  setupWindow(popup_sformat, "do-closeparent()", False, True);
+  XtSetKeyboardFocus(popup_sformat, sbox_ratetext);
+}
+
+static void
+recordCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  String rate;
+  Widget warning;
+  id_list *result;
+  int i;
+
+  if (client_data != NULL) w = (Widget)client_data;
+  result = (id_list *)XawToggleGetCurrent(record->formatGroup);
+  XtVaGetValues(w, XtNstring,&rate, NULL);
+  i = atoi(rate);
+  if ((i < MIN_OUTPUT_RATE) || (i > MAX_OUTPUT_RATE)) return;
+  if (recording == True) {
+    warnCB(toplevel, "warnrecording", True);
+    return;
+  }
+  recording = True;
+  snprintf(local_buf, sizeof(local_buf), "W%c%d %s", result->id_char,
+           i, record->lbuf);
+  w = seekTransientShell(w);
+  XtPopdown(XtParent(w));
+  XtPopdown(w);
+
+  stopCB(NULL, NULL, NULL);
+  warning = warnCB(toplevel, "waitforwav", False);
+  a_pipe_write("%s", local_buf);
+  while (strncmp(local_buf, "Z1", 2)) {
+    XtAppProcessEvent(app_con, XtIMAll);
+  }
+  if (*(local_buf + 2) == 'E') goto savend;
+#ifdef CLEARVALUE
+  clearValue(load_d);
+#endif /* CLEARVALUE */
+  XtVaSetValues(load_d, XtNvalue,"", NULL);
+  a_pipe_write("P");
+  while (strncmp(local_buf, "Z2", 2)) {
+    XtAppProcessEvent(app_con, XtIMAll);
+  }
+savend:
+  XtDestroyWidget(warning);
+  a_pipe_write("w");
+  nextCB(NULL, NULL, NULL);
+  stopCB(NULL, NULL, NULL);
+  recording = False;
+}
+
+static void
+recordACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  recordCB(w, NULL, NULL);
+}
+
+static void
+scrollListACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  int i = atoi(*v);
+  Widget scrollbar;
+  int x, y;
+  Window win;
+
+  XTranslateCoordinates(disp, XtWindow(w), XtWindow(XtParent(w)),
+                        e->xbutton.x, e->xbutton.y, &x, &y, &win);
+
+  scrollbar = XtNameToWidget(XtParent(w), "vertical");
+  if (scrollbar != NULL) {
+    e->xbutton.y = y;
+  } else {
+    scrollbar = XtNameToWidget(XtParent(w), "horizontal");
+    if (scrollbar == NULL) return;
+    e->xbutton.x = x;
+  }
+
+  if (i > 0) {
+    String arg[1];
+    arg[0] = XtNewString("Forward");
+    XtCallActionProc(scrollbar, (String)"StartScroll", e, arg, ONE);
+    XtFree(arg[0]);
+#ifdef USEOWNSTARTSCROLL
+    XtCallActionProc(scrollbar, (String)"NotifyThumb", e, NULL, ZERO);
+#else
+    arg[0] = XtNewString("Proportional");
+    XtCallActionProc(scrollbar, (String)"NotifyScroll", e, arg, ONE);
+    XtFree(arg[0]);
+#endif /* USEOWNSTARTSCROLL */
+    XtCallActionProc(scrollbar, (String)"EndScroll", e, NULL, ZERO);
+  } else {
+    String arg[1];
+    arg[0] = XtNewString("Backward");
+    XtCallActionProc(scrollbar, (String)"StartScroll", e, arg, ONE);
+    XtFree(arg[0]);
+#ifdef USEOWNSTARTSCROLL
+    XtCallActionProc(scrollbar, (String)"NotifyThumb", e, NULL, ZERO);
+#else
+    arg[0] = XtNewString("Proportional");
+    XtCallActionProc(scrollbar, (String)"NotifyScroll", e, arg, ONE);
+    XtFree(arg[0]);
+#endif /* USEOWNSTARTSCROLL */
+    XtCallActionProc(scrollbar, (String)"EndScroll", e, NULL, ZERO);
+  }
+}
+
+static void
+toggleMark(Widget w, Boolean value) {
+  XtVaSetValues(w, XtNleftBitmap,(value == True)?check_mark:None, NULL);
+}
+
+static void
+filemenuACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  int i = atoi(*v);
+
+  filemenuCB(file_menu[i-100].widget, (XtPointer)&file_menu[i-100].id, NULL);
+}
+
+static void
+popupfilemenuACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  XtCallActionProc(file_mb, (String)"reset", e, NULL, ZERO);
+  XtCallActionProc(file_mb, (String)"PopupMenu", e, NULL, ZERO);
+}
+
+static void
+popdownfilemenuACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  XtCallActionProc(file_mb, (String)"reset", e, NULL, ZERO);
+  XtCallActionProc(file_sm, (String)"MenuPopdown", e, NULL, ZERO);
+}
+
+static void
+filemenuCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  int *id = (int *)client_data;
+
+  switch (*id) {
+    case ID_LOAD:
+      popupDialog(w, "dialog_lfile", NULL, popdownLoadfile, ldSstart);
+      break;
+    case ID_SAVE:
+      if ((record == NULL) || (max_files == 0)) return;
+      popupDialog(w, "dialog_sfile", NULL, popdownSavefile, ldSstart);
+      break;
+    case ID_LOAD_PLAYLIST:
+      popupDialog(w, LISTDIALOGBASENAME, 
+                &app_resources.load_LISTDIALOGBASENAME_title,
+                popdownLoadPL, ldSstart);
+      break;
+    case ID_SAVE_PLAYLIST:
+      popupDialog(w, LISTDIALOGBASENAME, 
+                 &app_resources.save_LISTDIALOGBASENAME_title,
+                 popdownSavePL, ldSstart);
+      break;
+    case ID_AUTOSTART:
+      Cfg.autostart ^= True;
+      toggleMark(w, Cfg.autostart);
+      break;
+    case ID_AUTOQUIT:
+      Cfg.autoexit ^= True;
+      toggleMark(w, Cfg.autoexit);
+      a_pipe_write("q");
+      break;
+    case ID_HIDETRACE:
+      XawFormDoLayout(base_f, False);
+      if (!ctl->trace_playing) {
+        Boolean s;
+
+        XtVaSetValues(b_box, XtNleft,XawRubber, XtNright,XawRubber, NULL);
+        createTraceWidgets();
+       /*
+        * trace_vport should be unmanaged before calling XResizeWindow, with
+        * XtNtop set to XawChainTop else xaw tends to place it on the wrong
+        * place (typically where lyric_t used to be before calling
+        * XResizeWindow). After the resize, we'll remange trace_vport, and
+        * set XtNtop to XawChainBottom (useful in case of resizing).
+        */
+        XtUnmanageChild(trace_vport);
+        callInitTrace();
+        ctl->trace_playing = 1;
+#ifdef HAVE_TIP
+        xawTipSet(Cfg.tooltips);
+#endif /* HAVE_TIP */
+       /*
+        * In the case lyric_t is not managed, the maximum height has been 
+        * defined to curr_height by setSizeHints. We need to increase it 
+        * otherwise the trace may not be shown - the WM may cap
+        * XConfigureEvent->height to
+        * maximum_height - WINDOW_DECORATIONS_HEIGHT.
+        */
+        if (!XtIsManaged(lyric_t)) setSizeHints(root_height);
+        XResizeWindow(disp, XtWindow(toplevel),
+                      TRACE_WIDTH+8, curr_height + trace_v_height);
+        XtVaGetValues(play_b, XtNstate,&s, NULL);
+        if (s == True) a_pipe_write("tR");
+        else a_pipe_write("t");
+        toggleMark(w, True);
+        return;
+      }
+     /*
+      * We must do this via XResizeWindow, as we are unable to calculate
+      * lyric_height correctly here in the case
+      * (trace_v_height + curr_height) is too big.
+      *
+      * lyric_height = curr_height - base_height -
+      * (XtIsManaged(trace_vport))?trace_v_height:0.
+      *
+      * curr_height should be capped to max_height - WINDOW_DECORATIONS_HEIGHT
+      *
+      * We do not know WDH, so we cannot avoid overflow leading to
+      * display artifacts when (trace_v_height + curr_height)
+      * is larger than the cap.
+      * However, most of these WMs will not return an XConfigureEvent->
+      * height greater than that cap, so resizeToplevelAction can
+      * calculate a correct lyric_height.
+      */
+      if (XtIsManaged(trace_vport)) {
+        XtUnmanageChild(trace_vport);
+        XtUnmanageChild(fast_b); XtUnmanageChild(slow_b);
+        XtUnmanageChild(keyup_b); XtUnmanageChild(keydown_b);
+        XtVaSetValues(b_box, XtNleft,XawChainLeft, XtNright,XawChainLeft, NULL);
+        XResizeWindow(disp, XtWindow(toplevel), DEFAULT_REG_WIDTH,
+                      curr_height - trace_v_height);
+        Cfg.disptrace = False;
+      } else {
+        XtVaSetValues(trace_vport, XtNtop,XawChainTop, NULL);
+        if (!XtIsManaged(lyric_t)) setSizeHints(root_height);
+        XtVaSetValues(b_box, XtNleft,XawRubber, XtNright,XawRubber, NULL);
+        XtManageChild(fast_b); XtManageChild(slow_b);
+        XtManageChild(keyup_b); XtManageChild(keydown_b);
+        XResizeWindow(disp, XtWindow(toplevel),
+                      TRACE_WIDTH+8, curr_height + trace_v_height);
+        Cfg.disptrace = True;
+      }
+      toggleMark(w, !Cfg.disptrace);
+      break;
+    case ID_HIDETXT:
+      XawFormDoLayout(base_f, False);
+      if (Cfg.disptrace == True) {
+        XtUnmanageChild(trace_vport);
+        XtVaSetValues(trace_vport, XtNtop,XawChainTop, NULL);
+      }
+      if (XtIsManaged(lyric_t)) {
+        if (ctl->trace_playing)
+          XtVaSetValues(trace_vport, XtNfromVert,t_box, NULL);
+        XtUnmanageChild(lyric_t);
+        XResizeWindow(disp, XtWindow(toplevel),
+                      curr_width, curr_height - lyric_height);
+        Cfg.disptext = False;
+      } else {
+        setSizeHints(curr_height + lyric_height);
+        if (ctl->trace_playing)
+          XtVaSetValues(trace_vport, XtNfromVert,lyric_t, NULL);
+        XtManageChild(lyric_t);
+        XResizeWindow(disp, XtWindow(toplevel),
+                      curr_width, curr_height + lyric_height);
+        Cfg.disptext = True;
       }
-      toggleMark(w,*id);
+      toggleMark(w, !Cfg.disptext);
       break;
     case ID_SAVECONFIG:
-      a_saveconfig(dotfile);
+      a_saveconfig(dotfile, Cfg.save_list);
       break;
     case ID_SHUFFLE:
-      randomAction(NULL,NULL,NULL,NULL);
+      Cfg.shuffle ^= True;
+      randomCB(NULL, (XtPointer)&Cfg.shuffle, NULL);
       break;
     case ID_REPEAT:
-      repeatAction(NULL,NULL,NULL,NULL);
+      Cfg.repeat ^= True;
+      repeatCB(NULL, (XtPointer)&Cfg.repeat, NULL);
       break;
     case ID_OPTIONS:
-      optionspopupCB(w,NULL,NULL);
-      break;    
+      optionspopupACT(w, NULL, NULL, NULL);
+      break;
     case ID_FILELIST:
-      flistpopupCB(w,NULL,NULL);
-      break;    
+      flistpopupACT(w, NULL, NULL, NULL);
+      break;
     case ID_ABOUT:
-      aboutCB(w,NULL,NULL);
+      aboutACT(w, NULL, NULL, NULL);
       break;
     case ID_QUIT:
-      quitCB(w,NULL,NULL);
-      break;    
+      quitCB(w, NULL, NULL);
+      break;
   }
 }
 
 #ifdef WIDGET_IS_LABEL_WIDGET
-static void a_print_msg(Widget w)
-{
-    int i, msglen;
-    a_pipe_nread((char *)&msglen, sizeof(int));
-    while(msglen > 0)
-    {
+static void
+a_print_msg(Widget w) {
+  size_t i, msglen;
+
+  a_pipe_nread((char *)&msglen, sizeof(size_t));
+  while (msglen > 0) {
     i = msglen;
-    if(i > sizeof(local_buf)-1)
-        i = sizeof(local_buf)-1;
+    if (i > sizeof(local_buf)-1) i = sizeof(local_buf)-1;
     a_pipe_nread(local_buf, i);
     local_buf[i] = '\0';
-    XtVaSetValues(w,XtNlabel,local_buf,NULL);
+    XtVaSetValues(w, XtNlabel,local_buf, NULL);
     msglen -= i;
-    }
+  }
 }
 #else
-static void a_print_msg(Widget w)
-{
-    int i, msglen;
-    XawTextPosition pos;
-    XawTextBlock tb;
+static void
+a_print_msg(Widget w) {
+  size_t i, msglen;
+  XawTextPosition pos;
+  XawTextBlock tb;
 
-    tb.firstPos = 0;
-    tb.ptr = local_buf;
-    tb.format = FMT8BIT;
-    pos = XawTextGetInsertionPoint(w);
+  tb.firstPos = 0;
+  tb.ptr = local_buf;
+  tb.format = XawFmt8Bit;
+  pos = XawTextGetInsertionPoint(w);
 
-    a_pipe_nread((char *)&msglen, sizeof(int));
-    while(msglen > 0)
-    {
-        i = msglen;
-        if(i > sizeof(local_buf))
-            i = sizeof(local_buf);
-        a_pipe_nread(local_buf, i);
-        tb.length = i;
-        XawTextReplace(w, pos, pos, &tb);
-        pos += i;
-        XawTextSetInsertionPoint(w, pos);
-        msglen -= i;
-    }
+  a_pipe_nread((char *)&msglen, sizeof(size_t));
+  while (msglen > 0) {
+    i = msglen;
+    if (i > sizeof(local_buf)) i = sizeof(local_buf);
+    a_pipe_nread(local_buf, i);
+    tb.length = i;
+    XawTextReplace(w, pos, pos, &tb);
+    pos += i;
+    XawTextSetInsertionPoint(w, pos+1);
+    msglen -= i;
+  }
+#ifdef BYPASSTEXTSCROLLBUG
+  XtCallActionProc(lyric_t, (String)"redraw-display", NULL, NULL, ZERO);
+#endif /* BYPASSTEXTSCROLLBUG */
 }
 #endif /* WIDGET_IS_LABEL_WIDGET */
 
-#define DELTA_VEL       32
+static void
+free_vars(void) {
+  Cardinal n;
+  int i = 0;
+  WidgetList wl;
+  Pixmap bm_Pixmap;
+
+#if 0
+  free_ldS(ldSstart);
+  free(Cfg.DefaultDir);
+  free(home); free(dotfile);
+  free(psmenu);
+  if (record != NULL) {
+    for (i = 0; i < record->max; i++)
+      free(record->output_list[i].id_name); 
+    free(record->output_list);
+    free(record);
+  }
+  if (play != NULL) {
+    for (i = 0; i < play->max; i++)
+      free(play->output_list[i].id_name); 
+    free(play->output_list);
+    free(play);
+  }
+  free_ptr_list(flist, max_files);
+#endif
 
-static void ctl_channel_note(int ch, int note, int velocity) {
-  
-  if(!ctl->trace_playing) return;
-  if (velocity == 0) {
-    if (note == Panel->cnote[ch])     
-      Panel->v_flags[ch] = FLAG_NOTE_OFF;
-    Panel->cvel[ch] = 0;
-  } else if (velocity > Panel->cvel[ch]) {
-    Panel->cvel[ch] = velocity;
-    Panel->cnote[ch] = note;
-    Panel->ctotal[ch] = velocity * Panel->channel[ch].volume *
-      Panel->channel[ch].expression / (127*127);
-    Panel->v_flags[ch] = FLAG_NOTE_ON;
+  XtUnmapWidget(toplevel);
+  if (ctl->trace_playing) uninitTrace();
+  XFreePixmap(disp, check_mark); XFreePixmap(disp, arrow_mark);
+  XFreePixmap(disp, on_mark); XFreePixmap(disp, off_mark);
+  XtVaGetValues(b_box, XtNchildren,&wl, XtNnumChildren,&n, NULL);
+  for (i = 0; i < n; i++) {
+    XtVaGetValues(wl[i], XtNbitmap,&bm_Pixmap, NULL);
+    XFreePixmap(disp, bm_Pixmap);
   }
+  XtDestroyApplicationContext(app_con);
 }
 
-/*ARGSUSED*/
-static void handle_input(XtPointer data,int *source,XtInputId *id) {
-  char s[16], c;
-  int i=0, n, ch, note;
-  float thumb;
-  char **pp;
+static void
+handle_input(XtPointer data, int *source, XtInputId *id) {
+  char s[16];
+  int n; long i;
+  barfloat thumb;
 
-  a_pipe_read(local_buf,sizeof(local_buf));
+  a_pipe_read(local_buf, sizeof(local_buf));
   switch (local_buf[0]) {
-  case 't' :
-    curr_time = n = atoi(local_buf+2); i= n % 60; n /= 60;
-    sprintf(s, "%d:%02d", n,i);
-    XtVaSetValues(tune_l0, XtNlabel, s, NULL);
-    if (total_time >0) {
-      thumbj = (float)curr_time / (float)total_time;
-      if (sizeof(thumbj) > sizeof(XtArgVal)) {
-        XtVaSetValues(tune_bar,XtNtopOfThumb,&thumbj,NULL);
-      } else {
-        XtArgVal *l_thumbj = (XtArgVal *) &thumbj;
-        XtVaSetValues(tune_bar,XtNtopOfThumb,*l_thumbj,NULL);
-      }
+  case 't':
+    curr_time = n = atoi(local_buf+2);
+    if (halt) break;
+    i = n % 60; n /= 60;
+    sprintf(s, "%d:%02ld", n, i);
+    XtVaSetValues(tune_l0, XtNlabel,s, NULL);
+    if (total_time > 0) {
+      thumb.f = (float)curr_time / (float)total_time;
+      setThumb(tune_bar, thumb);
     }
     break;
-  case 'T' :
-    n= atoi(local_buf+2);
-    if(n > 0) {
+  case 'T':
+    n = atoi(local_buf+2);
+    if (n > 0) {
       total_time = n;
-      snprintf(s,sizeof(s), "/%2d:%02d", n/60, n%60);
-      XtVaSetValues(tune_l,XtNlabel,s,NULL);
+      snprintf(s, sizeof(s), "/%2d:%02d", n/60, n%60);
+      XtVaSetValues(tune_l, XtNlabel,s, NULL);
     }
     break;
-  case 'E' :
+  case 'E':
     {
       char *name;
-      name=strrchr(local_buf+2,' ');
-      n= atoi(local_buf+2);
-      if(popup_shell_exist & FLIST_WINDOW)
+      name = strchr(local_buf+2, ' ');
+      current_n_displayed = n = atoi(local_buf+2);
+      lockevents = False;
+      if (IsRealized(popup_file))
         XawListHighlight(file_list, n-1);
-      if(name==NULL)
-        break;
+      if (name == NULL) break;
       name++;
-      XtVaSetValues(title_mb,XtNlabel,name,NULL);
-      snprintf(window_title, sizeof(window_title), "%s : %s", APP_CLASS, local_buf+2);
-      XtVaSetValues(toplevel,XtNtitle,window_title,NULL);
-      *window_title = '\0';
+      XtVaSetValues(title_mb, XtNlabel,name, NULL);
+      snprintf(window_title, sizeof(window_title), "%s : %s",
+               APP_CLASS, local_buf+2);
+      XtVaSetValues(toplevel, XtNtitle,window_title, NULL);
     }
     break;
-  case 'e' :
-    if (arrangetitle) {
-      char *p= local_buf+2;
-      if (!strcmp(p, "(null)")) p = UNTITLED_STR;
+  case 'e':
+    if (app_resources.arrange_title) {
+      char *p = local_buf+2;
+      if (!strcmp(p, "(null)")) p = (char *)app_resources.tracecfg.untitled;
       snprintf(window_title, sizeof(window_title), "%s : %s", APP_CLASS, p);
-      XtVaSetValues(toplevel,XtNtitle,window_title,NULL);
+      XtVaSetValues(toplevel, XtNtitle,window_title, NULL);
     }
     snprintf(window_title, sizeof(window_title), "%s", local_buf+2);
     break;
-  case 'O' : offPlayButton();break;
-  case 'L' :
+  case 'O' :
+    thumb.f = 0;
+    setThumb(tune_bar, thumb);
+    XtVaSetValues(tune_l0, XtNlabel,"0:00", NULL);
+    offPlayButton();
+    break;
+  case 'L':
     a_print_msg(lyric_t);
     break;
-  case 'Q' : exit(0);
+  case 'Q':
+    free_vars();
+    exit(0);
   case 'V':
-    amplitude=atoi(local_buf+2);
-    thumb = (float)amplitude / (float)MAXVOLUME;
-    sprintf(s, "%d", amplitude);
-    XtVaSetValues(vol_l, XtNlabel, s, NULL);
-    if (sizeof(thumb) > sizeof(XtArgVal)) {
-      XtVaSetValues(vol_bar, XtNtopOfThumb, &thumb, NULL);
-    } else {
-      XtArgVal *l_thumb = (XtArgVal *) &thumb;
-      XtVaSetValues(vol_bar, XtNtopOfThumb,*l_thumb, NULL);
-    }
-    break;
-  case 'v':
-    c= *(local_buf+1);
-    n= atoi(local_buf+2);
-    if(c == 'L')
-      xaw_i_voices = n;
-    else
-      last_voice = n;
-    if(IsTracePlaying()) drawVoices();
+    if (lockevents == True) return;
+    amplitude = atoi(local_buf+2);
+    snprintf(s, sizeof(s), "%d", amplitude);
+    XtVaSetValues(vol_l, XtNlabel,s, NULL);
+    thumb.f = (float)amplitude / (float)MAXVOLUME;
+    setThumb(vol_bar, thumb);
     break;
   case 'g':
-  case '\0' :
+  case '\0':
+  case 'Z':
     break;
   case 'X':
-    n=max_files;
-    max_files+=atoi(local_buf+2);
+    n = max_files;
+    max_files += atoi(local_buf+2);
+    if ((max_files > 0) && (record != NULL))
+      XtVaSetValues(file_menu[ID_SAVE - 100].widget, XtNsensitive,True, NULL);
     for (i=n;i<max_files;i++) {
-      a_pipe_read(local_buf,sizeof(local_buf));
-      addOneFile(max_files,i,local_buf,True);
-    }
-    if(popup_shell_exist & FLIST_WINDOW){
-      Dimension h,w;
-      XtVaGetValues(file_list,XtNwidth,&w,NULL);
-      XawListChange(file_list,flist,max_files,w,True);
-      /* to keep Viewport size */
-      XtVaGetValues(file_vport,XtNwidth,&w,XtNheight,&h,NULL);
-      XtVaSetValues(file_vport,XtNheight,((h>FILEVPORT_HEIGHT)? h:FILEVPORT_HEIGHT),NULL);
-    }
-    break;
-  case 'Y':
-    if(ctl->trace_playing) {
-      ch= *(local_buf+1) - 'A';
-      c= *(local_buf+2);
-      note= (*(local_buf+3)-'0')*100 + (*(local_buf+4)-'0')*10 + *(local_buf+5)-'0';
-      n= atoi(local_buf+6);
-      if (c == '*' || c == '&') {
-        Panel->c_flags[ch] |= FLAG_PROG_ON;
-      } else {
-        Panel->c_flags[ch] &= ~FLAG_PROG_ON; n= 0;
-      }
-      ctl_channel_note(ch, note, n);
-      draw1Note(ch,note,c);
-      draw1Chan(ch,Panel->ctotal[ch],c);
-    }
-    break;
-  case 'I':
-    if(IsTracePlaying()) {
-      ch= *(local_buf+1) - 'A';
-      strncpy(inst_name[ch], (char *)&local_buf[2], INST_NAME_SIZE);
-      drawInstname(ch, inst_name[ch]);
-    }
-    break;
-  case 'i':
-    if(IsTracePlaying()) {
-      ch= *(local_buf+1) - 'A';
-      Panel->is_drum[ch]= *(local_buf+2) - 'A';
-      drawDrumPart(ch, Panel->is_drum[ch]);
+      a_pipe_read(local_buf, sizeof(local_buf));
+      addOneFile(max_files, i, local_buf);
+      addFlist(local_buf, i);
     }
-    break;
-  case 'P':
-    if(IsTracePlaying()) {
-      c= *(local_buf+1);
-      ch= *(local_buf+2)-'A';
-      n= atoi(local_buf+3);
-      switch(c) {
-      case  'A':        /* panning */
-        Panel->channel[ch].panning = n;
-        Panel->c_flags[ch] |= FLAG_PAN;
-        drawPan(ch,n,True);
-        break;
-      case  'B':        /* pitch_bend */
-        Panel->channel[ch].pitchbend = n;
-        Panel->c_flags[ch] |= FLAG_BENDT;
-        if (!plane) drawPitch(ch,n);
-        break;
-      case  'b':        /* tonebank */
-        Panel->channel[ch].bank = n;
-        if (plane) drawBank(ch,n);
-        break;
-      case  'r':        /* reverb */
-        Panel->reverb[ch] = n;
-        if (plane) drawReverb(ch,n);
-        break;
-      case  'c':        /* chorus */
-        Panel->channel[ch].chorus_level = n;
-        if (plane) drawChorus(ch,n);
-        break;
-      case  'S':        /* sustain */
-        Panel->channel[ch].sustain = n;
-        Panel->c_flags[ch] |= FLAG_SUST;
-        break;
-      case  'P':        /* program */
-        Panel->channel[ch].program = n;
-        Panel->c_flags[ch] |= FLAG_PROG;
-        drawProg(ch,n,4,pl[plane].ofs[CL_PR],True);
-        break;
-      case  'E':        /* expression */
-        Panel->channel[ch].expression = n;
-        ctl_channel_note(ch, Panel->cnote[ch], Panel->cvel[ch]);
-        drawExp(ch,n);
-        break;
-      case  'V':        /* volume */
-        Panel->channel[ch].volume = n;
-        ctl_channel_note(ch, Panel->cnote[ch], Panel->cvel[ch]);
-        drawVol(ch,n);
-        break;
-      }
-    }
-    break;
-  case 'R':
-    redrawTrace(True);  break;
-  case 'U':         /* update timer */
-    if(ctl->trace_playing) {
-      static double last_time = 0;
-      double d, t;
-      Bool need_flush;
-      double delta_time;
-
-      t = get_current_calender_time();
-      d = t - last_time;
-      if(d > 1)
-        d = 1;
-      delta_time = d / XAW_UPDATE_TIME;
-      last_time = t;
-      need_flush = False;
-      for(i=0; i<MAX_XAW_MIDI_CHANNELS; i++)
-        if (Panel->v_flags[i]) {
-          if (Panel->v_flags[i] == FLAG_NOTE_OFF) {
-            Panel->ctotal[i] -= DELTA_VEL * delta_time;
-            if (Panel->ctotal[i] <= 0) {
-              Panel->ctotal[i] = 0;
-              Panel->v_flags[i] = 0;
-            }
-            draw1Chan(i,Panel->ctotal[i],'*');
-            need_flush = True;
-          } else {
-            Panel->v_flags[i] = 0;
-          }
-        }
-      if(need_flush)
-        XFlush(XtDisplay(trace));
+    if (IsRealized(popup_file)) {
+      XawListReturnStruct *lr = XawListShowCurrent(file_list);
+
+      XawListChange(file_list, flist, max_files, 0, True);
+      if ((lr != NULL) && (lr->list_index != XAW_LIST_NONE))
+         XawListHighlight(file_list, lr->list_index);
+      else
+        if (max_files > 0) XawListHighlight(file_list, 0);
     }
     break;
   case 'm':
-    n= atoi(local_buf+1);
-    switch(n) {
+    n = atoi(local_buf+1);
+    switch (n) {
     case GM_SYSTEM_MODE:
-      sprintf(s,"%d:%02d / GM",total_time/60,total_time%60); break;
+      snprintf(s, sizeof(s), "%d:%02d / GM", total_time/60, total_time%60);
+      break;
     case GS_SYSTEM_MODE:
-      sprintf(s,"%d:%02d / GS",total_time/60,total_time%60); break;
+      snprintf(s, sizeof(s), "%d:%02d / GS", total_time/60, total_time%60);
+      break;
     case XG_SYSTEM_MODE:
-      sprintf(s,"%d:%02d / XG",total_time/60,total_time%60); break;
+      snprintf(s, sizeof(s), "%d:%02d / XG", total_time/60, total_time%60);
+      break;
     default:
-      sprintf(s,"%d:%02d",total_time/60,total_time%60); break;
+      snprintf(s, sizeof(s), "%d:%02d", total_time/60, total_time%60);
+      break;
     }
-    XtVaSetValues(time_l,XtNlabel,s,NULL);
+    XtVaSetValues(time_l, XtNlabel,s, NULL);
     break;
   case 's':
-    n= atoi(local_buf+1);
-    pp = current_flist;
-    if(pp != NULL) {
-      while(*pp != NULL) free(*pp++);
-      free(current_flist);
+    savePlaylist(local_buf);
+    break;
+  case 'o':         /* pitch offset */
+    if (IsTracePlaying()) {
+      XtCallActionProc(keyup_b, (String)"unset", NULL, NULL, ZERO);
+      XtCallActionProc(keydown_b, (String)"unset", NULL, NULL, ZERO);
+#ifdef XAWPLUS
+      XtCallActionProc(keyup_b, (String)"unhighlight", NULL, NULL, ZERO);
+      XtCallActionProc(keydown_b, (String)"unhighlight", NULL, NULL, ZERO);
+#endif /* XAWPLUS */
+      (void)handleTraceinput(local_buf);
     }
-    current_flist = (char **)safe_malloc(sizeof(char *) * (n+1));
-    if ('\0' != *dotfile) {
-      FILE *fp;
-      if (savelist) {
-        if (NULL != (fp=fopen(dotfile, "a+"))) {
-          for(i=0; i<n; i++) {
-            a_pipe_read(local_buf,sizeof(local_buf));
-            current_flist[i]=(char *)safe_malloc(sizeof(char)*(strlen(local_buf)+1));
-            strcpy(current_flist[i], local_buf);
-            fprintf(fp,"set %s %s\n",cfg_items[S_MidiFile],current_flist[i]);
-          }
-          fclose(fp);
-        }
-      } else
-        for(i=0; i<n; i++) a_pipe_read(local_buf,sizeof(local_buf));
+    break;
+  case 'p':         /* pitch */
+    if (IsTracePlaying()) (void)handleTraceinput(local_buf);
+    break;
+  case 'q':         /* quotient, ratio */
+    if (IsTracePlaying()) {
+      XtCallActionProc(fast_b, (String)"unset", NULL, NULL, ZERO);
+      XtCallActionProc(slow_b, (String)"unset", NULL, NULL, ZERO);
+#ifdef XAWPLUS
+      XtCallActionProc(fast_b, (String)"unhighlight", NULL, NULL, ZERO);
+      XtCallActionProc(slow_b, (String)"unhighlight", NULL, NULL, ZERO);
+#endif /* XAWPLUS */
+      (void)handleTraceinput(local_buf);
     }
-    current_flist[n] = NULL;
     break;
-  default : 
-    fprintf(stderr,"Unkown message '%s' from CONTROL" NLS,local_buf);
+  case 'r':         /* rhythem, tempo */
+    if (IsTracePlaying()) (void)handleTraceinput(local_buf);
+    break;
+  default :
+    if ((lockevents == True) || (((ctl->trace_playing) &&
+         (!handleTraceinput(local_buf)))))
+      return;
+    fprintf(stderr, "Unkown message '%s' from CONTROL\n", local_buf);
   }
 }
 
 
-static int configcmp(char *s, int *num) {
+static int
+configcmp(char *s, int *num) {
   int i;
   char *p;
-  for (i= 0; i < CFGITEMSNUMBER; i++) {
-    if (0 == strncasecmp(s, cfg_items[i], strlen(cfg_items[i]))) {
+
+  for (i = 0; i < CFGITEMSNUMBER; i++) {
+    if (strncasecmp(s, cfg_items[i], strlen(cfg_items[i])) == 0) {
       p = s + strlen(cfg_items[i]);
-      while (*p == SPACE || *p == TAB) p++;
-      if(i == S_MidiFile)
-        *num = p - s;
+      while ((*p == ' ') || (*p == '\t')) p++;
+      if ((i == S_MidiFile) || (i == S_DefaultDirectory))
+        *num = p - s + SPLEN;
       else
         *num = atoi(p);
       return i;
     }
   }
-  return(-1);
+  return -1;
 }
 
-static char *strmatch(char *s1, char *s2) {
+static char *
+strmatch(char *s1, char *s2) {
   char *p = s1;
 
-  while (*p != '\0' && *p == *s2++) p++;
+  while ((*p != '\0') && (*p == *s2++)) p++;
   *p = '\0';
-  return(s1);
+  return s1;
 }
 
 /* Canonicalize by removing /. and /foo/.. if they appear. */
-static char *canonicalize_path(char *path)
+static char *
+canonicalize_path(char *path)
 {
-    char *o, *p, *target;
-    int abspath;
+  char *o, *p, *target;
+  int abspath;
 
-    o = p = path;
-    while(*p)
-    {
-       if(p[0] == '/' && p[1] == '/')
-           p++;
-       else 
-           *o++ = *p++;
-    }
-    while(path < o-1 && path[o - path - 1] == '/')
-       o--;
-    path[o - path] = '\0';
+  o = p = path;
+  while (*p) {
+    if ((p[0] == '/') && (p[1] == '/')) p++;
+    else *o++ = *p++;
+  }
+  while ((path < o-1) && (path[o - path - 1] == '/')) o--;
+  path[o - path] = '\0';
 
-    if((p = strchr(path, '/')) == NULL)
-       return path;
-    abspath = (p == path);
+  if ((p = strchr(path, '/')) == NULL) return path;
+  abspath = (p == path);
 
-    o = target = p;
-    while(*p)
+  o = target = p;
+  while (*p) {
+    if (*p != '/') *o++ = *p++;
+    else if ((p[0] == '/') && (p[1] == '.') && ((p[2] == '/')||(p[2] == '\0')))
     {
-       if(*p != '/')
-           *o++ = *p++;
-       else if(p[0] == '/' && p[1] == '.'
-               && (p[2]=='/' || p[2] == '\0'))
-       {
-           /* If "/." is the entire filename, keep the "/".  Otherwise,
-              just delete the whole "/.".  */
-           if(o == target && p[2] == '\0')
-               *o++ = *p;
-           p += 2;
-       }
-       else if(p[0] == '/' && p[1] == '.' && p[2] == '.'
-               /* `/../' is the "superroot" on certain file systems.  */
-               && o != target
-               && (p[3]=='/' || p[3] == '\0'))
-       {
-           while(o != target && (--o) && *o != '/')
-               ;
-           p += 3;
-           if(o == target && !abspath)
-               o = target = p;
-       }
-       else
-           *o++ = *p++;
+      /* If "/." is the entire filename, keep the "/".  Otherwise,
+       *  just delete the whole "/.".
+       */
+      if ((o == target) && (p[2] == '\0')) *o++ = *p;
+      p += 2;
     }
+    else if ((p[0] == '/') && (p[1] == '.') && (p[2] == '.') &&
+    /* `/../' is the "superroot" on certain file systems.  */
+             (o != target) && (p[3] == '/' || p[3] == '\0'))
+    {
+      while ((o != target) && (--o) && (*o != '/'));
+      p += 3;
+      if ((o == target) && (!abspath)) o = target = p;
+    }
+    else *o++ = *p++;
+  }
 
-    target[o - target] = '\0';
-    if(!*path)
-       strcpy(path, "/");
-    return path;
+  target[o - target] = '\0';
+  if (*path == '\0') strcpy(path, "/");
+  return path;
 }
 
-static char *expandDir(char *path, DirPath *full) {
-  static char tmp[PATH_MAX];
+static char *
+expandDir(char *path, DirPath *full, char *bpath) {
   static char newfull[PATH_MAX];
+  char tmp[PATH_MAX];
   char *p, *tail;
 
   p = path;
   if (path == NULL) {
     strcpy(tmp, "/");
-    full->dirname = tmp;
-    full->basename = NULL;
-    strcpy(newfull, tmp); return newfull;
-  } else if (*p != '~' && NULL == (tail = strrchr(path, '/'))) {
+    strcpy(newfull, "/");
+    if (full != NULL) {
+      full->basename = NULL;
+      full->dirname = newfull;
+    }
+    return newfull;
+  } else 
+    if ((*p != '~') && ((tail = strrchr(path, '/')) == NULL) 
+         && (strcmp(p, ".")) && (strcmp(p, "..")) )
+  {
     p = tmp;
-    strncpy(p, basepath, PATH_MAX - 1);
-    full->dirname = p;
+    strlcpy(p, bpath, PATH_MAX);
+    if (full != NULL) full->dirname = p;
     while (*p++ != '\0') ;
-    strncpy(p, path, PATH_MAX - (p - tmp) - 1);
-    tmp[PATH_MAX-1] = '\0';
-    snprintf(newfull,sizeof(newfull),"%s/%s", basepath, path);
-    full->basename = p; return newfull;
+    strlcpy(p, path, PATH_MAX - (p - tmp));
+    snprintf(newfull, sizeof(newfull), "%s/%s", bpath, path);
+    if (full != NULL) full->basename = p;
+    return newfull;
   }
   if (*p  == '/') {
-    strncpy(tmp, path, PATH_MAX - 1);
+    strlcpy(tmp, path, PATH_MAX);
   } else {
     if (*p == '~') {
       struct passwd *pw;
 
       p++;
-      if (*p == '/' || *p == '\0') {
-        pw = getpwuid(getuid());
+      if ((*p == '/') || (*p == '\0')) {
+        if (home == NULL) return NULL;
+        while (*p == '/') p++;
+        snprintf(tmp, sizeof(tmp), "%s/%s", home, p);
       } else {
         char buf[80], *bp = buf;
 
-        while (*p != '/' && *p != '\0') *bp++ = *p++;
+        while ((*p != '/') && (*p != '\0')) *bp++ = *p++;
         *bp = '\0';
         pw = getpwnam(buf);
+        if (pw == NULL) {
+          ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
+                    "I tried to expand a non-existant user's homedir!");
+          return NULL;
+        }
+        else home = pw->pw_dir;
+        while (*p == '/') p++;
+        snprintf(tmp, sizeof(tmp), "%s/%s", home, p);
       }
-      if (pw == NULL) {
-        ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
-                  "something wrong with getting path."); return NULL;
-      }
-      while (*p == '/') p++;
-      snprintf(tmp, sizeof(tmp), "%s/%s", pw->pw_dir, p);
     } else {    /* *p != '~' */
-      snprintf(tmp, sizeof(tmp), "%s/%s", basepath, path);
+      snprintf(tmp, sizeof(tmp), "%s/%s", bpath, path);
     }
   }
   p = canonicalize_path(tmp);
   tail = strrchr(p, '/'); *tail++ = '\0';
-  full->dirname = p;
-  full->basename = tail;
-  snprintf(newfull,sizeof(newfull),"%s/%s", p, tail);
+  if (full != NULL) {
+    full->dirname = p;
+    full->basename = tail;
+  }
+  snprintf(newfull, sizeof(newfull), "%s/%s", p, tail);
   return newfull;
 }
 
-/*ARGSUSED*/
-static void setDirAction(Widget w,XEvent *e,String *v,Cardinal *n) {
+static void
+setDirACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+/* uses global ld */
   char *p, *p2;
   struct stat st;
-  DirPath full;
-  XawListReturnStruct lrs;
 
   p = XawDialogGetValueString(load_d);
-  if (NULL != (p2 = expandDir(p, &full)))
-    p = p2;
-  if(stat(p, &st) == -1) return;
-  if(S_ISDIR(st.st_mode)) {
-    strncpy(basepath,p,sizeof(basepath)-1);
-    p = strrchr(basepath, '/');
-    if (*(p+1) == '\0') *p = '\0';
-    lrs.string = "";
-    if(dirlist != NULL)
-    {
-       free(dirlist_top);
-       free(dirlist);
-       dirlist = NULL;
+  if ((p2 = expandDir(p, NULL, basepath)) != NULL) p = p2;
+  if (stat(p, &st) == -1) XtCallCallbacks(load_ok, XtNcallback, (XtPointer)ld);
+  else if (S_ISDIR(st.st_mode)) {
+    p2 = strrchr(p, '/');
+    if ((*(p2+1) == '\0') && (p2 != p)) *p2 = '\0';
+    if (!setDirList(ld, p) ) {
+      strlcpy(basepath, p, sizeof(basepath));
+      XtVaSetValues(cwd_l, XtNlabel,basepath, NULL);
+#ifdef CLEARVALUE
+      clearValue(load_d);
+#endif /* CLEARVALUE */
+      XtVaSetValues(load_d, XtNvalue,"", NULL);
     }
-    setDirList(load_flist, cwd_l, &lrs);
   }
+  else XtCallCallbacks(load_ok, XtNcallback,(XtPointer)ld);
 }
 
-/*
- * sort algorithm for DirList:
- * - directories before files
- */
-static int dirlist_cmp (const void *p1, const void *p2)
-{
-    int i1, i2;
-    char *s1, *s2;
-
-    s1 = *((char **)p1);
-    s2 = *((char **)p2);
-    i1 = strlen (s1) - 1;
-    i2 = strlen (s2) - 1;
-    if (i1 >= 0 && i2 >= 0) {
-    if (s1 [i1] == '/' && s2 [i2] != '/')
-        return -1;
-    if (s1 [i1] != '/' && s2 [i2] == '/')
-        return  1;
-    }
-    return strcmp (s1, s2);
+static void
+callFilterDirList(Widget w, XtPointer client_data, XtPointer call_data) {
+  Boolean toggle;
+
+  ldPointer ld = (ldPointer)client_data;
+  XtVaGetValues(load_b, XtNstate,&toggle, NULL);
+  filterDirList(w, ld, toggle);
+}
+
+static void
+filterDirList(Widget w, ldPointer ld, Boolean toggle) {
+/* can use global ld when called from SetDirAction via SetDirList */
+  String *fulllist = fulldirlist, *filelist;
+  StringTable strtab;
+  char *filename;
+  char mbuf[35];
+  unsigned int f_num = 0;
+
+  if (toggle == False) {
+    XawListChange(load_flist, fulldirlist, fullfilenum, 0, True);
+    XtVaSetValues(load_flist, XtNwidth,0, XtNheight,0, NULL);
+    snprintf(mbuf, sizeof(mbuf), "%d Directories, %d Files",
+             dirnum, fullfilenum);
+    XtVaSetValues(load_info, XtNlabel,mbuf, NULL);
+    return;
+  }
+  else if ( (fdirlist != NULL) &&
+            (!(strncmp(cur_filter, filter, sizeof(cur_filter)))) )
+  {
+    XawListChange(load_flist, fdirlist, filenum, 0, True);
+    XtVaSetValues(load_flist, XtNwidth,0, XtNheight,0, NULL);
+    snprintf(mbuf, sizeof(mbuf), "%d Directories, %d Files", dirnum, filenum);
+    XtVaSetValues(load_info, XtNlabel,mbuf, NULL);
+    return;
+  }
+  if (!strcmp(filter, "SetDirList")) strcpy(filter, cur_filter);
+  init_string_table(&strtab);
+  while ((filename = *(fulllist++)) != NULL) {
+    if (!(arc_case_wildmat(filename, filter))) continue;
+    f_num++;
+    put_string_table(&strtab, filename, strlen(filename));
+  }
+  filenum = f_num;
+  if (f_num > 0)
+    filelist = (String *)make_string_array(&strtab);
+  else {
+    filelist = (String *)safe_malloc(sizeof(String));
+    *filelist = '\0';
+  }
+  XawListChange(load_flist, filelist, f_num, 0, True);
+  free(fdirlist);
+  fdirlist = filelist;
+  XtVaSetValues(load_flist, XtNwidth,0, XtNheight,0, NULL);
+  strlcpy(cur_filter, filter, sizeof(cur_filter));
+
+  snprintf(mbuf, sizeof(mbuf), "%d Directories, %d Files", dirnum, filenum);
+  XtVaSetValues(load_info, XtNlabel,mbuf, NULL);
 }
 
-#ifndef        ORIGINAL
-/* RAKK/HIOENS: Save a string on the heap. Addition for 'common.c' ? */
-static  char  * strsav( char  * str ) {
-    char  * tp = safe_malloc( strlen(str)+1 );
-    strcpy(tp, str);
-    return tp;
+static int
+cmpstringp(const void *p1, const void *p2) {
+  return strcmp(* (char * const *) p1, * (char * const *) p2);
 }
-#endif /* RAKK/HIOENS */
 
-static void setDirList(Widget list, Widget label, XawListReturnStruct *lrs) {
+static int
+setDirList(ldPointer ld, char *curr_dir) {
+/* uses global ld when called from SetDirAction */
   URL dirp;
   struct stat st;
-  char currdir[PATH_MAX], filename[PATH_MAX];
-  int i, d_num, f_num;
-
-  snprintf(currdir, sizeof(currdir)-1, "%s/%s", basepath, lrs->string);
-  canonicalize_path(currdir);
-  if(stat(currdir, &st) == -1) return;
-  if(!S_ISDIR(st.st_mode)) {
-#ifdef ORIGINAL
-      XtVaSetValues(load_d,XtNvalue,currdir,NULL);
-#else  /* RAKK/HIOENS */
-      XtVaSetValues(load_d,XtNvalue,strsav(currdir),NULL);
-#endif /* ORIGINAL */
-      return;
-  }
+  char filename[PATH_MAX];
+  unsigned int d_num = 0, f_num = 0;
+  Boolean toggle;
 
-  if (NULL != (dirp=url_dir_open(currdir))) {
+  if ((dirp = url_dir_open(curr_dir)) != NULL) {
     char *fullpath;
     MBlockList pool;
-    StringTable strtab;
+    StringTable strftab, strdtab;
+    String *olddirlist = ddirlist, *oldfullfilelist = fulldirlist;
+    char lbuf[50];
+
     init_mblock(&pool);
+    XtVaGetValues(load_b, XtNstate,&toggle, NULL);
 
-    if(dirlist != NULL)
-    {
-       free(dirlist_top);
-       free(dirlist);
-    }
-    init_string_table(&strtab);
-    i = 0; d_num = 0; f_num = 0;
+    init_string_table(&strftab); init_string_table(&strdtab);
     while (url_gets(dirp, filename, sizeof(filename)) != NULL) {
-      fullpath = (char *)new_segment(&pool,strlen(currdir) +strlen(filename) +2);
-      sprintf(fullpath, "%s/%s", currdir, filename);
-      if(stat(fullpath, &st) == -1) continue;
-      if(filename[0] == '.' && filename[1] == '\0') continue;
-      if (currdir[0] == '/' && currdir[1] == '\0' && filename[0] == '.'
-          && filename[1] == '.' && filename[2] == '\0') continue;
-      if(S_ISDIR(st.st_mode)) {
+      fullpath = (char *)new_segment(&pool, strlen(curr_dir) + 
+                                     strlen(filename) + 2);
+      sprintf(fullpath, "%s/%s", curr_dir, filename);
+      if (filename[0] == '.') {
+        if (filename[1] == '\0') continue;
+        if ((filename[1] == '.') && (filename[2] == '\0')) {
+          if ((curr_dir[0] == '/') && (curr_dir[1] == '\0')) continue;
+        }
+        else if (!Cfg.showdotfiles) continue;
+      }
+      if (stat(fullpath, &st) == -1) continue;
+      if (S_ISDIR(st.st_mode)) {
         strcat(filename, "/"); d_num++;
+        put_string_table(&strdtab, filename, strlen(filename));
       } else {
         f_num++;
+        put_string_table(&strftab, filename, strlen(filename));
       }
-      put_string_table(&strtab, filename, strlen(filename));
-      i++;
     }
-    dirlist = (String *)make_string_array(&strtab);
-    dirlist_top = (String)dirlist[0]; /* Marking for free() */
-    qsort (dirlist, i, sizeof (char *), dirlist_cmp);
-    snprintf(local_buf, sizeof(local_buf), "%d Directories, %d Files", d_num, f_num);
-    XawListChange(list,dirlist,0,0,True);
-  }
-  else
-    strcpy(local_buf, "Can't read directry");
-
-  XtVaSetValues(load_info,XtNlabel,local_buf,NULL);
-#ifdef ORIGINAL
-  XtVaSetValues(label,XtNlabel,currdir,NULL);
-#else  /* RAKK/HIOENS */
-  XtVaSetValues(label,XtNlabel,strsav(currdir),NULL);
-#endif /* RAKK/HIOENS */
-  strcpy(basepath, currdir);
-  if(currdir[strlen(currdir) - 1] != '/')
-      strcat(currdir, "/");
-#ifdef ORIGINAL
-  XtVaSetValues(load_d,XtNvalue,currdir,NULL);
-#else  /* RAKK/HIOENS */
-  XtVaSetValues(load_d,XtNvalue,strsav(currdir),NULL);
-#endif /* RAKK/HIOENS */
-}
-
-static int Red_depth,Green_depth,Blue_depth;
-static int Red_sft,Green_sft,Blue_sft;
-static int bitcount( int d )
-{
-    int rt=0;
-    while( (d & 0x01)==0x01 ){
-        d>>=1;
-        rt++;
+    if (d_num > 0) {
+      ddirlist = (String *)make_string_array(&strdtab);
+      qsort (ddirlist, d_num, sizeof (char *), cmpstringp);
+    } else {
+      ddirlist = (String *)safe_malloc(sizeof(String));
+      *ddirlist = '\0';
     }
-    return(rt);
-}
-static int sftcount( int *mask )
-{
-    int rt=0;
-    while( (*mask & 0x01)==0 ){
-        (*mask)>>=1;
-            rt++;
+    if (f_num > 0) {
+      fulldirlist = (String *)make_string_array(&strftab);
+      qsort (fulldirlist, f_num, sizeof (char *), cmpstringp);
+    } else {
+      fulldirlist = (String *)safe_malloc(sizeof(String));
+      *fulldirlist = '\0';
     }
-    return(rt);
-}
-static int getdisplayinfo()
-{
-    XWindowAttributes xvi;
-    XGetWindowAttributes( disp, XtWindow(trace), &xvi );
-    if( 16 <= xvi.depth ){
-       Red_depth=(xvi.visual)->red_mask;
-       Green_depth=(xvi.visual)->green_mask;
-       Blue_depth=(xvi.visual)->blue_mask;
-       Red_sft=sftcount(&(Red_depth));
-       Green_sft=sftcount(&(Green_depth));
-       Blue_sft=sftcount(&(Blue_depth));
-       Red_depth=bitcount(Red_depth);
-       Green_depth=bitcount(Green_depth);
-       Blue_depth=bitcount(Blue_depth);
+    fullfilenum = f_num; dirnum = d_num;
+
+    XawListChange(load_dlist, ddirlist, d_num, 0, True);
+    XtVaSetValues(load_dlist, XtNwidth,0, XtNheight,0, NULL);
+    free(olddirlist);
+    /* According to CLI p. 49, we must keep the list usable
+     * until it is replaced, so we use a local pointer first,
+     * and free the previous list only after it has been replaced.
+     */
+    if (toggle == True) {
+      strcpy(filter, "SetDirList");
+      filterDirList(load_d, ld, True);
+      if (oldfullfilelist) free(oldfullfilelist);
+      return 0;
     }
-    return(xvi.depth);
-}
-
-static void drawBar(int ch,int len, int xofs, int column, Pixel color) {
-  static Pixel column1color0;
-  static GC gradient_gc[T2COLUMN];
-  static Pixmap gradient_pixmap[T2COLUMN];
-  static int gradient_set[T2COLUMN];
-  static int depth,init=1;
-  static XColor x_boxcolor;
-  static XGCValues gv;
-  int i;
-  int col;
-  XColor x_color;
-  if( init ){
-      for(i=0;i<T2COLUMN;i++) gradient_set[i]=0;
-      depth=getdisplayinfo();
-      if( 16 <= depth && app_resources.gradient_bar != 0 ){
-         x_boxcolor.pixel=boxcolor;
-         XQueryColor(disp,DefaultColormap(disp,0),&x_boxcolor);
-         gv.fill_style = FillTiled;
-         gv.fill_rule = WindingRule;
-      }
-      init=0;
-  }
-  if( 16 <= depth && app_resources.gradient_bar != 0 ){
-      if( column < T2COLUMN ){
-         col=column;
-         if( column==1 ){
-             if( gradient_set[0]==0 ){
-                 column1color0=color;
-                 col=0;
-             }
-             else if(gradient_set[1]==0 && column1color0!=color){
-                 col=1;
-             }
-             else{
-                 if( column1color0==color ) col=0;
-                 else col=1;
-             }
-         }
-         if( gradient_set[col]==0 ){
-             unsigned long pxl;
-             gradient_pixmap[col]=XCreatePixmap(disp,XtWindow(trace),BARH2_SPACE[column],1,
-                                                   DefaultDepth(disp,screen));   
-             x_color.pixel=color;
-             XQueryColor(disp,DefaultColormap(disp,0),&x_color);
-             for(i=0;i<BARH2_SPACE[column];i++){
-                 int r,g,b;
-                 r=(x_boxcolor.red)+(x_color.red-x_boxcolor.red)*i/BARH2_SPACE[column];
-                 g=(x_boxcolor.green)+(x_color.green-x_boxcolor.green)*i/BARH2_SPACE[column];
-                 b=(x_boxcolor.blue)+(x_color.blue-x_boxcolor.blue)*i/BARH2_SPACE[column];
-                 if(r<0) r=0;
-                 if(g<0) g=0;
-                 if(b<0) b=0;
-                 r >>= 8;
-                 g >>= 8;
-                 b >>= 8;
-                 if(255<r) r=255;
-                 if(255<g) g=255;
-                 if(255<b) b=255;
-                 pxl  = (r>>(8-Red_depth))<<Red_sft;
-                 pxl |= (g>>(8-Green_depth))<<Green_sft;
-                 pxl |= (b>>(8-Blue_depth))<<Blue_sft;
-                 XSetForeground(disp, gct, pxl);
-                 XDrawPoint(disp,gradient_pixmap[col],gct,i,0);
-             }
-             gv.tile = gradient_pixmap[col];
-             gradient_gc[col] = XCreateGC( disp,XtWindow(trace),GCFillStyle|GCFillRule|GCTile,&gv );
-             gradient_set[col]=1;
-         }
-         XSetForeground(disp, gct, boxcolor);
-         XFillRectangle(XtDisplay(trace),XtWindow(trace),gct,
-                        xofs+len+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                        pl[plane].w[column] -len -4,BAR_HEIGHT);
-         gv.ts_x_origin=xofs+2 - BARH2_SPACE[column]+len;
-         XChangeGC(disp,gradient_gc[col],GCTileStipXOrigin,&gv);
-         XFillRectangle(XtDisplay(trace),XtWindow(trace),gradient_gc[col],
-                        xofs+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                        len,BAR_HEIGHT);
-      }
-  }
-  else{
-      /* XSetForeground(disp, gct, bgcolor); */ /* ?? */
-      XSetForeground(disp, gct, boxcolor);
-      XFillRectangle(XtDisplay(trace),XtWindow(trace),gct,
-                    xofs+len+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                    pl[plane].w[column] -len -4,BAR_HEIGHT);
-      XSetForeground(disp, gct, color);
-      XFillRectangle(XtDisplay(trace),XtWindow(trace),gct,
-                    xofs+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                    len,BAR_HEIGHT);
+    XawListChange(load_flist, fulldirlist, f_num, 0, True);
+    XtVaSetValues(load_flist, XtNwidth,0, XtNheight,0, NULL);
+    /* Same reason as in popupDialog */
+    free(fdirlist);
+    fdirlist = NULL;
+    free(oldfullfilelist);
+    snprintf(lbuf, sizeof(lbuf), "%d Directories, %d Files",
+             d_num, f_num);
+    XtVaSetValues(load_info, XtNlabel,lbuf, NULL);
+    return 0;
+  } else {
+    fprintf(stderr, "Can't read directory\n");
+    return 1;
   }
 }
 
-static void drawProg(int ch,int val,int column,int xofs, Boolean do_clean) {
-  char s[4];
+static void
+setFileLoadCB(Widget list, XtPointer client_data, XawListReturnStruct *lrs) {
+  ldPointer ld = (ldPointer)client_data;
 
-  if(do_clean) {
-    XSetForeground(disp, gct, boxcolor);
-    XFillRectangle(XtDisplay(trace),XtWindow(trace),gct,
-                   xofs+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                   pl[plane].w[4]-4,BAR_HEIGHT);
-  }
-  XSetForeground(disp, gct, black);
-  sprintf(s, "%3d", val);
-  XDrawString(XtDisplay(trace), XtWindow(trace), gct,
-              xofs+5,TRACEV_OFS+BAR_SPACE*ch+16,s,3);
+#ifdef CLEARVALUE
+  clearValue(load_d);
+#endif /* CLEARVALUE */
+  Widget Text = XtNameToWidget(load_d, "value");
+  XtVaSetValues(Text, XtNstring,lrs->string, NULL);
+  XtVaSetValues(Text, XtNinsertPosition,strlen(lrs->string), NULL);
+  return;
 }
 
-static void drawPan(int ch,int val,Boolean setcolor) {
-  int ap,bp;
-  int x;
-  static XPoint pp[3];
-
-  if (val < 0) return;
-  if (setcolor) {
-    XSetForeground(disp, gct, boxcolor);
-    XFillRectangle(XtDisplay(trace),XtWindow(trace),gct,
-                   pl[plane].ofs[CL_PA]+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                   pl[plane].w[CL_PA]-4,BAR_HEIGHT);
-    XSetForeground(disp, gct, pancolor);
+static void
+setDirLoadCB(Widget list, XtPointer client_data, XawListReturnStruct *lrs) {
+  ldPointer ld = (ldPointer)client_data;
+  struct stat st;
+  char curr_dir[PATH_MAX];
+
+  snprintf(curr_dir, sizeof(curr_dir)-1, "%s/%s", basepath, lrs->string);
+  canonicalize_path(curr_dir);
+  if (stat(curr_dir, &st) == -1) return;
+  if (!setDirList(ld, curr_dir) ) {
+    strcpy(basepath, curr_dir);
+    XtVaSetValues(cwd_l, XtNlabel,basepath, NULL);
   }
-  x= pl[plane].ofs[CL_PA]+3;
-  ap= 31 * val/127;
-  bp= 31 -ap -1;
-  pp[0].x= ap+ x; pp[0].y= 12 +BAR_SPACE*(ch+1);
-  pp[1].x= bp+ x; pp[1].y= 8 +BAR_SPACE*(ch+1);
-  pp[2].x= bp+ x; pp[2].y= 16 +BAR_SPACE*(ch+1);
-  XFillPolygon(XtDisplay(trace),XtWindow(trace),gct,pp,3,
-               (int)Nonconvex,(int)CoordModeOrigin);
+  return;
 }
 
-static void draw1Chan(int ch,int val,char cmd) {
-  if (cmd == '*' || cmd == '&')
-    drawBar(ch, (int)(val*BARSCALE2), pl[plane].ofs[CL_VE], CL_VE, barcol[ch]);
+static void
+toggleTraceACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  if (ctl->trace_playing && ((e->xbutton.button == 1) || (e->type == KeyPress)))
+    toggleTracePlane(IsTracePlaying());
 }
 
-static void drawVol(int ch,int val) {
-  drawBar(ch, (int)(val*BARSCALE3), pl[plane].ofs[CL_VO], CL_VO, volcolor);
-}
+static void
+muteChanACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  int c;
 
-static void drawExp(int ch,int val) {
-  drawBar(ch, (int)(val*BARSCALE4), pl[plane].ofs[CL_EX], CL_EX, expcolor);
+  if (e->xbutton.y <= TRACE_HEADER) return;
+  c = (e->xbutton.y - TRACE_FOOT - BAR_SPACE/2)/BAR_SPACE;
+  if ((c > getVisibleChanNum()-1) || (c < 0)) return;
+  else a_pipe_write("M %d", c+getLowestVisibleChan());
 }
 
-static void drawReverb(int ch,int val) {
-  drawBar(ch, (int)(val*BARSCALE5), pl[plane].ofs[CL_RE], CL_RE, revcolor);
-}
+static void
+scrollTraceACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  int i = atoi(*v);
 
-static void drawChorus(int ch,int val) {
-  drawBar(ch, (int)(val*BARSCALE5), pl[plane].ofs[CL_CH], CL_CH, chocolor);
+  if (!ctl->trace_playing) return;
+  if (i>0) scrollTrace(1);
+  else scrollTrace(-1);
 }
 
-static void drawPitch(int ch,int val) {
-  char s[3];
-
-  XSetForeground(disp, gct, boxcolor);
-  XFillRectangle(XtDisplay(trace),XtWindow(trace),gct,
-                 pl[plane].ofs[CL_PI]+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                 pl[plane].w[CL_PI] -4,BAR_HEIGHT);
-  XSetForeground(disp, gct, barcol[9]);
-  if (val != 0) {
-    if (val<0) {
-      sprintf(s, "=");
-    } else {
-      if (val == 0x2000) sprintf(s, "*");
-      else if (val>0x3000) sprintf(s, ">>");
-      else if (val>0x2000) sprintf(s, ">");
-      else if (val>0x1000) sprintf(s, "<");
-      else sprintf(s, "<<");
-    }
-    XDrawString(XtDisplay(trace), XtWindow(trace), gct,
-                pl[plane].ofs[CL_PI]+4,TRACEV_OFS+BAR_SPACE*ch+16,s,strlen(s));
-  }
-}
-
-static void drawInstname(int ch, char *name) {
-  int len;
-  if(!ctl->trace_playing) return;
-  if(plane!=0) return;
-
-  XSetForeground(disp, gct, boxcolor);
-  XFillRectangle(XtDisplay(trace),XtWindow(trace),gct,
-                 pl[plane].ofs[CL_IN]+2,TRACEV_OFS+BAR_SPACE*ch+2,
-                 pl[plane].w[CL_IN] -4,BAR_HEIGHT);
-  XSetForeground(disp, gct, ((Panel->is_drum[ch])? capcolor:black));
-  len = strlen(name);
-  XDrawString(XtDisplay(trace), XtWindow(trace), gct,
-              pl[plane].ofs[CL_IN]+4,TRACEV_OFS+BAR_SPACE*ch+15,
-              name,(len>disp_inst_name_len)? disp_inst_name_len:len);
-}
-
-static void drawDrumPart(int ch, int is_drum) {
-  if(!ctl->trace_playing) return;
-  if(plane!=0) return;
-
-  if (is_drum) barcol[ch]=app_resources.drumvelocity_color;
-  else         barcol[ch]=app_resources.velocity_color;
-}
-
-static void draw1Note(int ch,int note,int flag) {
-  int i, j;
-  XSegment dot[3];
-
-  j = note -9;
-  if (j<0) return;
-  if (flag == '*') {
-    XSetForeground(disp, gct, playcolor);
-  } else if (flag == '&') {
-    XSetForeground(disp, gct,
-                   ((keyG[j].col == black)? suscolor:barcol[0]));
-  }  else {
-    XSetForeground(disp, gct, keyG[j].col);
-  }
-  for(i= 0; i<3; i++) {
-    dot[i].x1 = keyG[j].xofs +i;
-    dot[i].y1 = TRACEV_OFS+ keyG[j].k[i].y+ ch*BAR_SPACE;
-    dot[i].x2 = dot[i].x1;
-    dot[i].y2 = dot[i].y1 + keyG[j].k[i].l;
-  }
-  XDrawSegments(XtDisplay(trace),XtWindow(trace),gct,dot,3);
-}
-
-static void drawKeyboardAll(Display *disp,Drawable pix) {
-  int i, j;
-  XSegment dot[3];
-
-  XSetForeground(disp, gc, tracecolor);
-  XFillRectangle(disp,pix,gc,0,0,BARH_OFS8,BAR_SPACE);
-  XSetForeground(disp, gc, boxcolor);
-  XFillRectangle(disp,pix,gc,BARH_OFS8,0,TRACE_WIDTH-BARH_OFS8+1,BAR_SPACE);
-  for(i= 0; i<KEY_NUM; i++) {
-    XSetForeground(disp, gc, keyG[i].col);
-    for(j= 0; j<3; j++) {
-      dot[j].x1 = keyG[i].xofs +j;
-      dot[j].y1 = keyG[i].k[j].y;
-      dot[j].x2 = dot[j].x1;
-      dot[j].y2 = dot[j].y1 + keyG[i].k[j].l;
-    }
-    XDrawSegments(disp,pix,gc,dot,3);
-  }
+static void
+exchgWidthACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+#define MEDIAN (TRACE_WIDTH+8 + DEFAULT_REG_WIDTH)/2
+  if (curr_width < DEFAULT_REG_WIDTH)
+    XResizeWindow(disp, XtWindow(toplevel), DEFAULT_REG_WIDTH, curr_height);
+  else if (curr_width < MEDIAN)
+    XResizeWindow(disp, XtWindow(toplevel), MEDIAN, curr_height);
+  else if (curr_width < TRACE_WIDTH+8)
+    XResizeWindow(disp, XtWindow(toplevel), TRACE_WIDTH+8, curr_height);
+  else
+    XResizeWindow(disp, XtWindow(toplevel), DEFAULT_REG_WIDTH, curr_height);
+#undef MEDIAN
 }
 
-static void drawBank(int ch,int val) {
-  char s[4];
-
-  XSetForeground(disp, gct, black);
-  sprintf(s, "%3d", (int)val);
-  XDrawString(disp,XtWindow(trace),gct,
-              pl[plane].ofs[CL_BA],TRACEV_OFS+BAR_SPACE*ch+15, s,strlen(s));
+static void
+redrawACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  if (e->xexpose.count == 0) callRedrawTrace(IsTracePlaying());
 }
 
-#define VOICENUM_WIDTH 56
-static void drawVoices(void) {
-  XSetForeground(disp, gct, tracecolor);
-  XFillRectangle(disp,XtWindow(trace),gct,voices_num_width +4,
-                 MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+1,VOICENUM_WIDTH,TRACE_FOOT);  
-  sprintf(local_buf, "%3d/%d", last_voice, xaw_i_voices);
-  XSetForeground(disp, gct, capcolor);  
-  XDrawString(disp, XtWindow(trace),gct,voices_num_width+6,
-              MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+16,local_buf,strlen(local_buf));
+static void
+redrawCaptionACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  if (e->type == EnterNotify) redrawCaption(True);
+  else redrawCaption(False);
 }
 
-static void drawTitle(char *str) {
-  char *p = str;
-
-  if(ctl->trace_playing) {
-    if (!strcmp(p, "(null)")) p = UNTITLED_STR;
-    XSetForeground(disp, gcs, capcolor);
-#ifdef I18N
-    XmbDrawString(XtDisplay(trace), XtWindow(trace),ttitlefont,gcs,
-                  VOICES_NUM_OFS+TTITLE_OFS,
-                  MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+ ttitlefont0->ascent +3,
-                  p,strlen(p));
-#else
-    XDrawString(XtDisplay(trace), XtWindow(trace),gcs,
-                VOICES_NUM_OFS+TTITLE_OFS,
-                MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+ ttitlefont->ascent +3,
-                p,strlen(p));
-#endif
-    }
-}
+static void
+completeDirACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  char *p;
+  DirPath full;
+  Widget load_dialog_widget = XtParent(w);  /* XtParent = ld->ld_load_d */
 
-static void toggletrace(Widget w,XEvent *e,String *v,Cardinal *n) {
-  if((e->xbutton.button == 1) || e->type == KeyPress) {
-    plane ^= 1;
-    redrawTrace(True);
+  p = XawDialogGetValueString(load_dialog_widget);
+  if (!expandDir(p, &full, basepath)) { /* uses global ld */
+    ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "something wrong with getting path.");
+    return;
   }
-}
-
-/*ARGSUSED*/
-static void exchgWidth(Widget w,XEvent *e,String *v,Cardinal *n) {
-  Dimension w1,h1,w2,h2;
+  if (full.basename != NULL) {
+    int lenb, lend, match = 0;
+    char filename[PATH_MAX], matchstr[PATH_MAX], *path = "/";
+    char *fullpath;
+    URL dirp;
 
-  XtVaGetValues(toplevel,XtNheight,&h1,NULL);
-  ++currwidth;
-  currwidth %= 3;       /* number of rotatewidth */
-  w1 = rotatewidth[currwidth];
-  XtMakeResizeRequest(toplevel,w1,h1,&w2,&h2);
-  resizeAction(w,NULL,NULL,NULL);  
-}
+    lenb = strlen(full.basename);
+    lend = strlen(full.dirname);
+    if (lend != 0) path = full.dirname;
+    if ((dirp = url_dir_open(path)) != NULL) {
+      MBlockList pool;
+      struct stat st;
+      init_mblock(&pool);
 
-/*ARGSUSED*/
-static void redrawAction(Widget w,XEvent *e,String *v,Cardinal *n) {
-  if(e->xexpose.count == 0)
-    redrawTrace(True);
-}
+      while (url_gets(dirp, filename, sizeof(filename)) != NULL) {
+        if (!strncmp(full.basename, filename, lenb)) {
 
-/*ARGSUSED*/
-static Boolean cursor_is_in = False;
-static void redrawCaption(Widget w,XEvent *e,String *v,Cardinal *n) {
-  char *p;
-  int i;
-
-  if(e->type == EnterNotify) {
-    cursor_is_in = True;
-    XSetForeground(disp, gct, capcolor);
-  } else {
-    cursor_is_in = False;
-    XSetForeground(disp, gct, tracecolor);
-  }
-  XFillRectangle(disp,XtWindow(trace),gct, 0,0,TRACE_WIDTH,TRACEV_OFS);
-  XSetBackground(disp, gct, (e->type == EnterNotify)? expcolor:tracecolor);
-  XSetForeground(disp, gct, (e->type == EnterNotify)? tracecolor:capcolor);
-  for(i=0; i<pl[plane].col; i++) {
-    p = pl[plane].cap[i];
-    XDrawString(disp,XtWindow(trace),gct,pl[plane].ofs[i]+4,16,p,strlen(p));
-  }
-}
-
-static void redrawTrace(Boolean draw) {
-  int i;
-  /* Dimension w1, h1; */
-  char s[3];
-
-  if(!ctl->trace_playing) return;
-  if(!XtIsRealized(trace)) return;
-
-  /* XtVaGetValues(trace,XtNheight,&h1,XtNwidth,&w1,NULL); */
-  /* XSetForeground(disp, gct, tracecolor); */
-  /* XFillRectangle(disp,XtWindow(trace),gct, 0,0,w1,h1); */
-  /* XSetForeground(disp, gct, boxcolor); */
-  /* XFillRectangle(disp,XtWindow(trace),gct,
-                 BARH_OFS8 -1,TRACEV_OFS, TRACE_WIDTH-BARH_OFS8+1,
-                 BAR_SPACE*MAX_XAW_MIDI_CHANNELS); */
-  for(i= 0; i<MAX_XAW_MIDI_CHANNELS; i++) {
-    XGCValues gv;
-    gv.tile = layer[plane];
-    gv.ts_x_origin = 0;
-    gv.ts_y_origin = TRACEV_OFS+i*BAR_SPACE;
-    XChangeGC(disp,gc_xcopy,GCTile|GCTileStipXOrigin|GCTileStipYOrigin,&gv);
-    XFillRectangle(disp,XtWindow(trace),gc_xcopy,
-                  0, TRACEV_OFS+i*BAR_SPACE, TRACE_WIDTH,BAR_SPACE);
-    /* XCopyArea(disp, layer[plane], XtWindow(trace), gct, 0,0,
-              TRACE_WIDTH,BAR_SPACE, 0, TRACEV_OFS+i*BAR_SPACE); */
-  }
-  XSetForeground(disp, gct, capcolor);
-  XDrawLine(disp,XtWindow(trace),gct,BARH_OFS0,TRACEV_OFS+BAR_SPACE*MAX_XAW_MIDI_CHANNELS,
-            TRACE_WIDTH-1,TRACEV_OFS+BAR_SPACE*MAX_XAW_MIDI_CHANNELS);
-
-  XSetForeground(disp, gct, black);
-  for(i= 1; i<MAX_XAW_MIDI_CHANNELS+1; i++) {
-    sprintf(s, "%2d", i);
-    XDrawString(disp, XtWindow(trace), gct,
-                pl[plane].ofs[CL_C]+2,TRACEV_OFS+BAR_SPACE*i-5,s,2);
-  }
-
-  if(cursor_is_in) {
-    XSetForeground(disp, gct, capcolor);
-    XFillRectangle(disp,XtWindow(trace),gct, 0,0,TRACE_WIDTH,TRACEV_OFS);
-  }
-  XSetForeground(disp, gct, (cursor_is_in)? tracecolor:capcolor);
-  for(i=0; i<pl[plane].col; i++) {
-    char *p;
-    p = pl[plane].cap[i];
-    XDrawString(disp,XtWindow(trace),gct,pl[plane].ofs[i]+4,16,p,strlen(p));
-  }
-  XSetForeground(disp, gct, tracecolor);
-  XFillRectangle(disp,XtWindow(trace),gct,0,MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+1,
-                 TRACE_WIDTH,TRACE_FOOT);
-  XSetForeground(disp, gct, capcolor);  
-  XDrawString(disp, XtWindow(trace),gct,VOICES_NUM_OFS,
-              MAX_XAW_MIDI_CHANNELS*BAR_SPACE+TRACEV_OFS+16,"Voices",6);
-  drawVoices();
-  drawTitle(window_title);
-  if(draw) {
-    for(i=0; i<MAX_XAW_MIDI_CHANNELS; i++)
-      if (Panel->ctotal[i] != 0 && Panel->c_flags[i] & FLAG_PROG_ON)
-        draw1Chan(i,Panel->ctotal[i],'*');
-    XSetForeground(disp, gct, pancolor);
-    for(i=0; i<MAX_XAW_MIDI_CHANNELS; i++) {
-      if (Panel->c_flags[i] & FLAG_PAN)
-        drawPan(i,Panel->channel[i].panning,False);
-    }
-    XSetForeground(disp, gct, black);
-    for(i=0; i<MAX_XAW_MIDI_CHANNELS; i++) {
-      drawProg(i,Panel->channel[i].program,CL_PR,pl[plane].ofs[4],False);
-      drawVol(i,Panel->channel[i].volume);
-      drawExp(i,Panel->channel[i].expression);
-      if (plane) {
-        drawBank(i,Panel->channel[i].bank);
-        drawReverb(i,Panel->reverb[i]);
-        drawChorus(i,Panel->channel[i].chorus_level);
-      } else {
-        drawPitch(i,Panel->channel[i].pitchbend);
-        drawInstname(i, inst_name[i]);
-      }
-    }
-  }
-}
-
-static void initStatus(void) {
-  int i;
-
-  if(!ctl->trace_playing) return;
-  for(i=0; i<MAX_XAW_MIDI_CHANNELS; i++) {
-    Panel->channel[i].program= 0;
-    Panel->channel[i].volume= 0;
-    Panel->channel[i].sustain= 0;
-    Panel->channel[i].expression= 0;
-    Panel->channel[i].pitchbend= 0;
-    Panel->channel[i].panning= -1;
-    Panel->ctotal[i] = 0;
-    Panel->cvel[i] = 0;
-    Panel->bank[i] = 0;
-    Panel->reverb[i] = 0;
-    Panel->channel[i].chorus_level = 0;
-    Panel->v_flags[i] = 0;
-    Panel->c_flags[i] = 0;
-    Panel->is_drum[i] = 0;
-    *inst_name[i] = '\0';
-  }
-  last_voice = 0;
-}
-
-/*ARGSUSED*/
-static void completeDir(Widget w,XEvent *e, XtPointer data)
-{
-  char *p;
-  DirPath full;
-
-  p = XawDialogGetValueString(load_d);
-  if (!expandDir(p, &full))
-    ctl->cmsg(CMSG_WARNING,VERB_NORMAL,"something wrong with getting path.");
-  if(full.basename != NULL) {
-    int len, match = 0;
-    char filename[PATH_MAX], matchstr[PATH_MAX],*path = "/";
-    char *fullpath;
-    URL dirp;
-
-    len = strlen(full.basename);
-    if(strlen(full.dirname)) path = full.dirname;
-    if (NULL != (dirp=url_dir_open(path))) {
-      MBlockList pool;
-      init_mblock(&pool);
-
-      while (url_gets(dirp, filename, sizeof(filename)) != NULL) {
-        if (!strncmp(full.basename, filename, len)) {
-          struct stat st;
-
-          fullpath = (char *)new_segment(&pool,
-                            strlen(full.dirname) + strlen(filename) + 2);
-          sprintf(fullpath, "%s/%s", full.dirname, filename);
+          fullpath = (char *)new_segment(&pool,
+                            lend + strlen(filename) + 2);
+          sprintf(fullpath, "%s/%s", full.dirname, filename);
 
           if (stat(fullpath, &st) == -1)
             continue;
           if (!match)
-            strncpy(matchstr, filename, PATH_MAX - 1);
+            strlcpy(matchstr, filename, PATH_MAX);
           else
             strmatch(matchstr, filename);
           match++;
-          if(S_ISDIR(st.st_mode) && (!strcmp(filename,full.basename))) {
-            strncpy(matchstr, filename, PATH_MAX - 1);
-            strncat(matchstr, "/", PATH_MAX - strlen(matchstr) - 1);
+          if (S_ISDIR(st.st_mode) && (!strcmp(filename, full.basename))) {
+            lenb = strlcpy(matchstr, filename, PATH_MAX);
+            if (lenb >= PATH_MAX) lenb = PATH_MAX - 1;
+            strncat(matchstr, "/", PATH_MAX - 1 - lenb);
             match = 1;
             break;
           }
         }
       }
+      url_close(dirp);
+      reuse_mblock(&pool);
 
       if (match) {
-        sprintf(filename, "%s/%s", full.dirname, matchstr);
-        XtVaSetValues(load_d,XtNvalue,filename,NULL);
+#ifdef CLEARVALUE
+        clearValue(XtParent(w));
+#endif /* CLEARVALUE */
+        snprintf(filename, sizeof(filename), "%s/%s", full.dirname, matchstr);
+        XtVaSetValues(load_dialog_widget, XtNvalue,filename, NULL); 
       }
-      url_close(dirp);
-      reuse_mblock(&pool);
     }
   }
 }
 
-static char **dotfile_flist;
-static int dot_nfile = 0;
-#define SSIZE 256
+static int
+readPlaylist(char *p) {
+  FILE *Playlist;
+  char fname[SLINELEN], *pp;
+  int ret = 1;
 
-static void a_readconfig (Config *Cfg) {
-  char s[SSIZE];
-  char *home, c = ' ', *p;
+  if ((Playlist = fopen(p, "r")) == NULL) {
+     fprintf(stderr, "Can't open %s for reading.\n", p);
+     return 2;
+  }
+  if ((pp = fgets(fname, SLINELEN, Playlist)) == NULL) goto out;
+  if (memcmp(fname, "\0timidity playlist:\n", 20)) goto out;
+  while (fgets(fname, SLINELEN, Playlist) != NULL) {
+    if ((pp = strchr(fname, '\n')) != NULL) *pp = '\0';
+    a_pipe_write("X %s", fname);
+  }
+  ret = 0;
+out:
+  fclose(Playlist);
+  return ret;
+}
+
+static void
+savePlaylist(char *p) {
+  int i, n;
+  char *file, *space;
   FILE *fp;
-  int i, k;
 
-  if (NULL == (home=getenv("HOME"))) home=getenv("home");
-  if (home != NULL) {
-    dotfile = (char *)XtMalloc(sizeof(char) * PATH_MAX);
-    snprintf(dotfile, PATH_MAX, "%s/%s", home, INITIAL_CONFIG);
-    if (NULL != (fp=fopen(dotfile, "r"))) {
+  space = strchr(p, ' ');
+  file = space + 1;
+  *space = '\0';
+  n = atoi(p+1);
+  if (n <= 0) return;
+  if (!strcmp(file, dotfile)) {
+    char prefix[10];
+
+    snprintf(prefix, sizeof(prefix), SPREFIX "%s ", cfg_items[S_MidiFile]);
+    if ((fp = fopen(dotfile, "a")) != NULL) {
+      for(i=0; i<n; i++) {
+        a_pipe_read(local_buf, sizeof(local_buf));
+        if (fprintf(fp,"%s%s\n", prefix, local_buf) < 0) goto error;
+      }
+      fclose(fp);
+    }
+    else goto error;
+  } else {
+    if ((fp = fopen(file, "w")) != NULL) {
+      if (fputc('\0', fp) == EOF) goto error;
+      if (fprintf(fp, "timidity playlist:\n") < 0) goto error;
+      for(i=0; i<n; i++) {
+        a_pipe_read(local_buf, sizeof(local_buf));
+        if (fprintf(fp,"%s\n", local_buf) < 0) goto error;
+      }
+      fclose(fp);
+    }
+    else goto error;
+  }
+  return;
+error:
+  if (fp != NULL) fclose(fp);
+  for(i=0; i<n; i++) a_pipe_read(local_buf, sizeof(local_buf));
+  warnCB(toplevel, "saveplaylisterror", True);
+  return;
+}
+
+static void
+a_readconfig (Config *Cfg, char **home) {
+  char s[SLINELEN];
+  char *p, *pp;
+  int k;
+  struct stat st;
+  FILE *fp;
+
+  *home = get_user_home_dir();
+  if (*home != NULL) {
+    dotfile = (char *)safe_malloc(sizeof(char) * PATH_MAX);
+    snprintf(dotfile, PATH_MAX, "%s/%s", *home, INITIAL_CONFIG);
+    if ( (fp = fopen(dotfile, "r")) != NULL) {
       dotfile_flist = (char **)safe_malloc(sizeof(char *) * INIT_FLISTNUM);
-      while (c != EOF) {
-        p = s;
-        for(i=0;;i++) {
-          c = fgetc(fp);
-          if (c == LF || c == EOF || i > SSIZE) break;
-          *p++ = c;
-        }
-        *p = (char)NULL;
-        if (0 != strncasecmp(s, "set ", 4)) continue;
-        switch (configcmp(s+4, &k)) {
+      while ((p = fgets(s, SLINELEN, fp)) != NULL) {
+        if ((pp = strchr(p, '\n')) != NULL) *pp = '\0';
+        if (strncasecmp(s, SPREFIX, SPLEN) != 0) continue;
+        switch (configcmp(s+SPLEN, &k)) {
+        case S_ConfirmExit:
+          Cfg->confirmexit = (Boolean)k; break;
         case S_RepeatPlay:
           Cfg->repeat = (Boolean)k; break;
         case S_AutoStart:
@@ -2336,70 +2642,102 @@ static void a_readconfig (Config *Cfg) {
         case S_AutoExit:
           Cfg->autoexit = (Boolean)k; break;
         case S_DispText:
-          Cfg->hidetext = (Boolean)(k ^ 1);
+          Cfg->disptext = (Boolean)k;
           break;
         case S_ShufflePlay:
           Cfg->shuffle = (Boolean)k; break;
         case S_DispTrace:
           Cfg->disptrace = (Boolean)k; break;
         case S_CurVol:
-          Cfg->amplitude = (int)k; break;
+          Cfg->amplitude = (int)k;
+          if (Cfg->amplitude > MAXVOLUME) Cfg->amplitude = MAXVOLUME;
+          else if (Cfg->amplitude < 0) Cfg->amplitude = 0;
+          break;
         case S_ExtOptions:
           Cfg->extendopt = (int)k; break;
         case S_ChorusOption:
           Cfg->chorusopt = (int)k; break;
+        case S_Tooltips:
+          Cfg->tooltips = (Boolean)k; break;
+        case S_Showdotfiles:
+          Cfg->showdotfiles = (Boolean)k; break;
+        case S_SaveList:
+          Cfg->save_list = (Boolean)k; break;
+        case S_DefaultDirectory:
+          p = s+k;
+          pp = expandDir(p, NULL, "/");
+          if ((stat(pp, &st) == -1) || (!(S_ISDIR(st.st_mode)))) {
+            fprintf(stderr, "Default directory %s doesn't exist!\n", p);
+            Cfg->DefaultDir = NULL;
+          } else {
+            Cfg->DefaultDir = safe_strdup(pp);
+          }
+          break;
         case S_MidiFile:
-          if(savelist) {
-            p = s+k+4;
-            if(dot_nfile < INIT_FLISTNUM)
-              if(IsEffectiveFile(p)) {
-                dotfile_flist[dot_nfile]
-                  = (char *)safe_malloc(sizeof(char)*(strlen(p) +1));
-                strcpy(dotfile_flist[dot_nfile],p);
-                dotfile_flist[++dot_nfile] = NULL;
-              }
+          p = s+k;
+          if ((dot_nfile < INIT_FLISTNUM) && (IsEffectiveFile(p)) ) {
+            dotfile_flist[dot_nfile] = safe_strdup(p);
+            dot_nfile++;
           }
+          dotfile_flist[dot_nfile] = NULL;
           break;
         }
       }
-
       fclose(fp);
+      if (Cfg->DefaultDir == NULL) Cfg->DefaultDir = safe_strdup(*home);
+    } else {
+      Cfg->DefaultDir = safe_strdup(*home);
+      a_saveconfig(dotfile, False);
     }
+  } else {
+    Cfg->DefaultDir = safe_strdup("/");
   }
+
+  if (ctl->flags & CTLF_AUTOSTART) Cfg->autostart = True;
+  if (ctl->flags & CTLF_AUTOEXIT) Cfg->autoexit = True;
+  if (ctl->flags & CTLF_LIST_LOOP) Cfg->repeat = True;
+  if (ctl->flags & CTLF_LIST_RANDOM) Cfg->shuffle = True;
 }
 
-static void a_saveconfig (char *file) {
+static void
+a_saveconfig(char *file, Boolean save_list) {
   FILE *fp;
-  Boolean s1, s2;
-  int i,flags, cflag;
-
-  if ('\0' != *file) {
-    if (NULL != (fp=fopen(file, "w"))) {
-      XtVaGetValues(repeat_b,XtNstate,&s1,NULL);
-      XtVaGetValues(random_b,XtNstate,&s2,NULL);
-      fprintf(fp,"set %s %d\n",cfg_items[S_ConfirmExit],(int)Cfg.confirmexit);
-      fprintf(fp,"set %s %d\n",cfg_items[S_RepeatPlay],(int)s1);
-      fprintf(fp,"set %s %d\n",cfg_items[S_AutoStart],(int)file_menu[ID_AUTOSTART-100].bmflag);
-      fprintf(fp,"set %s %d\n",cfg_items[S_DispText],(int)(file_menu[ID_HIDETXT-100].bmflag ^ TRUE));
-      fprintf(fp,"set %s %d\n",cfg_items[S_ShufflePlay],(int)s2);
-      fprintf(fp,"set %s %d\n",cfg_items[S_DispTrace],((int)file_menu[ID_HIDETRACE-100].bmflag ? 0:1));
-      fprintf(fp,"set %s %d\n",cfg_items[S_CurVol],amplitude);
-      fprintf(fp,"set %s %d\n",cfg_items[S_AutoExit],(int)file_menu[ID_AUTOQUIT-100].bmflag);
-      if(popup_shell_exist & OPTIONS_WINDOW) {
-        flags = 0; cflag = 0;
-        for(i=0; i<MAX_OPTION_N; i++) {
-          XtVaGetValues(option_num[i].widget,XtNstate,&s1,NULL);
-          flags |= ((s1)? option_num[i].bit:0);
-        }
-        XtVaGetValues(chorus_b,XtNstate,&s1,NULL);
-        if(s1) cflag = (init_chorus)? init_chorus:1;
-      } else {
-        flags = init_options; cflag = init_chorus;
-      }
-      fprintf(fp,"set %s %d\n",cfg_items[S_ExtOptions],flags);
-      fprintf(fp,"set %s %d\n",cfg_items[S_ChorusOption],cflag);
+
+  if (*file != '\0') {
+    if ((fp = fopen(file, "w")) != NULL) {
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_RepeatPlay],
+                Cfg.repeat?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_ShufflePlay],
+                Cfg.shuffle?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_ExtOptions], init_options);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_ChorusOption], init_chorus);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_CurVol], amplitude);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_Showdotfiles],
+                 Cfg.showdotfiles?1:0);
+      fprintf(fp, SPREFIX "%s %s\n", cfg_items[S_DefaultDirectory],
+                 Cfg.DefaultDir);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_DispTrace],
+                 Cfg.disptrace?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_DispText],
+                 Cfg.disptext?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_Tooltips],
+                 Cfg.tooltips?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_AutoStart],
+                 Cfg.autostart?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_AutoExit],
+                 Cfg.autoexit?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_ConfirmExit],
+                 Cfg.confirmexit?1:0);
+      fprintf(fp, SPREFIX "%s %d\n", cfg_items[S_SaveList],
+                 Cfg.save_list?1:0);
       fclose(fp);
-      a_pipe_write("s");
+      if (save_list) {
+        /* TODO: We're doing this dance via the pipe because no structure
+         * in xaw_i.c contains full filenames (including paths).
+         * Changing this would require changing xaw_c.c as well.
+         */
+        a_pipe_write("s %s", dotfile);
+      }
     } else {
       fprintf(stderr, "cannot open initializing file '%s'.\n", file);
     }
@@ -2407,555 +2745,1147 @@ static void a_saveconfig (char *file) {
 }
 
 #ifdef OFFIX
-static void FileDropedHandler(Widget widget ,XtPointer data,XEvent *event,Boolean *b)
-{
+static void
+FileDropedHandler(Widget widget, XtPointer data, XEvent *event, Boolean *b) {
   char *filename;
   unsigned char *Data;
   unsigned long Size;
   char local_buffer[PATH_MAX];
   int i;
-  static const int AcceptType[]={DndFile,DndFiles,DndDir,DndLink,DndExe,DndURL,
-                 DndNotDnd};
+  static const int AcceptType[] = {DndFile, DndFiles, DndDir, DndLink,
+                                   DndExe, DndURL, DndNotDnd};
   int Type;
-  Type=DndDataType(event);
-  for(i=0;AcceptType[i]!=DndNotDnd;i++){
-    if(AcceptType[i]==Type)
+
+  Type = DndDataType(event);
+  for(i=0;AcceptType[i] != DndNotDnd;i++) {
+    if (AcceptType[i] == Type)
       goto OK;
   }
-  fprintf(stderr,"NOT ACCEPT\n");
+  fprintf(stderr, "NOT ACCEPT\n");
   /*Not Acceptable,so Do Nothing*/
   return;
 OK:
-  DndGetData(&Data,&Size);
-  if(Type==DndFiles){
+  DndGetData(&Data, &Size);
+  if (Type == DndFiles) {
     filename = Data;
-    while (filename[0] != '\0'){
-      snprintf(local_buffer,sizeof(local_buffer),"X %s\n",filename);
-      a_pipe_write(local_buffer);
+    while (filename[0] != '\0') {
+      a_pipe_write("X %s", filename);
       filename = filename + strlen(filename) + 1;
-    }       
-  }
-  else{
-    snprintf(local_buffer,sizeof(local_buffer),"X %s%s\n",Data,(Type==DndDir)?"/":"");
-    a_pipe_write(local_buffer);
+    }
+  } else {
+    a_pipe_write("X %s%s", Data, (Type == DndDir)?"/":"");
   }
   return;
 }
-#endif
+#endif /* OFFIX */
 
-/*ARGSUSED*/
-static void leaveSubmenu(Widget w, XEvent *e, String *v, Cardinal *n) {
+static void
+leaveSubmenuACT(Widget w, XEvent *e, String *v, Cardinal *n) {
   XLeaveWindowEvent *leave_event = (XLeaveWindowEvent *)e;
   Dimension height;
 
-  XtVaGetValues(w,XtNheight,&height,NULL);
-  if (leave_event->x <= 0 || leave_event->y <= 0 || leave_event->y >= height)
+  XtVaGetValues(w, XtNheight,&height, NULL);
+  if ((leave_event->x <= 0) || (leave_event->y <= 0) ||
+      (leave_event->y >= height))
     XtPopdown(w);
 }
 
-/*ARGSUSED*/
-static void checkRightAndPopupSubmenu(Widget w, XEvent *e, String *v, Cardinal *n) {
+#ifdef TimNmenu
+static void
+checkRightAndPopupSubmenuACT(Widget w, XEvent *e, String *v, Cardinal *n) {
   XLeaveWindowEvent *leave_ev = (XLeaveWindowEvent *)e;
-  Dimension nheight,height,width;
-  Position x,y;
+  Dimension nheight, height, width;
+  Position x, y;
   int i;
 
-  if(!maxentry_on_a_menu) return;
+  if (maxentry_on_a_menu == 0) return;
 
-  if(e == NULL)
-    i= *(int *)n;
-  else
-    i= atoi(*v);
-  if(w != title_sm) {
-    if(leave_ev->x <= 0 || leave_ev->y < 0) {
-        XtPopdown(w); return;
+  if (e == NULL) i = *(int *)n;
+  else i = atoi(*v);
+  if (w != title_sm) {
+    if ((leave_ev->x <= 0) || (leave_ev->y < 0)) {
+      XtPopdown(w);
+      return;
     }
   } else {
-    if(leave_ev->x <= 0 || leave_ev->y <= 0) return;
+    if ((leave_ev->x <= 0) || (leave_ev->y <= 0)) return;
   }
-  if(psmenu[i] == NULL) return;
-  XtVaGetValues(psmenu[i],XtNheight,&height,NULL);
-  
+  if (psmenu[i] == NULL) return;
+  XtVaGetValues(psmenu[i], XtNheight,&height, NULL);
+
   /* neighbor menu height */
-  XtVaGetValues((i>0)? psmenu[i-1]:title_sm,
-                XtNwidth,&width,XtNheight,&nheight,XtNx,&x,XtNy,&y,NULL);
-  if(leave_ev->x > 0 && leave_ev->y > nheight - 22) {
-    XtVaSetValues(psmenu[i],XtNx,x+80,NULL);
-    XtPopup(psmenu[i],XtGrabNone);  
-    XtVaGetValues(psmenu[i],XtNheight,&height,NULL);
-    XtVaSetValues(psmenu[i],XtNy,y +((height)? nheight-height:0),NULL);
+  XtVaGetValues((i > 0)? psmenu[i-1]:title_sm, XtNwidth,&width,
+                         XtNheight,&nheight, XtNx,&x, XtNy,&y, NULL);
+  if ((leave_ev->x > 0) && (leave_ev->y > nheight - 22)) {
+    XtVaSetValues(psmenu[i], XtNx,x+80, NULL);
+    XtPopup(psmenu[i], XtGrabNone);
+    XtVaGetValues(psmenu[i], XtNheight,&height, NULL);
+    XtVaSetValues(psmenu[i], XtNy,y +((height)? nheight-height:0), NULL);
   }
 }
+#endif /* TimNmenu */
 
-/*ARGSUSED*/
-static void popdownSubmenuCB(Widget w,XtPointer data,XtPointer dummy) {
-  int i = (int)data;
+static void
+popdownSubmenuCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  long i = (long)client_data;
 
   if (i < 0) i = submenu_n -1;
-  while(i >= 0) XtPopdown(psmenu[i--]);
+  while (i >= 0) XtPopdown(psmenu[i--]);
 }
 
-/*ARGSUSED*/
-static void popdownSubmenu(Widget w, XEvent *e, String *v, Cardinal *n) {
+static void
+popdownSubmenuACT(Widget w, XEvent *e, String *v, Cardinal *n) {
   int i = atoi(*v);
 
-  while(i >= 0) XtPopdown(psmenu[i--]);
+  while (i >= 0) XtPopdown(psmenu[i--]);
 }
 
-/*ARGSUSED*/
-static void closeParent(Widget w, XEvent *e, String *v, Cardinal *n) {
-  XtPopdown(XtParent(w));
+static void
+closeParentACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  XtPopdown(seekTransientShell(w));
 }
 
-/*ARGSUSED*/
-static void flistMove(Widget w, XEvent *e, String *v, Cardinal *n) {
+static void
+flistMoveACT(Widget w, XEvent *e, String *v, Cardinal *n) {
   int i = atoi(*v);
   XawListReturnStruct *lr;
 
-  if(!max_files) return;
-  lr= XawListShowCurrent(file_list);
-  if(popup_shell_exist & FLIST_WINDOW) {
-    if(lr != NULL && lr->list_index != XAW_LIST_NONE) {
-      i += atoi(lr->string) -1;
-      if(i<0) i= 0;
-      if(i>=max_files) i= max_files -1;
+  if (max_files == 0) return;
+  lr = XawListShowCurrent(file_list);
+  if (XtIsRealized(popup_file)) {
+    if ((lr != NULL) && (lr->list_index != XAW_LIST_NONE)) {
+      Dimension listheight, vportheight;
+      Widget file_vport = XtParent(file_list);
+      int perpage;
+
+      XtVaGetValues(file_list, XtNheight,&listheight, NULL);
+      XtVaGetValues(file_vport, XtNheight,&vportheight, NULL);
+      perpage = ceil((max_files * vportheight) / listheight - 0.5);
+      if (*(int *)n == 1) {
+        i += lr->list_index;
+      } else if (*(int *)n == 2) {
+        i = lr->list_index + i*perpage;
+      } else {
+        if (i > 0) i = max_files-1;
+        else i = 0;
+      }
+      if (i < 0) i = 0;
+      else if (i >= max_files) i = max_files-1;
+      if (listheight > vportheight) {
+        Widget scrollbar; barfloat thumb; int covered;
+
+        scrollbar = XtNameToWidget(file_vport, "vertical");
+        if (scrollbar == NULL) return;
+        XtVaGetValues(scrollbar, XtNtopOfThumb,&thumb.f, NULL);
+        covered = thumb.f*max_files;
+
+        if ( ((i - 1) < covered) || ((i + 1) > (covered + perpage)) ) {
+          String arg[1];
+
+          if ((i - 1) < covered) {
+            if (i > perpage/2)
+              thumb.f = (float)(i - perpage/2) / (float)max_files;
+            else thumb.f = 0;
+          }
+          else thumb.f = (float) (i - perpage/2) / (float)max_files;
+          arg[0] = XtNewString("Continuous");
+          XtCallActionProc(scrollbar, (String)"StartScroll", e, arg, ONE);
+          XtFree(arg[0]);
+          setThumb(scrollbar, thumb);
+          XtCallActionProc(scrollbar, (String)"NotifyThumb", e, NULL, ZERO);
+          XtCallActionProc(scrollbar, (String)"EndScroll", e, NULL, ZERO);
+        }
+      }
       XawListHighlight(file_list, i);
     } else {
-      XawListHighlight(file_list, (i>0)? max_files-1:0);
+/* should never be reached */
+      XawListHighlight(file_list, (i<0)?max_files-1:0);
     }
   }
 }
 
-static int max_num = INIT_FLISTNUM;
-
-static void addFlist(char *fname, int current_n) {
-  char *p;
-
-  if(max_num < current_n+1) {
+static void
+addFlist(char *fname, long current_n) {
+  if (max_num < current_n+1) {
     max_num += 64;
-    flist = (String *)safe_realloc(flist,(max_num+1)*sizeof(String));
+    flist = (String *)safe_realloc(flist, (max_num+1)*sizeof(String));
   }
-  p = (char *)safe_malloc(sizeof(char) * (strlen(fname) +1));
-  flist[current_n]= strcpy(p, fname);
-  flist[current_n+1]= NULL;
+  free(flist[current_n]);
+  flist[current_n] = safe_strdup(fname);
+  flist[current_n+1] = NULL;
 }
 
-static void addOneFile(int max_files,int curr_num,char *fname,Boolean update_flist) {
+static void
+addOneFile(int max_files, long curr_num, char *fname) {
   static Dimension tmpi;
   static int menu_height;
   static Widget tmpw;
-  static int j;
+  static int jjj;
+  Widget pbox;
   char sbuf[256];
 
-  if(curr_num == 0) {
-    j = 0; tmpi = 0; menu_height = 0; tmpw = title_sm;
+  if (curr_num == 0) {
+    jjj = 0; tmpi = 0; menu_height = 0; tmpw = title_sm;
   }
-  if(menu_height + tmpi*2 > root_height) {
-    if(!maxentry_on_a_menu) {
-      maxentry_on_a_menu = j = curr_num;
-      XtAddCallback(title_sm,XtNpopdownCallback,popdownSubmenuCB,(XtPointer)(submenu_n -1));
+  if (menu_height + tmpi*2 > root_height) {
+    if (maxentry_on_a_menu == 0) {
+      jjj = curr_num;
+      maxentry_on_a_menu = jjj;
+      XtAddCallback(title_sm, XtNpopdownCallback,popdownSubmenuCB,
+                         (XtPointer)(submenu_n -1));
     }
-    if(j >= maxentry_on_a_menu) {
-      if (psmenu == NULL)
-        psmenu = (Widget *)safe_malloc(sizeof(Widget) * ((int)(max_files / curr_num)+ 2));
-      else
-        psmenu = (Widget *)safe_realloc((char *)psmenu, sizeof(Widget)*(submenu_n + 2));
-      sprintf(sbuf, "morebox%d", submenu_n);
-      pbox=XtVaCreateManagedWidget(sbuf,smeBSBObjectClass,tmpw,XtNlabel,"  More...",
-                                   XtNbackground,textbgcolor,XtNforeground,capcolor,
-                                   XtNrightBitmap,arrow_mark,
-                                   XtNfont,app_resources.label_font, NULL);
-      snprintf(sbuf,sizeof(sbuf),
-              "<LeaveWindow>: unhighlight() checkRightAndPopupSubmenu(%d)",submenu_n);
+    if (jjj >= maxentry_on_a_menu) {
+      if (!psmenu) {
+        psmenu = (Widget *)safe_malloc(sizeof(Widget)
+                              * ((int)(max_files / curr_num) + 2));
+#ifndef TimNmenu
+       sb = (String *)safe_malloc(sizeof(String));
+#endif
+      } else {
+        psmenu = (Widget *)safe_realloc((char *)psmenu,
+                    sizeof(Widget)*(submenu_n + 2));
+#ifndef TimNmenu
+        sb = (String *)safe_realloc(sb, sizeof(String)*(submenu_n + 2));
+#endif
+      }
+      snprintf(sbuf, sizeof(sbuf), "morebox%ld", submenu_n);
+      pbox = XtVaCreateManagedWidget(sbuf,smeBSBObjectClass,tmpw,
+               XtNlabel,app_resources.more_text,
+               XtNbackground,textbgcolor, XtNforeground,capcolor,
+               XtNrightBitmap,arrow_mark,
+               XtNfontSet,app_resources.label_font, NULL);
+
+      snprintf(sbuf, sizeof(sbuf), "psmenu%ld", submenu_n);
+      psmenu[submenu_n] = XtVaCreatePopupShell(sbuf,simpleMenuWidgetClass,
+                                 title_sm, XtNforeground,textcolor,
+                                 XtNbackingStore,NotUseful, XtNsaveUnder,False,
+                                 XtNwidth,app_resources.menu_width,
+                                 XtNbackground,textbgcolor, NULL);
+#ifndef TimNmenu
+      sb[submenu_n] = safe_strdup(sbuf);
+      XtVaSetValues(pbox, XtNmenuName,sb[submenu_n], NULL);
+#else
+      snprintf(sbuf, sizeof(sbuf),
+              "<LeaveWindow>: unhighlight() \
+                  checkRightAndPopupSubmenu(%ld)", submenu_n);
       XtOverrideTranslations(tmpw, XtParseTranslationTable(sbuf));
-
-      sprintf(sbuf, "psmenu%d", submenu_n);
-      psmenu[submenu_n] = XtVaCreatePopupShell(sbuf,simpleMenuWidgetClass,title_sm,
-                                   XtNforeground,textcolor, XtNbackground,textbgcolor,
-                                   XtNbackingStore,NotUseful,XtNsaveUnder,False,
-                                   XtNwidth,menu_width,
-                                   NULL);
-      snprintf(sbuf,sizeof(sbuf), "<BtnUp>: popdownSubmenu(%d) notify() unhighlight()\n\
+      snprintf(sbuf, sizeof(sbuf), "<BtnUp>: popdownSubmenu(%ld) \
+                                      notify() unhighlight()\n\
         <EnterWindow>: unhighlight()\n\
-        <LeaveWindow>: leaveSubmenu(%d) unhighlight()",submenu_n,submenu_n);
-      XtOverrideTranslations(psmenu[submenu_n],XtParseTranslationTable(sbuf));
+        <LeaveWindow>: leaveSubmenu(%ld) unhighlight()", submenu_n, submenu_n);
+      XtOverrideTranslations(psmenu[submenu_n], XtParseTranslationTable(sbuf));
+#endif /* !TimNmenu */
       tmpw = psmenu[submenu_n++]; psmenu[submenu_n] = NULL;
-      j = 0;
+      jjj = 0;
     }
   }
-  if(maxentry_on_a_menu) j++;
-  bsb=XtVaCreateManagedWidget(fname,smeBSBObjectClass,tmpw,NULL);
-  XtAddCallback(bsb,XtNcallback,menuCB,(XtPointer)curr_num);
-  XtVaGetValues(bsb, XtNheight, &tmpi, NULL);
-  if(!maxentry_on_a_menu)
-    menu_height += tmpi;
-  else
-    psmenu[submenu_n] = NULL;
-  if(update_flist)
-    addFlist(fname, curr_num);
-}
-
-static void createOptions(void) {
-  if(!(popup_shell_exist & OPTIONS_WINDOW)) {
-    popup_opt= XtVaCreatePopupShell("popup_option",transientShellWidgetClass,
-                                  toplevel,NULL);
-    popup_optbox= XtVaCreateManagedWidget("popup_optbox",boxWidgetClass,popup_opt,
-                                  XtNorientation,XtorientVertical,
-                                  XtNwidth,220,XtNheight,280,
-                                  XtNbackground,bgcolor,NULL);
-    modul_bb=XtVaCreateManagedWidget("modul_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    modul_b=XtVaCreateManagedWidget("modul_button",toggleWidgetClass,modul_bb,
-                                  XtNbitmap,off_mark,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    modul_l=XtVaCreateManagedWidget("modul_lbl",labelWidgetClass,modul_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    porta_bb=XtVaCreateManagedWidget("porta_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    porta_b=XtVaCreateManagedWidget("porta_button",toggleWidgetClass,porta_bb,
-                                  XtNbitmap,off_mark,XtNfromVert,modul_b,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    porta_l=XtVaCreateManagedWidget("porta_lbl",labelWidgetClass,porta_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    nrpnv_bb=XtVaCreateManagedWidget("nrpnv_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    nrpnv_b=XtVaCreateManagedWidget("nrpnv_button",toggleWidgetClass,nrpnv_bb,
-                                  XtNbitmap,off_mark,XtNfromVert,porta_b,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    nrpnv_l=XtVaCreateManagedWidget("nrpnv_lbl",labelWidgetClass,nrpnv_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    reverb_bb=XtVaCreateManagedWidget("reverb_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    reverb_b=XtVaCreateManagedWidget("reverb_button",toggleWidgetClass,reverb_bb,
-                                  XtNbitmap,off_mark,XtNfromVert,nrpnv_b,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    reverb_l=XtVaCreateManagedWidget("reverb_lbl",labelWidgetClass,reverb_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    chorus_bb=XtVaCreateManagedWidget("chorus_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    chorus_b=XtVaCreateManagedWidget("chorus_button",toggleWidgetClass,chorus_bb,
-                                  XtNbitmap,off_mark,XtNfromVert,reverb_b,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    chorus_l=XtVaCreateManagedWidget("chorus_lbl",labelWidgetClass,chorus_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    chpressure_bb=XtVaCreateManagedWidget("chpressure_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,XtNfromVert,chorus_b,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    chpressure_b=XtVaCreateManagedWidget("chpressure_button",toggleWidgetClass,chpressure_bb,
-                                  XtNbitmap,off_mark,XtNfromVert,chorus_b,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    chpressure_l=XtVaCreateManagedWidget("chpressure_lbl",labelWidgetClass,chpressure_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    overlapv_bb=XtVaCreateManagedWidget("overlapvoice_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,XtNfromVert,chpressure_b,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    overlapv_b=XtVaCreateManagedWidget("overlapvoice_button",toggleWidgetClass,overlapv_bb,
-                                  XtNbitmap,off_mark,XtNfromVert,chpressure_b,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    overlapv_l=XtVaCreateManagedWidget("overlapv_lbl",labelWidgetClass,overlapv_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    txtmeta_bb=XtVaCreateManagedWidget("txtmeta_box",boxWidgetClass,popup_optbox,
-                                  XtNorientation,XtorientHorizontal,XtNfromVert,overlapv_b,
-                                  XtNforeground,boxcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    txtmeta_b=XtVaCreateManagedWidget("txtmeta_button",toggleWidgetClass,txtmeta_bb,
-                                  XtNbitmap,off_mark,XtNfromVert,overlapv_b,
-                                  XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-                                  NULL);
-    txtmeta_l=XtVaCreateManagedWidget("txtmeta_lbl",labelWidgetClass,txtmeta_bb,
-                                  XtNforeground,textcolor, XtNbackground,bgcolor,
-                                  XtNborderWidth,0,NULL);
-    popup_oclose= XtVaCreateManagedWidget("closebutton",
-                                  commandWidgetClass, popup_optbox,
-                                  XtNfromVert,txtmeta_b,
-                                  XtNwidth,80,XtNresize,False,NULL);
-    XtAddCallback(popup_opt,XtNdestroyCallback,optionsdestroyCB,NULL);
-    XtAddCallback(popup_oclose,XtNcallback,optionscloseCB,NULL);
-    XtAddCallback(modul_b,XtNcallback,optionsCB,(XtPointer)&option_num[MODUL_N].id);
-    XtAddCallback(porta_b,XtNcallback,optionsCB,(XtPointer)&option_num[PORTA_N].id);
-    XtAddCallback(nrpnv_b,XtNcallback,optionsCB,(XtPointer)&option_num[NRPNV_N].id);
-    XtAddCallback(reverb_b,XtNcallback,optionsCB,(XtPointer)&option_num[REVERB_N].id);
-    XtAddCallback(chpressure_b,XtNcallback,optionsCB,(XtPointer)&option_num[CHPRESSURE_N].id);
-    XtAddCallback(overlapv_b,XtNcallback,optionsCB,(XtPointer)&option_num[OVERLAPV_N].id);
-    XtAddCallback(txtmeta_b,XtNcallback,optionsCB,(XtPointer)&option_num[TXTMETA_N].id);
-    XtAddCallback(chorus_b,XtNcallback,chorusCB,NULL);
-    option_num[MODUL_N].widget= modul_b;
-    option_num[PORTA_N].widget= porta_b;
-    option_num[NRPNV_N].widget= nrpnv_b;
-    option_num[REVERB_N].widget= reverb_b;
-    option_num[CHPRESSURE_N].widget= chpressure_b;
-    option_num[OVERLAPV_N].widget= overlapv_b;
-    option_num[TXTMETA_N].widget= txtmeta_b;
-    XtSetKeyboardFocus(popup_opt, popup_optbox);
-    if(init_options) {
-      int i;
-      for(i=0; i<MAX_OPTION_N; i++) {
-        if(init_options & option_num[i].bit)
-          XtVaSetValues(option_num[i].widget,XtNstate,True,XtNbitmap,on_mark,NULL);
-      }
+  if (maxentry_on_a_menu != 0) jjj++;
+  bsb = XtVaCreateManagedWidget(fname,smeBSBObjectClass,tmpw, NULL);
+  XtAddCallback(bsb, XtNcallback,menuCB, (XtPointer)curr_num);
+  XtVaGetValues(bsb, XtNheight,&tmpi, NULL);
+  if (maxentry_on_a_menu == 0) menu_height += tmpi;
+  else psmenu[submenu_n] = NULL;
+}
+
+static void
+createOptions(void) {
+  Widget modul_b, modul_bb, modul_l, porta_b, porta_bb, porta_l, nrpnv_b,
+         nrpnv_bb, nrpnv_l, reverb_b, reverb_bb, reverb_l, chorus_bb, chorus_l,
+         chpressure_b, chpressure_bb, chpressure_l, overlapv_b, overlapv_bb,
+         overlapv_l, txtmeta_b, txtmeta_bb, txtmeta_l,
+         popup_optform, lowBox, popup_olabel, popup_ook, popup_ocancel;
+  Dimension x, y;
+
+  popup_opt = XtVaCreatePopupShell("popup_option",transientShellWidgetClass,
+                       toplevel, NULL);
+  XtVaGetValues(toplevel, XtNx,&x, XtNy,&y, NULL);
+  XtVaSetValues(popup_opt, XtNx,x+DEFAULT_REG_WIDTH, XtNy,y, NULL);
+
+  popup_optform = XtVaCreateManagedWidget("popup_optform",formWidgetClass,
+                       popup_opt, XtNorientation,XtorientVertical,
+                       XtNbackground,bgcolor, NULL);
+  modul_bb = XtVaCreateManagedWidget("modul_box",boxWidgetClass,popup_optform,
+                       XtNbackground,bgcolor,
+                       XtNorientation,XtorientHorizontal, NULL);
+  modul_b = XtVaCreateManagedWidget("modul_button",toggleWidgetClass,modul_bb,
+                       XtNbitmap,off_mark, XtNforeground,togglecolor,
+                       XtNbackground,buttonbgcolor, NULL);
+  modul_l = XtVaCreateManagedWidget("modul_lbl",labelWidgetClass,modul_bb,
+                       XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
+  porta_bb = XtVaCreateManagedWidget("porta_box",boxWidgetClass,popup_optform,
+                       XtNfromVert,modul_bb, 
+                       XtNorientation,XtorientHorizontal,
+                       XtNbackground,bgcolor, NULL);
+  porta_b = XtVaCreateManagedWidget("porta_button",toggleWidgetClass,porta_bb,
+                       XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+                       XtNbitmap,off_mark, XtNfromVert,modul_b, NULL);
+  porta_l = XtVaCreateManagedWidget("porta_lbl",labelWidgetClass,porta_bb,
+                       XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
+  nrpnv_bb = XtVaCreateManagedWidget("nrpnv_box",boxWidgetClass,popup_optform,
+                       XtNfromVert,porta_bb, 
+                       XtNorientation,XtorientHorizontal,
+                       XtNbackground,bgcolor, NULL);
+  nrpnv_b = XtVaCreateManagedWidget("nrpnv_button",toggleWidgetClass,nrpnv_bb,
+                       XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+                       XtNbitmap,off_mark, XtNfromVert,porta_b, NULL);
+  nrpnv_l = XtVaCreateManagedWidget("nrpnv_lbl",labelWidgetClass,nrpnv_bb,
+                       XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
+  reverb_bb = XtVaCreateManagedWidget("reverb_box",boxWidgetClass,
+                       popup_optform, XtNfromVert,nrpnv_bb,
+                       XtNorientation,XtorientHorizontal,
+                       XtNbackground,bgcolor, NULL);
+  reverb_b = XtVaCreateManagedWidget("reverb_button",toggleWidgetClass,
+                       reverb_bb, XtNbitmap,off_mark, XtNfromVert,nrpnv_b,
+                       XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+                       NULL);
+  reverb_l = XtVaCreateManagedWidget("reverb_lbl",labelWidgetClass,reverb_bb,
+                       XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
+  chorus_bb = XtVaCreateManagedWidget("chorus_box",boxWidgetClass,
+                       popup_optform, XtNorientation,XtorientHorizontal,
+                       XtNfromVert,reverb_bb, 
+                       XtNbackground,bgcolor, NULL);
+  chorus_b = XtVaCreateManagedWidget("chorus_button",toggleWidgetClass,
+                       chorus_bb, XtNbitmap,off_mark, XtNfromVert,reverb_b,
+                       XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+                       NULL);
+  chorus_l = XtVaCreateManagedWidget("chorus_lbl",labelWidgetClass,chorus_bb,
+                       XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
+  chpressure_bb = XtVaCreateManagedWidget("chpressure_box",boxWidgetClass,
+                       popup_optform, XtNorientation,XtorientHorizontal,
+                       XtNfromVert,chorus_bb, 
+                       XtNbackground,bgcolor, NULL);
+  chpressure_b = XtVaCreateManagedWidget("chpressure_button",
+                       toggleWidgetClass,chpressure_bb, XtNbitmap,off_mark,
+                       XtNfromVert,chorus_b, XtNforeground,togglecolor,
+                       XtNbackground,buttonbgcolor, NULL);
+  chpressure_l = XtVaCreateManagedWidget("chpressure_lbl",labelWidgetClass,
+                       chpressure_bb, XtNforeground,textcolor,
+                       XtNbackground,bgcolor, NULL);
+  overlapv_bb = XtVaCreateManagedWidget("overlapvoice_box",boxWidgetClass,
+                       popup_optform, XtNorientation,XtorientHorizontal,
+                       XtNfromVert,chpressure_bb, 
+                       XtNbackground,bgcolor, NULL);
+  overlapv_b = XtVaCreateManagedWidget("overlapvoice_button",
+                       toggleWidgetClass,overlapv_bb, XtNbitmap,off_mark, 
+                       XtNfromVert,chpressure_b, XtNforeground,togglecolor,
+                       XtNbackground,buttonbgcolor, NULL);
+  overlapv_l = XtVaCreateManagedWidget("overlapv_lbl",labelWidgetClass,
+                       overlapv_bb, XtNforeground,textcolor,
+                       XtNbackground,bgcolor, NULL);
+  txtmeta_bb = XtVaCreateManagedWidget("txtmeta_box",boxWidgetClass,
+                       popup_optform, XtNorientation,XtorientHorizontal,
+                       XtNfromVert,overlapv_bb, 
+                       XtNbackground,bgcolor, NULL);
+  txtmeta_b = XtVaCreateManagedWidget("txtmeta_button",toggleWidgetClass,
+                       txtmeta_bb, XtNbitmap,off_mark, XtNfromVert,overlapv_b,
+                       XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+                       NULL);
+  txtmeta_l = XtVaCreateManagedWidget("txtmeta_lbl",labelWidgetClass,
+                       txtmeta_bb, XtNforeground,textcolor,
+                       XtNbackground,bgcolor, NULL);
+
+
+  popup_olabel = XtVaCreateManagedWidget("popup_olabel",labelWidgetClass,
+            popup_optform, XtNbackground,menubcolor, XtNfromVert,txtmeta_bb,
+            NULL);
+  lowBox = createOutputSelectionWidgets(popup_opt, popup_optform,
+                                        popup_olabel, play, True);
+
+  popup_ook = XtVaCreateManagedWidget("closebutton",commandWidgetClass,
+                                      popup_optform, XtNfromVert,lowBox,
+                                      XtNwidth,80, NULL);
+  popup_ocancel = XtVaCreateManagedWidget("Cancel",commandWidgetClass,
+                                          popup_optform, XtNfromVert,lowBox,
+                                          XtNfromHoriz,popup_ook, XtNwidth,80,
+                                          NULL);
+  XtAddCallback(popup_ook, XtNcallback,optionscloseCB, NULL);
+  XtAddCallback(popup_ocancel, XtNcallback,closeWidgetCB, (XtPointer)popup_opt);
+  XtAddCallback(modul_b, XtNcallback,optionsCB, NULL);
+  XtAddCallback(porta_b, XtNcallback,optionsCB, NULL);
+  XtAddCallback(nrpnv_b, XtNcallback,optionsCB, NULL);
+  XtAddCallback(reverb_b, XtNcallback,optionsCB, NULL);
+  XtAddCallback(chpressure_b, XtNcallback,optionsCB, NULL);
+  XtAddCallback(overlapv_b, XtNcallback,optionsCB, NULL);
+  XtAddCallback(txtmeta_b, XtNcallback,optionsCB, NULL);
+  XtAddCallback(chorus_b, XtNcallback,optionsCB, NULL);
+  option_num[MODUL_N].widget = modul_b;
+  option_num[PORTA_N].widget = porta_b;
+  option_num[NRPNV_N].widget = nrpnv_b;
+  option_num[REVERB_N].widget = reverb_b;
+  option_num[CHPRESSURE_N].widget = chpressure_b;
+  option_num[OVERLAPV_N].widget = overlapv_b;
+  option_num[TXTMETA_N].widget = txtmeta_b;
+  XtSetKeyboardFocus(popup_opt, popup_optform);
+  if (init_options != 0) {
+    int i;
+
+    for(i=0; i<MAX_OPTION_N; i++) {
+      if (init_options & option_num[i].bit)
+        XtVaSetValues(option_num[i].widget, XtNstate,True,
+                      XtNbitmap,on_mark, NULL);
     }
-    if(init_chorus)
-      XtVaSetValues(chorus_b,XtNstate,True,XtNbitmap,on_mark,NULL);
-    popup_shell_exist |= OPTIONS_WINDOW;
   }
+  if (init_chorus != 0)
+    XtVaSetValues(chorus_b, XtNstate,True, XtNbitmap,on_mark, NULL);
 }
 
-/*ARGSUSED*/
-static void fselectCB(Widget w,XtPointer data,XtPointer call_data) {
+static void
+fselectCB(Widget w, XtPointer client_data, XtPointer call_data) {
   XawListReturnStruct *lr = XawListShowCurrent(file_list);
 
-  if(lr != NULL && lr->list_index != XAW_LIST_NONE) {
+  if ((lr != NULL) && (lr->list_index != XAW_LIST_NONE)) {
     onPlayOffPause();
-    sprintf(local_buf,"L %d",atoi(lr->string));
-    a_pipe_write(local_buf);
+    a_pipe_write("L %d", lr->list_index + 1);
   }
 }
 
-/*ARGSUSED*/
-static void fdeleteCB(Widget w,XtPointer data,XtPointer call_data) {
+static void
+fdeleteCB(Widget w, XtPointer client_data, XtPointer call_data) {
   XawListReturnStruct *lr = XawListShowCurrent(file_list);
-  int i,n;
+  int n; long i;
   char *p;
 
-  if(lr == NULL || lr->list_index == XAW_LIST_NONE) return;
-  stopCB(w,NULL,NULL);
-  if(max_files==1) {
-    fdelallCB(w,NULL,NULL); return;
+  if ((lr == NULL) || (lr->list_index == XAW_LIST_NONE)) return;
+  if (max_files == 1) {
+    fdelallCB(w, NULL, NULL);
+    return;
+  }
+  n = lr->list_index;
+  if (n+1 < current_n_displayed) current_n_displayed--;
+  else if (n+1 == current_n_displayed) {
+    stopCB(w, NULL, NULL);
+    XtVaSetValues(tune_l, XtNlabel,"/ 00:00", NULL);
+    if (n+1<max_files) p = strchr(flist[n+1], ' ');
+    else {
+      p = strchr(flist[n-1], ' ');
+      current_n_displayed--;
+    }
+    if (p != NULL) XtVaSetValues(title_mb, XtNlabel,p+1, NULL);
+    else fprintf(stderr, "No space character in flist!\n"); 
+         /* Should never happen */
   }
-  n = atoi(lr->string) -1;
-  sprintf(local_buf,"d %d",n);
-  a_pipe_write(local_buf);
+  a_pipe_write("d %d", n);
   --max_files;
   free(flist[n]);
-  for(i= n; i<max_files; i++) {
-    p= strchr(flist[i+1],'.');
-    snprintf(local_buf,sizeof(local_buf),"%d%s",i+1,p);
-    strncpy(flist[i+1],local_buf,strlen(flist[i+1]));
-    flist[i]= flist[i+1];
-  }
-  flist[max_files]= NULL;
-  if(popup_shell_exist & FLIST_WINDOW) {
-    Dimension h,w;
-    XawListChange(file_list,flist,max_files,360,True);
-    /* keep Viewport size */
-    XtVaGetValues(file_vport,XtNwidth,&w,XtNheight,&h,NULL);
-    XtVaSetValues(file_vport,XtNheight,((h>FILEVPORT_HEIGHT)? h:FILEVPORT_HEIGHT),NULL);
-    if(n>=max_files) --n;
-    XawListHighlight(file_list,n);
-  }
-  if(psmenu != NULL) free(psmenu);
-  XtDestroyWidget(title_sm); psmenu = NULL;
-  maxentry_on_a_menu = 0,submenu_n = 0;
-  title_sm=XtVaCreatePopupShell("title_simplemenu",simpleMenuWidgetClass,title_mb,
-                                XtNforeground,textcolor, XtNbackground,textbgcolor,
-                                XtNbackingStore,NotUseful, XtNsaveUnder,False, NULL);
-  for(i= 0; i<max_files; i++)
-    addOneFile(max_files,i,flist[i],False);
-}
-
-/*ARGSUSED*/
-static void fdelallCB(Widget w,XtPointer data,XtPointer call_data) {
-  int i;
+  for(i=n; i<max_files; i++) {
+    p = strchr(flist[i+1], '.');
+    snprintf(flist[i+1], strlen(flist[i+1])+1, "%ld%s", i+1, p);
+    flist[i] = flist[i+1];
+  }
+  flist[max_files] = NULL;
+  if (XtIsRealized(popup_file)) {
+    XawListChange(file_list, flist, max_files, 0, True);
+    if (n >= max_files) --n;
+    XawListHighlight(file_list, n);
+  }
+  if (psmenu != NULL) { 
+    free(psmenu);
+    psmenu = NULL;
+#ifndef TimNmenu
+    if (sb != NULL) {
+      free(sb);
+      sb = NULL;
+    }
+#endif /* !TimNmenu */
+  }
+  XtDestroyWidget(title_sm);
+  maxentry_on_a_menu = 0;
+  submenu_n = 0;
+  title_sm = XtVaCreatePopupShell("title_simplemenu",simpleMenuWidgetClass,
+                                title_mb, XtNforeground,textcolor,
+                                XtNbackground,textbgcolor, XtNsaveUnder,False,
+                                XtNbackingStore,NotUseful, NULL);
+  for(i=0; i<max_files; i++)
+    addOneFile(max_files, i, flist[i]);
+}
 
-  stopCB(w,NULL,NULL);
+static void
+fdelallCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  int i; char lbuf[50];
+
+  stopCB(w, NULL, NULL);
   a_pipe_write("A");
-  for(i=0; i<max_files; i++) free(flist[i]);
-  max_files= 0;
-  flist[0]= NULL;
-  if(popup_shell_exist & FLIST_WINDOW) {
-    Dimension h,w;
-    XawListChange(file_list,NULL,max_files,360,True);
-    /* keep Viewport size */
-    XtVaGetValues(file_vport,XtNwidth,&w,XtNheight,&h,NULL);
-    XtVaSetValues(file_vport,XtNheight,((h>FILEVPORT_HEIGHT)? h:FILEVPORT_HEIGHT),NULL);
-  }
-  if(psmenu != NULL) free(psmenu);
-  XtDestroyWidget(title_sm); psmenu = NULL;
-  maxentry_on_a_menu = 0,submenu_n = 0;
-  title_sm=XtVaCreatePopupShell("title_simplemenu",simpleMenuWidgetClass,title_mb,
-                                XtNforeground,textcolor, XtNbackground,textbgcolor,
-                                XtNbackingStore,NotUseful, XtNsaveUnder,False, NULL);
-  bsb=XtVaCreateManagedWidget("dummyfile",smeLineObjectClass,title_sm,NULL);
-  snprintf(local_buf,sizeof(local_buf),"TiMidity++ %s",timidity_version);
-  XtVaSetValues(title_mb,XtNlabel,local_buf,NULL);
-  if(ctl->trace_playing)
-    strcpy(window_title,"[ No Playing File ]");
+  for(i=1; i<max_files; i++) free(flist[i]);
+  /* We keep a single member in flist. Otherwise, Xaw will display the
+   * widget's name as a member, also letting the user "delete" it (with a
+   * crash to follow).
+   */
+  max_files = 0;
+  current_n_displayed = 0;
+  if (*flist == NULL) *flist = (String)safe_malloc(sizeof(char *));
+  **flist = '\0';
+  if (XtIsRealized(popup_file))
+    XawListChange(file_list, flist, max_files?max_files:1, 0, True);
+  XtVaSetValues(file_menu[ID_SAVE - 100].widget, XtNsensitive,False, NULL);
+  if (psmenu != NULL) {
+    free(psmenu);
+    psmenu = NULL;
+#ifndef TimNmenu
+    if (sb != NULL) {
+      free(sb);
+      sb = NULL;
+    }
+#endif /* !TimNmenu */
+  }
+  XtDestroyWidget(title_sm);
+  maxentry_on_a_menu = 0; submenu_n = 0;
+  title_sm = XtVaCreatePopupShell("title_simplemenu",simpleMenuWidgetClass,
+                                title_mb, XtNforeground,textcolor,
+                                XtNbackground,textbgcolor, XtNsaveUnder,False,
+                                XtNbackingStore,NotUseful, NULL);
+  bsb = XtVaCreateManagedWidget("dummyfile",smeLineObjectClass,title_sm, NULL);
+  snprintf(lbuf, sizeof(lbuf), "TiMidity++ %s", timidity_version);
+  XtVaSetValues(title_mb, XtNlabel,lbuf, NULL);
+  snprintf(window_title, sizeof(window_title), "%s : %s",
+           APP_CLASS, app_resources.no_playing);
+  XtVaSetValues(toplevel, XtNtitle,window_title, NULL);
+  XtVaSetValues(tune_l, XtNlabel,"/ ----", NULL);
 #ifndef WIDGET_IS_LABEL_WIDGET
-  deleteTextCB(w,NULL,NULL);
+  deleteTextACT(w, NULL, NULL, NULL);
 #endif
 }
 
-/*ARGSUSED*/
-static void backspaceCB(Widget w,XtPointer data,XtPointer call_data) {
-  XawTextPosition begin,end,curr;
+static void
+backspaceACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  XawTextPosition begin, end;
   XawTextBlock tb;
+
   XawTextGetSelectionPos(w, &begin, &end);
-  curr = XawTextGetInsertionPoint(w);
-  if(begin == end) return;
+  if (begin == end) return;
   tb.firstPos = 0;
   tb.ptr = ".";
-  tb.format = FMT8BIT;
+  tb.format = XawFmt8Bit;
   tb.length = strlen(tb.ptr);
-  XawTextReplace(w,begin,end,&tb);
-  XawTextSetInsertionPoint(w,begin+1);
+  XawTextReplace(w, begin, end, &tb);
+  XawTextSetInsertionPoint(w, begin+1);
 }
 
-/*ARGSUSED*/
 #ifndef WIDGET_IS_LABEL_WIDGET
-static void deleteTextCB(Widget w,XtPointer data,XtPointer call_data) {
-  XtVaSetValues(lyric_t,XtNstring,(String)"<< TiMidity Messages >>",NULL);
+static void
+deleteTextACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+#ifdef CLEARVALUE
+  Widget TextSrc;
+
+  XtVaGetValues(lyric_t, XtNtextSource,&TextSrc, NULL); 
+  XawAsciiSourceFreeString(TextSrc);
+#endif /* CLEARVALUE */
+  XtVaSetValues(lyric_t, XtNstring,(String)"<< TiMidity Messages >>\n", NULL);
 }
 #endif
 
-static void createFlist(void) {
-  if(!(popup_shell_exist & FLIST_WINDOW)) {
-    popup_file= XtVaCreatePopupShell("popup_file",transientShellWidgetClass,
-                                  toplevel,NULL);
-    popup_fbox= XtVaCreateManagedWidget("popup_fbox",boxWidgetClass,popup_file,
-                                  XtNwidth,280,XtNheight,360,
-                                  XtNorientation,XtorientVertical,
-                                  XtNbackground,bgcolor,NULL);
-    file_vport = XtVaCreateManagedWidget("file_vport",viewportWidgetClass,popup_fbox,
-                                  XtNallowHoriz,True, XtNallowVert,True,
-                                  XtNuseBottom,True,
-                                  XtNwidth,FILEVPORT_WIDTH, XtNheight,FILEVPORT_HEIGHT,
-                                  XtNbackground,textbgcolor,XtNborderWidth,1,NULL);
-    file_list= XtVaCreateManagedWidget("filelist",listWidgetClass,file_vport,
-                                  XtNverticalList,True,
-                                  XtNforceColumns,True,XtNdefaultColumns,1,
-                                  XtNbackground,textbgcolor,NULL);
-    flist_cmdbox= XtVaCreateManagedWidget("flist_cmdbox",boxWidgetClass,popup_fbox,
-                                  XtNorientation,XtorientHorizontal,
-                                  XtNwidth,272,XtNheight,24,
-                                  XtNborderWidth,0,
-                                  XtNbackground,bgcolor,NULL);
-    popup_fplay= XtVaCreateManagedWidget("fplaybutton",
-                    commandWidgetClass,flist_cmdbox,
-                    XtNfont,volumefont,XtNresize,False,NULL);
-    popup_fdelete= XtVaCreateManagedWidget("fdeletebutton",
-                    commandWidgetClass,flist_cmdbox,
-                    XtNfont,volumefont,XtNresize,False,NULL);
-    popup_fdelall= XtVaCreateManagedWidget("fdelallbutton",
-                    commandWidgetClass,flist_cmdbox,
-                    XtNfont,volumefont,XtNresize,False,NULL);
-    popup_fclose= XtVaCreateManagedWidget("closebutton",
-                    commandWidgetClass,flist_cmdbox,
-                    XtNfont,volumefont,XtNresize,False,NULL);
-    XtAddCallback(popup_fclose,XtNcallback,flistcloseCB,NULL);
-    XtAddCallback(popup_fplay,XtNcallback,fselectCB,NULL);
-    XtAddCallback(popup_fdelete,XtNcallback,fdeleteCB,NULL);
-    XtAddCallback(popup_fdelall,XtNcallback,fdelallCB,NULL);
-    XtSetKeyboardFocus(popup_file, popup_fbox);
-    popup_shell_exist |= FLIST_WINDOW;
-    XawListChange(file_list, flist, 0,0,True);
+static void
+scrollTextACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  int i, l = atoi(*v);
+
+  for (i=0; i<l; i++)
+    XtCallActionProc(lyric_t, "scroll-one-line-up", NULL, NULL, ZERO);
+  for (i=0; i>l; i--)
+    XtCallActionProc(lyric_t, "scroll-one-line-down", NULL, NULL, ZERO);
+}
+
+static void
+createFlist(void) {
+
+  if (popup_file == NULL) {
+    Widget popup_fform, flist_cmdbox, popup_fplay, popup_fdelete,
+           popup_fdelall, popup_fclose;
+
+    popup_file = XtVaCreatePopupShell("popup_file",transientShellWidgetClass,
+                    toplevel, NULL);
+    popup_fform = XtVaCreateManagedWidget("popup_fform",formWidgetClass,
+                    popup_file, XtNbackground,bgcolor,
+                    XtNorientation,XtorientVertical, NULL);
+    file_vport = XtVaCreateManagedWidget("file_vport",viewportWidgetClass,
+                    popup_fform, XtNallowHoriz,True, XtNallowVert,True,
+                    XtNuseBottom,True, XtNbackground,textbgcolor,
+                    XtNleft,XawChainLeft, XtNright,XawChainRight,
+                    XtNbottom,XawChainBottom, NULL);
+    file_list = XtVaCreateManagedWidget("filelist",listWidgetClass,file_vport,
+                    XtNbackground,textbgcolor, XtNverticalList,True,
+                    XtNdefaultColumns,1, XtNforceColumns,True, NULL);
+    flist_cmdbox = XtVaCreateManagedWidget("flist_cmdbox",boxWidgetClass,
+                    popup_fform, XtNfromVert,file_vport, XtNright,XawChainLeft,
+                    XtNbottom,XawChainBottom, XtNtop,XawChainBottom,
+                    XtNorientation,XtorientHorizontal, XtNbackground,bgcolor,
+                    NULL);
+    popup_fplay = XtVaCreateManagedWidget("fplaybutton",commandWidgetClass,
+                    flist_cmdbox, XtNfontSet,app_resources.volume_font, NULL);
+    popup_fdelete = XtVaCreateManagedWidget("fdeletebutton",commandWidgetClass,
+                    flist_cmdbox, XtNfontSet,app_resources.volume_font, NULL);
+    popup_fdelall = XtVaCreateManagedWidget("fdelallbutton",commandWidgetClass,
+                    flist_cmdbox, XtNfontSet,app_resources.volume_font, NULL);
+    popup_fclose = XtVaCreateManagedWidget("closebutton",commandWidgetClass,
+                    flist_cmdbox, XtNfontSet,app_resources.volume_font, NULL);
+    XtAddCallback(popup_fclose, XtNcallback,closeWidgetCB,
+                  (XtPointer)popup_file);
+    XtAddCallback(popup_fplay, XtNcallback,fselectCB, NULL);
+    XtAddCallback(popup_fdelete, XtNcallback,fdeleteCB, NULL);
+    XtAddCallback(popup_fdelall, XtNcallback,fdelallCB, NULL);
+    XtSetKeyboardFocus(popup_file, popup_fform);
+#ifdef XawTraversal
+    XtSetKeyboardFocus(file_list, popup_fform);
+#endif /* XawTraversal */
+    XawListChange(file_list, flist, 0, 0, True);
+    if (max_files != 0) XawListHighlight(file_list, 0);
   }
 }
 
-void a_start_interface(int pipe_in) {
-  static XtActionsRec actions[] ={
-    {"do-quit",(XtActionProc)quitCB},
+#ifdef XDND
+static void
+xdnd_file_drop_handler(char *filename) {
+  char local_buffer[PIPE_LENGTH], *fp;
+  struct stat st;
+
+  fp = filename;
+  if (!strncmp(fp, "file:", 5)) {
+    fp += 5;
+    if (!strncmp(fp, "//", 2)) {
+      fp += 2;
+      if (*fp == '\0') return; /* path given was file :// */
+      if (*fp != '/') {
+        if (!strncmp(fp, "localhost/", 10)) {
+          fp += 10;
+        } else return;
+       /*
+        * This is either a remote URL (which we don't support)
+        * or a malformed file://text URL
+        */
+      }
+    }
+  }
+
+  if ((*fp == '~') && ((*(fp+1) == '/') || (*(fp+1) == '\0'))) {
+    if (home == NULL) return;
+    fp++;
+    snprintf(local_buffer, sizeof(local_buffer), "X %s%s",
+             home, fp);
+  }
+  else if ( (*fp == '/') && (*(fp+1) == '~') &&
+            ((*(fp+2) == '/') || (*(fp+2) == '\0')) ) {
+    if (home == NULL) return;
+    fp += 2;
+    snprintf(local_buffer, sizeof(local_buffer), "X %s%s",
+             home, fp);
+  }
+  else
+    snprintf(local_buffer, sizeof(local_buffer), "X %s",
+             fp);
+
+  if (stat(local_buffer + 2, &st) == -1) return;
+  if (S_ISDIR(st.st_mode))
+     strlcat(local_buffer, "/", sizeof(local_buffer));
+  a_pipe_write("%s", local_buffer);
+}
+
+static void
+a_dnd_init(void) {
+  init_dnd(disp, dnd);
+  enable_dnd_for_widget(dnd, toplevel, xdnd_file_drop_handler);
+}
+
+static void
+enable_dnd_for_widget(DndClass *dnd, Widget widget, dnd_callback_t cb) {
+  make_window_dnd_aware(dnd, XtWindow(widget), cb);
+  XtAddEventHandler(widget, ClientMessage, True, 
+                     xdnd_listener, (XtPointer)dnd);
+  XtAddEventHandler(widget, SelectionNotify, True, 
+                     xdnd_listener, (XtPointer)dnd);
+}
+
+static void
+xdnd_listener(Widget w, XtPointer client_data, XEvent *ev, Boolean *dummy) {
+  DndClass *dnd = (DndClass *)client_data;
+  dnd->win = XtWindow(w);
+  process_client_dnd_message(dnd, ev); 
+}
+#endif /* XDND */
+
+static void
+destroyWidgetCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  w = (Widget)client_data;
+  if (XtIsRealized(XtParent(w))) {
+    XWindowAttributes war;
+    Window win;
+
+    win = XtWindow(XtParent(w));
+    XGetWindowAttributes(disp, win, &war);
+    if (war.map_state == IsViewable)
+      XSetInputFocus(disp, win, RevertToParent, CurrentTime);
+  }
+#ifdef RECFMTGROUPDESTHACK
+  if (seekTransientShell(record->formatGroup) == w) {
+    XtDestroyWidget(XtParent(XtParent(record->formatGroup)));
+    record->formatGroup = NULL;
+  }
+#endif /* RECFMTGROUPDESTHACK */
+  XtDestroyWidget(w);
+}
+
+static void
+setupWindow(Widget w, String action, Boolean xdnd,
+            Boolean destroyWidgetOnPopdown) {
+  char s[255];
+
+  snprintf(s, sizeof(s), "<Message>WM_PROTOCOLS: %s", action);
+  XtOverrideTranslations(w, XtParseTranslationTable(s));
+  if (destroyWidgetOnPopdown == True)
+    XtAddCallback(w, XtNpopdownCallback,destroyWidgetCB, (XtPointer)w);
+  XtPopup(w, XtGrabNone);
+  XSetWMProtocols(disp, XtWindow(w), &wm_delete_window, 1);
+#ifdef HAVE_GETPID
+  XChangeProperty(disp, XtWindow(w), net_wm_pid, XA_CARDINAL, 32,
+                    PropModeReplace, (unsigned char *)&pid, 1);
+  /* The WM spec requires setting up WM_CLIENT_MACHINE along with
+   * _NET_WM_PID. Xt sets it up automatically for us.
+   */
+#endif
+#ifdef XDND
+  if (xdnd == True) enable_dnd_for_widget(dnd, w, xdnd_file_drop_handler);
+#endif /* XDND */
+}
+
+static void
+callRedrawTrace(Boolean draw) {
+  if ((ctl->trace_playing) && (XtIsRealized(trace))) redrawTrace(draw);
+}
+
+static void
+createTraceWidgets(void) {
+
+  if ((app_resources.tracecfg.trace_height > TRACE_HEIGHT_WITH_FOOTER) ||
+      (app_resources.tracecfg.trace_height < BAR_SPACE+TRACE_FOOT+TRACE_HEADER))
+    trace_v_height = TRACE_HEIGHT_WITH_FOOTER;
+  else
+    trace_v_height = app_resources.tracecfg.trace_height;
+  trace_vport = XtVaCreateManagedWidget("trace_vport",viewportWidgetClass,
+          base_f, XtNbottom,XawChainBottom, XtNtop,XawChainTop,
+          XtNleft,XawChainLeft, XtNright,XawChainLeft,
+          XtNfromVert,(XtIsManaged(lyric_t))?lyric_t:t_box,
+          XtNallowHoriz,True, XtNallowVert,True,
+#ifndef WIDGET_IS_LABEL_WIDGET
+          XtNuseBottom,True, XtNuseRight,True,
+#endif
+          XtNwidth,TRACE_WIDTH+8, XtNheight,trace_v_height, NULL);
+  trace = XtVaCreateManagedWidget("trace",widgetClass,trace_vport,
+          XtNheight,app_resources.tracecfg.trace_height,
+          XtNwidth,app_resources.tracecfg.trace_width, NULL);
+  Cfg.disptrace = True;
+
+  XtSetKeyboardFocus(trace, base_f);
+
+  fast_b = XtVaCreateManagedWidget("fast_button",commandWidgetClass,b_box,
+              XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+              XtNbitmap,GET_BITMAP(fast), XtNfromHoriz,repeat_b, NULL);
+  slow_b = XtVaCreateManagedWidget("slow_button",commandWidgetClass,b_box,
+                XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+                XtNbitmap,GET_BITMAP(slow), XtNfromHoriz,fast_b, NULL);
+  keyup_b = XtVaCreateManagedWidget("keyup_button",commandWidgetClass,b_box,
+              XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+              XtNbitmap,GET_BITMAP(keyup), XtNfromHoriz,slow_b, NULL);
+  keydown_b = XtVaCreateManagedWidget("keydown_button",commandWidgetClass,b_box,
+                XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
+                XtNbitmap,GET_BITMAP(keydown), XtNfromHoriz,keyup_b, NULL);
+
+  XtAddCallback(fast_b, XtNcallback,tempoCB, (XtPointer)TRUE);
+  XtAddCallback(slow_b, XtNcallback,tempoCB, (XtPointer)FALSE);
+  XtAddCallback(keyup_b, XtNcallback,pitchCB, (XtPointer)TRUE);
+  XtAddCallback(keydown_b, XtNcallback,pitchCB, (XtPointer)FALSE);
+
+#ifndef XawTraversal
+  XtSetKeyboardFocus(fast_b, base_f);
+  XtSetKeyboardFocus(slow_b, base_f);
+  XtSetKeyboardFocus(keyup_b, base_f);
+  XtSetKeyboardFocus(keydown_b, base_f);
+#endif /* XawTraversal */
+}
+
+static void
+callInitTrace(void) {
+  initTrace(disp, XtWindow(trace), window_title, &(app_resources.tracecfg));
+}
+
+static void
+createBars(void) {
+  int i, j, k, l, vol_hd, tune_hd;
+#ifdef SCROLLBARLENGTHBUG
+  int m, m2;
+#endif /* !SCROLLBARLENGTHBUG */
+  barfloat thumb;
+
+  v_box = XtVaCreateManagedWidget("volume_box",formWidgetClass,base_f,
+            XtNorientation,XtorientHorizontal, XtNheight,36,
+            XtNtop,XawChainTop, XtNbottom,XawChainTop,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNfromVert,b_box, XtNbackground,bgcolor, NULL);
+  t_box = XtVaCreateManagedWidget("tune_box",formWidgetClass,base_f,
+            XtNorientation,XtorientHorizontal,
+            XtNtop,XawChainTop, XtNbottom,XawChainTop,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNheight,36, XtNfromVert,v_box, XtNbackground,bgcolor, NULL);
+  i = XmbTextEscapement(app_resources.volume_font, "Volume ", 7)+8;
+  j = snprintf(local_buf, sizeof(local_buf), "%3d  ", amplitude);
+  j = XmbTextEscapement(app_resources.volume_font, local_buf, j)+8;
+  k = XmbTextEscapement(app_resources.volume_font, " 0:00", 5)+8;
+  l = XmbTextEscapement(app_resources.volume_font, "/ 00:00", 7)+8;
+  if (k+l > i+j) {
+    vol_hd = k+l-i-j;
+    tune_hd = 0;
+  } else {
+    tune_hd = i+j-k-l;
+    vol_hd = 0;
+  }
+  vol_l0 = XtVaCreateManagedWidget("volume_label0",labelWidgetClass,v_box,
+            XtNwidth,i, XtNfontSet,app_resources.volume_font,
+            XtNlabel,"Volume", XtNborderWidth,0, XtNforeground,textcolor,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNbackground,bgcolor, NULL);
+  vol_l = XtVaCreateManagedWidget("volume_label",labelWidgetClass,v_box,
+            XtNwidth,j, XtNborderWidth,0, XtNfromHoriz,vol_l0,
+            XtNfontSet,app_resources.volume_font,
+            XtNorientation,XtorientHorizontal, XtNforeground,textcolor,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNbackground,bgcolor, XtNlabel,local_buf, NULL);
+  /* VOLUME_LABEL_WIDTH = i+30+j */
+  vol_bar = XtVaCreateManagedWidget("volume_bar",scrollbarWidgetClass,v_box,
+            XtNorientation,XtorientHorizontal, XtNfromHoriz,vol_l,
+            XtNwidth,DEFAULT_REG_WIDTH - (i+30+j+vol_hd),
+            XtNhorizDistance,vol_hd,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNbackground,textbgcolor, NULL);
+  thumb.f = (float)amplitude / (float)MAXVOLUME;
+  setThumb(vol_bar, thumb);
+  tune_l0 = XtVaCreateManagedWidget("tune_label0",labelWidgetClass,t_box,
+            XtNwidth,k, XtNlabel,"0:00",
+            XtNfontSet,app_resources.volume_font,
+            XtNborderWidth,0, XtNforeground,textcolor,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNbackground,bgcolor, NULL);
+  tune_l = XtVaCreateManagedWidget("tune_label",labelWidgetClass,t_box,
+            XtNwidth,l, XtNfontSet,app_resources.volume_font,
+            XtNfromHoriz,tune_l0, XtNborderWidth,0, XtNforeground,textcolor,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNbackground,bgcolor, NULL);
+  tune_bar = XtVaCreateManagedWidget("tune_bar",scrollbarWidgetClass,t_box,
+            XtNwidth,DEFAULT_REG_WIDTH-(k+l+30+tune_hd),
+            XtNbackground,textbgcolor,
+            XtNhorizDistance,tune_hd, XtNfromHoriz,tune_l,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNorientation,XtorientHorizontal, NULL);
+#ifdef SCROLLBARLENGTHBUG
+  XtVaGetValues(vol_bar, XtNminimumThumb,&m, NULL);
+  XtVaGetValues(tune_bar, XtNminimumThumb,&m2, NULL);
+  XtVaSetValues(vol_bar,
+                  XtNlength,DEFAULT_REG_WIDTH-(i+j+30+vol_hd)-m, NULL);
+  XtVaSetValues(tune_bar,
+                  XtNlength,DEFAULT_REG_WIDTH-(k+l+30+tune_hd)-m2, NULL);
+#endif /* SCROLLBARLENGTHBUG */
+}
+
+static void
+createButtons(void) {
+  play_b = XtVaCreateManagedWidget("play_button",toggleWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(play), XtNforeground,buttoncolor,
+            XtNbackground,buttonbgcolor, NULL);
+  pause_b = XtVaCreateManagedWidget("pause_button",toggleWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(pause), XtNfromHoriz,play_b,
+            XtNforeground,togglecolor, XtNbackground,buttonbgcolor, NULL);
+  stop_b = XtVaCreateManagedWidget("stop_button",commandWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(stop), XtNforeground,buttoncolor,
+            XtNbackground,buttonbgcolor, XtNfromHoriz,pause_b, NULL);
+  prev_b = XtVaCreateManagedWidget("prev_button",commandWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(prev), XtNforeground,buttoncolor,
+            XtNbackground,buttonbgcolor, XtNfromHoriz,stop_b, NULL);
+  back_b = XtVaCreateManagedWidget("back_button",commandWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(back), XtNforeground,buttoncolor,
+            XtNbackground,buttonbgcolor, XtNfromHoriz,prev_b, NULL);
+  fwd_b = XtVaCreateManagedWidget("fwd_button",commandWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(fwrd), XtNforeground,buttoncolor,
+            XtNbackground,buttonbgcolor, XtNfromHoriz,back_b, NULL);
+  next_b = XtVaCreateManagedWidget("next_button",commandWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(next), XtNforeground,buttoncolor,
+            XtNbackground,buttonbgcolor, XtNfromHoriz,fwd_b, NULL);
+  quit_b = XtVaCreateManagedWidget("quit_button",commandWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(quit), XtNforeground,buttoncolor,
+            XtNbackground,buttonbgcolor, XtNfromHoriz,next_b, NULL);
+  random_b = XtVaCreateManagedWidget("random_button",toggleWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(random), XtNfromHoriz,quit_b,
+            XtNforeground,togglecolor, XtNbackground,buttonbgcolor, NULL);
+  repeat_b = XtVaCreateManagedWidget("repeat_button",toggleWidgetClass,b_box,
+            XtNbitmap,GET_BITMAP(repeat2), XtNfromHoriz,random_b,
+            XtNforeground,togglecolor, XtNbackground,buttonbgcolor, NULL);
+
+  XtAddCallback(quit_b, XtNcallback,quitCB, NULL);
+  XtAddCallback(play_b, XtNcallback,playCB, NULL);
+  XtAddCallback(pause_b, XtNcallback,pauseCB, NULL);
+  XtAddCallback(stop_b, XtNcallback,stopCB, NULL);
+  XtAddCallback(prev_b, XtNcallback,prevCB, NULL);
+  XtAddCallback(next_b, XtNcallback,nextCB, NULL);
+  XtAddCallback(fwd_b, XtNcallback,forwardCB, NULL);
+  XtAddCallback(back_b, XtNcallback,backCB, NULL);
+  XtAddCallback(random_b, XtNcallback,randomCB, NULL);
+  XtAddCallback(repeat_b, XtNcallback,repeatCB, NULL);
+
+#ifndef XawTraversal
+  XtSetKeyboardFocus(play_b, base_f);
+  XtSetKeyboardFocus(stop_b, base_f);
+  XtSetKeyboardFocus(prev_b, base_f);
+  XtSetKeyboardFocus(back_b, base_f);
+  XtSetKeyboardFocus(fwd_b, base_f);
+  XtSetKeyboardFocus(next_b, base_f);
+  XtSetKeyboardFocus(quit_b, base_f);
+  XtSetKeyboardFocus(random_b, base_f);
+  XtSetKeyboardFocus(repeat_b, base_f);
+#endif /* XawTraversal */
+}
+
+static void
+init_output_lists(void) {
+  int i = 0, j = 0;
+
+  play = (outputs *)safe_malloc(sizeof(outputs));
+  record = (outputs *)safe_malloc(sizeof(outputs));
+  play->output_list = (id_list *)safe_malloc(sizeof(id_list) * 7);
+  record->output_list = (id_list *)safe_malloc(sizeof(id_list) * 7);
+  play->current = play->def = 0; play->formatGroup = NULL;
+  record->current = record->def = 0; record->formatGroup = NULL;
+  while (strcmp(local_buf, "Z0")) {
+    a_pipe_read(local_buf, sizeof(local_buf));
+    if ((*local_buf == 'F') || (*local_buf == 'f')) {
+      record->output_list[i].id_char = *(local_buf + 1);
+      record->output_list[i].id_name = safe_strdup(local_buf + 3);
+      if (((i+1) % 7) == 0) record->output_list = (id_list *)safe_realloc(
+                                                          record->output_list,
+                                                          sizeof(id_list) *
+                                                          (7 * ((i+1)/7 + 1)));
+      i++;
+    } else if ((*local_buf == 'O') || (*local_buf == 'o')) {
+      play->output_list[j].id_char = *(local_buf + 1);
+      play->output_list[j].id_name = safe_strdup(local_buf + 3);
+      if (((j+1) % 7) == 0) play->output_list = (id_list *)safe_realloc(
+                                                         play->output_list,
+                                                         sizeof(id_list) *
+                                                         (7 * ((j+1)/7 + 1)));
+      if (*local_buf == 'o') play->def = play->current = j;
+      j++;
+    }
+  }
+  if (i == 0) {
+    free(record->output_list);
+    free(record);
+    record = NULL;
+    XtVaSetValues(file_menu[ID_SAVE - 100].widget, XtNsensitive,False, NULL);
+  } else {
+    record->output_list = (id_list *)safe_realloc(record->output_list,
+                                                sizeof(id_list) * i);
+    record->max = i;
+    record->lbuf = NULL;
+  }
+  if (j == 0) {
+    free(play->output_list);
+    free(play);
+    play = NULL;
+  } else {
+    play->output_list = (id_list *)safe_realloc(play->output_list,
+                                               sizeof(id_list) * j);
+    play->max = j;
+    play->lbuf = NULL;
+  }
+}
+
+static void
+a_init_interface(int pipe_in) {
+  static XtActionsRec actions[] = {
+    {"do-quit", (XtActionProc)quitCB},
+    {"show-menu", popupfilemenuACT},
+    {"hide-menu", popdownfilemenuACT},
+#ifdef OLDXAW
     {"fix-menu", (XtActionProc)filemenuCB},
-    {"do-menu", (XtActionProc)filemenuAction},
-    {"do-complete", (XtActionProc)completeDir},
-    {"do-chgdir", (XtActionProc)setDirAction},
-    {"draw-trace",(XtActionProc)redrawAction},
-    {"do-exchange",(XtActionProc)exchgWidth},
-    {"do-toggletrace",(XtActionProc)toggletrace},
-    {"do-revcaption",(XtActionProc)redrawCaption},
-    {"do-dialog-button",(XtActionProc)popdownLoad},
-    {"do-load",(XtActionProc)popupLoad},
-    {"do-play",(XtActionProc)playCB},
-    {"do-sndspec",(XtActionProc)sndspecCB},
-    {"do-pause",(XtActionProc)pauseAction},
-    {"do-stop",(XtActionProc)stopCB},
-    {"do-next",(XtActionProc)nextCB},
-    {"do-prev",(XtActionProc)prevCB},
-    {"do-forward",(XtActionProc)forwardCB},
-    {"do-back",(XtActionProc)backCB},
-    {"do-key",(XtActionProc)soundkeyAction},
-    {"do-speed",(XtActionProc)speedAction},
-    {"do-voice",(XtActionProc)voiceAction},
-    {"do-volset",(XtActionProc)volsetCB},
-    {"do-volupdown",(XtActionProc)volupdownAction},
-    {"do-tuneset",(XtActionProc)tunesetAction},
-    {"do-tuneslide",(XtActionProc)tuneslideAction},
-    {"do-resize",(XtActionProc)resizeAction},
-    {"checkRightAndPopupSubmenu",checkRightAndPopupSubmenu},
-    {"leaveSubmenu",leaveSubmenu},
-    {"popdownSubmenu",popdownSubmenu},
-    {"do-options",(XtActionProc)optionspopupCB},
-    {"do-filelist",(XtActionProc)flistpopupCB},
-    {"do-about",(XtActionProc)aboutCB},
-    {"do-closeparent",closeParent},
-    {"do-flistmove",flistMove},
-    {"do-fselect",(XtActionProc)fselectCB},
-    {"do-fdelete",(XtActionProc)fdeleteCB},
-    {"do-backspace",(XtActionProc)backspaceCB},
+#endif
+    {"do-menu", filemenuACT},
+    {"do-addall", popdownAddALLACT},
+    {"do-complete", completeDirACT},
+    {"do-chgdir", setDirACT},
+    {"draw-trace", redrawACT},
+    {"do-exchange", exchgWidthACT},
+    {"do-toggletrace", toggleTraceACT},
+    {"do-mutechan", muteChanACT},
+    {"do-revcaption", redrawCaptionACT},
+    {"do-popdown", (XtActionProc)popdownCB},
+    {"do-play", (XtActionProc)playCB},
+    {"do-sndspec", sndspecACT},
+    {"do-pause", pauseACT},
+    {"do-stop", (XtActionProc)stopCB},
+    {"do-next", (XtActionProc)nextCB},
+    {"do-prev", (XtActionProc)prevCB},
+    {"do-forward", (XtActionProc)forwardCB},
+    {"do-back", (XtActionProc)backCB},
+    {"do-key", soundkeyACT},
+    {"do-speed", speedACT},
+    {"do-voice", voiceACT},
+    {"do-volupdown", volupdownACT},
+    {"do-tuneset", tunesetACT},
+    {"do-resize", resizeToplevelACT},
+    {"do-scroll", scrollListACT},
+    {"do-scroll-lyrics", scrollTextACT},
+#ifdef TimNmenu
+    {"checkRightAndPopupSubmenu", checkRightAndPopupSubmenuACT},
+#endif
+    {"leaveSubmenu", leaveSubmenuACT},
+    {"popdownSubmenu", popdownSubmenuACT},
+    {"do-options", optionspopupACT},
+    {"do-optionsclose", (XtActionProc)optionscloseCB},
+    {"do-filelist", flistpopupACT},
+    {"do-about", aboutACT},
+    {"do-toggle-tooltips", xawtipsetACT},
+    {"do-closeparent", closeParentACT},
+    {"do-flistmove", flistMoveACT},
+    {"do-fselect", (XtActionProc)fselectCB},
+    {"do-fdelete", (XtActionProc)fdeleteCB},
+    {"do-fdelall", (XtActionProc)fdelallCB},
+    {"do-backspace", backspaceACT},
+    {"do-cancel", cancelACT},
+    {"do-ok", okACT},
+    {"do-up", upACT},
+    {"do-down", downACT},
+    {"do-record", recordACT},
+    {"changetrace", scrollTraceACT},
 #ifndef WIDGET_IS_LABEL_WIDGET
-    {"do-deltext",(XtActionProc)deleteTextCB},
+    {"do-deltext", deleteTextACT},
 #endif
+#ifdef USEOWNSTARTSCROLL
+    {"StartScroll", StartScrollACT},
+#endif /* USEOWNSTARTSCROLL */
   };
 
 static String fallback_resources[]={
-#ifdef I18N
-    "*Command*international: True",
-    "*file_simplemenu*international: True",
-    "*Label*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*",
-    "*MenuButton*fontSet: -adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
-    "*Command*fontSet: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-    "*List*fontSet: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*Text*fontSet: -misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
-    "*Form*fontSet: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
XtResource xaw_resources[] = {
+#define offset(entry) XtOffset(struct _app_resources*, entry)
+#define toffset(entry) XtOffset(struct _app_resources*, tracecfg.entry)
+  {"arrangeTitle", "ArrangeTitle", XtRBoolean, sizeof(Boolean),
+   offset(arrange_title), XtRImmediate, (XtPointer)False},
+  {"gradientBar", "GradientBar", XtRBoolean, sizeof(Boolean),
+   toffset(gradient_bar), XtRImmediate, (XtPointer)False},
+#ifdef WIDGET_IS_LABEL_WIDGET
+  {"textLHeight", "TextLHeight", XtRShort, sizeof(short),
+   offset(text_height), XtRImmediate, (XtPointer)30},
 #else
-    "*Label.font: -adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
-    "*Text*font: -misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*",
-#endif
+  {"textHeight", "TextHeight", XtRShort, sizeof(short),
+   offset(text_height), XtRImmediate, (XtPointer)120},
+#endif /* WIDGET_IS_LABEL_WIDGET */
+  {"traceWidth", "TraceWidth", XtRShort, sizeof(short),
+   toffset(trace_width), XtRImmediate, (XtPointer)TRACE_WIDTH},
+  {"traceHeight", "TraceHeight", XtRShort, sizeof(short),
+   toffset(trace_height), XtRImmediate, (XtPointer)TRACE_HEIGHT_WITH_FOOTER},
+  {"menuWidth", "MenuWidth", XtRShort, sizeof(Dimension),
+   offset(menu_width), XtRImmediate, (XtPointer)200},
+  {"foreground", XtCForeground, XtRPixel, sizeof(Pixel),
+   toffset(common_fgcolor), XtRString, "black"},
+  {"background", XtCBackground, XtRPixel, sizeof(Pixel),
+   offset(common_bgcolor), XtRString, COMMON_BGCOLOR},
+  {"menubutton", "MenuButtonBackground", XtRPixel, sizeof(Pixel),
+   offset(menub_bgcolor), XtRString, "#CCFF33"},
+  {"textbackground", "TextBackground", XtRPixel, sizeof(Pixel),
+   toffset(text_bgcolor), XtRString, TEXTBG_COLOR},
+  {"text2background", "Text2Background", XtRPixel, sizeof(Pixel),
+   offset(text2_bgcolor), XtRString, "gray80"},
+  {"toggleforeground", "ToggleForeground", XtRPixel, sizeof(Pixel),
+   offset(toggle_fgcolor), XtRString, "MediumBlue"},
+  {"buttonforeground", "ButtonForeground", XtRPixel, sizeof(Pixel),
+   offset(button_fgcolor), XtRString, "blue"},
+  {"buttonbackground", "ButtonBackground", XtRPixel, sizeof(Pixel),
+   offset(button_bgcolor), XtRString, COMMANDBUTTON_COLOR},
+  {"velforeground", "VelForeground", XtRPixel, sizeof(Pixel),
+   toffset(velocity_color), XtRString, "orange"},
+  {"veldrumforeground", "VelDrumForeground", XtRPixel, sizeof(Pixel),
+   toffset(drumvelocity_color), XtRString, "red"},
+  {"volforeground", "VolForeground", XtRPixel, sizeof(Pixel),
+   toffset(volume_color), XtRString, "LightPink"},
+  {"expforeground", "ExpForeground", XtRPixel, sizeof(Pixel),
+   toffset(expr_color), XtRString, "aquamarine"},
+  {"panforeground", "PanForeground", XtRPixel, sizeof(Pixel),
+   toffset(pan_color), XtRString, "blue"},
+  {"tracebackground", "TraceBackground", XtRPixel, sizeof(Pixel),
+   toffset(trace_bgcolor), XtRString, "gray90"},
+  {"rimcolor", "RimColor", XtRPixel, sizeof(Pixel),
+   toffset(rim_color), XtRString, "gray20"},
+  {"boxcolor", "BoxColor", XtRPixel, sizeof(Pixel),
+   toffset(box_color), XtRString, "gray76"},
+  {"captioncolor", "CaptionColor", XtRPixel, sizeof(Pixel),
+   toffset(caption_color), XtRString, "DarkSlateGrey"},
+  {"sustainedkeycolor", "SustainedKeyColor", XtRPixel, sizeof(Pixel),
+   toffset(sus_color), XtRString, "red4"},
+  {"whitekeycolor", "WhiteKeyColor", XtRPixel, sizeof(Pixel),
+   toffset(white_key_color), XtRString, "white"},
+  {"blackkeycolor", "BlackKeyColor", XtRPixel, sizeof(Pixel),
+   toffset(black_key_color), XtRString, "black"},
+  {"playingkeycolor", "PlayingKeyColor", XtRPixel, sizeof(Pixel),
+   toffset(play_color), XtRString, "maroon1"},
+  {"reverbcolor", "ReverbColor", XtRPixel, sizeof(Pixel),
+   toffset(rev_color), XtRString, "PaleGoldenrod"},
+  {"choruscolor", "ChorusColor", XtRPixel, sizeof(Pixel),
+   toffset(cho_color), XtRString, "yellow"},
+  {"labelfont", XtCFontSet, XtRFontSet, sizeof(XFontSet *),
+   offset(label_font), XtRString,
+       "-adobe-helvetica-bold-r-*-*-14-*-75-75-*-*-*-*,*"},
+  {"volumefont", XtCFontSet, XtRFontSet, sizeof(XFontSet *),
+   offset(volume_font), XtRString,
+       "-adobe-helvetica-bold-r-*-*-12-*-75-75-*-*-*-*,*"},
+  {"textfontset", XtCFontSet, XtRFontSet, sizeof(XFontSet),
+   offset(text_font), XtRString, "-*-*-medium-r-normal--14-*-*-*-*-*-*-*,*"},
+  {"ttitlefont", XtCFontSet, XtRFontSet, sizeof(XFontSet),
+   toffset(ttitle_font), XtRString,
+       "-*-fixed-medium-r-normal--14-*-*-*-*-*-*-*,*"},
+  {"tracefont", XtCFontSet, XtRFontSet, sizeof(XFontSet *),
+   toffset(trace_font), XtRString, "7x14,*"},
+  {"labelfile", "LabelFile", XtRString, sizeof(String),
+   offset(file_text), XtRString, "file..."},
+  {"popup_confirm_title", XtCString, XtRString, sizeof(String),
+   offset(popup_confirm), XtRString, "Dialog"},
+  {"moreString", XtCString, XtRString, sizeof(String),
+   offset(more_text), XtRString, "More..."},
+  {"noplaying", XtCString, XtRString, sizeof(String),
+   offset(no_playing), XtRString, "[ No Playing File ]"},
+  {"untitled", XtCString, XtRString, sizeof(String),
+   toffset(untitled), XtRString, "<No Title>"},
+  {"load_" LISTDIALOGBASENAME ".title", XtCString, XtRString,
+   sizeof(String), offset(load_LISTDIALOGBASENAME_title), XtRString,
+   "TiMidity <Load Playlist>"},
+  {"save_" LISTDIALOGBASENAME ".title", XtCString, XtRString,
+   sizeof(String), offset(save_LISTDIALOGBASENAME_title), XtRString,
+   "TiMidity <Save Playlist>"},
+#undef offset
+#undef toffset
+};
+
+  String fallback_resources[] = {
+    "*international: True",
+    "*Label*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*,*",
+    "*MenuButton*fontSet: -adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*,*",
+    "*Command*fontSet: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*List*fontSet: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*Dialog*List*fontSet: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*Dialog*fontSet: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*Text*fontSet: -misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*,*",
     "*Text*background: " TEXTBG_COLOR "",
     "*Text*scrollbar*background: " TEXTBG_COLOR "",
     "*Scrollbar*background: " TEXTBG_COLOR "",
     "*Label.foreground: black",
     "*Label.background: #CCFF33",
     "*Command.background: " COMMANDBUTTON_COLOR "",
+    "*Tip.fontSet: -misc-fixed-medium-r-normal-*-10-*-*-*-*-*-*-*",
+    "*Tip.background: white",
+    "*Tip.foreground: black",
+    "*Tip.borderColor: black",
     "*Dialog.Command.background: " COMMANDBUTTON_COLOR "",
     "*Dialog.Text.background: " TEXTBG_COLOR "",
     "*fontSet: -*--14-*",
     "*load_dialog.label.background: " COMMON_BGCOLOR "",
-#ifdef I18N
-    "*international: True",
-#else
-    "*international: False",
-#endif
-    "*Command.font: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-    "*Toggle.font: -adobe-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*",
+    "*Command.fontSet: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*Toggle.fontSet: -adobe-helvetica-medium-o-*-*-12-*-*-*-*-*-*-*,*",
+#ifdef OLDXAW
     "*MenuButton.translations:<EnterWindow>:    highlight()\\n\
         <LeaveWindow>:  reset()\\n\
         Any<BtnDown>:   reset() fix-menu() PopupMenu()",
+#endif
     "*menu_box.borderWidth: 0",
     "*button_box.borderWidth: 0",
     "*button_box.horizDistance: 4",
@@ -2964,16 +3894,14 @@ void a_start_interface(int pipe_in) {
     "*file_menubutton.height: 28",
     "*file_menubutton.horizDistance: 6",
     "*file_menubutton.vertDistance: 4",
-#ifdef I18N
     "*file_menubutton.file_simplemenu*fontSet: -*--14-*",
-    "*title_menubutton.title_simplemenu*fontSet: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-#else
-    "*file_menubutton.file_simplemenu*font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*title_menubutton.title_simplemenu*font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-#endif
-    "*title_menubutton*SmeBSB.font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
+    "*title_menubutton.title_simplemenu*fontSet: \
+         -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*title_menubutton*SmeBSB.fontSet: \
+         -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*,*",
     "*title_menubutton.menuName: title_simplemenu",
-    "*popup_abox.OK.label: OK",
+    "*OK.label: OK",
+    "*Cancel.label: Cancel",
     "*title_menubutton.width: 210",
     "*title_menubutton.height: 28",
     "*title_menubutton.resize: false",
@@ -2988,149 +3916,154 @@ void a_start_interface(int pipe_in) {
     "*time_label.vertDistance: 4",
     "*time_label.label: time / mode",
     "*button_box.height: 40",
-    "*play_button.width: 32",
-    "*play_button.height: 32",
-    "*play_button.horizDistance: 1",
-    "*play_button.vertDistance: 9",
-    "*pause_button.width: 32",
-    "*pause_button.height: 32",
-    "*pause_button.horizDistance: 1",
-    "*pause_button.vertDistance: 1",
-    "*stop_button.width: 32",
-    "*stop_button.height: 32",
-    "*stop_button.horizDistance: 1",
-    "*stop_button.vertDistance: 1",
-    "*prev_button.width: 32",
-    "*prev_button.height: 32",
-    "*prev_button.horizDistance: 1",
-    "*prev_button.vertDistance: 1",
-    "*back_button.width: 32",
-    "*back_button.height: 32",
-    "*back_button.horizDistance: 1",
-    "*back_button.vertDistance: 1",
-    "*fwd_button.width: 32",
-    "*fwd_button.height: 32",
-    "*fwd_button.horizDistance: 1",
-    "*fwd_button.vertDistance: 1",
-    "*next_button.width: 32",
-    "*next_button.height: 32",
-    "*next_button.horizDistance: 1",
-    "*next_button.vertDistance: 1",
-    "*quit_button.width: 32",
-    "*quit_button.height: 32",
-    "*quit_button.horizDistance: 1",
-    "*quit_button.vertDistance: 1",
-    "*random_button.width: 32",
-    "*random_button.height: 32",
+    "*button_box*Command.width: 32",
+    "*button_box*Command.height: 32",
+    "*button_box*Toggle.width: 32",
+    "*button_box*Toggle.height: 32",
+    "*button_box*Command.horizDistance: 1",
+    "*button_box*Command.vertDistance: 1",
+    "*button_box*Toggle.horizDistance: 1",
+    "*button_box*Toggle.vertDistance: 1",
     "*random_button.horizDistance: 4",
-    "*random_button.vertDistance: 1",
-    "*repeat_button.width: 32",
-    "*repeat_button.height: 32",
-    "*repeat_button.horizDistance: 1",
-    "*repeat_button.vertDistance: 1",
+    "*play_button.vertDistance: 9",
+    "*play_button.tip: Play",
+    "*pause_button.tip: Pause",
+    "*stop_button.tip: Stop",
+    "*prev_button.tip: Previous",
+    "*back_button.tip: Back",
+    "*fwd_button.tip: Forward",
+    "*next_button.tip: Next",
+    "*quit_button.tip: Quit",
+    "*random_button.tip: Shuffle",
+    "*repeat_button.tip: Repeat",
+    "*fast_b.tip: Increase tempo",
+    "*slow_b.tip: Decrease Tempo",
+    "*keyup_b.tip: Raise pitch",
+    "*keydown_b.tip: Lower pitch",
+    "*repeat_button.tip: Repeat",
+    "*repeat_button.tip: Repeat",
+    "*repeat_button.tip: Repeat",
+    "*repeat_button.tip: Repeat",
     "*lyric_text.fromVert: tune_box",
     "*lyric_text.borderWidth: 1" ,
     "*lyric_text.vertDistance: 4",
     "*lyric_text.horizDistance: 6",
 #ifndef WIDGET_IS_LABEL_WIDGET
     "*lyric_text.height: 120",
-    "*lyric_text.scrollVertical: WhenNeeded",
+    "*lyric_text.scrollVertical: Always",
     "*lyric_text.translations: #override\\n\
-        <Btn2Down>:     do-deltext()",
+        <Btn2Down>:    do-deltext()\\n\
+        <Btn4Down>:    do-scroll-lyrics(-1)\\n\
+        <Btn5Down>:    do-scroll-lyrics(1)",
 #else
     "*lyric_text.height: 30",
     "*lyric_text.label: MessageWindow",
     "*lyric_text.resize: true",
 #endif
-#ifdef I18N
-    "*popup_optbox*international: True",
-    "*lyric_text.international: True",
-    "*volume_box*fontSet: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-    "*tune_box*fontSet: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-#else
-    "*popup_optbox*international: False",
-    "*lyric_text.international: False",
-    "*volume_box*font: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-    "*tune_box*font: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-#endif
-    "*volume_label.vertDistance: 0",
+    "*volume_box*fontSet: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*tune_box*fontSet: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*volume_box*horizDistance: 0",
+    "*volume_box*vertDistance: 0",
     "*volume_box.vertDistance: 2",
     "*volume_box.borderWidth: 0",
     "*volume_label.borderWidth: 0",
-    "*volume_bar.length: 330",
     "*tune_box.borderWidth: 0",
-    "*tune_label.label: ----",
-    "*tune_label.vertDistance: 0",
-    "*tune_label.horizDistance: 0",
-    "*tune_label0.horizDistance: 0",
+    "*tune_label.label: / ----",
+    "*tune_box*horizDistance: 0",
+    "*tune_box*vertDistance: 0",
     "*tune_box.vertDistance: 2",
-    "*tune_bar.length: 330",
-    "*popup_load.title: TiMidity <Load File>",
-    "*popup_loadform.height: 400",
     "*popup_option.title: TiMidity <Extend Modes>",
     "*popup_file.title: TiMidity <File List>",
+    "*dialog_lfile.title: TiMidity <Load File>",
+    "*dialog_sfile.title: TiMidity <Save File>",
     "*popup_about.title: Information",
+    "*popup_warning.title: Information",
+    "*popup_sformat.title: Dialog",
+    "*popup_slabel.label: Select output format",
+    "*popup_olabel.label: Output device",
     "*load_dialog.label: File Name",
     "*load_dialog.borderWidth: 0",
-    "*load_dialog.height: 132",
+    "*load_dialog.height: 400",
     "*trace.vertDistance: 2",
     "*trace.borderWidth: 1",
     "*trace_vport.borderWidth: 1",
-#ifdef I18N
-    "*popup_loadform.load_dialog.label.fontSet: -*--14-*",
-    "*popup_abox*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*",
-#else
-    "*popup_loadform.load_dialog.label.font: -adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
-    "*popup_abox*font: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*",
-#endif
-    "*cwd_label.font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*time_label*cwd_info.font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*time_label.font: -adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*",
-    "*BitmapDir: " XAW_BITMAP_DIR "/",
-#ifdef XAW3D
-    "*volume_bar.translations: #override\\n\
-        ~Ctrl Shift<Btn1Down>: do-volupdown(-50)\\n\
-        ~Ctrl Shift<Btn3Down>: do-volupdown(50)\\n\
-        Ctrl ~Shift<Btn1Down>: do-volupdown(-5)\\n\
-        Ctrl ~Shift<Btn3Down>: do-volupdown(5)\\n\
-        <Btn1Down>: MoveThumb()\\n\
-        <BtnUp>: NotifyScroll(FullLength) EndScroll()",
-    "*tune_bar.translations: #override\\n\
-        <Btn1Up>: do-tuneset()\\n\
-        <Btn3Up>: do-tuneslide()\\n\
-        <Btn1Down>: MoveThumb()\\n\
-        <BtnUp>: NotifyScroll(FullLength) EndScroll()",
-#else
+    "*popup_optform*Box*borderWidth: 0",
+    "*load_dialog.label.fontSet: -*--14-*",
+    "*popup_abox*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*,*",
+    "*popup_cform*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*,*",
+    "*popup_optform*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*,*",
+    "*popup_sform*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*,*",
+    "*popup_wbox*fontSet: -adobe-helvetica-bold-o-*-*-14-*-*-*-*-*-*-*,*",
+    "*cwd_label.fontSet: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*time_label*cwd_info.fontSet: \
+           -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*,*",
+    "*time_label.fontSet: -adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-*-*,*",
     "*volume_bar.translations: #override\\n\
         ~Ctrl Shift<Btn1Down>: do-volupdown(-50)\\n\
         ~Ctrl Shift<Btn3Down>: do-volupdown(50)\\n\
+        ~Ctrl Shift<Btn2Down>: do-volupdown(1)\\n\
+        Ctrl ~Shift<Btn2Down>: do-volupdown(-1)\\n\
         Ctrl ~Shift<Btn1Down>: do-volupdown(-5)\\n\
         Ctrl ~Shift<Btn3Down>: do-volupdown(5)\\n\
-        <Btn1Down>: StartScroll(Forward) MoveThumb()\\n\
-        <Btn3Down>: StartScroll(Backward) MoveThumb()\\n\
+        <BtnDown>: StartScroll(Continuous) MoveThumb() NotifyThumb()\\n\
         <BtnUp>: NotifyScroll(FullLength) EndScroll()",
     "*tune_bar.translations: #override\\n\
-        <Btn1Up>: do-tuneset()\\n\
-        <Btn3Up>: do-tuneslide()\\n\
-        <Btn1Down>: StartScroll(Forward) MoveThumb()\\n\
-        <Btn3Down>: StartScroll(Backward) MoveThumb()\\n\
-        <BtnUp>: NotifyScroll(FullLength) EndScroll()",
-#endif
+        <BtnDown>:     StartScroll(Continuous) MoveThumb() NotifyThumb()\\n\
+        <BtnMotion>:   MoveThumb() NotifyThumb()\\n\
+        <BtnUp>:       do-tuneset() NotifyScroll(FullLength) EndScroll()",
     "*file_simplemenu.load.label: Load (Meta-N)",
+    "*file_simplemenu.load.underline: 0",
+    "*file_simplemenu.save.label: Save (Ctrl-V)",
+    "*file_simplemenu.save.underline: 2",
+    "*file_simplemenu.load_playlist.label: Load Playlist (Meta-L)",
+    "*file_simplemenu.load_playlist.underline: 3",
+    "*file_simplemenu.save_playlist.label: Save Playlist (Meta-P)",
+    "*file_simplemenu.save_playlist.underline: 5",
     "*file_simplemenu.saveconfig.label: Save Config (Meta-S)",
+    "*file_simplemenu.saveconfig.underline: 0",
     "*file_simplemenu.hidetext.label: (Un)Hide Messages (Ctrl-M)",
+    "*file_simplemenu.hidetext.underline: 9",
     "*file_simplemenu.hidetrace.label: (Un)Hide Trace (Ctrl-T)",
+    "*file_simplemenu.hidetrace.underline: 9",
     "*file_simplemenu.shuffle.label: Shuffle (Ctrl-S)",
+    "*file_simplemenu.shuffle.underline: 1",
     "*file_simplemenu.repeat.label: Repeat (Ctrl-R)",
+    "*file_simplemenu.repeat.underline: 0",
     "*file_simplemenu.autostart.label: Auto Start",
+    "*file_simplemenu.autostart.underline: 1",
     "*file_simplemenu.autoquit.label: Auto Exit",
+    "*file_simplemenu.autoquit.underline: 5",
     "*file_simplemenu.filelist.label: File List (Ctrl-F)",
+    "*file_simplemenu.filelist.underline: 0",
     "*file_simplemenu.modes.label: Extend Modes (Ctrl-O)",
+    "*file_simplemenu.modes.underline: 8",
     "*file_simplemenu.about.label: About",
+    "*file_simplemenu.about.underline: 0",
     "*file_simplemenu.quit.label: Quit (Meta-Q, Q)",
-    "*load_dialog.OK.label: OK",
+    "*file_simplemenu.quit.underline: 0",
+    "*file_simplemenu.translations: #override\\n\
+        <Key>n:                MenuPopdown() do-menu(" S(ID_LOAD) ")\\n\
+        ~Meta<Key>l:   MenuPopdown() do-menu(" S(ID_LOAD) ")\\n\
+        <Key>v:                MenuPopdown() do-menu(" S(ID_SAVE) ")\\n\
+        Meta<Key>l:    MenuPopdown() do-menu(" S(ID_LOAD_PLAYLIST) ")\\n\
+        <Key>d:                MenuPopdown() do-menu(" S(ID_LOAD_PLAYLIST) ")\\n\
+        <Key>p:                MenuPopdown() do-menu(" S(ID_SAVE_PLAYLIST) ")\\n\
+        ~Ctrl<Key>s:   MenuPopdown() do-menu(" S(ID_SAVECONFIG) ")\\n\
+        <Key>h:                MenuPopdown() do-menu(" S(ID_SHUFFLE) ")\\n\
+        Ctrl<Key>s:    MenuPopdown() do-menu(" S(ID_SHUFFLE) ")\\n\
+        <Key>r:                MenuPopdown() do-menu(" S(ID_REPEAT) ")\\n\
+        <Key>m:                MenuPopdown() do-menu(" S(ID_HIDETXT) ")\\n\
+        <Key>t:                MenuPopdown() do-menu(" S(ID_HIDETRACE) ")\\n\
+        <Key>u:                MenuPopdown() do-menu(" S(ID_AUTOSTART) ")\\n\
+        <Key>e:                MenuPopdown() do-menu(" S(ID_AUTOQUIT) ")\\n\
+        ~Meta<Key>f:   MenuPopdown() do-filelist()\\n\
+        <Key>o:                MenuPopdown() do-options()\\n\
+        <Key>a:                MenuPopdown() do-about()\\n\
+        <Key>q:                MenuPopdown() do-quit()\\n\
+        <Key>Escape:   MenuPopdown()\\n\
+        <Motion>:      highlight()",
     "*load_dialog.add.label: Add ALL",
-    "*load_dialog.cancel.label: Cancel",
+    "*load_dialog.load_button.label: Filter",
     "*flist_cmdbox.fplaybutton.label: Play",
     "*flist_cmdbox.fdeletebutton.label: Delete",
     "*flist_cmdbox.fdelallbutton.label: Delete ALL",
@@ -3143,615 +4076,423 @@ void a_start_interface(int pipe_in) {
     "*chpressure_box.chpressure_lbl.label: Channel Pressure control",
     "*overlapvoice_box.overlapv_lbl.label: Allow Multiple Same Notes",
     "*txtmeta_box.txtmeta_lbl.label: Tracing All Text Meta Events",
+    "*sbox_ratelabel.label: Rate",
     "*base_form.translations: #override\\n\
-        ~Ctrl Meta<Key>n:   do-load()\\n\
-        ~Ctrl Meta<Key>s:   do-menu(" IDS_SAVECONFIG ")\\n\
-        Ctrl <Key>r:        do-menu(" IDS_REPEAT ")\\n\
-        Ctrl <Key>s:        do-menu(" IDS_SHUFFLE ")\\n\
-        Ctrl<Key>t:     do-menu(" IDS_HIDETRACE ")\\n\
-        Ctrl<Key>m:     do-menu(" IDS_HIDETXT ")\\n\
-        ~Ctrl<Key>q:        do-quit()\\n\
-        ~Ctrl<Key>r:        do-play()\\n\
-        <Key>Return:        do-play()\\n\
-        <Key>KP_Enter:      do-play()\\n\
-        ~Ctrl<Key>g:        do-sndspec()\\n\
-        ~Ctrl<Key>space:    do-pause()\\n\
-        ~Ctrl<Key>s:        do-stop()\\n\
-        <Key>p:         do-prev()\\n\
-        <Key>Left:      do-prev()\\n\
-        ~Meta<Key>n:        do-next()\\n\
-        <Key>Right:     do-next()\\n\
-        ~Ctrl<Key>f:        do-forward()\\n\
-        ~Ctrl<Key>b:        do-back()\\n\
-        ~Ctrl<Key>plus:     do-key()\\n\
-        ~Shift<Key>-:       do-key(1)\\n\
-        <Key>KP_Add:        do-key()\\n\
-        <Key>KP_Subtract:   do-key(1)\\n\
-        ~Ctrl<Key>greater:  do-speed()\\n\
-        ~Ctrl<Key>less:     do-speed(1)\\n\
-        ~Ctrl ~Shift<Key>o: do-voice()\\n\
-        ~Ctrl Shift<Key>o:  do-voice(1)\\n\
-        Ctrl<Key>o:     do-options()\\n\
-        Ctrl<Key>f:     do-filelist()\\n\
-        <Key>l:         do-filelist()\\n\
-        <Key>a:         do-about()\\n\
-        ~Ctrl ~Shift<Key>v: do-volupdown(-10)\\n\
-        ~Ctrl Shift<Key>v:  do-volupdown(10)\\n\
-        <Key>Down:  do-volupdown(-10)\\n\
-        <Key>Up:    do-volupdown(10)\\n\
-        ~Ctrl<Key>x:        do-exchange()\\n\
-        ~Ctrl<Key>t:        do-toggletrace()\\n\
-        <ConfigureNotify>:  do-resize()",
-
+        ~Ctrl Meta<Key>n:      do-menu(" S(ID_LOAD) ")\\n\
+        Ctrl ~Shift<Key>v:     do-menu(" S(ID_SAVE) ")\\n\
+        Meta<Key>l:            do-menu(" S(ID_LOAD_PLAYLIST) ")\\n\
+        Meta<Key>p:            do-menu(" S(ID_SAVE_PLAYLIST) ")\\n\
+        ~Ctrl Meta<Key>s:      do-menu(" S(ID_SAVECONFIG) ")\\n\
+        Ctrl<Key>r:            do-menu(" S(ID_REPEAT) ")\\n\
+        Ctrl<Key>s:            do-menu(" S(ID_SHUFFLE) ")\\n\
+        Ctrl<Key>t:            do-menu(" S(ID_HIDETRACE) ")\\n\
+        Ctrl<Key>m:            do-menu(" S(ID_HIDETXT) ")\\n\
+        ~Ctrl<Key>q:           do-quit()\\n\
+        ~Ctrl<Key>r:           do-play()\\n\
+        <Key>Return:           do-play()\\n\
+        <Key>KP_Enter:         do-play()\\n\
+        ~Ctrl<Key>g:           do-sndspec()\\n\
+        ~Ctrl<Key>space:       do-pause()\\n\
+        ~Ctrl<Key>s:           do-stop()\\n\
+        ~Meta<Key>p:           do-prev()\\n\
+        <Key>Left:             do-prev()\\n\
+        ~Meta<Key>n:           do-next()\\n\
+        <Key>Right:            do-next()\\n\
+        ~Ctrl ~Meta<Key>f:     do-forward()\\n\
+        ~Ctrl<Key>b:           do-back()\\n\
+        ~Ctrl<Key>plus:                do-key()\\n\
+        ~Shift<Key>-:          do-key(1)\\n\
+        <Key>KP_Add:           do-key()\\n\
+        <Key>KP_Subtract:      do-key(1)\\n\
+        ~Ctrl<Key>greater:     do-speed()\\n\
+        ~Ctrl<Key>less:                do-speed(1)\\n\
+        ~Ctrl ~Shift<Key>o:    do-voice()\\n\
+        ~Ctrl Shift<Key>o:     do-voice(1)\\n\
+        Ctrl<Key>o:            do-options()\\n\
+        ~Meta Ctrl<Key>f:      do-filelist()\\n\
+        ~Meta<Key>l:           do-filelist()\\n\
+        <Key>a:                        do-about()\\n\
+        Ctrl<Key>d:            do-toggle-tooltips(-1)\\n\
+        ~Ctrl ~Shift<Key>v:    do-volupdown(-10)\\n\
+        ~Ctrl Shift<Key>v:     do-volupdown(10)\\n\
+        <Key>Down:             do-volupdown(-10)\\n\
+        <Key>Up:               do-volupdown(10)\\n\
+        ~Ctrl<Key>x:           do-exchange()\\n\
+        ~Ctrl<Key>t:           do-toggletrace()\\n\
+        ~Ctrl Meta <Key>f:     show-menu()\\n\
+        <Key>z:                        show-menu()\\n\
+        <Key>j:                        changetrace(1)\\n\
+        <BtnDown>:             hide-menu()\\n\
+        <ConfigureNotify>:     do-resize()",
+
+    "*List.baseTranslations: #override\\n\
+        <Btn4Down>:   do-scroll(-1)\\n\
+        <Btn5Down>:   do-scroll(1)",
+    "*Scrollbar.baseTranslations: #override\\n\
+        <Btn4Down>:   StartScroll(Backward)\\n\
+        <Btn5Down>:   StartScroll(Forward)",
+    "*Text.baseTranslations: #override\\n\
+        ~Shift<Key>Delete:     delete-next-character()\\n\
+        Ctrl<Key>V:            insert-selection(CLIPBOARD)",
+    "*TransientShell.Box.baseTranslations: #override\\n\
+        ~Ctrl<Key>c:   do-closeparent()\\n\
+        <Key>Escape:   do-closeparent()\\n\
+        <Key>KP_Enter: do-closeparent()\\n\
+        <Key>Return:   do-closeparent()",
     "*load_dialog.value.translations: #override\\n\
-        ~Ctrl<Key>Return:   do-chgdir() end-of-line()\\n\
-        ~Ctrl<Key>KP_Enter: do-chgdir() end-of-line()\\n\
-        ~Ctrl ~Meta<Key>Tab:    do-complete() end-of-line()\\n\
-        Ctrl ~Shift<Key>g:  do-dialog-button(1)\\n\
-        <Key>BackSpace:     do-backspace() delete-previous-character()\\n\
-        <Key>Delete:        do-backspace() delete-previous-character()\\n\
-        Ctrl<Key>H:         do-backspace() delete-previous-character()\\n\
-        <Key>Escape:        do-dialog-button(1)",
+        ~Ctrl Meta<Key>KP_Enter:       do-addall()\\n\
+        ~Ctrl Meta<Key>Return:         do-addall()\\n\
+        ~Ctrl ~Meta<Key>KP_Enter:      do-chgdir()\\n\
+        ~Ctrl ~Meta<Key>Return:                do-chgdir()\\n\
+        ~Ctrl ~Meta<Key>Tab:           do-complete() end-of-line()\\n\
+        Ctrl ~Shift<Key>g:             do-popdown()\\n\
+        <Key>BackSpace:                do-backspace() delete-previous-character()\\n\
+        Ctrl<Key>H:            do-backspace() delete-previous-character()\\n\
+        <Key>Escape:           do-popdown()",
+    "*load_dialog.load_button.accelerators: #override\\n\
+        Ctrl<KeyPress>`: toggle() notify()",
+    "*dialog_sfile*load_dialog.add.Sensitive: False",
+    "*" LISTDIALOGBASENAME "*load_dialog.add.Sensitive: False",
     "*trace.translations: #override\\n\
-        <Btn1Down>:     do-toggletrace()\\n\
-        <EnterNotify>:      do-revcaption()\\n\
-        <LeaveNotify>:      do-revcaption()\\n\
-        <Expose>:       draw-trace()",
+        <Btn1Down>:    do-toggletrace()\\n\
+        <Btn3Down>:    do-mutechan()\\n\
+        <Btn4Down>:    changetrace(-1)\\n\
+        <Btn5Down>:    changetrace(1)\\n\
+        <EnterNotify>: do-revcaption()\\n\
+        <LeaveNotify>: do-revcaption()\\n\
+        <Expose>:      draw-trace()",
     "*time_label.translations: #override\\n\
-        <Btn2Down>:     do-menu(" IDS_HIDETRACE ")\\n\
-        <Btn3Down>:     do-exchange()",
-    "*popup_optbox.translations: #override\\n\
-        ~Ctrl<Key>c:        do-closeparent()\\n\
-        ~Ctrl<Key>q:        do-quit()",
-    "*popup_fbox.translations: #override\\n\
-        ~Ctrl<Key>c:        do-closeparent()\\n\
-        <Key>Up:        do-flistmove(-1)\\n\
-        <Key>p:         do-flistmove(-1)\\n\
-        <Key>Prior:     do-flistmove(-5)\\n\
-        <Key>Right:     do-flistmove(-5)\\n\
-        ~Ctrl<Key>r:        do-fselect()\\n\
-        <Key>Return:        do-fselect()\\n\
-        <Key>KP_Enter:      do-fselect()\\n\
-        Ctrl<Key>m:     do-fselect()\\n\
-        <Key>space:     do-pause()\\n\
-        <Key>s:         do-stop()\\n\
-        <Key>Down:      do-flistmove(1)\\n\
-        <Key>n:         do-flistmove(1)\\n\
-        <Key>Next:      do-flistmove(5)\\n\
-        <Key>Left:      do-flistmove(5)\\n\
-        <Key>d:         do-fdelete()\\n\
-        ~Shift<Key>v:       do-volupdown(-10)\\n\
-        Shift<Key>v:        do-volupdown(10)\\n\
-        ~Ctrl<Key>f:        do-forward()\\n\
-        ~Ctrl<Key>b:        do-back()\\n\
-        ~Ctrl<Key>q:        do-quit()",
-    "*popup_abox.translations: #override\\n\
-        ~Ctrl<Key>c:        do-closeparent()\\n\
-        <Key>KP_Enter:      do-closeparent()\\n\
-        <Key>Return:        do-closeparent()",
+        <Btn2Down>:    do-menu(" S(ID_HIDETRACE) ")\\n\
+        <Btn3Down>:    do-exchange()",
+    "*popup_optform.translations: #override\\n\
+        ~Ctrl<Key>c:   do-closeparent()\\n\
+        ~Ctrl<Key>q:   do-quit()\\n\
+        <Key>Escape:   do-closeparent()\\n\
+        <Key>KP_Enter: do-optionsclose()\\n\
+        <Key>Return:   do-optionsclose()",
+    "*popup_file*filelist.translations: #override\\n\
+        <Btn1Up>(2+):  do-fselect()\\n\
+        <Btn3Up>:      do-stop()",
+    "*flist_cmdbox.width: 272",
+    "*flist_cmdbox.height: 24",
+    "*flist_cmdbox.borderWidth: 0",
+    "*file_vport.width: 272",
+    "*file_vport.height: 336",
+    "*file_vport.borderWidth: 1",
+    "*popup_fform.translations: #override\\n\
+        ~Ctrl<Key>c:   do-closeparent()\\n\
+        <Key>Escape:   do-closeparent()\\n\
+        <Key>Home:     do-flistmove(-1, 0, 0)\\n\
+        <Key>Prior:    do-flistmove(-1, 0)\\n\
+        <Key>Right:    do-flistmove(-5)\\n\
+        <Key>Up:       do-flistmove(-1)\\n\
+        <Key>p:                do-flistmove(-1)\\n\
+        ~Ctrl<Key>r:   do-fselect()\\n\
+        <Key>Return:   do-fselect()\\n\
+        <Key>KP_Enter: do-fselect()\\n\
+        Ctrl<Key>m:    do-fselect()\\n\
+        <Key>space:    do-pause()\\n\
+        <Key>s:                do-stop()\\n\
+        <Key>Down:     do-flistmove(1)\\n\
+        <Key>n:                do-flistmove(1)\\n\
+        <Key>Left:     do-flistmove(5)\\n\
+        <Key>Next:     do-flistmove(1, 0)\\n\
+        <Key>End:      do-flistmove(1, 0, 0)\\n\
+        <Key>d:                do-fdelete()\\n\
+        :<Key>A:       do-fdelall()\\n\
+        ~Shift<Key>v:  do-volupdown(-10)\\n\
+        Shift<Key>v:   do-volupdown(10)\\n\
+        ~Ctrl<Key>f:   do-forward()\\n\
+        ~Ctrl<Key>b:   do-back()\\n\
+        ~Ctrl<Key>q:   do-quit()",
+    "*popup_cform.translations: #override\\n\
+        ~Ctrl<Key>c:   do-cancel()\\n\
+        <Key>Escape:   do-cancel()\\n\
+        <Key>KP_Enter: do-ok()\\n\
+        <Key>Return:   do-ok()",
+    "*sbox_ratetext.translations: #override\\n\
+        <Key>Escape:   do-closeparent()\\n\
+        <Key>KP_Enter: do-record()\\n\
+        <Key>Return:   do-record()\\n\
+        <Key>BackSpace:        delete-previous-character()\\n\
+        Shift<Key>:    no-op()\\n\
+        ~Ctrl<Key>0:   insert-char()\\n\
+        ~Ctrl<Key>KP_0:        insert-char()\\n\
+        ~Ctrl<Key>1:   insert-char()\\n\
+        ~Ctrl<Key>KP_1:        insert-char()\\n\
+        ~Ctrl<Key>2:   insert-char()\\n\
+        ~Ctrl<Key>KP_2:        insert-char()\\n\
+        ~Ctrl<Key>3:   insert-char()\\n\
+        ~Ctrl<Key>KP_3:        insert-char()\\n\
+        ~Ctrl<Key>4:   insert-char()\\n\
+        ~Ctrl<Key>KP_4:        insert-char()\\n\
+        ~Ctrl<Key>5:   insert-char()\\n\
+        ~Ctrl<Key>KP_5:        insert-char()\\n\
+        ~Ctrl<Key>6:   insert-char()\\n\
+        ~Ctrl<Key>KP_6:        insert-char()\\n\
+        ~Ctrl<Key>7:   insert-char()\\n\
+        ~Ctrl<Key>KP_7:        insert-char()\\n\
+        ~Ctrl<Key>8:   insert-char()\\n\
+        ~Ctrl<Key>KP_8:        insert-char()\\n\
+        ~Ctrl<Key>9:   insert-char()\\n\
+        ~Ctrl<Key>KP_9:        insert-char()\\n\
+        <Key>Home:     beginning-of-file()\\n\
+        :<Key>KP_Home: beginning-of-file()\\n\
+        <Key>End:      end-of-file()\\n\
+        :<Key>KP_End:  end-of-file()\\n\
+        <Key>Right:    forward-character()\\n\
+        :<Key>KP_Right:        forward-character()\\n\
+        <Key>Left:     backward-character()\\n\
+        :<Key>KP_Left: backward-character()\\n\
+        Hyper<Key>:    no-op()\\n\
+        Super<Key>:    no-op()\\n\
+        None<Key>:     no-op()\\n\
+        Alt<Key>:      no-op()\\n\
+        Meta<Key>:     no-op()\\n\
+        Lock<Key>:     no-op()",
+    "*fbox_toggle0.accelerators: #override\\n\
+        <Key>Up:       do-up()\\n\
+        <Key>Down:     do-down()\\n\
+        <Btn4Down>:    do-up()\\n\
+        <Btn5Down>:    do-down()",
+    "*confirmexit.label: Do you wish to exit?",
+    "*warnoverwrite.label: Do you wish to overfile this file?",
+    "*saveplaylisterror.label: Could not save playlist!",
+    "*waitforwav.label: Please wait. This may take several minutes.",
+    "*warnrecording.label: Cannot record - a file is already being recorded",
     NULL,
   };
-  XtAppContext app_con;
-  char cbuf[PATH_MAX];
-  Pixmap bmPixmap;
-  int bmwidth, bmheight;
-  int i, j, k, tmpi;
-  int argc=1;
-  float thumb, l_thumb, l_thumbj;
-  char *argv=APP_NAME, *filetext;
-#ifdef I18N
-  #define XtNfontDEF XtNfontSet
-  XFontSet textfont;
-#else
-  #define XtNfontDEF XtNfont
-  XFontStruct *textfont;
-#endif
-  XawListReturnStruct lrs;
-  unsigned long gcmask;
-  XGCValues gcval;
-
-#ifdef DEBUG_PRINT_RESOURCE
-  char str[BUFSIZ], *p,*new;
-  for(i=0; fallback_resources[i] != NULL; i++) {
-    p = fallback_resources[i]; new= str;
-    while(*p != NULL) {
-      if(*p == 'n' && *(p-1) == '\\') {
-        *new++ = 'n'; *new++ = '\\'; *new++ = '\n';
-      } else {
-        *new++ = *p;
-      }
-      p++;
-    }
-    *new = '\0'; fputs(str, stderr);
-  }
-  exit(0);
-#endif
+  int argc = 1, i;
+  char *argv = APP_NAME;
 
   xaw_vendor_setup();
 
-#ifdef I18N
-  XtSetLanguageProc(NULL,NULL,NULL);
-#endif
-  toplevel=XtVaAppInitialize(&app_con,APP_CLASS,NULL,ZERO,&argc,&argv,
-                         fallback_resources,NULL);
-  XtGetApplicationResources(toplevel,(caddr_t)&app_resources,xaw_resources,
-                          XtNumber(xaw_resources),NULL,0);
-  bitmapdir = app_resources.bitmap_dir;
-  arrangetitle = app_resources.arrange_title;
-  savelist = app_resources.save_list;
-  text_height = (Dimension)app_resources.text_height;
-  trace_width = (Dimension)app_resources.trace_width;
-  trace_height = (Dimension)app_resources.trace_height;
-  menu_width = (Dimension)app_resources.menu_width;
-  labelfont = app_resources.label_font;
-  volumefont = app_resources.volume_font;
-  textfont = app_resources.text_font;
-  tracefont = app_resources.trace_font;
-  ttitlefont = app_resources.ttitle_font;
-  a_readconfig(&Cfg);
-  amplitude=
-    (amplification == DEFAULT_AMPLIFICATION)? Cfg.amplitude:amplification;
+  XtSetLanguageProc(NULL, NULL, NULL);
+  toplevel = XtVaAppInitialize(&app_con, APP_CLASS, NULL, ZERO, &argc, &argv,
+                         fallback_resources, NULL);
+  XtGetApplicationResources(toplevel, (XtPointer)&app_resources,
+                         xaw_resources, XtNumber(xaw_resources), NULL, 0);
+  a_readconfig(&Cfg, &home);
+  if (Cfg.disptrace) ctl->trace_playing = 1;
+  amplitude =
+    (amplification == DEFAULT_AMPLIFICATION)?Cfg.amplitude:amplification;
   disp = XtDisplay(toplevel);
-  screen = DefaultScreen(disp);
-  root_height = DisplayHeight(disp, screen);
-  root_width = DisplayWidth(disp, screen);
-  check_mark = XCreateBitmapFromData(XtDisplay(toplevel),
-                                     RootWindowOfScreen(XtScreen(toplevel)),
-                                     (char *)check_bits,
-                                     check_width, check_height);
-  arrow_mark = XCreateBitmapFromData(XtDisplay(toplevel),
-                                      RootWindowOfScreen(XtScreen(toplevel)),
-                                      (char *)arrow_bits,
-                                      (unsigned int)arrow_width,arrow_height);
-  on_mark = XCreateBitmapFromData(XtDisplay(toplevel),
-                                      RootWindowOfScreen(XtScreen(toplevel)),
-                                      (char *)on_bits,
-                                      (unsigned int)on_width,on_height);
-  off_mark = XCreateBitmapFromData(XtDisplay(toplevel),
-                                      RootWindowOfScreen(XtScreen(toplevel)),
-                                      (char *)off_bits,
-                                      (unsigned int)off_width,off_height);
-  for(i= 0; i < MAXBITMAP; i++) {
-    snprintf(cbuf,sizeof(cbuf),"%s/%s",bitmapdir,bmfname[i]);
-    XReadBitmapFile(disp,RootWindow(disp,screen),cbuf,&bm_width[i],&bm_height[i],
-                    &bm_Pixmap[i],&x_hot,&y_hot);
-  }
-
-  safe_getcwd(basepath, sizeof(basepath));
+  root_height = DisplayHeight(disp, DefaultScreen(disp));
+  root_width = DisplayWidth(disp, DefaultScreen(disp));
+  XtVaSetValues(toplevel, XtNiconPixmap,GET_BITMAP(timidity), NULL);
+
+  check_mark = GET_BITMAP(check);
+  arrow_mark = GET_BITMAP(arrow);
+  on_mark = GET_BITMAP(on);
+  off_mark = GET_BITMAP(off);
+
+  ldSstart = init_ldS();
 
 #ifdef OFFIX
   DndInitialize(toplevel);
   DndRegisterOtherDrop(FileDropedHandler);
   DndRegisterIconDrop(FileDropedHandler);
-#endif
+#endif /* OFFIX */
   XtAppAddActions(app_con, actions, XtNumber(actions));
 
-  bgcolor = app_resources.common_bgcolor;
-  menubcolor = app_resources.menub_bgcolor;
-  textcolor = app_resources.common_fgcolor;
-  textbgcolor = app_resources.text_bgcolor;
-  text2bgcolor = app_resources.text2_bgcolor;
-  buttonbgcolor = app_resources.button_bgcolor;
-  buttoncolor = app_resources.button_fgcolor;
-  togglecolor = app_resources.toggle_fgcolor;
-  if(ctl->trace_playing) {
-    volcolor = app_resources.volume_color;
-    expcolor = app_resources.expr_color;
-    pancolor = app_resources.pan_color;
-    tracecolor = app_resources.trace_bgcolor;
-  }
-  if(ctl->trace_playing) {
-    gcmask = GCForeground | GCBackground | GCFont;
-    gcval.foreground = 1;
-    gcval.background = 1;
-    gcval.plane_mask = 1;
-#ifdef I18N
-    XFontsOfFontSet(ttitlefont,&fs_list,&ml);
-    ttitlefont0 = fs_list[0];
-    if (! ttitlefont0->fid) {
-      ttitlefont0 = XLoadQueryFont(disp, ml[0]);
-      if (! ttitlefont0) {
-       fprintf(stderr, "can't load fonts %s\n", ml[0]);
-       exit(1);
-      }
-    }
-    gcval.font = ttitlefont0->fid;
-#else
-    gcval.font = ttitlefont->fid;
-#endif
-    gcs = XCreateGC(disp, RootWindow(disp, screen), gcmask, &gcval);
-  }
-  base_f=XtVaCreateManagedWidget("base_form",boxWidgetClass,toplevel,
-            XtNbackground,bgcolor,
-            XtNwidth,rotatewidth[currwidth], NULL);
-  m_box=XtVaCreateManagedWidget("menu_box",boxWidgetClass,base_f,
-            XtNorientation,XtorientHorizontal,
+  base_f = XtVaCreateManagedWidget("base_form",formWidgetClass,toplevel,
             XtNbackground,bgcolor, NULL);
-  filetext = app_resources.file_text;
-  file_mb=XtVaCreateManagedWidget("file_menubutton",menuButtonWidgetClass,m_box,
-            XtNbackground,menubcolor,
-            XtNfont,labelfont, XtNlabel,filetext, NULL);
-  file_sm=XtVaCreatePopupShell("file_simplemenu",simpleMenuWidgetClass,file_mb,
-            XtNforeground,textcolor, XtNbackground,textbgcolor,XtNresize,False,
-            XtNbackingStore,NotUseful, XtNsaveUnder,False, XtNwidth,menu_width+100,
-            NULL);
-  snprintf(cbuf,sizeof(cbuf),"TiMidity++ %s",timidity_version);
-  title_mb=XtVaCreateManagedWidget("title_menubutton",menuButtonWidgetClass,m_box,
-            XtNbackground,menubcolor,XtNlabel,cbuf,
-            XtNfont,labelfont, NULL);
-  title_sm=XtVaCreatePopupShell("title_simplemenu",simpleMenuWidgetClass,title_mb,
-            XtNforeground,textcolor, XtNbackground,textbgcolor,
+#ifdef XawTraversal
+  XawFocusInstallActions(app_con);
+  XawFocusInstall(base_f, False);
+#endif /* XawTraversal */
+  m_box = XtVaCreateManagedWidget("menu_box",boxWidgetClass,base_f,
+            XtNtop,XawChainTop, XtNbottom,XawChainTop,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNorientation,XtorientHorizontal, XtNbackground,bgcolor, NULL);
+  file_mb = XtVaCreateManagedWidget("file_menubutton",menuButtonWidgetClass,
+            m_box, XtNbackground,menubcolor,
+            XtNfontSet,app_resources.label_font,
+            XtNlabel,app_resources.file_text, NULL);
+  file_sm = XtVaCreatePopupShell("file_simplemenu",simpleMenuWidgetClass,
+            file_mb, XtNforeground,textcolor, XtNbackground,textbgcolor,
+            XtNresize,False, XtNbackingStore,NotUseful, XtNsaveUnder,False,
+            XtNwidth,app_resources.menu_width+100, NULL);
+  for (i = 0; i < (int)XtNumber(file_menu); i++) {
+    bsb = XtVaCreateManagedWidget(file_menu[i].name,
+            *(file_menu[i].class), file_sm,XtNleftBitmap,None,
+             XtNleftMargin,24, NULL);
+    XtAddCallback(bsb, XtNcallback,filemenuCB, (XtPointer)&file_menu[i].id);
+    file_menu[i].widget = bsb;
+  }
+  snprintf(local_buf, sizeof(local_buf), "TiMidity++ %s", timidity_version);
+  title_mb = XtVaCreateManagedWidget("title_menubutton",menuButtonWidgetClass,
+            m_box, XtNbackground,menubcolor, XtNlabel,local_buf,
+            XtNfontSet,app_resources.label_font, NULL);
+  title_sm = XtVaCreatePopupShell("title_simplemenu",simpleMenuWidgetClass,
+            title_mb, XtNforeground,textcolor, XtNbackground,textbgcolor,
             XtNbackingStore,NotUseful, XtNsaveUnder,False, NULL);
-  time_l=XtVaCreateManagedWidget("time_label",commandWidgetClass,m_box,
-            XtNfont,labelfont,
-            XtNbackground,menubcolor,NULL);
-  b_box=XtVaCreateManagedWidget("button_box",boxWidgetClass,base_f,
-            XtNorientation,XtorientHorizontal,
-            XtNwidth,rotatewidth[currwidth]-10,
-            XtNbackground,bgcolor,XtNfromVert,m_box, NULL);
-  v_box=XtVaCreateManagedWidget("volume_box",boxWidgetClass,base_f,
+  time_l = XtVaCreateManagedWidget("time_label",commandWidgetClass,m_box,
+            XtNfontSet,app_resources.label_font,
+            XtNbackground,menubcolor, NULL);
+  b_box = XtVaCreateManagedWidget("button_box",boxWidgetClass,base_f,
             XtNorientation,XtorientHorizontal,
-            XtNwidth,TRACE_WIDTH_SHORT, XtNheight,36,
-            XtNfromVert,b_box,XtNbackground,bgcolor, NULL);
-  t_box=XtVaCreateManagedWidget("tune_box",boxWidgetClass,base_f,
-            XtNorientation,XtorientHorizontal,
-            XtNwidth,TRACE_WIDTH_SHORT, XtNheight,36,
-            XtNfromVert,v_box,XtNbackground,bgcolor, NULL);
-  i = XTextWidth(volumefont,"Volume ",7)+8;
-  vol_l0=XtVaCreateManagedWidget("volume_label0",labelWidgetClass,v_box,
-            XtNwidth,i, XtNresize,False,
-            XtNfont,volumefont, XtNlabel, "Volume", XtNborderWidth,0,
-            XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
-  VOLUME_LABEL_WIDTH = i+30;
-  j =   XTextWidth(volumefont,"000",3)+8;
-  VOLUME_LABEL_WIDTH += j;
-  vol_l=XtVaCreateManagedWidget("volume_label",labelWidgetClass,v_box,
-            XtNwidth,j, XtNresize,False,XtNborderWidth,0,
-            XtNfont,volumefont, XtNorientation, XtorientHorizontal,
-            XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
-  vol_bar=XtVaCreateManagedWidget("volume_bar",scrollbarWidgetClass,v_box,
-            XtNorientation, XtorientHorizontal,
-            XtNwidth, TRACE_WIDTH_SHORT -VOLUME_LABEL_WIDTH,
-            XtNbackground,textbgcolor,
-            XtNfromVert,vol_l, XtNtopOfThumb,&l_thumb, NULL);
-  i = XTextWidth(volumefont," 00:00",6);
-  tune_l0=XtVaCreateManagedWidget("tune_label0",labelWidgetClass,t_box,
-            XtNwidth,i, XtNresize,False, XtNlabel, " 0:00",
-            XtNfont,volumefont, XtNfromVert,vol_l0,XtNborderWidth,0,
-            XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
-  j = XTextWidth(volumefont,"/ 00:00",7);
-  tune_l=XtVaCreateManagedWidget("tune_label",labelWidgetClass,t_box,
-            XtNwidth,j, XtNresize,False,
-            XtNfont,volumefont, XtNfromVert,vol_l,XtNborderWidth,0,
-            XtNforeground,textcolor, XtNbackground,bgcolor, NULL);
-  tune_bar=XtVaCreateManagedWidget("tune_bar",scrollbarWidgetClass,t_box,
-            XtNwidth, TRACE_WIDTH_SHORT -i -j -30,
-            XtNbackground,textbgcolor,XtNorientation, XtorientHorizontal,
-            XtNfromVert,tune_l, XtNtopOfThumb,&l_thumbj, NULL);
-  l_thumb = thumb = (float)amplitude / (float)MAXVOLUME;
-  if (sizeof(thumb) > sizeof(XtArgVal)) {
-    XtVaSetValues(vol_bar,XtNtopOfThumb,&thumb,NULL);
-  } else {
-    XtArgVal * l_thumb = (XtArgVal *) &thumb;
-    XtVaSetValues(vol_bar,XtNtopOfThumb,*l_thumb,NULL);
-  }
-  play_b=XtVaCreateManagedWidget("play_button",toggleWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_PLAY],
-            XtNforeground,buttoncolor, XtNbackground,buttonbgcolor,
-            NULL);
-  pause_b=XtVaCreateManagedWidget("pause_button",toggleWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_PAUSE],
-            XtNfromHoriz, play_b,
-            XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-            NULL);
-  stop_b=XtVaCreateManagedWidget("stop_button",commandWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_STOP],
-            XtNforeground,buttoncolor, XtNbackground,buttonbgcolor,
-            XtNfromHoriz,pause_b,NULL);
-  prev_b=XtVaCreateManagedWidget("prev_button",commandWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_PREV],
-            XtNforeground,buttoncolor, XtNbackground,buttonbgcolor,
-            XtNfromHoriz,stop_b,NULL);
-  back_b=XtVaCreateManagedWidget("back_button",commandWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_BACK],
-            XtNforeground,buttoncolor, XtNbackground,buttonbgcolor,
-            XtNfromHoriz,prev_b,NULL);
-  fwd_b=XtVaCreateManagedWidget("fwd_button",commandWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_FWRD],
-            XtNforeground,buttoncolor, XtNbackground,buttonbgcolor,
-            XtNfromHoriz,back_b,NULL);
-  next_b=XtVaCreateManagedWidget("next_button",commandWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_NEXT],
-            XtNforeground,buttoncolor, XtNbackground,buttonbgcolor,
-            XtNfromHoriz,fwd_b,NULL);
-  quit_b=XtVaCreateManagedWidget("quit_button",commandWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_QUIT],
-            XtNforeground,buttoncolor, XtNbackground,buttonbgcolor,
-            XtNfromHoriz,next_b,NULL);
-  random_b=XtVaCreateManagedWidget("random_button",toggleWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_RANDOM],
-            XtNfromHoriz,quit_b,
-            XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-            NULL);
-  repeat_b=XtVaCreateManagedWidget("repeat_button",toggleWidgetClass,b_box,
-            XtNbitmap,bm_Pixmap[BM_REPEAT],
-            XtNfromHoriz,random_b,
-            XtNforeground,togglecolor, XtNbackground,buttonbgcolor,
-            NULL);
-  popup_load=XtVaCreatePopupShell("popup_load",transientShellWidgetClass,toplevel,
-            NULL);  
-  popup_load_f= XtVaCreateManagedWidget("popup_loadform",formWidgetClass,popup_load,
-            XtNbackground,bgcolor, NULL);
-  load_d=XtVaCreateManagedWidget("load_dialog",dialogWidgetClass,popup_load_f,
-            XtNbackground,bgcolor, XtNresizable,True, NULL);
-  cwd_l = XtVaCreateManagedWidget("cwd_label",labelWidgetClass,popup_load_f,
-            XtNlabel,basepath, XtNborderWidth,0, XtNfromVert,load_d,
-            XtNwidth,250, XtNheight,20,
-            XtNbackground,text2bgcolor, XtNresizable,False, NULL);
-  load_vport = XtVaCreateManagedWidget("vport",viewportWidgetClass, popup_load_f,
-            XtNfromVert,cwd_l, XtNallowHoriz,True, XtNallowVert,True,
-            XtNbackground,textbgcolor, XtNuseBottom,True, 
-            XtNwidth,250, XtNheight,200, NULL);
-  load_flist = XtVaCreateManagedWidget("files",listWidgetClass,load_vport,
-            XtNverticalList,True, XtNforceColumns,False,
-            XtNbackground,textbgcolor, XtNdefaultColumns,3, NULL);
-  load_info = XtVaCreateManagedWidget("cwd_info",labelWidgetClass,popup_load_f,
-            XtNborderWidth,0, XtNwidth,250, XtNheight,20, XtNresizable,False,
-            XtNbackground,text2bgcolor, XtNfromVert,load_vport, NULL);
-  XawDialogAddButton(load_d, "OK", popdownLoad,"Y");
-  XawDialogAddButton(load_d, "add", popdownLoad,"A");
-  XawDialogAddButton(load_d, "cancel", popdownLoad,NULL);
+            XtNtop,XawChainTop, XtNbottom,XawChainTop,
+            XtNleft,XawChainLeft, XtNright,XawChainLeft,
+            XtNbackground,bgcolor, XtNfromVert,m_box, NULL);
+
+  createButtons();
+
+  createBars();
+
 #ifndef WIDGET_IS_LABEL_WIDGET
-  lyric_t=XtVaCreateManagedWidget("lyric_text",asciiTextWidgetClass,base_f,
+  lyric_t = XtVaCreateWidget("lyric_text",asciiTextWidgetClass,base_f,
             XtNwrap,XawtextWrapWord, XtNeditType,XawtextAppend,
-            XtNwidth, rotatewidth[currwidth]-10,
+            XtNborderWidth,1,
+            XtNwidth,(ctl->trace_playing)?TRACE_WIDTH+8:DEFAULT_REG_WIDTH,
 #else
-  lyric_t=XtVaCreateManagedWidget("lyric_text",labelWidgetClass,base_f,
-            XtNresize,False,
+  lyric_t = XtVaCreateWidget("lyric_text",labelWidgetClass,base_f,
             XtNforeground,textcolor, XtNbackground,menubcolor,
-            XtNwidth,rotatewidth[currwidth]-10,
 #endif
-            XtNfontDEF,textfont, XtNheight,text_height,
-            XtNfromVert,t_box, NULL);
-  if(ctl->trace_playing) {
-    trace_vport = XtVaCreateManagedWidget("trace_vport",viewportWidgetClass, base_f,
-            XtNallowHoriz,True, XtNallowVert,True,
-            XtNuseBottom,True, XtNfromVert,lyric_t, XtNbackground,tracecolor,
-#ifdef WIDGET_IS_LABEL_WIDGET
-            XtNuseRight,True,
+            XtNfontSet,app_resources.text_font,
+            XtNtop,XawChainTop, XtNright,XawChainRight,
+            XtNheight,app_resources.text_height, XtNfromVert,t_box, NULL);
+  if (Cfg.disptext == True) XtManageChild(lyric_t);
+
+  if (ctl->trace_playing) createTraceWidgets();
+
+  XtAddCallback(vol_bar, XtNjumpProc,volsetCB, NULL);
+  XtAddCallback(tune_bar, XtNjumpProc,tuneslideCB, NULL);
+  XtAddCallback(time_l, XtNcallback,filemenuCB,
+                (XtPointer)&file_menu[ID_HIDETXT-100].id);
+  XtAppAddInput(app_con, pipe_in,
+                (XtPointer)XtInputReadMask, handle_input, NULL);
+
+  wm_delete_window = XInternAtom(disp, "WM_DELETE_WINDOW", False);
+#ifdef HAVE_GETPID
+  net_wm_pid = XInternAtom(disp, "_NET_WM_PID", False);
+  pid = getpid();
 #endif
-            XtNwidth,trace_width, XtNheight,trace_height+12, NULL);
-    trace = XtVaCreateManagedWidget("trace",widgetClass,trace_vport,
-            XtNwidth,trace_width, XtNbackground,tracecolor,
-            XtNheight,BAR_SPACE*MAX_XAW_MIDI_CHANNELS+TRACEV_OFS, NULL);
-  }
-  XtAddCallback(quit_b,XtNcallback,quitCB,NULL);
-  XtAddCallback(play_b,XtNcallback,playCB,NULL);
-  XtAddCallback(pause_b,XtNcallback,pauseCB,NULL);
-  XtAddCallback(stop_b,XtNcallback,stopCB,NULL);
-  XtAddCallback(prev_b,XtNcallback,prevCB,NULL);
-  XtAddCallback(next_b,XtNcallback,nextCB,NULL);
-  XtAddCallback(fwd_b,XtNcallback,forwardCB,NULL);
-  XtAddCallback(back_b,XtNcallback,backCB,NULL);
-  XtAddCallback(random_b,XtNcallback,randomCB,NULL);
-  XtAddCallback(repeat_b,XtNcallback,repeatCB,NULL);
-  XtAddCallback(vol_bar,XtNjumpProc,volsetCB,NULL);
-  XtAddCallback(vol_bar,XtNscrollProc,volupdownCB,NULL);
-  XtAppAddInput(app_con,pipe_in,(XtPointer)XtInputReadMask,handle_input,NULL);
-  XtAddCallback(load_flist,XtNcallback,(XtCallbackProc)setDirList,cwd_l);
-  XtAddCallback(time_l,XtNcallback,(XtCallbackProc)filemenuAction,NULL);
-
-  XtRealizeWidget(toplevel);
-  dirlist = NULL;
-  lrs.string = "";
-  setDirList(load_flist, cwd_l, &lrs);
+  setupWindow(toplevel, "do-quit()", False, False);
+
+  XtVaGetValues(toplevel, XtNheight,&curr_height,
+                          XtNwidth,&curr_width, NULL);
+  XtVaGetValues(lyric_t, XtNheight,&lyric_height, NULL);
+  base_height = curr_height;
+
   XtSetKeyboardFocus(base_f, base_f);
   XtSetKeyboardFocus(lyric_t, base_f);
-  if(ctl->trace_playing) 
-    XtSetKeyboardFocus(trace, base_f);
-  XtSetKeyboardFocus(popup_load_f, load_d);
-  load_t = XtNameToWidget(load_d,"value");
-  XtOverrideTranslations(toplevel,
-            XtParseTranslationTable("<Message>WM_PROTOCOLS: do-quit()"));
-  snprintf(cbuf,sizeof(cbuf),"%s/%s",bitmapdir,iconname);
-  XReadBitmapFile(disp,RootWindow(disp,screen),cbuf,
-                  &bmwidth,&bmheight,&bmPixmap,&x_hot,&y_hot);
-  XtVaSetValues(toplevel,XtNiconPixmap,bmPixmap,NULL);
-  strcpy(window_title,APP_CLASS);
-  w_title = strncat(window_title," : ",3);
-  w_title += sizeof(APP_CLASS)+ 2;
-  XtVaGetValues(toplevel,XtNheight,&base_height,NULL);
-  XtVaGetValues(lyric_t,XtNheight,&lyric_height,NULL);
-  a_print_text(lyric_t,strcpy(local_buf,"<< TiMidity Messages >>"));
+#ifdef XDND
+  a_dnd_init();
+#endif /* XDND */
+  snprintf(window_title, sizeof(window_title), "%s : %s",
+           APP_CLASS, app_resources.no_playing);
+  XtVaSetValues(toplevel, XtNtitle,window_title, NULL);
+
+  a_print_text(lyric_t, strcpy(local_buf, "<< TiMidity Messages >>"));
   a_pipe_write("READY");
 
-  if(ctl->trace_playing) {
-    XGCValues gv;
-    gv.fill_style = FillTiled;
-    gv.fill_rule = WindingRule;
-    Panel = (PanelInfo *)safe_malloc(sizeof(PanelInfo));
-    gc_xcopy = XCreateGC(disp,RootWindow(disp, screen),GCFillStyle|GCFillRule,&gv);
-    gct = XCreateGC(disp, RootWindow(disp, screen), 0, NULL);
-    gc = XCreateGC(disp, RootWindow(disp, screen), 0, NULL);
-    for(i=0; i<MAX_XAW_MIDI_CHANNELS; i++) {
-      if(ISDRUMCHANNEL(i)) {
-        Panel->is_drum[i]=1;
-        barcol[i]=app_resources.drumvelocity_color;
-      }
-      else {
-        barcol[i]=app_resources.velocity_color;
-      }
-      inst_name[i] = (char *)safe_malloc(sizeof(char) * INST_NAME_SIZE);
-    }
-    rimcolor = app_resources.rim_color;
-    boxcolor = app_resources.box_color;
-    capcolor = app_resources.caption_color;
-    black = app_resources.black_key_color;
-    white = app_resources.white_key_color;
-    suscolor = app_resources.sus_color;
-    playcolor = app_resources.play_color;
-    revcolor = app_resources.rev_color;
-    chocolor = app_resources.cho_color;
-    XSetFont(disp, gct, tracefont->fid);
-
-    keyG = (ThreeL *)safe_malloc(sizeof(ThreeL) * KEY_NUM);
-    for(i=0, j= BARH_OFS8+1; i<KEY_NUM; i++) {
-      tmpi = i%12;
-      switch(tmpi) {
-      case 0:
-      case 5:
-      case 10:
-        keyG[i].k[0].y = 11; keyG[i].k[0].l = 7;
-        keyG[i].k[1].y = 2; keyG[i].k[1].l = 16;
-        keyG[i].k[2].y = 11; keyG[i].k[2].l = 7;
-        keyG[i].col = white;
-        break;
-      case 2:
-      case 7:
-        keyG[i].k[0].y = 11; keyG[i].k[0].l = 7;
-        keyG[i].k[1].y = 2; keyG[i].k[1].l = 16;
-        keyG[i].k[2].y = 2; keyG[i].k[2].l = 16;        
-        keyG[i].col = white; break;
-      case 3:
-      case 8:
-        j += 2;
-        keyG[i].k[0].y = 2; keyG[i].k[0].l = 16;
-        keyG[i].k[1].y = 2; keyG[i].k[1].l = 16;
-        keyG[i].k[2].y = 11; keyG[i].k[2].l = 7;
-        keyG[i].col = white; break;
-      default:  /* black key */
-        keyG[i].k[0].y = 2; keyG[i].k[0].l = 8;
-        keyG[i].k[1].y = 2; keyG[i].k[1].l = 8;
-        keyG[i].k[2].y = 2; keyG[i].k[2].l = 8;
-        keyG[i].col = black; break;
-      }
-      keyG[i].xofs = j; j += 2;
-    }
-
-    /* draw on template pixmaps that includes one channel row */
-    for(i=0; i<2; i++) {
-      layer[i] = XCreatePixmap(disp,XtWindow(trace),TRACE_WIDTH,BAR_SPACE,
-                               DefaultDepth(disp,screen));
-      drawKeyboardAll(disp, layer[i]);
-      XSetForeground(disp, gc, capcolor);
-      XDrawLine(disp,layer[i],gc,0,0,TRACE_WIDTH,0);
-      XDrawLine(disp,layer[i],gc,0,0,0,BAR_SPACE);
-      XDrawLine(disp,layer[i],gc,TRACE_WIDTH-1,0,TRACE_WIDTH-1,BAR_SPACE);
-
-      for(j=0; j<pl[i].col -1; j++) {
-        int w;
-        tmpi= TRACEH_OFS; w= pl[i].w[j];
-        for(k= 0; k<j; k++) tmpi += pl[i].w[k];
-        tmpi = pl[i].ofs[j];
-        XSetForeground(disp,gc, capcolor);
-        XDrawLine(disp,layer[i],gc, tmpi+w,0,tmpi+w,BAR_SPACE);
-        XSetForeground(disp,gc, rimcolor);
-        XDrawLine(disp,layer[i],gc,tmpi+w-2,2,tmpi+w-2,BAR_HEIGHT+1);
-        XDrawLine(disp,layer[i],gc,tmpi+2,BAR_HEIGHT+2,tmpi+w-2,BAR_HEIGHT+2);
-        XSetForeground(disp,gc, ((j)? boxcolor:textbgcolor));
-        XFillRectangle(disp,layer[i],gc,tmpi+2,2,w-4,BAR_HEIGHT);
-      }
-    }
-    initStatus();
-    XFreeGC(disp,gc);
-    voices_num_width = XTextWidth(tracefont,"Voices",6) +VOICES_NUM_OFS;
-  }
   while (1) {
-    a_pipe_read(local_buf,sizeof(local_buf));
+    a_pipe_read(local_buf, sizeof(local_buf));
     if (local_buf[0] < 'A') break;
-    a_print_text(lyric_t,local_buf+2);
-  }
-  bsb=XtVaCreateManagedWidget("dummyfile",smeLineObjectClass,title_sm,XtNforeground,textbgcolor,NULL);
-  init_options=atoi(local_buf);
-  a_pipe_read(local_buf,sizeof(local_buf));
-  init_chorus=atoi(local_buf);
-
-  a_pipe_read(local_buf,sizeof(local_buf));
-  max_files=atoi(local_buf);
-  flist=(String *)safe_malloc((INIT_FLISTNUM+1)*sizeof(char *));
-  for (i=0;i<max_files;i++) {
-    a_pipe_read(local_buf,sizeof(local_buf));
-    addOneFile(max_files,i,local_buf,True);
-  }
-  for(i=0;i<dot_nfile;i++) {
-    snprintf(local_buf,sizeof(local_buf),"X %s\n",dotfile_flist[i]);
+    a_print_text(lyric_t, local_buf+2);
+  }
+  bsb = XtVaCreateManagedWidget("dummyfile",smeLineObjectClass,title_sm,
+                                 XtNforeground,textbgcolor, NULL);
+  init_options = atoi(local_buf);
+  a_pipe_read(local_buf, sizeof(local_buf));
+  init_chorus = atoi(local_buf);
+
+  init_output_lists();
+  a_pipe_read(local_buf, sizeof(local_buf));
+  max_files = atoi(local_buf);
+  flist = (String *)safe_malloc((INIT_FLISTNUM+1)*sizeof(char *));
+  *flist = NULL;
+  for (i=0; i<max_files; i++) {
+    a_pipe_read(local_buf, sizeof(local_buf));
+    addOneFile(max_files, i, local_buf);
+    addFlist(local_buf, i);
+  }
+  for (i=0; i<dot_nfile; i++) {
+    a_pipe_write("X %s", dotfile_flist[i]);
     free(dotfile_flist[i]);
-    a_pipe_write(local_buf);
   }
   free(dotfile_flist);
-  for (i = 0; i < XtNumber(file_menu); i++) {
-    bsb=XtVaCreateManagedWidget(file_menu[i].name,
-            (file_menu[i].trap ? smeBSBObjectClass:smeLineObjectClass),
-            file_sm,XtNleftBitmap,None,XtNleftMargin,24,NULL);
-    XtAddCallback(bsb,XtNcallback,filemenuCB,(XtPointer)&file_menu[i].id);
-    file_menu[i].widget = bsb;
+
+  if (Cfg.disptext == False)
+    XtVaSetValues(file_menu[ID_HIDETXT - 100].widget,
+                  XtNleftBitmap,check_mark, NULL);
+  else base_height -= lyric_height;
+
+  if (ctl->trace_playing) {
+    callInitTrace();
+    a_pipe_write("t");
+    base_height -= trace_v_height;
+    toggleMark(file_menu[ID_HIDETRACE-100].widget, False);
+    resizeToplevelACT(toplevel, NULL, NULL, NULL);
+  } else {
+    toggleMark(file_menu[ID_HIDETRACE-100].widget, True);
   }
-  if(!ctl->trace_playing || !Cfg.disptrace) {
-    Dimension w2,h2,h;
-    XtVaSetValues(lyric_t,XtNwidth,rotatewidth[0] -12,NULL);
-    XtVaGetValues(toplevel,XtNheight,&h,NULL);
-    XtMakeResizeRequest(toplevel,rotatewidth[0],h,&w2,&h2);
-  }
-  if (!ctl->trace_playing)
-      XtVaSetValues(file_menu[ID_HIDETRACE-100].widget,XtNsensitive,False,NULL);
-  /* Please sleep here to make widgets arrange by Form Widget,
-   * otherwise the widget geometry is broken.
-   * Strange!!
-   */
-  if(Cfg.hidetext || !Cfg.disptrace) {
-    XSync(disp, False);
-    usleep(10000);
-  }
-  sprintf(cbuf,"%d",amplitude);
-  XtVaSetValues(vol_l,XtNlabel,cbuf,NULL);
-  sprintf(local_buf,"V %d\n",amplitude);
-  a_pipe_write(local_buf);
-  if (init_options == DEFAULT_OPTIONS) init_options=Cfg.extendopt;
-  if (init_chorus == DEFAULT_CHORUS) init_chorus=Cfg.chorusopt;
-  sprintf(local_buf,"E %03d",init_options);
-  a_pipe_write(local_buf);
-  sprintf(local_buf,"C %03d",init_chorus);
-  a_pipe_write(local_buf);
-
-  if(Cfg.autostart)
-    filemenuCB(file_menu[ID_AUTOSTART-100].widget,
-               &file_menu[ID_AUTOSTART-100].id,NULL);
-  if(Cfg.autoexit) {
-    filemenuCB(file_menu[ID_AUTOQUIT-100].widget,
-               &file_menu[ID_AUTOQUIT-100].id,NULL);
-  }
-  if(Cfg.hidetext)
-    filemenuCB(file_menu[ID_HIDETXT-100].widget,
-        &file_menu[ID_HIDETXT-100].id,NULL);
-  if(!Cfg.disptrace)
-    filemenuCB(file_menu[ID_HIDETRACE-100].widget,
-               &file_menu[ID_HIDETRACE-100].id,NULL);
-
-  if(Cfg.repeat) repeatCB(NULL,&Cfg.repeat,NULL);
-  if(Cfg.shuffle) randomCB(NULL,&Cfg.shuffle,NULL);
-  if(Cfg.autostart) {
-    if(max_files==0)
-      prevCB(NULL,NULL,NULL);
-    else
-      playCB(NULL,NULL,NULL);
-  } else
-    stopCB(NULL,NULL,NULL);
-  if(ctl->trace_playing) initStatus();
+#ifdef HAVE_TIP
+  if (Cfg.tooltips == True) xawTipSet(True);
+#endif /* HAVE_TIP */
+
+  a_pipe_write("V %d", amplitude);
+  if (init_options == DEFAULT_OPTIONS) init_options = Cfg.extendopt;
+  if (init_chorus == DEFAULT_CHORUS) init_chorus = Cfg.chorusopt;
+  else Cfg.chorusopt = init_chorus;
+  a_pipe_write("E %03d", init_options);
+  a_pipe_write("C %03d", init_chorus);
+
+  if (Cfg.autostart)
+    XtVaSetValues(file_menu[ID_AUTOSTART - 100].widget,
+                  XtNleftBitmap,check_mark, NULL);
+  if (Cfg.autoexit) {
+    XtVaSetValues(file_menu[ID_AUTOQUIT - 100].widget,
+                  XtNleftBitmap,check_mark, NULL);
+    a_pipe_write("q");
+  }
+
+  if (Cfg.repeat) {
+    XtVaSetValues(file_menu[ID_REPEAT - 100].widget,
+                  XtNleftBitmap,check_mark, NULL);
+    repeatCB(NULL, &Cfg.repeat, NULL);
+  }
+  if (Cfg.shuffle) {
+    XtVaSetValues(file_menu[ID_SHUFFLE - 100].widget,
+                  XtNleftBitmap,check_mark, NULL);
+    randomCB(NULL, &Cfg.shuffle, NULL);
+  }
+  if (Cfg.autostart) {
+    if (max_files != 0) playCB(NULL, NULL, NULL);
+    else if (dot_nfile != 0) {
+      onPlayOffPause();
+      a_pipe_write("B");
+    }
+  }
+  else stopCB(NULL, NULL, NULL);
+  if ((max_files == 0) && (dot_nfile == 0))
+    XtVaSetValues(file_menu[ID_SAVE - 100].widget, XtNsensitive,False, NULL);
+}
+
+void a_start_interface(int pipe_in) {
+  a_init_interface(pipe_in);
   XtAppMainLoop(app_con);
 }
 
-static void safe_getcwd(char *cwd, int maxlen)
-{
-#ifndef STDC_HEADERS
-  if(!getwd(cwd))
-#else
-  if(!getcwd(cwd, maxlen))
-#endif
-  {
-    ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
-             "Warning: Can't get current working directory");
-    strcpy(cwd, ".");
+static char *
+get_user_home_dir(void) {
+  char *home, *p;
+  struct passwd *pw;
+
+  home = getenv("HOME");
+  if (home == NULL) home = getenv("home");
+  if (home == NULL) {
+    pw = getpwuid(getuid());
+    if (pw == NULL) {
+      ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
+                 "I cannot find the current user's home directory!");
+      return NULL;
+    }
+    home = pw->pw_dir;
   }
+  p = safe_strdup(home);
+  return p;
 }
 
 #include "interface.h"
@@ -3766,12 +4507,338 @@ static void safe_getcwd(char *cwd, int maxlen)
 #undef vendorShellWidgetClass
 extern WidgetClass vendorShellWidgetClass;
 extern VendorShellClassRec vendorShellClassRec;
-static void xaw_vendor_setup(void)
-{
+static void
+xaw_vendor_setup(void) {
     memcpy(&vendorShellClassRec, &xaw_vendorShellClassRec,
-          sizeof(VendorShellClassRec));
+           sizeof(VendorShellClassRec));
     vendorShellWidgetClass = (WidgetClass)&xaw_vendorShellWidgetClass;
 }
 #else
-static void xaw_vendor_setup(void) { }
+static void
+xaw_vendor_setup(void) { }
 #endif
+
+#ifdef CLEARVALUE
+static void
+clearValue(Widget w) {
+  Widget TextSrc;
+
+  XtVaGetValues(XtNameToWidget(w, "value"), XtNtextSource, &TextSrc, NULL); 
+  XawAsciiSourceFreeString(TextSrc);
+}
+#endif /* CLEARVALUE */
+
+#ifdef USEOWNSTARTSCROLL
+static void
+simulateArrowsCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  long offset = (long)call_data;
+  XEvent *e = (XEvent *)client_data;
+  barfloat thumb;
+  Dimension len;
+
+  XtVaGetValues(w, XtNtopOfThumb,&thumb.f, XtNlength,&len, NULL);
+  if (abs(offset) >= len) return;
+  thumb.f += (float)offset/(float)len;
+  if (thumb.f < 0) thumb.f = 0;
+  else if (thumb.f > 1) thumb.f = 1;
+  setThumb(w, thumb);
+  XtCallActionProc(w, (String)"NotifyThumb", e, NULL, ZERO);
+  e->xmotion.same_screen = 0;
+}
+
+static void
+StartScrollACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  XtOrientation Orientation;
+  long call_data;
+
+  if ((e->type != ButtonPress) && (e->type != ButtonRelease)) return;
+  XtVaGetValues(w, XtNorientation,&Orientation, NULL);
+  if (Orientation == XtorientHorizontal) call_data = e->xbutton.x;
+  else call_data = e->xbutton.y;
+  if (!strcasecmp("Continuous", *v)) {
+    XtAddCallback(w, XtNscrollProc,simulateArrowsCB, (XtPointer)e);
+    XtCallActionProc(w, (String)"NotifyScroll", e, NULL, ZERO);
+    XtRemoveCallback(w, XtNscrollProc,simulateArrowsCB, (XtPointer)e);
+    return;
+  } else if (!strcasecmp("Backward", *v)) {
+    call_data = -call_data;
+  }
+  XtCallCallbacks(w, XtNscrollProc, (XtPointer)call_data);
+}
+#endif /* USEOWNSTARTSCROLL */
+
+/* XawScrollbarSetThumb is buggy. */
+static void
+setThumb(Widget w, barfloat u)
+{
+  if (sizeof(float) > sizeof(XtArgVal)) {
+    XtVaSetValues(w, XtNtopOfThumb,&u.f, NULL);
+  } else {
+    XtVaSetValues(w, XtNtopOfThumb,u.x, NULL);
+  }
+}
+
+static Widget seekTransientShell(Widget w) {
+  if (w == NULL) return NULL;
+  while (w != toplevel) {
+    if (XtIsTransientShell(w)) return w;
+    w = XtParent(w);
+  }
+  return toplevel;
+}
+
+/* The following implements a series of toggles, to be used for output
+ * selection either when saving a file, or changing output in options.
+ */
+
+static void
+freevarCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  outputs *out = (outputs *)client_data;
+
+  free(out->lbuf);
+  free(out->toggleGroup);
+}
+
+static void
+restoreDefaultOSelectionCB(Widget w, XtPointer client_data,
+                           XtPointer call_data) {
+  outputs *out = (outputs *)client_data;
+
+  XawToggleSetCurrent(out->formatGroup,
+                      (XtPointer)(out->output_list + out->def));
+}
+
+static void
+tnotifyCB(Widget w, XtPointer client_data, XtPointer call_data) {
+  outputs *out;
+  id_list *result;
+  int i;
+  Boolean s;
+
+  XtVaGetValues(w, XtNstate,&s, NULL);
+  if (s == False) return;
+  if ((Widget)client_data == play->formatGroup) out = play;
+  else out = record;
+  result = (id_list *)XawToggleGetCurrent(out->formatGroup);
+  for (i=0; i<out->max; i++)
+    if (result->id_char == (out->output_list[i].id_char)) break;
+  out->current = i;
+}
+
+static void
+upACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  char s[20];
+  Widget w1, w2;
+  outputs *out;
+  id_list *result;
+  int i;
+
+  if (w == play->formatGroup) out = play;
+  else out = record;
+  result = (id_list *)XawToggleGetCurrent(out->formatGroup);
+  for (i=0; i<out->max; i++)
+    if (result->id_char == (out->output_list[i].id_char)) break;
+  if (i == 0) i = out->max-1;
+  else i--;
+  snprintf(s, sizeof(s), "sbox_fbox%d", i);
+  w1 = XtNameToWidget(XtParent(XtParent(w)), s);
+  snprintf(s, sizeof(s), "fbox_toggle%d", i);
+  w2 = XtNameToWidget(w1, s);
+  XtVaSetValues(w2, XtNstate,True, NULL);
+  out->current = i;
+}
+
+static void
+downACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  char s[20];
+  Widget w1, w2;
+  outputs *out;
+  id_list *result;
+  int i;
+
+  if (w == play->formatGroup) out = play;
+  else out = record;
+  result = (id_list *)XawToggleGetCurrent(out->formatGroup);
+  for (i=0; i<out->max; i++)
+    if (result->id_char == (out->output_list[i].id_char)) break;
+  if (i >= out->max-1) i = 0;
+  else i++;
+  snprintf(s, sizeof(s), "sbox_fbox%d", i);
+  w1 = XtNameToWidget(XtParent(XtParent(w)), s);
+  snprintf(s, sizeof(s), "fbox_toggle%d", i);
+  w2 = XtNameToWidget(w1, s);
+  XtVaSetValues(w2, XtNstate,True, NULL);
+  out->current = i;
+}
+
+static Widget
+createOutputSelectionWidgets(Widget popup, Widget parent,
+                             Widget fromVert, outputs *out,
+                             Boolean restoreDefault) {
+  Widget *sbox_fbox, *fbox_toggle, *fbox_label, *pw, formatGroup;
+  char s[20];
+  int i = out->max, j;
+  id_list *list;
+  char defaultToggleTranslations[] =
+    "<EnterWindow>:         highlight(Always)\n\
+    <LeaveWindow>:         unhighlight()\n\
+    <Btn1Down>,<Btn1Up>:   set() notify()";
+  XtTranslations ToggleTrans;
+
+  if (out == NULL) return None;
+  list = out->output_list;
+  pw = (Widget *)safe_malloc(sizeof(Widget) * 3 * i);
+  out->toggleGroup = pw;
+
+  sbox_fbox = pw;
+  fbox_toggle = pw + i;
+  fbox_label = pw + 2*i;
+  ToggleTrans = XtParseTranslationTable(defaultToggleTranslations);
+
+  sbox_fbox[0] = XtVaCreateManagedWidget("sbox_fbox0",boxWidgetClass,parent,
+                                         XtNorientation,XtorientHorizontal,
+                                         XtNbackground,bgcolor,
+                                         XtNfromVert,fromVert,
+                                         XtNborderWidth,0, NULL);
+  fbox_toggle[0] = XtVaCreateManagedWidget("fbox_toggle0",toggleWidgetClass,
+                                      sbox_fbox[0], XtNlabel,"",
+                                      XtNtranslations,ToggleTrans,
+                                      XtNbackground,buttonbgcolor,
+                                      XtNforeground,togglecolor,
+                                      XtNradioGroup,NULL, XtNborderWidth,1,
+                                      XtNradioData,(XtPointer)list,
+#ifndef DONTUSEOVALTOGGLES
+                                      XtNshapeStyle,XmuShapeOval,
+#endif /* DONTUSEOVALTOGGLES */
+                                      XtNborderColor,togglecolor,
+                                      XtNinternalWidth,3, XtNinternalHeight,1,
+                                      XtNwidth,17, XtNheight,17, NULL);
+  fbox_label[0] = XtVaCreateManagedWidget("fbox_label0",labelWidgetClass,
+                                            sbox_fbox[0], XtNbackground,bgcolor,
+                                            XtNlabel,list[0].id_name,
+                                            XtNforeground,textcolor,
+                                            XtNfromHoriz,fbox_toggle[0],
+                                            XtNborderWidth,0, NULL);
+  out->formatGroup = formatGroup = fbox_toggle[0];
+  XtAddCallback(fbox_toggle[0], XtNcallback,tnotifyCB,
+                (XtPointer)formatGroup);
+
+  for (j = 1; j < i; j++) {
+    snprintf(s, sizeof(s), "sbox_fbox%d", j);
+    sbox_fbox[j] = XtVaCreateManagedWidget(s,boxWidgetClass,parent,
+                                           XtNorientation,XtorientHorizontal,
+                                           XtNfromVert,sbox_fbox[j-1],
+                                           XtNbackground,bgcolor,
+                                           XtNborderWidth,0, NULL);
+    snprintf(s, sizeof(s), "fbox_toggle%d", j);
+    fbox_toggle[j] = XtVaCreateManagedWidget(s,toggleWidgetClass,sbox_fbox[j],
+                                        XtNbackground,buttonbgcolor,
+                                        XtNforeground,togglecolor,
+                                        XtNradioData,(XtPointer)(list + j),
+                                        XtNradioGroup,formatGroup,
+                                        XtNfromVert,fbox_toggle[j-1],
+#ifndef DONTUSEOVALTOGGLES
+                                        XtNshapeStyle,XmuShapeOval,
+#endif /* DONTUSEOVALTOGGLES */
+                                        XtNinternalWidth,3, XtNinternalHeight,1,
+                                        XtNwidth,17, XtNheight,17, XtNlabel,"",
+                                       XtNtranslations,ToggleTrans,
+                                        XtNborderColor,togglecolor,
+                                        XtNborderWidth,1, NULL);
+    XtAddCallback(fbox_toggle[j], XtNcallback,tnotifyCB,
+                  (XtPointer)formatGroup);
+    snprintf(s, sizeof(s), "fbox_label%d", j);
+    fbox_label[j] = XtVaCreateManagedWidget(s,labelWidgetClass,sbox_fbox[j],
+                                              XtNfromHoriz,fbox_toggle[j],
+                                              XtNlabel,list[j].id_name,
+                                              XtNforeground,textcolor,
+                                              XtNbackground,bgcolor,
+                                              XtNjustify,XtJustifyLeft,
+                                              XtNborderWidth,0, NULL);
+  }
+  XtCallActionProc(fbox_toggle[out->def], (String)"set", NULL, NULL, ZERO);
+
+  XtAddCallback(popup, XtNdestroyCallback,freevarCB,
+                (XtPointer)out);
+  if (restoreDefault == True)
+    XtAddCallback(popup, XtNpopdownCallback,restoreDefaultOSelectionCB,
+                  (XtPointer)out);
+  XtInstallAccelerators(parent, formatGroup);
+  XtInstallAccelerators(popup, formatGroup);
+
+  return sbox_fbox[i-1];
+}
+
+/* End output selection routines */
+
+#ifdef HAVE_TIP
+static void
+TipEnable(Widget w, String s) {
+#ifdef XAW3D
+  XawTipEnable(w, s);
+#elif defined(XAWPLUS)
+  XtVaSetValues(w, XtNhelpText,s, XtNuseHelp,True, NULL);
+#else
+  XawTipEnable(w);
+#endif /* !XAW3D */
+}
+
+static void
+TipDisable(Widget w) {
+#ifdef XAWPLUS
+  XtVaSetValues(w, XtNuseHelp,False, NULL);
+#else
+  XawTipDisable(w);
+#endif /* XAWPLUS */
+}
+
+static void
+xawtipsetACT(Widget w, XEvent *e, String *v, Cardinal *n) {
+  int state = atoi(*v);
+  if (state == -1) Cfg.tooltips ^= True;
+  else Cfg.tooltips = (Boolean)state;
+  xawTipSet(Cfg.tooltips);
+}
+
+static void
+xawTipSet(Boolean tooltips) {
+  if (tooltips == True) {
+    TipEnable(play_b, "Play");
+    TipEnable(pause_b, "Pause");
+    TipEnable(stop_b, "Stop");
+    TipEnable(prev_b, "Previous");
+    TipEnable(back_b, "Back");
+    TipEnable(fwd_b, "Forward");
+    TipEnable(next_b, "Next");
+    TipEnable(quit_b, "Quit");
+    TipEnable(random_b, "Shuffle");
+    TipEnable(repeat_b, "Repeat");
+    if (ctl->trace_playing) {
+      TipEnable(fast_b, "Increase tempo");
+      TipEnable(slow_b, "Decrease Tempo");
+      TipEnable(keyup_b, "Raise pitch");
+      TipEnable(keydown_b, "Lower pitch");
+    }
+  } else {
+    TipDisable(play_b);
+    TipDisable(pause_b);
+    TipDisable(stop_b);
+    TipDisable(prev_b);
+    TipDisable(back_b);
+    TipDisable(fwd_b);
+    TipDisable(next_b);
+    TipDisable(quit_b);
+    TipDisable(random_b);
+    TipDisable(repeat_b);
+    if (ctl->trace_playing) {
+      TipDisable(fast_b);
+      TipDisable(slow_b);
+      TipDisable(keyup_b);
+      TipDisable(keydown_b);
+    }
+  }
+}
+#else
+static void
+xawtipsetACT(Widget w, XEvent *e, String *v, Cardinal *n) { }
+#endif /* HAVE_TIP */
index e228c80..180fcb0 100644 (file)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index de8b588..539bed4 100644 (file)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index f688879..588a253 100644 (file)
@@ -133,6 +133,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -213,6 +215,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -278,6 +282,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 
 EXTRA_DIST = \
        dllutl.rb \
index eb44509..0ce3b13 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 bar="AUTHORS Makefile.am COPYING Makefile.in NEWS interface.h.in ChangeLog 
     README common.makefile.in ChangeLog.1  README.ja config.h.in ChangeLog.2 
-    TODO INSTALL TiMidity-uj.ad.in configure INSTALL.ja TiMidity.ad.in 
+    TODO INSTALL TiMidity-uj.ad configure INSTALL.ja TiMidity.ad 
     configure.in "
 bar="$bar `ls libarc/*|grep libarc/` `ls libunimod/*|grep libunimod/`  `ls utils/*|grep utils/`
   `ls timidity/*|grep timidity/` `ls windrv/*|grep windrv/` `ls interface/*|grep interface/`
index 6b8ca40..8ae8b9e 100644 (file)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index f421b4c..73e8574 100644 (file)
@@ -69,7 +69,7 @@ PlayMode dpm = {
 #else
     PE_SIGNED|PE_16BIT,
 #endif
-    PF_PCM_STREAM,
+    PF_PCM_STREAM|PF_FILE_OUTPUT,
     -1,
     {0,0,0,0,0},
     "AIFF file", 'a',
index cbbdb38..56b808d 100644 (file)
@@ -74,7 +74,7 @@ static int write_u32(uint32 value);
 #define dpm au_play_mode
 
 PlayMode dpm = {
-    8000, PE_MONO|PE_ULAW, PF_PCM_STREAM,
+    8000, PE_MONO|PE_ULAW, PF_PCM_STREAM|PF_FILE_OUTPUT,
     -1,
     {0,0,0,0,0},
     "Sun audio file", 'u',
index 9b5ce42..a212209 100644 (file)
@@ -1093,6 +1093,16 @@ void code_convert(char *in, char *out, int outsiz, char *icode, char *ocode)
 #endif
 }
 
+static int is_playlist(char *file)
+{
+  FILE *f; char sig[20], *ret;
+  if ((f = fopen(file, "r")) == NULL) return 0;
+  ret = fgets(sig, 20, f); 
+  fclose(f);
+  if ((!ret) || (strcmp(sig, "timidity playlist:\n"))) return 0;
+  return 1;
+}
+
 /* EAW -- insert stuff from playlist files
  *
  * Tue Apr 6 1999: Modified by Masanao Izumo <mo@goice.co.jp>
@@ -1104,7 +1114,7 @@ static char **expand_file_lists(char **files, int *nfiles_in_out)
     int i;
     char input_line[256];
     char *pfile;
-    static const char *testext = ".m3u.pls.asx.M3U.PLS.ASX";
+    static const char *testext = ".m3u.pls.asx.M3U.PLS.ASX.tpl";
     struct timidity_file *list_file;
     char *one_file[1];
     int one;
@@ -1138,7 +1148,7 @@ static char **expand_file_lists(char **files, int *nfiles_in_out)
        /* extract the file extension */
        pfile = strrchr(files[i], '.');
 
-       if(*files[i] == '@' || (pfile != NULL && strstr(testext, pfile)))
+       if(*files[i] == '@' || (pfile != NULL && strstr(testext, pfile)) || is_playlist(files[i]))
        {
            /* Playlist file */
             if(*files[i] == '@')
index 5f4093b..ad31251 100644 (file)
@@ -87,7 +87,7 @@ static int acntl(int request, void *arg);
 #define dpm flac_play_mode
 
 PlayMode dpm = {
-  DEFAULT_RATE, PE_SIGNED|PE_16BIT, PF_PCM_STREAM,
+  DEFAULT_RATE, PE_SIGNED|PE_16BIT, PF_PCM_STREAM|PF_FILE_OUTPUT,
   -1,
   {0}, /* default: get all the buffer fragments you can */
 #ifndef AU_OGGFLAC
index ea98bc6..d8edbac 100644 (file)
@@ -84,7 +84,7 @@ PlayMode dpm = {
 #else
     PE_16BIT|PE_SIGNED|PE_BYTESWAP,
 #endif
-    PF_PCM_STREAM,
+    PF_PCM_STREAM|PF_FILE_OUTPUT,
     -1,
     {0,0,0,0,0},
     "MP3 GOGO", 'g',
index 2609699..c763de4 100644 (file)
@@ -1536,7 +1536,7 @@ void m2m_output_midi_file(void)
 
 
 
-void convert_mod_to_midi_file(MidiEvent * ev)
+int convert_mod_to_midi_file(MidiEvent * ev)
 {
 
     int i;
@@ -1554,7 +1554,7 @@ void convert_mod_to_midi_file(MidiEvent * ev)
     {
        ctl->cmsg(CMSG_INFO, VERB_NORMAL,
                  "Aborting!  This doesn't look like a MOD file!");
-       return;
+       return 1;
     }
 
     read_m2m_cfg_file();
@@ -1568,4 +1568,5 @@ void convert_mod_to_midi_file(MidiEvent * ev)
        if (track_events[i])
            free(track_events[i]);
     }
+    return 0;
 }
index cf22ac5..2458f08 100644 (file)
@@ -97,7 +97,7 @@ static int ticks_per_quarter_note;
 #define dmp midi_play_mode
 
 PlayMode dmp = {
-    DEFAULT_RATE, 0, PF_MIDI_EVENT,
+    DEFAULT_RATE, 0, PF_MIDI_EVENT|PF_FILE_OUTPUT,
     -1,
     {0, 0, 0, 0, 0},
     "Write MIDI file", 'm',
index 33c1832..659aa0f 100644 (file)
@@ -32,7 +32,7 @@ static int acntl(int request, void *arg);
 PlayMode modmidi_play_mode = {
     DEFAULT_RATE,
     PE_16BIT|PE_SIGNED,
-    PF_PCM_STREAM,
+    PF_PCM_STREAM|PF_FILE_OUTPUT,
     -1,
     {0,0,0,0,0},
     "MOD -> MIDI file conversion", 'M',
index bcea131..dbefbd3 100644 (file)
@@ -121,6 +121,7 @@ enum {
 #define PF_BUFF_FRAGM_OPT (1u<<3) /* Enable set extra_param[0] to specify
                                   the number of audio buffer fragments */
 #define PF_AUTO_SPLIT_FILE (1u<<4) /* Split PCM files automatically */
+#define PF_FILE_OUTPUT (1u<<5) /* Output is to file rather than device */
 #define IS_STREAM_TRACE        ((play_mode->flag & (PF_PCM_STREAM|PF_CAN_TRACE)) == (PF_PCM_STREAM|PF_CAN_TRACE))
 
 typedef struct {
index 5dc314d..e5a6713 100644 (file)
@@ -61,7 +61,7 @@
 #include "freq.h"
 #include "quantity.h"
 
-extern void convert_mod_to_midi_file(MidiEvent * ev);
+extern int convert_mod_to_midi_file(MidiEvent * ev);
 
 #define ABORT_AT_FATAL 1 /*#################*/
 #define MYCHECK(s) do { if(s == 0) { printf("## L %d\n", __LINE__); abort(); } } while(0)
@@ -8248,16 +8248,17 @@ static int play_midi(MidiEvent *eventlist, int32 samples)
     static int play_count = 0;
 
     if (play_mode->id_character == 'M') {
-       int cnt;
+       int cnt, err;
 
-       convert_mod_to_midi_file(eventlist);
+       err = convert_mod_to_midi_file(eventlist);
 
        play_count = 0;
        cnt = free_global_mblock();     /* free unused memory */
        if(cnt > 0)
            ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
                      "%d memory blocks are free", cnt);
-       return RC_NONE;
+       if (err) return RC_ERROR;
+       return RC_TUNE_END;
     }
 
     sample_count = samples;
index bacdcba..b51b27a 100644 (file)
@@ -73,7 +73,7 @@ static int acntl(int request, void *arg);
 #define dpm raw_play_mode
 
 PlayMode dpm = {
-    DEFAULT_RATE, PE_16BIT|PE_SIGNED, PF_PCM_STREAM,
+    DEFAULT_RATE, PE_16BIT|PE_SIGNED, PF_PCM_STREAM|PF_FILE_OUTPUT,
     -1,
     {0,0,0,0,0},
     "Raw waveform data", 'r',
index 1fea500..0a672ce 100644 (file)
@@ -56,7 +56,7 @@ static int acntl(int request, void *arg);
 #define dpm speex_play_mode
 
 PlayMode dpm = {
-  DEFAULT_RATE, PE_SIGNED|PE_16BIT, PF_PCM_STREAM,
+  DEFAULT_RATE, PE_SIGNED|PE_16BIT, PF_PCM_STREAM|PF_FILE_OUTPUT,
   -1,
   {0},
   "Ogg Speex", 'S',
index 90d5bf8..d136047 100644 (file)
@@ -83,7 +83,7 @@ static int acntl(int request, void *arg);
 #define dpm vorbis_play_mode
 
 PlayMode dpm = {
-    44100, PE_16BIT|PE_SIGNED, PF_PCM_STREAM,
+    44100, PE_16BIT|PE_SIGNED, PF_PCM_STREAM|PF_FILE_OUTPUT,
     -1,
     {0,0,0,0,0},
     "Ogg Vorbis", 'v',
index 5b89cb3..6137fbe 100644 (file)
@@ -76,7 +76,7 @@ PlayMode dpm = {
 #else
     PE_16BIT|PE_SIGNED|PE_BYTESWAP,
 #endif
-    PF_PCM_STREAM,
+    PF_PCM_STREAM|PF_FILE_OUTPUT,
     -1,
     {0,0,0,0,0},
     "RIFF WAVE file", 'w',
index f1bb51e..5a80312 100644 (file)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps
index c4c9921..4d658c3 100755 (executable)
@@ -157,6 +157,8 @@ ENABLE_WRD_FALSE = @ENABLE_WRD_FALSE@
 ENABLE_WRD_TRUE = @ENABLE_WRD_TRUE@
 ENABLE_XAW_FALSE = @ENABLE_XAW_FALSE@
 ENABLE_XAW_TRUE = @ENABLE_XAW_TRUE@
+ENABLE_XDND_FALSE = @ENABLE_XDND_FALSE@
+ENABLE_XDND_TRUE = @ENABLE_XDND_TRUE@
 ENABLE_XSKIN_FALSE = @ENABLE_XSKIN_FALSE@
 ENABLE_XSKIN_TRUE = @ENABLE_XSKIN_TRUE@
 ESD_CFLAGS = @ESD_CFLAGS@
@@ -238,6 +240,8 @@ WINDRV_FALSE = @WINDRV_FALSE@
 WINDRV_TRUE = @WINDRV_TRUE@
 WISH = @WISH@
 W_so_libs = @W_so_libs@
+XAW_INSTALL_RESOURCE_FILES_FALSE = @XAW_INSTALL_RESOURCE_FILES_FALSE@
+XAW_INSTALL_RESOURCE_FILES_TRUE = @XAW_INSTALL_RESOURCE_FILES_TRUE@
 XMKMF = @XMKMF@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
@@ -303,6 +307,7 @@ target_vendor = @target_vendor@
 tcltk_dep = @tcltk_dep@
 timidity_LDFLAGS = @timidity_LDFLAGS@
 w_so_libs = @w_so_libs@
+xawresdir = @xawresdir@
 #INSTALL = @INSTALL@
 
 # Where to install the patches, config files.
@@ -318,6 +323,10 @@ SHLIB_DIR = $(pkglibdir)
 # Where to install timidity.el
 ELISP_DIR = $(lispdir)
 
+# Where to install TiMidity.ad
+XAWRES = ${xawresdir}/app-defaults
+XAWRES_JA = ${xawresdir}/ja_JP.eucJP/app-defaults
+
 # If you want to change TCL_DIR, please do follows.
 # * Add -DTKPROGPATH=\"$(TCL_DIR)/tkmidity.tcl\" to CPPFLAGS.
 # * Make a symbolic link $(PKGLIBDIR)/bitmaps to $(TCL_DIR)/bitmaps