
/*  Menu.c: Aileron is all about menus.  
 *
 *  This file is part of Aileron, a WINGs email client. 
 *
 *  Copyright (c) 1999 - 2001  Nwanua Elumeze
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "Aileron.h"


void infoPanelCB(void *data, int item, Time time)
{
  RunInfoPanel();
}

void gplPanelCB(void *data, int item, Time time)
{
  RunGPLPanel();
}

void helpPanelCB(void *data, int item, Time time)
{
  RunHelpPanel(0);
}

void prefsPanelCB(void *data, int item, Time time)
{
  RunPrefsPanel();
}


void composeCB(void *data, int item, Time time)
{
  ComposeMessage((int) data);
}

void addressesCB(void *data, int item, Time time)
{
  RunAddressesPanel();
}

void addAttachmentCB(void *data, int item, Time time)
{
  AddAttachment(Aileron.composer);
}
   
void deliverMessageCB(void *data, int item, Time time)
{
  DeliverMessage(Aileron.composer);
}

void sendOptionsPanelCB(void *data, int item, Time time)
{
  ShowSendOptionsPanel(Aileron.composer);
}

void saveDraftCB(void *data, int item, Time time)
{
  SaveDraft(Aileron.composer);
}

void restoreDraftCB(void *data, int item, Time time)
{
  RestoreDraft();
}

void mailboxesPanelCB(void *data, int item, Time time)
{
  RunMailboxesPanel();
}


void getNewMailCB (void *data, int item, Time time)
{
  OpenDefaultMailBoxes();
}

void sortMessage(void *data, int item, Time time)
{
  int type = (int) data;
  if(!Aileron.mbox)
    return;

  if(type == 111) {
    Bool rev =  GetMailBoxReverseSort(Aileron.mbox);
    SortMailSummaries(Aileron.mbox, GetMailBoxSortType(Aileron.mbox), !rev);
    WMSetUDBoolForKey(Aileron.defaultsDB, rev, "ReverseSortOrder");

  } else if(GetMailBoxSortType(Aileron.mbox) != type) {
    WMSetUDIntegerForKey(Aileron.defaultsDB, type, "SortingMethod");
    SortMailSummaries(Aileron.mbox, type, GetMailBoxReverseSort(Aileron.mbox));
  }

}

void focusCB(void *data, int item, Time time)
{
   FocusMailBox(Aileron.mbox, True);
}

void unfocusCB(void *data, int item, Time time)
{
   FocusMailBox(Aileron.mbox, False);
}

void markMessagesAsReadCB(void *data, int item, Time time)
{
  if(!Aileron.mbox)
    return;

  MarkMessagesAsRead(Aileron.mbox, False);
}

void markMessagesAsAnswered(void *data, int item, Time time)
{
  if(!Aileron.mbox)
    return;

  MarkMessagesAsAnswered(Aileron.mbox, False);
}

void saveAllAttachmentsCB(void *data, int item, Time time)
{
  if(!Aileron.mbox)
    return;

  SaveAllAttachments(Aileron.mbox);
}

void showAlternatives(void *data, int item, Time time)
{
  int alt = (int) data;

  if(!Aileron.mbox)
    return;

  GetMessage(Aileron.mbox, 
    GetMailBoxSelectedMessage(Aileron.mbox), alt);
}

void useFixedPitch(void *data, int item, Time time)
{ 
  int fixed = (int) data;
  WMText *tPtr;
  
  if(!Aileron.mbox)
    return;

  tPtr = GetMailBoxMessageView(Aileron.mbox);
  WMSetTextDefaultFont(tPtr, fixed? 
    WMCreateFont(Aileron.screen, "-misc-fixed-medium-*-*-*-*-*-*-*-*-*-*-*")
    : WMSystemFontOfSize(Aileron.screen, 12));
  WMRefreshText(tPtr);


} 

void showAsPlainText(void *data, int item, Time time)
{
  WMText *tPtr;

  if(!Aileron.mbox)
    return;
   
  tPtr = GetMailBoxMessageView(Aileron.mbox);
  Aileron.textIsPlain = 1;
  GetMessage(Aileron.mbox, 
    GetMailBoxSelectedMessage(Aileron.mbox), allAlternatives);
  Aileron.textIsPlain = 0;

}

void markMessagesAsDeletedCB(void *data, int item, Time time)
{
  if(!Aileron.mbox)
    return;
  MarkMessagesAsDeleted(Aileron.mbox, False);
}


void addAddressCB(void *data, int item, Time time)
{
  if(!Aileron.mbox)
    return;
  AddAddress(Aileron.mbox);
}

void findPanelCB(void *data, int item, Time time)
{
  RunFindPanel();
}

void findPreviousCB(void *data, int item, Time time)
{
   FindPrevious();
}

void findNextCB(void *data, int item, Time time)
{
   FindNext();
}

void enterSelectionCB(void *data, int item, Time time)
{
  EnterSelection();
}

/* this is just silly... you can Cut a message, but not its contents,
you may Paste a message into ANOTHER mailbox (think Transfer), but
not into the SAME mailbox! Neither can you Paste into the message view. */

