#! ./mofepython
#
# This is a test file for python build with the OSF/Motif 
# version of Wafe (renamed to mofepython). It serves two purposes:
#
#   - this is a little bit larger, style guid compliant application
#   - (more important) it test the usage of the regular expression
#     package by the file selection widget class of OSF/Motif
# 
# If this program comes up with empty contents in the output areas
# of the file selectionwidget, or it it even produces a segmentation
# violation or similar, a conflict of the regular expression packages
# is very likely. Apply the patch from the README file and these symptons
# should go away.
# 
# Gustaf Neumann              Mohegan Lake, NY, Sat Jun  4 17:58:27

import wafe

wafe.cmd( """
mergeResources topLevel *background gray75

XmMainWindow main topLevel

  XmMenuBar menu_bar main
    XmPulldownMenu mp1 menu_bar unmanaged
      XmPushButton Quit mp1 activateCallback quit
    XmCascadeButton Actions menu_bar \
        subMenuId mp1

    XmPulldownMenu mp2 menu_bar unmanaged
      XmPushButton Help    mp2 activateCallback "manageChild helpbox"
      XmPushButton Version mp2 activateCallback "manageChild versionbox"
    XmCascadeButton Help menu_bar \
        subMenuId mp2

  XmFileSelectionBox fsbox main \
        dirListLabelString Main \
        okCallback "do_ok %s" 

XmMessageDialog versionbox Version unmanaged \
        dialogTitle "Motif Filetimes Version" \
        okLabelString "Close" \
        messageString "@(#)filetimes Version A.00.15, Sep 30 21:05:17 MET 1992"

XmMessageDialog helpbox Help unmanaged \
        dialogTitle "Filetimes Help" \
        okLabelString "Close" \
        messageString "\
The FileSelectionBox displays files in the current directory.  You \n\
select a file by moving the pointer to that file name and clicking mouse \n\
button 1.  Then move the pointer to the `ok' button and click mouse \n\
button 1 again.  A message box will appear with the last file access time, \n\
the last file modification time, and the last file change time.  Note \n\
that writing to a file changes both modification time and change time. \n\
See the man page for stat (2) and ctime (3C) for more information."

XmMessageDialog messagebox fsbox unmanaged \
        dialogTitle "File Times" \
        labelFontList -b&h-*-medium-r-*-*-*-140-*-*-m-*-iso8859-* \
        okLabelString "Close" 

proc do_ok {file} { 
        if [file exists $file] {file lstat $file stat;
           sV messagebox messageString "\
Last access Time        = [ctime $stat(atime)]\n\
Last modification Time  = [ctime $stat(mtime)]\n\
Last change Time        = [ctime $stat(ctime)]"} else {
           sV messagebox MessageString "Invalid file or directroy"};
        manageChild messagebox}

unmanageChild \
        [XmFileSelectionBoxGetChild fsbox DIALOG_CANCEL_BUTTON] \
        [XmFileSelectionBoxGetChild fsbox DIALOG_HELP_BUTTON] 
unmanageChild \
        [XmMessageBoxGetChild versionbox DIALOG_CANCEL_BUTTON] \
        [XmMessageBoxGetChild versionbox DIALOG_HELP_BUTTON] 
unmanageChild \
        [XmMessageBoxGetChild helpbox DIALOG_CANCEL_BUTTON] \
        [XmMessageBoxGetChild helpbox DIALOG_HELP_BUTTON] 
unmanageChild \
        [XmMessageBoxGetChild messagebox DIALOG_CANCEL_BUTTON] \
        [XmMessageBoxGetChild messagebox DIALOG_HELP_BUTTON]

XmMainWindowSetAreas main menu_bar NULL NULL NULL fsbox
sV menu_bar menuHelpWidget Help
realize

""")

wafe.process_events()










