rhess@uunet.UU.NET (Richard Hess) (03/11/91)
Submitted-by: Richard Hess <cimshop!pleione!rhess@uunet.UU.NET> Posting-number: Volume 12, Issue 15 Archive-name: xmenu2/part01 [ This "little" OSF/Motif 1.1 toolkit program produces a popup menu on the [ screen taking the command line arguments as menu entries. Both simple and [ cascading menus are supported in this version. This release also supports [ automatic submenu generation when the maximum menu entry limit is exceeded [ (see xmenu2.man for more detailed info). Xmenu2 is designed to be plug compatible with the original xmenu release from Richard Hesketh (rlh2@ukc.ac.uk). Dick... +------------------------------------------------------------------------------ WHO: Richard Hess CORP: Consilium TITLE: Staff Engineer VOICE: [415] 691-6342 [ User Interface Services ] USNAIL: 640 Clyde Court UUCP: ...!uunet!cimshop!rhess Mountain View, CA 94043 +------------------------------------------------------------------------------ #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 02/28/1991 22:57 UTC by rhess@pleione # Source directory /maestro/r4/src/new # # existing files will NOT be overwritten unless -c is specified # This format requires very little intelligence at unshar time. # "if test", "echo", "true", and "sed" may be needed. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 465 -r--r--r-- xmenu2/Imakefile # 11768 -r--r--r-- xmenu2/xmenu.c # 9310 -rw-r--r-- xmenu2/Makefile # 1719 -r--r--r-- xmenu2/README # 6148 -r--r--r-- xmenu2/xmenu2.man # 4668 -r--r--r-- xmenu2/xmenu2.h # 21 -r--r--r-- xmenu2/patchlevel.h # # ============= xmenu2/Imakefile ============== if test ! -d 'xmenu2'; then echo 'x - creating directory xmenu2' mkdir 'xmenu2' fi if test -f 'xmenu2/Imakefile' -a X"$1" != X"-c"; then echo 'x - skipping xmenu2/Imakefile (File already exists)' else echo 'x - extracting xmenu2/Imakefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmenu2/Imakefile' && X#define ManSuffix nr4 X X INCLUDES = -I. -I/maestro/Xm/include -I$(TOP) X DEPLIBS = /maestro/Xm/lib/libXm.a $(XMULIB) $(XTOOLLIB) $(XLIB) XLOCAL_LIBRARIES = /maestro/Xm/lib/libXm.a $(XMULIB) $(XTOOLLIB) $(XLIB) X SRCS = xmenu.c X OBJS = xmenu.o X XAllTarget(xmenu) XNormalProgramTarget(xmenu,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES), /**/) XSaberProgramTarget(xmenu,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES), /**/) XInstallManPage(xmenu2, $(MANDIR)) SHAR_EOF true || echo 'restore of xmenu2/Imakefile failed' fi # ============= xmenu2/xmenu.c ============== if test -f 'xmenu2/xmenu.c' -a X"$1" != X"-c"; then echo 'x - skipping xmenu2/xmenu.c (File already exists)' else echo 'x - extracting xmenu2/xmenu.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmenu2/xmenu.c' && X/* X * XMenu2 - provide simple popup menu for shell scripts... [ xmenu ] X * X * Description: This "little" toolkit program produces a popup menu on the X * screen taking the command line arguments as menu entries. X * X * Features: X * OSF/Motif 1.1 support... [ 02-19-91 ] X * - new "-menu/-unem" option supports simple & cascading submenus... X * - new "-bell" option enables XBell calls... X * - new "-quiet" option disables XBell calls... X * - new "-punt" option allows setting the default return string... X * - new "-geo" option allows setting the popup position of the menu... X * - new "-nest" option allows setting the submenu nesting limit... X * - new "-xtra" option allows setting the menu/submenu size limit... X * - new xtimer mechanism supports the "cancelled" menu condition... X * X * [ OSF/Motif is a trademark of Open Software Foundation, Inc X * X * Copyright 1991 Richard Hess and Consilium Inc. X * Copyright 1990 Richard Hesketh / rlh2@ukc.ac.uk X * Computing Lab. University of Kent at Canterbury, UK X * X * See xmenu2.h for the terms of the copyright... X * X+------------------------------------------------------------------------------ XWHO: Richard Hess CORP: Consilium XTITLE: Staff Engineer VOICE: [415] 691-6342 X [ User Interface Services ] USNAIL: 640 Clyde Court XUUCP: ...!uunet!cimshop!rhess Mountain View, CA 94043 X+------------------------------------------------------------------------------ X */ X X#include <stdio.h> X#include <Xm/Xm.h> X#include <Xm/RowColumn.h> X X#include <Xm/LabelG.h> X#include <Xm/PushBG.h> X#include <Xm/CascadeBG.h> X#include <Xm/SeparatoG.h> X X#include "xmenu2.h" X Xstatic void buttonPressCbk(); Xstatic void unMappedCbk(); Xstatic void puntCbk(); Xstatic void nestingError(); Xstatic void submenuError(); Xstatic int getPrompt(); X Xstruct ret { X String out_val; X Cardinal exit_status; X}; X Xstatic Boolean Bell = FALSE; Xstatic Display *dpy; Xstatic XtAppContext appCon; Xstatic XtIntervalId xtimer = NULL; Xstatic char *DeFault = NULL; X Xstatic XrmOptionDescRec options[] = { X {"-bell", ".bell", XrmoptionNoArg, (XtPointer)"True"}, X {"-quiet", ".bell", XrmoptionNoArg, (XtPointer)"False"}, X {"-geo", ".geo", XrmoptionSepArg, (XtPointer)NULL}, X {"-heading", ".heading", XrmoptionSepArg, (XtPointer)NULL}, X {"-nest", ".nest", XrmoptionSepArg, (XtPointer)NULL}, X {"-punt", ".punt", XrmoptionSepArg, (XtPointer)NULL}, X {"-xtra", ".xtra", XrmoptionSepArg, (XtPointer)NULL}, X}; X Xstatic String MXdefs[] = { X "*marginHeight: 1", X "*marginWidth: 1", X "*menuButton.fontList: -*-helvetica-bold-r-normal--12-120-75-75*iso*", X "*menuLabel.fontList: -*-helvetica-medium-r-normal--12-120-75-75*iso*", X "*menuSub.fontList: -*-helvetica-medium-r-normal--12-120-75-75*iso*", X "*menuXtra.fontList: -*-helvetica-medium-r-normal--12-120-75-75*iso*", X "*menuXtra.labelString: Xtra...", X NULL X }; X X/* ****************************************************************[ main ] */ X Xmain(argc, argv) X int argc; X char *argv[]; X{ X Widget toplevel, shell, button; X Widget *menu; X int *mcount; X XrmDatabase xrdb; X XtCallbackRec cbk_arg[2]; X XtCallbackRec cbk2_arg[2]; X Arg args[20]; X int rtn; X Cardinal i, j; X Position x, y; X Window junk1; X int junk2; X unsigned int junk3; X int flags; X int x_rtn, y_rtn; X unsigned int w_rtn, h_rtn; X struct ret *output_values; X String name, Title; X XrmValue value; X char *blank; X char *geo = NULL; X int k = 0; X int iSub = 0; X int nSub = 0; X int nXtra = 0; X int MaxCount; X int NestLimit; X X cbk_arg[0].callback = buttonPressCbk; X cbk_arg[0].closure = 0; X cbk_arg[1].callback = NULL; X X cbk2_arg[0].callback = unMappedCbk; X cbk2_arg[0].closure = 0; X cbk2_arg[1].callback = NULL; X X XtToolkitInitialize(); X appCon = XtCreateApplicationContext(); X X XtAppSetFallbackResources(appCon, MXdefs); X X dpy = XtOpenDisplay(appCon, NULL, APP_NAME, APP_CLASS, X options, XtNumber(options), &argc, argv); X X toplevel = XtAppCreateShell(APP_NAME, APP_CLASS, X applicationShellWidgetClass, dpy, X NULL, 0); X xrdb = XtDatabase(dpy); X X if (XrmGetResource(xrdb, XR_BELL, "", &blank, &value)) { X if (strcmp((char *)value.addr, "True") == 0 ) X Bell = TRUE; X else X Bell = FALSE; X } X X if (XrmGetResource(xrdb, XR_GEO, "", &blank, &value)) { X geo = (char *)value.addr; X flags = XParseGeometry(geo, &x_rtn, &y_rtn, X (unsigned int *)&w_rtn, X (unsigned int *)&h_rtn); X if ((XValue & flags) && (YValue & flags)) { X if (x_rtn < 0) x = XWidthOfScreen(XtScreen(toplevel)) + x_rtn; X else x = x_rtn; X if (y_rtn < 0) y = XHeightOfScreen(XtScreen(toplevel)) + y_rtn; X else y = y_rtn; X } X else X x = y = DEFAULT_XY; /* XValue & YValue search failed... 8-( */ X } X else { X if (XQueryPointer(dpy, DefaultRootWindow(dpy), &junk1, &junk1, X &x_rtn, &y_rtn, &junk2, &junk2, &junk3)) { X x = x_rtn; X y = y_rtn; X } X else { X x = y = DEFAULT_XY; /* XQueryPointer() failed... 8-( */ X } X } X X if (XrmGetResource(xrdb, XR_HEADING, "", &blank, &value)) X Title = (char *)value.addr; X else X Title = NULL; X X if (XrmGetResource(xrdb, XR_NEST, "", &blank, &value)) { X NestLimit = atoi((char *)value.addr); X if (NestLimit < DEFAULT_NEST) X NestLimit = DEFAULT_NEST; X } X else X NestLimit = DEFAULT_NEST; X X menu = (Widget *) XtMalloc(NestLimit*(sizeof(Widget))); X mcount = (int *) XtMalloc(NestLimit*(sizeof(int))); X X if (XrmGetResource(xrdb, XR_PUNT, "", &blank, &value)) X DeFault = (char *)value.addr; X else X DeFault = DEFAULT_PUNT; X X if (XrmGetResource(xrdb, XR_XTRA, "", &blank, &value)) { X MaxCount = atoi((char *)value.addr); X if (MaxCount < DEFAULT_MIN) X MaxCount = DEFAULT_MIN; X } X else X MaxCount = DEFAULT_MAX; X X i = 0; X XtSetArg(args[i], XmNx, x); i++; X XtSetArg(args[i], XmNy, y); i++; X XtSetArg(args[i], XmNunmapCallback, cbk2_arg); i++; X shell = XmCreatePopupMenu(toplevel, MAIN_MENU, args, i); X X menu[nSub] = shell; X X if (Title != NULL) { X i = 0; X XtSetArg(args[i], XmNlabelString, X XmStringCreate(Title, XmSTRING_DEFAULT_CHARSET)); i++; X button = XmCreateLabelGadget(shell, MENU_LABEL, args, i); X XtManageChild(button); X k++; X button = XmCreateSeparatorGadget(shell, MENU_LINE, NULL, 0); X XtManageChild(button); X k++; X } X X for (j = 1; j < argc; j++) { X rtn = getPrompt(argv[j], &name, &output_values); X if (k > MaxCount) { X if (nXtra == 0) X nXtra = nSub; X mcount[nSub] = k; X k = 0; X nSub++; X if (nSub == NestLimit) X nestingError(nSub); X menu[nSub] = XmCreatePulldownMenu(menu[nSub-1], SUB_MENU, NULL, 0); X i = 0; X XtSetArg(args[i], XmNsubMenuId, menu[nSub]); i++; X button = XmCreateCascadeButtonGadget(menu[nSub-1], MENU_XTRA, args, i); X XtManageChild(button); X } X X switch (rtn) { X case LINE: X button = XmCreateSeparatorGadget(menu[nSub], MENU_LINE, NULL, 0); X break; X case MENU: X mcount[nSub] = k; X k = 0; X iSub++; X nSub++; X if (nSub == NestLimit) X nestingError(nSub); X j++; X if (j == argc) X submenuError(); X rtn = getPrompt(argv[j], &name, &output_values); X switch (rtn) { X case LINE: X case MENU: X case UNEM: X submenuError(); X break; X default: X menu[nSub] = XmCreatePulldownMenu(menu[nSub-1], SUB_MENU, NULL, 0); X i = 0; X XtSetArg(args[i], XmNsubMenuId, menu[nSub]); i++; X XtSetArg(args[i], XmNlabelString, X XmStringCreate(name, XmSTRING_DEFAULT_CHARSET)); i++; X button = XmCreateCascadeButtonGadget(menu[nSub-1], MENU_SUB, args, i); X break; X } X break; X case UNEM: X iSub--; X if (nXtra && iSub < nXtra) { X nSub = nXtra-1; X nXtra = 0; X } X else X nSub--; X if (iSub < 0) { X if (Bell) { X XBell(dpy, 50); X XFlush(dpy); X } X fprintf(stderr, X "xmMenu: unbalanced submenu closure... [ %s ]\n", UNEM_TOK); X exit(1); X } X k = mcount[nSub]; X break; X default: X i = 0; X XtSetArg(args[i], XmNlabelString, X XmStringCreate(name, XmSTRING_DEFAULT_CHARSET)); i++; X cbk_arg[0].closure = (XtPointer)output_values; X XtSetArg(args[i], XmNactivateCallback, cbk_arg); i++; X button = XmCreatePushButtonGadget(menu[nSub], MENU_BUTTON, args, i); X break; X } X XtManageChild(button); X k++; X } X if (!k) { X if (Bell) { X XBell(dpy, 50); X XFlush(dpy); X } X fprintf(stderr, "xmMenu: no menu items given...\n"); X exit(1); X } X X XtManageChild(shell); X X XtAppMainLoop(appCon); X} X X/* ******************************************************[ buttonPressCbk ] */ X Xstatic void buttonPressCbk(w, client_data, call_data) X Widget w; X XtPointer client_data, call_data; X{ X struct ret *values; X X if (xtimer) { X XtRemoveTimeOut(xtimer); X xtimer = NULL; X } X X values = (struct ret *)client_data; X if (values->out_val != NULL) X fprintf(stdout, "%s\n", values->out_val); X exit(values->exit_status); X} X X/* *********************************************************[ unMappedCbk ] */ X Xstatic void unMappedCbk(w, client_data, call_data) X Widget w; X XtPointer client_data, call_data; X{ X xtimer = XtAppAddTimeOut(appCon, XTIMEOUT, puntCbk, 0); X} X X/* *************************************************************[ puntCbk ] */ X Xstatic void puntCbk(data, id) X XtPointer data; X XtIntervalId *id; X{ X if (Bell) { X XBell(dpy, 50); X XFlush(dpy); X } X if (DeFault != NULL) X fprintf(stdout, "%s\n", DeFault); X exit(0); X} X X/* ********************************************************[ nestingError ] */ X Xstatic void nestingError(nest) X int nest; X{ X if (Bell) { X XBell(dpy, 50); X XFlush(dpy); X } X fprintf(stderr, X "xmMenu: submenu nesting limit exceeded... [ %d ]\n", X nest); X exit(1); X} X X/* ********************************************************[ submenuError ] */ X Xstatic void submenuError() X{ X if (Bell) { X XBell(dpy, 50); X XFlush(dpy); X } X fprintf(stderr, "xmMenu: invalid submenu definition... [ no label ]\n"); X exit(1); X} X X/* ***********************************************************[ getPrompt ] */ X Xstatic int getPrompt(str, rtn_name, values) X String str; X String *rtn_name; X struct ret **values; X{ X static Cardinal count = STATUS_START; X int s, t; X char name[1000]; X Boolean found_escape = FALSE; X X *values = NULL; X X if (strncmp(str, LINE_TOK, strlen(LINE_TOK)) == 0) { X rtn_name = NULL; X return (LINE); X } X if (strncmp(str, MENU_TOK, strlen(MENU_TOK)) == 0) { X rtn_name = NULL; X return (MENU); X } X if (strncmp(str, UNEM_TOK, strlen(UNEM_TOK)) == 0) { X rtn_name = NULL; X return (UNEM); X } X *values = XtNew(struct ret); X (*values)->out_val = NULL; X X for (t = s = 0; str[s] != '\0'; s++) { X if (str[s] == '\\') { X if (found_escape) { X found_escape = FALSE; X name[t++] = '\\'; X } else X found_escape = TRUE; X } else if (str[s] == '=') { X if (found_escape) { X found_escape = FALSE; X name[t++] = '='; X } else { X (*values)->out_val = str + s + 1; X break; X } X } else X name[t++] = str[s]; X } X name[t] = '\0'; X if ((*values)->out_val == NULL) X (*values)->out_val = str; X X (*values)->exit_status = count++; X *rtn_name = XtNewString(name); X return (0); X} X X/* *******************************************************************<eof> */ SHAR_EOF true || echo 'restore of xmenu2/xmenu.c failed' fi # ============= xmenu2/Makefile ============== if test -f 'xmenu2/Makefile' -a X"$1" != X"-c"; then echo 'x - skipping xmenu2/Makefile (File already exists)' else echo 'x - extracting xmenu2/Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmenu2/Makefile' && X# Makefile generated by imake - do not edit! X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $ X# X# The cpp used on this machine replaces all newlines and multiple tabs and X# spaces in a macro expansion with a single space. Imake tries to compensate X# for this, but is not always successful. X# X X########################################################################### X# Makefile generated from "Imake.tmpl" and <Imakefile> X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $ X# X# Platform-specific parameters may be set in the appropriate .cf X# configuration files. Site-wide parameters may be set in the file X# site.def. Full rebuilds are recommended if any parameters are changed. X# X# If your C preprocessor doesn't define any unique symbols, you'll need X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing X# "make Makefile", "make Makefiles", or "make World"). X# X# If you absolutely can't get imake to work, you'll need to set the X# variables at the top of each Makefile as well as the dependencies at the X# bottom (makedepend will do this automatically). X# X X########################################################################### X# platform-specific configuration parameters - edit sun.cf to change X X# platform: $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $ X# operating system: SunOS 3.5 X X########################################################################### X# site-specific configuration parameters - edit site.def to change X X# site: $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $ X X SHELL = /bin/sh X X TOP = ../../mit X CURRENT_DIR = /maestro/r4/src/new/xmenu2 X X AR = ar cq X BOOTSTRAPCFLAGS = X CC = gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return X X COMPRESS = compress X CPP = /usr3/X11/gcc/lib/gcc-cpp $(STD_CPP_DEFINES) X PREPROCESSCMD = gcc -DNOSTDHDRS -fstrength-reduce -fpcc-struct-return -E $(STD_CPP_DEFINES) X INSTALL = install X LD = ld X LINT = lint X LINTLIBFLAG = -C X LINTOPTS = -axz X LN = ln -s X MAKE = make X MV = mv X CP = cp X RANLIB = ranlib X RANLIBINSTFLAGS = X RM = rm -f X STD_INCLUDES = X STD_CPP_DEFINES = X STD_DEFINES = X EXTRA_LOAD_FLAGS = X EXTRA_LIBRARIES = X TAGS = ctags X X SIGNAL_DEFINES = -DSIGNALRETURNSINT X X PROTO_DEFINES = X X INSTPGMFLAGS = X X INSTBINFLAGS = -m 0755 X INSTUIDFLAGS = -m 4755 X INSTLIBFLAGS = -m 0664 X INSTINCFLAGS = -m 0444 X INSTMANFLAGS = -m 0444 X INSTDATFLAGS = -m 0444 X INSTKMEMFLAGS = -m 4755 X X DESTDIR = X X TOP_INCLUDES = -I$(TOP) X X CDEBUGFLAGS = -O X CCOPTIONS = X COMPATFLAGS = X X ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) X ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS) X CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) X LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) X LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) X LDCOMBINEFLAGS = -X -r X X MACROFILE = sun.cf X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut X X IMAKE_DEFINES = X X IRULESRC = $(CONFIGSRC) X IMAKE_CMD = $(NEWTOP)$(IMAKE) -I$(NEWTOP)$(IRULESRC) $(IMAKE_DEFINES) X X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) X X########################################################################### X# X Window System Build Parameters X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X########################################################################### X# X Window System make variables; this need to be coordinated with rules X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X PATHSEP = / X USRLIBDIR = $(DESTDIR)/usr/lib X BINDIR = $(DESTDIR)/usr/bin/X11 X INCROOT = $(DESTDIR)/usr/include X BUILDINCROOT = $(TOP) X BUILDINCDIR = $(BUILDINCROOT)/X11 X BUILDINCTOP = .. X INCDIR = $(INCROOT)/X11 X ADMDIR = $(DESTDIR)/usr/adm X LIBDIR = $(USRLIBDIR)/X11 X CONFIGDIR = $(LIBDIR)/config X LINTLIBDIR = $(USRLIBDIR)/lint X X FONTDIR = $(LIBDIR)/fonts X XINITDIR = $(LIBDIR)/xinit X XDMDIR = $(LIBDIR)/xdm X AWMDIR = $(LIBDIR)/awm X TWMDIR = $(LIBDIR)/twm X GWMDIR = $(LIBDIR)/gwm X MANPATH = $(DESTDIR)/usr3/X11/manX X MANSOURCEPATH = $(MANPATH)/man X MANDIR = $(MANSOURCEPATH)n X LIBMANDIR = $(MANSOURCEPATH)3 X XAPPLOADDIR = $(LIBDIR)/app-defaults X X FONTCFLAGS = -t X X INSTAPPFLAGS = $(INSTDATFLAGS) X X IMAKE = $(IMAKESRC)/imake X DEPEND = $(DEPENDSRC)/makedepend X RGB = $(RGBSRC)/rgb X FONTC = $(BDFTOSNFSRC)/bdftosnf X MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir X MKDIRHIER = /bin/sh $(SCRIPTSRC)/mkdirhier.sh X X CONFIGSRC = $(TOP)/config X CLIENTSRC = $(TOP)/clients X DEMOSRC = $(TOP)/demos X LIBSRC = $(TOP)/lib X FONTSRC = $(TOP)/fonts X INCLUDESRC = $(TOP)/X11 X SERVERSRC = $(TOP)/server X UTILSRC = $(TOP)/util X SCRIPTSRC = $(UTILSRC)/scripts X EXAMPLESRC = $(TOP)/examples X CONTRIBSRC = $(TOP)/../contrib X DOCSRC = $(TOP)/doc X RGBSRC = $(TOP)/rgb X DEPENDSRC = $(UTILSRC)/makedepend X IMAKESRC = $(CONFIGSRC) X XAUTHSRC = $(LIBSRC)/Xau X XLIBSRC = $(LIBSRC)/X X XMUSRC = $(LIBSRC)/Xmu X TOOLKITSRC = $(LIBSRC)/Xt X AWIDGETSRC = $(LIBSRC)/Xaw X OLDXLIBSRC = $(LIBSRC)/oldX X XDMCPLIBSRC = $(LIBSRC)/Xdmcp X BDFTOSNFSRC = $(FONTSRC)/bdftosnf X MKFONTDIRSRC = $(FONTSRC)/mkfontdir X EXTENSIONSRC = $(TOP)/extensions X X DEPEXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a X EXTENSIONLIB = $(DEPEXTENSIONLIB) X X DEPXLIB = $(DEPEXTENSIONLIB) $(XLIBSRC)/libX11.a X XLIB = $(EXTENSIONLIB) $(XLIBSRC)/libX11.a X X DEPXAUTHLIB = $(XAUTHSRC)/libXau.a X XAUTHLIB = $(DEPXAUTHLIB) X X DEPXMULIB = $(XMUSRC)/libXmu.a X XMULIB = $(DEPXMULIB) X X DEPOLDXLIB = $(OLDXLIBSRC)/liboldX.a X OLDXLIB = $(DEPOLDXLIB) X X DEPXTOOLLIB = $(TOOLKITSRC)/libXt.a X XTOOLLIB = $(DEPXTOOLLIB) X X DEPXAWLIB = $(AWIDGETSRC)/libXaw.a X XAWLIB = $(DEPXAWLIB) X X LINTEXTENSIONLIB = $(EXTENSIONSRC)/lib/llib-lXext.ln X LINTXLIB = $(XLIBSRC)/llib-lX11.ln X LINTXMU = $(XMUSRC)/llib-lXmu.ln X LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln X LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln X X DEPLIBS = $(LOCAL_LIBRARIES) X X DEPLIBS1 = $(DEPLIBS) X DEPLIBS2 = $(DEPLIBS) X DEPLIBS3 = $(DEPLIBS) X X########################################################################### X# Imake rules for building libraries, programs, scripts, and data files X# rules: $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $ X X########################################################################### X# start of Imakefile X X INCLUDES = -I. -I/maestro/Xm/include -I$(TOP) X DEPLIBS = /maestro/Xm/lib/libXm.a $(XMULIB) $(XTOOLLIB) $(XLIB) XLOCAL_LIBRARIES = /maestro/Xm/lib/libXm.a $(XMULIB) $(XTOOLLIB) $(XLIB) X SRCS = xmenu.c X OBJS = xmenu.o X Xall:: xmenu X Xxmenu: $(OBJS) $(DEPLIBS) X $(RM) $@ X $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X Xclean:: X $(RM) xmenu X Xsaber_xmenu: X #load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X Xosaber_xmenu: X #load $(ALLDEFINES) $(DEPLIBS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X Xinstall.man:: xmenu2.man X $(INSTALL) -c $(INSTMANFLAGS) xmenu2.man $(MANDIR)/xmenu2.nr4 X X########################################################################### X# common rules for all Makefiles - do not edit X Xemptyrule:: X Xclean:: X $(RM_CMD) \#* X XMakefile:: $(IMAKE) X X$(IMAKE): X @(cd $(IMAKESRC); if [ -f Makefile ]; then \ X echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) all; else \ X echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \ X $(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS); fi; \ X echo "okay, continuing in $(CURRENT_DIR)") X XMakefile:: X -@if [ -f Makefile ]; then \ X echo " $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ X else exit 0; fi X $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) X Xtags:: X $(TAGS) -w *.[ch] X $(TAGS) -xw *.[ch] > TAGS X Xsaber: X #load $(ALLDEFINES) $(SRCS) X Xosaber: X #load $(ALLDEFINES) $(OBJS) X X########################################################################### X# empty rules for directories that do not have SUBDIRS - do not edit X Xinstall:: X @echo "install in $(CURRENT_DIR) done" X Xinstall.man:: X @echo "install.man in $(CURRENT_DIR) done" X XMakefiles:: X Xincludes:: X X########################################################################### X# dependencies generated by makedepend X SHAR_EOF true || echo 'restore of xmenu2/Makefile failed' fi # ============= xmenu2/README ============== if test -f 'xmenu2/README' -a X"$1" != X"-c"; then echo 'x - skipping xmenu2/README (File already exists)' else echo 'x - extracting xmenu2/README (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmenu2/README' && XXMenu2 - provide an OSF/Motif popup menu from a shell script... X XThis "little" OSF/Motif 1.1 toolkit program produces a popup menu on the Xscreen taking the command line arguments as menu entries. Both simple and Xcascading menus are supported in this version. This release also supports Xautomatic submenu generation when the maximum menu entry limit is exceeded X(see xmenu2.man for more detailed info). X XBy default the menu is popped up below and to the right of the current pointer Xposition, use "-geo" to position the menu at a particular point. X XExamples: X Xxmenu -heading "Choose Files by Suffix" Compressed="*.Z" "C sources"="*.c" \ X "Headers"="*.h" -line -line " Cancel" X Xxmenu Hello="Hello World" -line " " " " -line Goodbye="Goodbye World" X Xxenu -heading XShell xman xmh xterm \ X -menu games spider xmandel xlife -unem \ X -menu tools xcmap cpicker pixedit -unem X X XEnjoy, X X Dick... X Xps. Just so we don't forget where this all started from... ;-) X X [ Original Author: Richard Hesketh X [ : @nsfnet-relay.ac.uk:rlh2@ukc.ac.uk X [ : rlh2@ukc.ac.uk ..!mcsun!ukc!rlh2 X [ Computing Lab., X [ University of Kent at Canterbury, X [ Canterbury, Kent, CT2 7NF, United Kingdom. X [ Tel: +44 227 764000 ext 3682/7620 X X and before I forget... X X [ OSF/Motif is a trademark of Open Software Foundation, Inc. X X+------------------------------------------------------------------------------ XWHO: Richard Hess CORP: Consilium XTITLE: Staff Engineer VOICE: [415] 691-6342 X [ User Interface Services ] USNAIL: 640 Clyde Court XUUCP: ...!uunet!cimshop!rhess Mountain View, CA 94043 X+------------------------------------------------------------------------------ SHAR_EOF true || echo 'restore of xmenu2/README failed' fi # ============= xmenu2/xmenu2.man ============== if test -f 'xmenu2/xmenu2.man' -a X"$1" != X"-c"; then echo 'x - skipping xmenu2/xmenu2.man (File already exists)' else echo 'x - extracting xmenu2/xmenu2.man (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmenu2/xmenu2.man' && X.TH XMENU2 l "19 Febuary 1990" X.SH NAME Xxmenu \- provide simple popup menus to shell scripts... X.SH SYNOPSIS X\fBxmenu\fR Menu_Items [ SubMenu_Defs ][ Options ] X X.br XMenu_Items: X [\|\fI menu_entry\fR[\fI=output_value\fR] | \fB-line \fR\|] ... X.br XSubMenu_Defs: X [\|\fB -menu\fI submenu_label \fRMenu_Items ...\fB -unem \fR\|] X.br XOptions: X [\|\fB -heading\fI menu_title \fR\|] X [\|\fB -punt\fI default_value \fR\|] X [\|\fB -geo\fI geometry \fR\|] X [\|\fB -nest\fI number \fR\|] X [\|\fB -xtra\fI number \fR\|] X [\|\fB -bell\fR | \fB-quiet \fR\|] X.SH DESCRIPTION X\fIxmenu\fP provides a quick and easy way of producing an OSF/Motif popup menu Xfor use by shell scripts. Both simple and cascading menus are supported in Xthis version of \fIxmenu\fP. By default the menu is popped up to the right Xand below of the current pointer position but this can be overridden using the X\fI-geo\fP option. Following the example of \fIxmessage\fP the exit status is Xset to a number greater than or equal to 101, indicating which menu item was Xpressed. X.SH ARGUMENTS X.TP 8 X.I menu_entry[=output_value]\fP XSpecifies a menu entry with a widget name of \fBmenuButton\fP. If the Xargument contains an equals sign then the string to the left of the equals is Xused as the displayed menu item and the string to the right is used as the Xtext output when the item is pressed. If no equals sign is present in the Xargument then the argument itself is output. This specification is used for Xall menu entries, including those in a submenu... X.TP 8 X.B \-line\fP XSpecifies a separator line menu item with a widget name of \fBmenuLine\fP and Xcan be used in both the primary menu and submenu definitions... X.TP 8 X.B \-menu \fIsubmenu_label\fP XSpecifies the beginning of a submenu definition. The \fIsubmenu_label\fP is Xthe label used for the cascade button in the primary menu. The cascade Xbutton's widget name is \fBmenuSub\fP... X.TP 8 X.B \-unem\fP XSpecifies the end of a submenu definition... X.TP 8 X.B \-heading \fImenu_title\fP XSpecifies the "title" of the popup menu. This widget's name is X\fBmenuLabel\fP... X.TP 8 X.B \-punt \fIdefault_value\fP XSpecifies the default return value to be used when no items are selected from Xthe menu. If not specified, the default return value is the string ""... X.TP 8 X.B \-geo \fIgeometry\fP XSpecifies the "posting" location, X and Y only, for the popup menu... X.TP 8 X.B \-nest \fInumber\fP XSpecifies the maximum depth of submenu nesting supported by the popup menu... X [ default value: 10 ] X [ minimum value: 10 ] X.TP 8 X.B \-xtra \fInumber\fP XSpecifies the maximum number of menu entries allowed in a menu/submenu. When this number is exceeded, \fIxmenu\fP will automatically create a new cascade Xbutton and will continue putting the "xtra" menu/submenu items into it's associated submenu. The cascade button's widget name is \fBmenuXtra\fP... X [ default value: 32 ] X [ minimum value: 10 ] X.TP 8 X.B \-bell\fP XEnables the \fIXBell()\fP calls embedded in \fIxmenu\fP... X.TP 8 X.B \-quiet\fP XDisables the \fIXBell()\fP calls embedded in \fIxmenu\fP... X [ default ] X.SH RESOURCES XThe widget class of the \fIxmenu\fP application is \fBXmMenu\fP and it's Xinstance name is \fBxmMenu\fP. The following resouces can only be accessed Xthru the instance name as shown; X.TP 8 X.B xmMenu.bell\fP [ True/False ] XAccepts the string "True" to enable the \fIXBell()\fP calls embedded within X\fIxmenu\fP (see \fI-bell\fP above). All other strings will fail to match X(see \fI-quiet\fP above)... X.TP 8 X.B xmMenu.geo\fP [ geometry ] XAccepts a geometry string but only uses the location values from this string. XSee the \fI-geo\fP option above for a description of it's usage... X.TP 8 X.B xmMenu.heading\fP [ string ] XSee the \fI-heading\fP option above for a description of it's usage... X.TP 8 X.B xmMenu.punt\fP [ string ] XSee the \fI-punt\fP option above for a description of it's usage... X.TP 8 X.B xmMenu.nest\fP [ number ] XSee the \fI-nest\fP option above for a description of it's usage... X.TP 8 X.B xmMenu.xtra\fP [ number ] XSee the \fI-xtra\fP option above for a description of it's usage... X.SH Widgets XThe following is the list of "internal" widget names, with their associated Xwidget types, supported by \fIxmenu\fP; X.TP 12 X.B menuButton\fP X[ Push Button Gadget ] X.TP 12 X.B menuLabel\fP X[ Label Gadget ] X.TP 12 X.B menuLine\fP X[ Separator Gadget ] X.TP 12 X.B menuSub\fP X[ Cascade Button Gadget ] X.TP 12 X.B menuXtra\fP X[ Cascade Button Gadget ] X.TP 12 X.B Menu\fP X[ RowColumn Widget ] X.TP 12 X.B SubMenu\fP X[ RowColumn Widget ] X.SH DEFAULTS XThe following resource strings are embedded in \fIxmenu\fP as fallback Xresource values. X.DS X *marginHeight: 1 X *marginWidth: 1 X *menuButton.fontList: -*-helvetica-bold-r-normal--12-120-75-75*iso* X *menuLabel.fontList: -*-helvetica-medium-r-normal--12-120-75-75*iso* X *menuSub.fontList: -*-helvetica-medium-r-normal--12-120-75-75*iso* X *menuXtra.fontList: -*-helvetica-medium-r-normal--12-120-75-75*iso*" X *menuXtra.labelString: Xtra... X.DE X.SH EXAMPLES X.DS Xxmenu -heading "Choose Files by Suffix" \\ X Compressed="*.Z" "C sources"="*.c" "Headers"="*.h" \\ X -line -line " Cancel" X Xxmenu Hello="Hello World" -line " " " " -line Goodbye="Goodbye World" X Xxmenu -heading XShell xman xmh xterm \\ X -menu games spider xmandel xlife -unem \\ X -menu tools xcmap cpicker pixedit -unem X X.DE X.SH EXIT STATUS XThe exit status is set to a number greater than or equal to 101. This number Xcorresponds to the position of the pressed button in the menu, 101 for the Xfirst button, 102 for the second and so on. X.SH AUTHOR XRichard Hess, Consilium Inc., Febuary 1991 [ OSF/Motif 1.1 ] X.br Xcimshop!rhess@uunet.UU.NET X.br X X[ OSF/Motif is a trademark of Open Software Foundation, Inc. X.SH ORIGINAL XRichard Hesketh, University of Kent at Canterbury, June 1990 X.br X@nsfnet-relay.ac.uk:rlh2@ukc.ac.uk X.SH COPYRIGHT X.DT XCopyright 1991 Richard Hess and Consilium Inc. X.br XCopyright 1990 Richard Hesketh / rlh2@ukc.ac.uk X Computing Lab. University of Kent at Canterbury, UK X.sp 1 X\fBNote:\fP see \fIxmenu2.h\fP for the terms of the copyright... SHAR_EOF true || echo 'restore of xmenu2/xmenu2.man failed' fi # ============= xmenu2/xmenu2.h ============== if test -f 'xmenu2/xmenu2.h' -a X"$1" != X"-c"; then echo 'x - skipping xmenu2/xmenu2.h (File already exists)' else echo 'x - extracting xmenu2/xmenu2.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmenu2/xmenu2.h' && X/* X * [ xmenu2.h ] X * X * Copyright 1991 Richard Hess and Consilium Inc. X * Copyright 1990 Richard Hesketh / rlh2@ukc.ac.uk X * Computing Lab. University of Kent at Canterbury, UK X * X * See terms of copyright below... X * X+------------------------------------------------------------------------------ XWHO: Richard Hess CORP: Consilium XTITLE: Staff Engineer VOICE: [415] 691-6342 X [ User Interface Services ] USNAIL: 640 Clyde Court XUUCP: ...!uunet!cimshop!rhess Mountain View, CA 94043 X+------------------------------------------------------------------------------ X */ X X#define APP_NAME "xmMenu" X#define APP_CLASS "XmMenu" X X#define XR_BELL "xmMenu.bell" X#define XR_GEO "xmMenu.geo" X#define XR_HEADING "xmMenu.heading" X#define XR_NEST "xmMenu.nest" X#define XR_PUNT "xmMenu.punt" X#define XR_XTRA "xmMenu.xtra" X X#define MENU_BUTTON "menuButton" X#define MENU_XTRA "menuXtra" X#define MENU_LABEL "menuLabel" X#define MENU_LINE "menuLine" X#define MENU_SUB "menuSub" X X#define MAIN_MENU "Menu" X#define SUB_MENU "SubMenu" X X#define DEFAULT_MAX 32 X#define DEFAULT_MIN 10 X#define DEFAULT_PUNT "" X#define DEFAULT_XY 200 X#define DEFAULT_NEST 10 X#define XTIMEOUT 200 X X#define LINE 1 X#define LINE_TOK "-line" X#define MENU 2 X#define MENU_TOK "-menu" X#define UNEM 3 X#define UNEM_TOK "-unem" X#define STATUS_START 101 X X/* X * Copyright 1991 Richard Hess and Consilium Inc. X * X * Permission to use, copy, modify and distribute this software [ XMenu2 ] and X * its documentation for any purpose is hereby granted without fee, provided X * that the above copyright notice appear in all copies and that both that X * copyright notice and this permission notice appear in supporting X * documentation, and that the name of Richard Hess or Consilium Inc not be X * used in advertising or publicity pertaining to distribution of the software X * without specific, written prior permission. Richard Hess and Consilium Inc X * make no representations about the suitability of this software for any X * purpose. It is provided "as is" without express or implied warranty. X * X * Richard Hess AND Consilium Inc DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, X * IN NO EVENT SHALL Richard Hess OR Consilium Inc BE LIABLE FOR ANY SPECIAL, X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR X * PERFORMANCE OF THIS SOFTWARE. X * X * Author: Richard Hess [ cimshop!rhess@uunet.UU.NET ][ Febuary 1991 ] X+------------------------------------------------------------------------------ XWHO: Richard Hess CORP: Consilium XTITLE: Staff Engineer VOICE: [415] 691-6342 X [ User Interface Services ] USNAIL: 640 Clyde Court XUUCP: ...!uunet!cimshop!rhess Mountain View, CA 94043 X+------------------------------------------------------------------------------ X */ X X/* X * Copyright 1990 Richard Hesketh / rlh2@ukc.ac.uk X * Computing Lab. University of Kent at Canterbury, UK X * X * Permission to use, copy, modify and distribute this software and its X * documentation for any purpose is hereby granted without fee, provided that X * the above copyright notice appear in all copies and that both that X * copyright notice and this permission notice appear in supporting X * documentation, and that the names of Richard Hesketh and The University of X * Kent at Canterbury not be used in advertising or publicity pertaining to X * distribution of the software without specific, written prior permission. X * Richard Hesketh and The University of Kent at Canterbury make no X * representations about the suitability of this software for any purpose. X * It is provided "as is" without express or implied warranty. X * X * Richard Hesketh AND THE UNIVERSITY OF KENT AT CANTERBURY DISCLAIMS ALL X * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Richard Hesketh OR THE X * UNIVERSITY OF KENT AT CANTERBURY BE LIABLE FOR ANY SPECIAL, INDIRECT OR X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE X * OF THIS SOFTWARE. X * X * Author: Richard Hesketh / rlh2@ukc.ac.uk, X * Computing Lab. University of Kent at Canterbury, UK X */ SHAR_EOF true || echo 'restore of xmenu2/xmenu2.h failed' fi # ============= xmenu2/patchlevel.h ============== if test -f 'xmenu2/patchlevel.h' -a X"$1" != X"-c"; then echo 'x - skipping xmenu2/patchlevel.h (File already exists)' else echo 'x - extracting xmenu2/patchlevel.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmenu2/patchlevel.h' && X#define patchlevel 1 SHAR_EOF true || echo 'restore of xmenu2/patchlevel.h failed' fi exit 0 -- Dan Heller ------------------------------------------------ O'Reilly && Associates Z-Code Software Senior Writer President argv@ora.com argv@zipcode.com