/* cut is like COPY, only it also deletes... */
void cutSelectionCB(void *data, int item, Time time)
{
  if(Aileron.cORm && Aileron.mbox) { 
    if(1||Aileron.mouseWithinSumary) {
      MarkMessagesAsDeleted(Aileron.mbox, True);
      Aileron.selectedStream = GetMailBoxStream(Aileron.mbox);
      Aileron.selectedMessage = GetMailBoxSelectedMessage(Aileron.mbox);
    } else { 
      XBell(Aileron.display, 0);
    }

  } else if(Aileron.composer) {
    EnterSelection();
    WMReplaceTextSelection(GetComposerMessageView(Aileron.composer), NULL);
  }
  
}

/* TODO: need to track MAILSTREAM, msgno and make sure it hasn't been purged */
/* show an error panel instead */
void copySelectionCB(void *data, int item, Time time)
{
  EnterSelection();
}

/* any willing TextField or Text with the focus gets it */
void pasteSelectionCB(void *data, int item, Time time)
{
printf("fix WMTExt.... if no selection, NULL is not returned!\n");
/* char *sel = WMGetTextSelection();
if(!sel) then append, otherwise replace selection... */
printf("paste into any willing TextField or Text with the focus \n");
  if(!Aileron.cORm && Aileron.composer && Aileron.selectionText) {
    WMReplaceTextSelection(GetComposerMessageView(Aileron.composer), 
      Aileron.selectionText);
  }
  
}


void showSizesCB(void *data, int item, Time time)
{
  ShowMessageSizes();
}

void showDeletedCB(void *data, int item, Time time)
{
  ShowDeletedMessages();
}

void showAllHeadersCB(void *data, int item, Time time)
{
  if(!Aileron.mbox)
    return;

  NextMessage((void *)Aileron.mbox, next_SAME);
}

void compactMailBox (void *data, int menuitem, Time time)
{
  CompactMailBox(Aileron.mbox);
}


void fontPanelCB(void *data, int item, Time time)
{
  WMFontPanel *fpanel = WMGetFontPanel(Aileron.screen);
  WMShowFontPanel(fpanel);
}

void boldFontCB(void *data, int item, Time time)
{
  WMFont *font;
  WMText *tPtr = GetComposerMessageView(Aileron.composer);

  if(!tPtr)
    return;
  
  font = WMGetTextSelectionFont(tPtr);
  if(!font)
    return;
  WMSetTextSelectionFont(tPtr, WMStrengthenFont(Aileron.screen, font));
}

void italicFontCB(void *data, int item, Time time)
{
  WMFont *font;
  WMText *tPtr = GetComposerMessageView(Aileron.composer);

  if(!tPtr)
    return;
  
  font = WMGetTextSelectionFont(tPtr);
  if(!font)
     return;
  WMSetTextSelectionFont(tPtr, WMEmphasizeFont(Aileron.screen, font));
}

void underlineCB(void *data, int item, Time time)
{
  WMText *text = GetComposerMessageView(Aileron.composer);
  WMSetTextSelectionUnderlined(text, True);
}



void colorPanelCB(void *data, int item, Time time)
{
  WMColorPanel *cpanel = WMGetColorPanel(Aileron.screen);
  WMShowColorPanel(cpanel);
}


void copyFontCB(void *data, int item, Time time)
{
  WMFont *font;
  WMText *tPtr = 
    (Aileron.cORm ? GetMailBoxMessageView(Aileron.mbox) 
      : GetComposerMessageView(Aileron.composer));

  if(!tPtr)
    return;

/* modify WMGetTextSelectionFont to return WMRetainFont() */
  font = WMGetTextSelectionFont(tPtr);
  if(!font)
    return;

  if(Aileron.copiedfont)
    WMReleaseFont(Aileron.copiedfont);

  Aileron.copiedfont = WMRetainFont(font);
/* will need a new WMFont in WMText for: currentFont for new appends */
/* don't use Selected, just where cursor is in future... */
/* uncomment only after WMGetTextSelectionFont is modified
 to return WMRetainFont() */
 // WMReleaseFont(font);
}

void pasteFontCB(void *data, int item, Time time)
{
  WMText *tPtr;

  /* can't paste to a Mailbox silly... 
     the fonts are what the SENDER chose :-p */
  if(Aileron.cORm)
    return;

  tPtr =  GetComposerMessageView(Aileron.composer);

  if(!tPtr || !Aileron.copiedfont)
    return;

  WMSetTextSelectionFont(tPtr, Aileron.copiedfont);
  
}



void setTextAlignmentCB(void *data, int item, Time time)
{
  WMAlignment alignment = (WMAlignment) data;

  if(Aileron.composer)
  SetComposerTextAlignment(Aileron.composer, alignment);
}


void hideShowRulerCB(void *data, int item, Time time)
{
  if(Aileron.composer)
  HideShowComposerRuler(Aileron.composer);
}
  

void copyRulerCB(void *data, int item, Time time)
{

printf("*WMGetRulerMargins(WMRule\n");

#if 0
   if(Aileron.cORm && Aileron.mbox) {
 //   Aileron.rulermargins = WMGetTextRi

   } else if(!Aileron.cORm && Aileron.composer) {
MText *tPtr = GetComposerMessageView(Aileron.composer);
#endif

}

void pasteRulerCB(void *data, int item, Time time)
{

printf("*WMGetRulerMargins(WMRule\n");

#if 0
   if(Aileron.cORm && Aileron.mbox) {
 //   Aileron.rulermargins = WMGetTextRi

   } else if(!Aileron.cORm && Aileron.composer) {
MText *tPtr = GetComposerMessageView(Aileron.composer);
#endif

}


void hideCB(void *data, int item, Time time)
{
  WMHideApplication(Aileron.appContext);
}

void hideOthersCB(void *data, int item, Time time)
{
  WMHideOthers(Aileron.appContext);
}

void quitCB(WMWidget *w, void *data)
{
  QuitAileron();
}


void BuildMainMenu(void)
{
  WMMenu   *submenu, *subsubmenu;
  
  Aileron.menu = WMMenuCreate(Aileron.appContext, "Aileron");

  /*******************************************/
  /*******************************************/
  /*  begin "Info" submenu and children */

  submenu = WMMenuCreate(Aileron.appContext, "Info");
  WMMenuAddSubmenu(Aileron.menu, "Info", submenu);

  WMMenuAddItem(submenu, "Info Panel...",
    (WMMenuAction) infoPanelCB, NULL, NULL, NULL);
  WMMenuAddItem(submenu, "Legal...",
    (WMMenuAction) gplPanelCB, NULL, NULL, NULL);
  WMMenuAddItem(submenu, "Help...",
    (WMMenuAction) helpPanelCB, NULL, NULL, NULL);
  /*  end "Info" submenu and children */
  /*******************************************/
  /*******************************************/



  /*******************************************/
  /*******************************************/
  /* begin "Mailbox" submenu and children */

  submenu = WMMenuCreate(Aileron.appContext, "Mailbox");
  WMMenuAddSubmenu(Aileron.menu, "Mailbox", submenu);

  WMMenuAddItem(submenu, "Mailboxes",
    (WMMenuAction) mailboxesPanelCB, NULL, NULL, NULL);
      

  WMMenuAddItem(submenu, "Get New Mail",
    (WMMenuAction) getNewMailCB, NULL, NULL, NULL);


  /*******************************************/
  /* begin "Sorting" subsubmenu and children */

  subsubmenu = WMMenuCreate(Aileron.appContext, "Sorting Method");
  WMMenuAddSubmenu(submenu, "Sorting Method", subsubmenu);

  WMMenuAddItem(subsubmenu, "Arrival",
    (WMMenuAction) sortMessage,(void *)byArrival, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Date",
    (WMMenuAction) sortMessage, (void *)byDate, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Sender",
    (WMMenuAction) sortMessage, (void *)bySender, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Size",
    (WMMenuAction) sortMessage, (void *)bySize, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Subject",
    (WMMenuAction) sortMessage, (void *)bySubject, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Reverse Order",
    (WMMenuAction) sortMessage, (void *)111, NULL, NULL);

  /* end "Sorting" subsubmenu and children */
  /*******************************************/

  WMMenuAddItem(submenu, "Focus",
    (WMMenuAction) focusCB, NULL, NULL, NULL);
  WMMenuAddItem(submenu, "Unfocus",
    (WMMenuAction) unfocusCB, NULL, NULL, NULL);

  WMMenuAddItem(submenu, "Show Sizes",
    (WMMenuAction) showSizesCB, (void *) False, NULL, NULL);

  WMMenuAddItem(submenu, "Show Deleted",
    (WMMenuAction) showDeletedCB, (void *) False, NULL, NULL);

  WMMenuAddItem(submenu, "Compact",
    (WMMenuAction) compactMailBox, NULL, NULL, NULL);

  /* end "Mailbox" submenu and children */
  /*******************************************/
  /*******************************************/



  /*******************************************/
  /*******************************************/
  /* begin "Message" submenu and children */

  submenu = WMMenuCreate(Aileron.appContext, "Message");
  WMMenuAddSubmenu(Aileron.menu, "Message", submenu);

/* change to "Show Filtered Headers", yadda yadda - Nwanua */
  WMMenuAddItem(submenu, "Show all Headers",
    (WMMenuAction) showAllHeadersCB, NULL, NULL, NULL);

/* change to "Delete", yadda yadda - Nwanua */
  WMMenuAddItem(submenu, "Undelete",
    (WMMenuAction) markMessagesAsDeletedCB, NULL, NULL, NULL);
/* if true, do this, if false do that */

/* change to "Mark as Read", yadda yadda - Nwanua */
/* use values returned... */
  WMMenuAddItem(submenu, "Mark as Unread",
    (WMMenuAction) markMessagesAsReadCB, NULL, NULL, NULL);

  WMMenuAddItem(submenu, "Mark as Unanswered",
    (WMMenuAction) markMessagesAsAnswered, NULL, NULL, NULL);

  WMMenuAddItem(submenu, "Save all Attachments",
    (WMMenuAction) saveAllAttachmentsCB, NULL, NULL, NULL);


  /*******************************************/
  /* begin "MIME" subsubmenu and children */

  subsubmenu = WMMenuCreate(Aileron.appContext, "MIME");
  WMMenuAddSubmenu(submenu, "MIME", subsubmenu);

  WMMenuAddItem(subsubmenu, "Show First Alternative",
    (WMMenuAction) showAlternatives, (void *) firstAlternative, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Show Best Alternative",
    (WMMenuAction) showAlternatives, (void *) bestAlternative, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Show All Alternatives",
    (WMMenuAction) showAlternatives, (void *) allAlternatives, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Show As Plain Text",
    (WMMenuAction) showAsPlainText, NULL, NULL, NULL);


  /* end "MIME" subsubmenu and children */
  /*******************************************/


#if 0
  WMMenuAddItem(submenu, "::Decode Foreign Attachment...",
    (WMMenuAction) NULL /*CB*/, NULL, NULL, NULL);
#endif
  WMMenuAddItem(submenu, "Add to Address book",
    (WMMenuAction) addAddressCB, NULL, NULL, NULL);

  /* end "Message" submenu and children */
  /*******************************************/
  /*******************************************/



  /*******************************************/
  /*******************************************/
  /* begin "Compose" submenu and children */

  submenu = WMMenuCreate(Aileron.appContext, "Compose");
  WMMenuAddSubmenu(Aileron.menu, "Compose", submenu);


  WMMenuAddItem(submenu, "New",
    (WMMenuAction) composeCB, (void *) CMCompose, NULL, "n");
  WMMenuAddItem(submenu, "Reply",
    (WMMenuAction) composeCB, (void *) CMReply, NULL, "r");
  WMMenuAddItem(submenu, "Reply All",
    (WMMenuAction) composeCB, (void *) CMReplyAll, NULL, "R");
  WMMenuAddItem(submenu, "Forward",
    (WMMenuAction) composeCB, (void *) CMForward, NULL, "W");
  WMMenuAddItem(submenu, "Bounce",
    (WMMenuAction) composeCB, (void *) CMBounce, NULL, "W");
  WMMenuAddItem(submenu, "Addresses",
    (WMMenuAction) addressesCB, NULL, NULL, "A");
  WMMenuAddItem(submenu, "Add Attachment",
    (WMMenuAction) addAttachmentCB, (void *) CMForward, NULL, NULL);
#if 0
  WMMenuAddItem(submenu, "::Lip Service",
    (WMMenuAction) NULL, NULL, NULL, NULL);
#endif
  WMMenuAddItem(submenu, "Deliver",
    (WMMenuAction) deliverMessageCB, NULL, NULL, "D");

  WMMenuAddItem(submenu, "Send Options...",
    (WMMenuAction) sendOptionsPanelCB, NULL, NULL, NULL);


  /*******************************************/
  /* begin "Drafts" subsubmenu and children */

  subsubmenu = WMMenuCreate(Aileron.appContext, "Drafts");
  WMMenuAddSubmenu(submenu, "Drafts", subsubmenu);

  WMMenuAddItem(subsubmenu, "Save in Drafts",
    (WMMenuAction) saveDraftCB, NULL, NULL, "s");

  WMMenuAddItem(subsubmenu, "Restore Draft",
    (WMMenuAction) restoreDraftCB, NULL, NULL, NULL);

  /* end "Drafts" subsubmenu and children */
  /*******************************************/

  /* end "Compose" submenu and children */
  /*******************************************/
  /*******************************************/



  /*******************************************/
  /*******************************************/
  /* begin "Edit" submenu and children */

  submenu = WMMenuCreate(Aileron.appContext, "Edit");
  WMMenuAddSubmenu(Aileron.menu, "Edit", submenu);

  WMMenuAddItem(submenu, "Cut",
    (WMMenuAction) cutSelectionCB, NULL, NULL, NULL);
  WMMenuAddItem(submenu, "Copy",
    (WMMenuAction) copySelectionCB, NULL, NULL, "c");
  WMMenuAddItem(submenu, "Paste",
    (WMMenuAction) pasteSelectionCB, NULL, NULL, NULL);

#if 0
  WMMenuAddItem(submenu, "::Undo",
    (WMMenuAction) NULL /*CB*/, NULL, NULL, NULL);

/* use ispell or some other... put in contrib */
  WMMenuAddItem(submenu, "::Spelling...",
    (WMMenuAction) NULL /*PanelCB*/, NULL, NULL, NULL);
  WMMenuAddItem(submenu, "::Check Spelling",
    (WMMenuAction) NULL /*CB*/, NULL, NULL, NULL);
#endif

/* Note that "Select All" is context sensitive: message (in mailbox window),
 * text (in compose window), sound, etc. Code accordingly - Nwanua */
  WMMenuAddItem(submenu, "Select All",
    (WMMenuAction) NULL /*CB*/, NULL, NULL, NULL);


  /* end "Edit" submenu and children */
  /*******************************************/
  /*******************************************/


  /*******************************************/
  /*******************************************/
  /* begin "Find" submenu and children */

  submenu = WMMenuCreate(Aileron.appContext, "Find");
  WMMenuAddSubmenu(Aileron.menu, "Find", submenu);

  WMMenuAddItem(submenu, "Find Panel...",
    (WMMenuAction) findPanelCB, NULL, NULL, "f");
  WMMenuAddItem(submenu, "Find Next",
    (WMMenuAction)  findNextCB, NULL, NULL, "g");
  WMMenuAddItem(submenu, "Find Previous",
    (WMMenuAction) findPreviousCB, NULL, NULL, "G");

  WMMenuAddItem(submenu, "Enter Selection",
    (WMMenuAction) enterSelectionCB, NULL, NULL, NULL);

  /* end "Find" submenu and children */
  /*******************************************/
  /*******************************************/



  /*******************************************/
  /*******************************************/
  /* begin "Format" submenu and children */

  submenu = WMMenuCreate(Aileron.appContext, "Format");
  WMMenuAddSubmenu(Aileron.menu, "Format", submenu);

  WMMenuAddItem(submenu, "Fixed Pitch",
    (WMMenuAction) useFixedPitch, (void *) True, NULL, NULL);

  WMMenuAddItem(submenu, "Default Pitch",
    (WMMenuAction) useFixedPitch, (void *) False, NULL, NULL);

  /*******************************************/
  /* begin "Font" subsubmenu and children */

  subsubmenu = WMMenuCreate(Aileron.appContext, "Font");
  WMMenuAddSubmenu(submenu, "Font", subsubmenu);

  WMMenuAddItem(subsubmenu, "Font Panel...",
    (WMMenuAction) fontPanelCB, NULL, NULL, NULL);

   
   WMMenuAddItem(subsubmenu, "Bold",
  (WMMenuAction) boldFontCB, NULL, NULL, NULL);
   WMMenuAddItem(subsubmenu, "Italic",
  (WMMenuAction) italicFontCB, NULL, NULL, NULL);
   WMMenuAddItem(subsubmenu, "Underline",
  (WMMenuAction) underlineCB, NULL, NULL, NULL);
  WMMenuAddItem(subsubmenu, "::Superscript",
    (WMMenuAction) NULL /*CB*/, NULL, NULL, NULL);
  WMMenuAddItem(subsubmenu, "::Subscript",
    (WMMenuAction) NULL /*CB*/, NULL, NULL, NULL);
  WMMenuAddItem(subsubmenu, "::Unscript",
    (WMMenuAction) NULL /*CB*/, NULL, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Colors...",
    (WMMenuAction) colorPanelCB, NULL, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Copy Font",
    (WMMenuAction) copyFontCB, NULL, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Paste Font",
    (WMMenuAction) pasteFontCB, NULL, NULL, NULL);

  /* end "Font" subsubmenu and children */
  /*******************************************/

  /*******************************************/
  /* begin "Text" subsubmenu and children */

  subsubmenu = WMMenuCreate(Aileron.appContext, "Text");
  WMMenuAddSubmenu(submenu, "Text", subsubmenu);


  WMMenuAddItem(subsubmenu, "Align Left",
    (WMMenuAction) setTextAlignmentCB, (void *) WALeft, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Align Right",
    (WMMenuAction) setTextAlignmentCB, (void *) WARight, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Center",
    (WMMenuAction) setTextAlignmentCB, (void *) WACenter, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Show Ruler",
    (WMMenuAction) hideShowRulerCB, (void *) False, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Copy Ruler",
    (WMMenuAction) copyRulerCB, NULL, NULL, NULL);
  WMMenuAddItem(subsubmenu, "Paste Ruler",
    (WMMenuAction) pasteRulerCB, NULL, NULL, NULL);

  /* end "Text" subsubmenu and children */
  /*******************************************/

  WMMenuAddItem(submenu, "::Page Layout...",
    (WMMenuAction) NULL /*PanelCB*/, NULL, NULL, NULL);

  /* end "Format" submenu and children */
  /*******************************************/
  /*******************************************/

#if 0
  WMMenuAddItem(Aileron.menu, "::Print...",
    (WMMenuAction) NULL /*PanelCB*/, NULL, NULL, "p");
#endif

  WMMenuAddItem(Aileron.menu, "Preferences...",
    (WMMenuAction) prefsPanelCB, NULL, NULL, NULL);


  /*******************************************/
  /*******************************************/
  /* begin "Services" submenu and children */
#if 0
  submenu = WMMenuCreate(Aileron.appContext, "Services");
  WMMenuAddSubmenu(Aileron.menu, "Services", submenu);
#endif


  /* end "Services" submenu and children */
  /*******************************************/
  /*******************************************/


  WMMenuAddItem(Aileron.menu, "Hide",
    (WMMenuAction) hideCB, NULL, NULL, "h");
  WMMenuAddItem(Aileron.menu, "Hide Others",
    (WMMenuAction) hideOthersCB, NULL, NULL, "H");
  WMMenuAddItem(Aileron.menu, "Quit",
    (WMMenuAction) quitCB, NULL, NULL, "q");


  WMAppSetMainMenu(Aileron.appContext, Aileron.menu);
  return;
}



