[comp.sources.x] v02i070: a browser, Part02/03

mikew@wyse.wyse.com (Mike Wexler) (01/04/89)

Submitted-by:  Schlichter.Wbst@Xerox.COM (Hans Schlichter)
Posting-number: Volume 2, Issue 70
Archive-name: xbrowser/part02

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 3)."
# Contents:  modcommand.c option.c popup.c scandir.c toggle.c
#   xfilebrowser.c
# Wrapped by mikew@wyse on Tue Jan  3 12:03:48 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'modcommand.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'modcommand.c'\"
else
echo shar: Extracting \"'modcommand.c'\" \(3455 characters\)
sed "s/^X//" >'modcommand.c' <<'END_OF_FILE'
X/* Systems Sciences Laboratory, Webster Research Center */
X
Xstatic char *PROGRAM_information[] =
X{
X    "Copyright (c) 1988 Xerox Corporation.  All rights reserved.",
X    "$Header$",
X    "$Locker$"
X}
X;
X
X/*
X * Copyright protection claimed includes all forms and matters of copyrightable
X * material and information now allowed by statutory or judicial lay or
X * herinafter granted, including without limitation, material generated from
X * the software programs which are displayed on the screen such as icons,
X * screen display looks, etc.
X */
X
X
X/*
X * this defines modifications to the command button widget;
X * it redefines the translation table to accept input from
X * all three mouse buttons; the notify routine is redone to
X * return the number of the pressed mouse button as the call_data
X * parameter;
X *
X */
X
X#include "xfilebrowser.h"
X#include <X11/IntrinsicP.h>
X#include <X11/CommandP.h>
X
X
X/* Private Data */
Xextern void My_Notify();
Xextern void My_Double();
X
Xstatic char defaultTranslations[] =
X    "<Btn1Down>:	set() \n\
X     <Btn1Up>:		mynotify(1) unset() \n\
X     <Btn2Down>:	set() \n\
X     <Btn2Up>:		mynotify(2) unset() \n\
X     <Btn3Down>:	set() \n\
X     <Btn3Up>:		mynotify(3) unset()";
X
Xstatic char textTranslations[] =
X     "<Btn1Up>(2):	mydouble()";
X
X
Xstatic XtActionsRec actionsList[] =
X{
X  {"mynotify",		My_Notify},
X};
X
Xstatic XtActionsRec actionsText[] =
X{
X  {"mydouble",		My_Double},
X};
X
X
X/************************************
X*
X*  Modifications for command buttons
X*
X*************************************/
X
X
X
X/* ARGSUSED */
Xvoid ModCommand_Init(command)
XWidget command;
X{
X	XtTranslations modtable;
X
X	modtable = XtParseTranslationTable(defaultTranslations);
X	XtOverrideTranslations(command, modtable);
X	XtAddActions(actionsList, 1);
X} 
X
X/***************************
X*
X*  Action Procedures
X*
X***************************/
X
X
X/* ARGSUSED */
Xstatic void My_Notify(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X	CommandWidget cbw = (CommandWidget)w;
X	int button;
X
X	if (cbw->command.set) {
X         button = 0;
X         if (params[0] != NULL) {
X         	if (*params[0] == '1') button = 1;
X         	else if (*params[0] == '2') button = 2;
X         	else if (*params[0] == '3') button = 3;
X	   }
X         XtCallCallbacks(w, XtNcallback, (caddr_t)button);
X	}
X}
X
X
X/************************************
X*
X*  Modifications for text widgets
X*
X*************************************/
X
X/* ARGSUSED */
Xvoid Modtext_Init(command)
XWidget command;
X{
X	XtTranslations modtable;
X
X	modtable = XtParseTranslationTable(textTranslations);
X	XtOverrideTranslations(command, modtable);
X	XtAddActions(actionsText, 1);
X} 
X
X/* ARGSUSED */
Xstatic void My_Double(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X	XtTextPosition pos1, pos2;
X	int i;
X	long view_edit = (viewEdit ? 2 : 1); 
X	struct stat buf; 
X
X	if (w == listwidget) {
X	   XtTextGetSelectionPos(listwidget, &pos1, &pos2);
X	   if (pos1 != pos2 && numfiles != 0 && 
X	      ( (i = select_file(pos1, pos2)) != -1)) {
X	   	if (stat((*files[i]).d_name, &buf) == -1) {
X 		   disp_message("\ncannot check file stats");
X 	   	   return;
X 	   	}
X	   }
X	   else return;
X
X 	   if (buf.st_mode & S_IFDIR) 
X	   	DoList(listbutton, (caddr_t)NULL, (caddr_t)0);
X	   else 
X	   	DoEdit(editbutton, (caddr_t)NULL, (caddr_t)view_edit);
X	}
X	else if (w == grepwidget) 
X	   DoGrepEdit(grepbutton, (caddr_t)NULL, (caddr_t)view_edit);
X}
END_OF_FILE
if test 3455 -ne `wc -c <'modcommand.c'`; then
    echo shar: \"'modcommand.c'\" unpacked with wrong size!
fi
# end of 'modcommand.c'
fi
if test -f 'option.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'option.c'\"
else
echo shar: Extracting \"'option.c'\" \(8712 characters\)
sed "s/^X//" >'option.c' <<'END_OF_FILE'
X/* Systems Sciences Laboratory, Webster Research Center */
X
Xstatic char *PROGRAM_information[] =
X{
X    "Copyright (c) 1988 Xerox Corporation.  All rights reserved.",
X    "$Header$",
X    "$Locker$"
X}
X;
X
X/*
X * Copyright protection claimed includes all forms and matters of copyrightable
X * material and information now allowed by statutory or judicial lay or
X * herinafter granted, including without limitation, material generated from
X * the software programs which are displayed on the screen such as icons,
X * screen display looks, etc.
X */
X
X
X/* NOTE: This is modelled after the dialog widget!  
X   Rather, this is an interface to a widget.
X   It implements policy, and gives a (hopefully) easier-to-use interface
X   than just directly making your own form. */
X
X
X#include <X11/Xlib.h>
X#include <X11/Xos.h>
X#include <X11/IntrinsicP.h>
X#include <X11/XawMisc.h>
X#include <X11/StringDefs.h>
X#include <X11/AsciiText.h>
X#include <X11/Command.h>
X#include <X11/Label.h>
X#include "optionP.h"
X#include "toggleP.h"
X#include <ctype.h>
X
X#define offset(field) XtOffset(OptionWidget, field)
X
X
Xstatic XtResource resourcelist[] = {
X  {XtNlabel, XtCLabel, XtRString, sizeof(String),
X     offset(option.label), XtRString, NULL},
X  {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
X     offset(option.orientation), XtRString, "orientVertical"},
X};
X
Xextern void Initialize(), ConstraintInitialize();
Xextern Boolean SetValues();
Xextern void DoOption();
X
XOptionClassRec optionClassRec = {
X  { /* core_class fields */
X    /* superclass         */    (WidgetClass) &formClassRec,
X    /* class_name         */    "Option",
X    /* widget_size        */    sizeof(OptionRec),
X    /* class_initialize   */    NULL,
X    /* class_part init    */    NULL,
X    /* class_inited       */    FALSE,
X    /* initialize         */    Initialize,
X    /* initialize_hook    */    NULL,
X    /* realize            */    XtInheritRealize,
X    /* actions            */    NULL,
X    /* num_actions        */    0,
X    /* resources          */    resourcelist,
X    /* num_resources      */    XtNumber(resourcelist),
X    /* xrm_class          */    NULLQUARK,
X    /* compress_motion    */    TRUE,
X    /* compress_exposure  */    TRUE,
X    /* compress_enterleave*/    TRUE,
X    /* visible_interest   */    FALSE,
X    /* destroy            */    NULL,
X    /* resize             */    XtInheritResize,
X    /* expose             */    XtInheritExpose,
X    /* set_values         */    SetValues,
X    /* set_values_hook    */    NULL,
X    /* set_values_almost  */    XtInheritSetValuesAlmost,
X    /* get_values_hook    */    NULL,
X    /* accept_focus       */    NULL,
X    /* version            */    XtVersion,
X    /* callback_private   */    NULL,
X    /* tm_table           */    NULL,
X    /* query_geometry     */	NULL,
X    /* display_accelerator*/	XtInheritDisplayAccelerator,
X    /* extension	  */	NULL,
X
X  },
X  { /* composite_class fields */
X    /* geometry_manager   */   XtInheritGeometryManager,
X    /* change_managed     */   XtInheritChangeManaged,
X    /* insert_child       */   XtInheritInsertChild,
X    /* delete_child       */   XtInheritDeleteChild,
X    /* extension 	    */   NULL,
X  },
X  { /* constraint_class fields */
X    /* subresourses       */   NULL,
X    /* subresource_count  */   0,
X    /* constraint_size    */   sizeof(OptionConstraintsRec),
X    /* initialize         */   ConstraintInitialize,
X    /* destroy            */   NULL,
X    /* set_values         */   NULL
X  },
X  { /* form_class fields */
X    /* empty              */   0
X  },
X  { /* option_class fields */
X    /* empty              */   0
X  }
X};
X
XWidgetClass optionWidgetClass = (WidgetClass)&optionClassRec;
X
X/****************************************************************
X *
X * Private Procedures
X *
X ****************************************************************/
X
X/* ARGSUSED */
Xstatic void Initialize(request, new)
XWidget request, new;
X{
X	OptionWidget dw = (OptionWidget)new;
X	static Arg label_args[] = {
X	   {XtNlabel, (XtArgVal)NULL},
X	   {XtNborderWidth, (XtArgVal) 0}
X       };
X
X	label_args[0].value = (XtArgVal)dw->option.label;
X	dw->option.labelW = XtCreateManagedWidget( "label", 
X				labelWidgetClass, new,
X				label_args, XtNumber(label_args) );
X	dw->option.select = 0;
X}
X
X
X/* ARGSUSED */
Xstatic void ConstraintInitialize(request, new)
XWidget request, new;
X{
X	OptionWidget dw = (OptionWidget)new->core.parent;
X	WidgetList children = dw->composite.children;
X	OptionConstraints constraint = (OptionConstraints)new->core.constraints;
X	Widget *childP;
X
X	if (!XtIsSubclass(new, toggleWidgetClass))	/* if not a toggle */
X	return;					/* then just use defaults */
X
X	constraint->form.left = constraint->form.right = XtChainLeft;
X	constraint->form.vert_base = dw->option.labelW;
X
X	if (dw->composite.num_children > 1) {
X        for (childP = children + dw->composite.num_children - 1;
X	     childP >= children; childP-- ) {
X	    if (*childP == dw->option.labelW)
X	        break;
X	    if (XtIsManaged(*childP) &&
X		XtIsSubclass(*childP, toggleWidgetClass)) {
X	        if (dw->option.orientation == XtorientHorizontal)
X			constraint->form.horiz_base = *childP;
X		else	constraint->form.vert_base = *childP;
X		break;
X	    }
X	}
X    }
X}
X
X/***************************
X*
X*  Action Procedures
X*
X***************************/
X
Xstatic void DoOption(w, client_data, call_data)
XWidget w;
Xcaddr_t client_data, call_data;
X{
X	ToggleWidget tw = (ToggleWidget)w;
X	OptionWidget parent = (OptionWidget)tw->core.parent;
X	XtState newstate = (XtState)call_data;
X	Arg togglearg[1];
X	Boolean found = 0;
X	int i = 1;
X
X	if (newstate == XtToggleOff) {
X		/* the currently selected toggle button is selected */
X	   XtSetArg(togglearg[0], XtNstate, XtToggleOn);
X	   XtSetValues(w, togglearg, (Cardinal)1);
X	   return;
X	}
X	else {
X	   XtSetArg(togglearg[0], XtNstate, XtToggleOff);
X
X	   XtSetValues(parent->composite.children[parent->option.select], 
X			togglearg, (Cardinal)1);
X	}
X
X	while (!found && i < parent->composite.num_children) 
X	   if ((Widget)parent->composite.children[i] == w) {
X		found = 1;
X		parent->option.select = i;
X		break;
X	   }
X	   else i++;
X}
X
X/* ARGSUSED */
Xstatic Boolean SetValues(current, request, new)
XWidget current, request, new;
X{
X    return False;
X}
X
Xvoid DoHorizontalOption(parent, left, upper)
XOptionWidget parent;
XWidget *left, *upper;
X{
X	*left = (Widget) parent->option.label;
X
X	if ( (parent->composite.num_children > 1) )
X      		*upper = (Widget)parent->
X	   	composite.children[parent->composite.num_children - 1];
X	else 	*upper = (Widget)NULL;
X}
X
Xvoid DoVerticalOption(parent, left, upper)
XOptionWidget parent;
XWidget *left, *upper;
X{
X	*upper = (Widget)parent->
X	composite.children[parent->composite.num_children - 1];
X
X	*left = (Widget)NULL;
X}
X
Xvoid XtOptionAddOption(option, name, set)
XWidget option;
Xchar *name;
XBoolean set;
X{
X	OptionWidget parent = (OptionWidget)option;
X	Widget left, upper;
X	Arg togglearg[1];
X	static XtCallbackRec callbackList[] = { {NULL, NULL}, {NULL, NULL} };
X
X	static Arg arglist[] = {
X	   {XtNfromHoriz, (XtArgVal) NULL},
X	   {XtNfromVert, (XtArgVal) NULL},
X	   {XtNstate, (XtArgVal) NULL},
X	   {XtNcallback,(XtArgVal)callbackList},
X	   {XtNleft, (XtArgVal) XtChainLeft},
X	   {XtNright, (XtArgVal) XtChainLeft},
X	   {XtNtop, (XtArgVal) XtChainTop},
X	   {XtNbottom, (XtArgVal) XtChainTop}
X	};
X
X	if (parent->option.orientation == XtorientHorizontal)
X		DoHorizontalOption(parent, &left, &upper);
X	else	DoVerticalOption(parent, &left, &upper);
X
X	arglist[0].value = (XtArgVal)left;
X	arglist[1].value = (XtArgVal)upper;
X
X	if (set && parent->option.select != 0) {
X	   arglist[2].value = (XtArgVal)XtToggleOn;
X			/* reset existing toggle widget */
X	   XtSetArg(togglearg[0], XtNstate, XtToggleOff);
X	   XtSetValues(parent->composite.children[parent->option.select],
X		 togglearg, (Cardinal)1);
X	   parent->option.select = parent->composite.num_children;
X	}	   
X	else if (parent->option.select == 0) {
X	   arglist[2].value = (XtArgVal)XtToggleOn;
X	   parent->option.select = parent->composite.num_children;
X	}
X	else arglist[2].value = (XtArgVal)XtToggleOff;	
X
X	callbackList[0].callback = DoOption;
X
X	XtCreateManagedWidget(name, toggleWidgetClass, option, 
X			arglist, XtNumber(arglist) );
X}
X
X
Xint XtOptionGetSelection(w)
XWidget w;
X{
X    return ((OptionWidget)w)->option.select;
X}
X
Xvoid XtOptionSetSelection(w, index)
XWidget w;
Xint index;
X{
X	Arg toggleargs[1];
X	OptionWidget parent = (OptionWidget)w;
X
X	XtSetArg(toggleargs[0], XtNstate, XtToggleOff);
X	XtSetValues(parent->composite.children[parent->option.select],
X		toggleargs, XtNumber(toggleargs));
X
X	XtSetArg(toggleargs[0], XtNstate, XtToggleOn);
X	XtSetValues(parent->composite.children[index],
X		toggleargs, XtNumber(toggleargs));
X	parent->option.select = index;
X}
END_OF_FILE
if test 8712 -ne `wc -c <'option.c'`; then
    echo shar: \"'option.c'\" unpacked with wrong size!
fi
# end of 'option.c'
fi
if test -f 'popup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'popup.c'\"
else
echo shar: Extracting \"'popup.c'\" \(10444 characters\)
sed "s/^X//" >'popup.c' <<'END_OF_FILE'
X/* Systems Sciences Laboratory, Webster Research Center */
X
Xstatic char *PROGRAM_information[] =
X{
X    "Copyright (c) 1988 Xerox Corporation.  All rights reserved.",
X    "$Header$",
X    "$Locker$"
X}
X;
X
X/*
X * Copyright protection claimed includes all forms and matters of copyrightable
X * material and information now allowed by statutory or judicial lay or
X * herinafter granted, including without limitation, material generated from
X * the software programs which are displayed on the screen such as icons,
X * screen display looks, etc.
X */
X
X#include "xfilebrowser.h"
X
XWidget confirmwidget = NULL;
Xstatic Widget confirmshell = NULL;
Xstatic Widget extpromptwidget = NULL;		/* specifies the form widget
X				in case a prompt with toggle was created */
Xstatic Widget extoutwidget;
Xstatic Widget extdiagwidget;
X
Xstatic Widget logshell = NULL;
Xstatic Widget loglabel;
Xstatic Widget logpane;
Xstatic Widget logbox;
Xstatic Widget logtext;
X
Xstatic short disp_prompt = 0;
X
Xcheck_confirm()
X{
X	return disp_prompt;
X}
X
Xcheck_prompt()
X{
X	return disp_prompt;
X}
X
X
X
X/* ARGSUSED */
Xchange_sensitive(w, value)
XWidget w;
XBoolean value;
X{
X	XtSetSensitive(listbutton, value);
X	XtSetSensitive(editbutton, value);
X	XtSetSensitive(parentdirbutton, value);
X	XtSetSensitive(renamebutton, value);
X	XtSetSensitive(deletebutton, value);
X	XtSetSensitive(shellbutton, value);
X	XtSetSensitive(copybutton, value);
X	XtSetSensitive(grepbutton, value);
X	XtSetSensitive(grepeditbutton, value);
X}
X
X/* ARGSUSED */
Xconfirmyes(w, client_data, call_data)
XWidget w;
Xcaddr_t client_data, call_data;
X{
X	DialogData *data = (DialogData *)client_data;
X
X	destroyconfirm(data, (*data->yes));
X}
X
X/* ARGSUSED */
Xconfirmno(w, client_data, call_data)
XWidget w;
Xcaddr_t client_data, call_data;
X{
X	DialogData *data = (DialogData *)client_data;
X
X	destroyconfirm(data, (*data->no));
X}
X
X/* ARGSUSED */
Xconfirmcancel(w, client_data, call_data)
XWidget w;
Xcaddr_t client_data, call_data;
X{
X	DialogData *data = (DialogData *)client_data;
X
X	destroyconfirm(data, (*data->cancel));
X}
X
X/* ARGSUSED */
Xdestroyconfirm(data, func)
XDialogData *data;
Xint (*func)();
X{
X	change_sensitive(data->w, TRUE);
X	XtPopdown(confirmshell);
X	disp_prompt = 0;
X
X	extpromptwidget = NULL;
X	XtDestroyWidget(confirmshell);
X	confirmshell = NULL;
X		/* I tried to reuse the previous popup shell for new
X		dialog widgets; but after the first use the dialog buttons
X		of my dialog widget were never displayed; it displayed
X		only the label of the dialog box */
X	
X	func(data);
X}
X
Xint move_popup(w, caller)
XWidget w, caller;
X{
X	Dimension widthw, heightw;
X	Position callerx, callery;
X	int wx, wy;
X	Window parentcaller, child;
X	Screen *screen;
X
X	getsize(w, &widthw, &heightw);
X	getpos(caller, &callerx, &callery);
X	parentcaller = XtWindow(XtParent(caller));
X	screen = XtScreen(caller);
X	if (XTranslateCoordinates(curdisplay, parentcaller, screen->root, 
X		(int)callerx, (int)callery, &wx, &wy, &child) == BadWindow) 
X	   return(-1);
X	wx += 5; wy += 5;
X
X	if ( (wx + widthw) >= screen->width)
X	   wx = screen->width - widthw - 10;
X	if ( (wy + heightw) >= screen->height)
X	   wy = screen->height - heightw - 10;
X
X	XtMoveWidget(w, (Position)wx, (Position)wy);
X	return(0);
X}
X
X/* ARGSUSED */
Xint position_dialog(dialog, caller)
XWidget dialog, caller;
X{
X	XtSetMappedWhenManaged(dialog, FALSE);
X	XtRealizeWidget(dialog);
X
X	move_popup(dialog, caller);
X
X	change_sensitive(caller, FALSE);
X	XtMapWidget(dialog);
X	return(0);
X}
X
X/* ARGSUSED */
Xint create_confirm(data, str)
XDialogData *data;
Xchar *str;
X{
X	Arg args[1];
X	Arg popargs[1];
X
X	if (disp_prompt) return(-1);
X
X	disp_prompt = 1;
X	XtSetArg( popargs[0], XtNborderWidth, 2 );
X
X
X	confirmshell = XtCreatePopupShell("popupshell",
X	   		overrideShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));
X
X	XtSetArg( args[0], XtNlabel, str );
X	
X	confirmwidget = XtCreateManagedWidget("confirm", dialogWidgetClass,
X			confirmshell, args, XtNumber(args) );
X	XtDialogAddButton(confirmwidget, "yes", confirmyes, (caddr_t)data);
X	XtDialogAddButton(confirmwidget, "no", confirmno, (caddr_t)data);
X	XtDialogAddButton(confirmwidget, "cancel", confirmcancel, (caddr_t)data);
X
X	if (position_dialog(confirmshell, data->w) == -1) {
X	   XtDestroyWidget(confirmshell);
X	   confirmwidget = NULL;
X	   confirmshell = NULL;
X	}
X	XtPopup(confirmshell, XtGrabNonexclusive);
X	return(0);
X}
X
X
X/* ARGSUSED */
Xpromptok(w, client_data, call_data)
XWidget w;
Xcaddr_t client_data, call_data;
X{
X	DialogData *data = (DialogData *)client_data;
X	Arg togargs[1];
X	XtState extstate;
X
X	data->answer = XtDialogGetValueString(confirmwidget);
X	if (extpromptwidget != NULL) {
X	   XtSetArg(togargs[0], XtNstate, (XtArgVal)&extstate);
X	   XtGetValues(extdiagwidget, togargs, (Cardinal)1);
X	   data->diag = (Boolean)extstate;
X
X	   XtSetArg(togargs[0], XtNstate, (XtArgVal)&extstate);
X	   XtGetValues(extoutwidget, togargs, (Cardinal)1);
X	   data->out = (Boolean)extstate;
X	}
X	else data->diag = data->out = FALSE;
X
X	destroyconfirm(data, (*data->yes));
X}
X
X/* ARGSUSED */
Xpromptcancel(w, client_data, call_data)
XWidget w;
Xcaddr_t client_data, call_data;
X{
X	DialogData *data = (DialogData *)client_data;
X
X	destroyconfirm(data, (*data->cancel));
X}
X
X/* ARGSUSED */
Xint create_prompt(data, str, defvalue)
XDialogData *data;
Xchar *str, *defvalue;
X{
X	Arg args[2];
X	Arg popargs[1];
X
X	if (disp_prompt) return(-1);
X	disp_prompt = 1;
X
X	XtSetArg( popargs[0], XtNborderWidth, 2 );
X
X/*	confirmshell = XtCreatePopupShell("promptshell",
X	   		transientShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));*/
Xconfirmshell = XtCreatePopupShell("promptshell",
X	   		topLevelShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));
X
X	XtSetArg( args[0], XtNlabel, str );
X	XtSetArg( args[1], XtNvalue, defvalue );
X	
X	confirmwidget = XtCreateManagedWidget("confirm", dialogWidgetClass,
X			confirmshell, args, XtNumber(args) );
X	XtDialogAddButton(confirmwidget, "ok", promptok, (caddr_t)data);
X	XtDialogAddButton(confirmwidget, "cancel", promptcancel, (caddr_t)data);
X
X	if (position_dialog(confirmshell, data->w) == -1) {
X	   XtDestroyWidget(confirmshell);
X	   confirmwidget = NULL;
X	   confirmshell = NULL;
X	}
X	XtPopup(confirmshell, XtGrabNonexclusive);
X	return(0);
X}
X
X/* ARGSUSED */
X/* creates a prompt window which contains a dialog widget as well as two
X * toggle widgets defining if the output/diagnostics should be returned 
X */
Xint create_toggleprompt(data, str, defvalue)
XDialogData *data;
Xchar *str, *defvalue;
X{
X	Arg args[3];
X	Arg popargs[1];
X	Arg toggleargs[6];
X
X	if (disp_prompt) return(-1);
X	disp_prompt = 1;
X
X	XtSetArg( popargs[0], XtNborderWidth, 2 );
X
X/*	confirmshell = XtCreatePopupShell("toggleshell",
X	   		transientShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));*/
Xconfirmshell = XtCreatePopupShell("toggleshell",
X	   		topLevelShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));
X	extpromptwidget = XtCreateManagedWidget("form", formWidgetClass,
X			confirmshell, NULL, 0);
X
X	XtSetArg( args[0], XtNlabel, str );
X	XtSetArg( args[1], XtNvalue, defvalue );
X	XtSetArg( args[2], XtNborderWidth, 0 );
X	
X	confirmwidget = XtCreateManagedWidget("confirm", dialogWidgetClass,
X			extpromptwidget, args, XtNumber(args) );
X	XtDialogAddButton(confirmwidget, "ok", promptok, (caddr_t)data);
X	XtDialogAddButton(confirmwidget, "cancel", promptcancel, (caddr_t)data);
X
X	/* create the two toggle buttons "Return Diagnostic"
X	 * and "Return Output" */ 
X	XtSetArg( toggleargs[0], XtNfromVert, (XtArgVal)confirmwidget );
X	XtSetArg( toggleargs[1], XtNfromHoriz, (XtArgVal)NULL);
X	XtSetArg( toggleargs[2], XtNleft, (XtArgVal)XtChainLeft);
X	XtSetArg( toggleargs[3], XtNright, (XtArgVal)XtChainLeft);
X	XtSetArg( toggleargs[4], XtNstate, (XtArgVal)XtToggleOff );
X	extoutwidget = XtCreateManagedWidget( "Return Output", 
X			toggleWidgetClass, extpromptwidget, toggleargs,
X			XtNumber(toggleargs) - 1 );
X
X	XtSetArg( toggleargs[0], XtNfromVert, (XtArgVal)confirmwidget );
X	XtSetArg( toggleargs[1], XtNfromHoriz, (XtArgVal)extoutwidget );
X	XtSetArg( toggleargs[2], XtNleft, (XtArgVal)XtChainLeft);
X	XtSetArg( toggleargs[3], XtNright, (XtArgVal)XtChainLeft);
X	XtSetArg( toggleargs[4], XtNstate, (XtArgVal)XtToggleOn);
X	XtSetArg( toggleargs[5], XtNhorizDistance, (XtArgVal)20);
X	extdiagwidget = XtCreateManagedWidget( "Return Diagnostic", 
X			toggleWidgetClass, extpromptwidget, toggleargs,
X			XtNumber(toggleargs) );
X
X	if (position_dialog(confirmshell, data->w) == -1) {
X	   XtDestroyWidget(confirmshell);
X	   confirmshell = NULL;
X	   extpromptwidget = NULL;
X	}
X	XtPopup(confirmshell, XtGrabNonexclusive);
X	return(0);
X}
X
X
X/* ARGSUSED */
Xlogquit()
X{
X	XtPopdown(logshell);
X	XtSetSensitive(outer, TRUE);	
X	return;
X}
X
Xcreate_log()
X{
X	Arg popargs[1];
X
X	static Arg textargs[] = {
X	   { XtNfile, (XtArgVal)"/dev/null"},
X	   { XtNeditType, (XtArgVal)XttextRead },
X	   { XtNtextOptions, (XtArgVal)(wordBreak | scrollVertical) },
X	};	
X
X	static Arg labelargs[] = {
X	   { XtNjustify, (XtArgVal)XtJustifyCenter },
X	   { XtNlabel, 	NULL },
X	};
X
X
X	if (logshell != NULL)  return;
X	XtSetArg( popargs[0], XtNborderWidth, 2 );
X
X/*	logshell = XtCreatePopupShell("logshell",
X	   		transientShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));*/
Xlogshell = XtCreatePopupShell("logshell",
X	   		topLevelShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));
X
X	logpane = XtCreateManagedWidget("pane", vPanedWidgetClass, 
X			logshell, (ArgList)NULL, 0);
X	logbox = XtCreateManagedWidget("box", boxWidgetClass, 
X			logpane, (ArgList)NULL,0);
X	makeCommandButton(logbox, "Quit", logquit);
X	loglabel = XtCreateManagedWidget("labelWindow",labelWidgetClass, 
X		logpane, labelargs, XtNumber(labelargs)); 
X	logtext = XtCreateManagedWidget("data", asciiDiskWidgetClass,
X			logpane, textargs, XtNumber(textargs));
X	
X}
X
X/* ARGSUSED */
Xlog_popup(label, file)
Xchar *label, *file;
X{
X	XtTextSource old, new;
X
X	static Arg textargs[] = {
X	   { XtNfile, NULL},
X	   { XtNeditType, (XtArgVal)XttextRead },
X	   { XtNtextOptions, (XtArgVal)(wordBreak | scrollVertical) },
X	};	
X
X	static Arg labelargs[] = {
X	   { XtNjustify, (XtArgVal)XtJustifyCenter },
X	   { XtNlabel, 	NULL },
X	};
X
X	textargs[0].value = (XtArgVal)file;
X	labelargs[1].value = (XtArgVal)label;
X	
X
X	if (logshell == NULL) create_log();
X	old = XtTextGetSource(logtext);
X	new = XtDiskSourceCreate(logtext, textargs, XtNumber(textargs));
X	XtTextSetSource(logtext, new, 0);
X	XtDiskSourceDestroy(old);
X	XtSetValues(loglabel, labelargs, XtNumber(labelargs));
X
X	XtSetSensitive(outer, FALSE);	
X	XtPopup(logshell, XtGrabExclusive);
X	return(0);
X}
X
END_OF_FILE
if test 10444 -ne `wc -c <'popup.c'`; then
    echo shar: \"'popup.c'\" unpacked with wrong size!
fi
# end of 'popup.c'
fi
if test -f 'scandir.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'scandir.c'\"
else
echo shar: Extracting \"'scandir.c'\" \(11063 characters\)
sed "s/^X//" >'scandir.c' <<'END_OF_FILE'
X/* Systems Sciences Laboratory, Webster Research Center */
X
Xstatic char *PROGRAM_information[] =
X{
X    "Copyright (c) 1988 Xerox Corporation.  All rights reserved.",
X    "$Header$",
X    "$Locker$"
X}
X;
X
X/*
X * Copyright protection claimed includes all forms and matters of copyrightable
X * material and information now allowed by statutory or judicial lay or
X * herinafter granted, including without limitation, material generated from
X * the software programs which are displayed on the screen such as icons,
X * screen display looks, etc.
X */
X
X#include "xfilebrowser.h"
X
X
X/**************************
X*   local data structures *
X**************************/
Xextern int getfiles();
Xextern int my_alphasort();
Xextern int filesizesort();
Xextern int datesort();
X
Xstatic Widget listshell = NULL;
Xstatic Widget sortoption;	/* option for sorting files */
Xstatic Widget owneroption;	/* print owner or group */
Xstatic Widget dottoggle;	/* should dot file be printed */
X
Xstatic Widget optioncaller;
X
Xstatic int currentsort = 1;
Xstatic int currentdotfiles = 0; 	/* don't print dot files */
Xint currentid = 1; 	/* 1 = print owner name; 2 = print group name */
X
Xstatic short direction = 1;
X
Xstatic short disp_option = 0;
Xtypedef int (*intfunc)();
X
Xstatic intfunc sortfunc[] = {
X	my_alphasort, filesizesort, datesort };
X
X
Xcheck_option()
X{
X	return disp_option;
X}
X
XXtState GetToggle(w)
XWidget w;
X{
X	XtState toggle;
X	Arg arglist[1];
X
X	XtSetArg(arglist[0], XtNstate, &toggle);
X	XtGetValues(w, arglist, (Cardinal)1);
X	return(toggle);
X}
X
Xvoid SetToggle(w, value)
XWidget w;
XXtState value;
X{
X	Arg arglist[1];
X
X	XtSetArg(arglist[0], XtNstate, value);
X	XtSetValues(w, arglist, (Cardinal)1);
X}
X
Xvoid DoApply()
X{
X	currentsort = XtOptionGetSelection(sortoption);
X	currentid = XtOptionGetSelection(owneroption);
X	reset_ownercache();
X
X	if (GetToggle(dottoggle) == XtToggleOn) currentdotfiles = 1;
X	else currentdotfiles = 0;
X
X	disp_option = 0;
X	change_sensitive(optioncaller, TRUE);
X	XtPopdown(listshell);
X}
X
Xvoid DoCancel()
X{
X	XtState toggle;
X
X	/* reset the option dialog window */
X	if ( !(currentsort == XtOptionGetSelection(sortoption)) ) 
X		/* sorting was modified by user */
X	   XtOptionSetSelection(sortoption, currentsort);
X
X	if ( !(currentid == XtOptionGetSelection(owneroption)) ) 
X		/* printing owner/group was modified by user */
X	   XtOptionSetSelection(owneroption, currentid);
X
X		/* reset toggle switch for dot files */
X	toggle = GetToggle(dottoggle);
X	if (toggle == XtToggleOn && currentdotfiles == 0)
X	   SetToggle(dottoggle, XtToggleOff);
X	else if (toggle == XtToggleOff && currentdotfiles == 1)
X	   SetToggle(dottoggle, XtToggleOn);
X
X	disp_option = 0;
X	change_sensitive(optioncaller, TRUE);
X	XtPopdown(listshell);
X}
X
X
Xbuild_listoptions()
X{
X	Arg popargs[1];
X	Widget listpane, listrow1, listrow2, optform;
X
X	static Arg paneargs[] = {
X	   { XtNallowResize, (XtArgVal)True },
X	};
X	static Arg optformlist[] = {
X	   {XtNborderWidth, (XtArgVal)0 }
X	};
X
X	static Arg optionargs[] = { 
X	   { XtNlabel, (XtArgVal)NULL },
X	   { XtNorientation,(XtArgVal)XtorientVertical },
X	   { XtNfromHoriz, (XtArgVal) NULL },
X	   { XtNfromVert, (XtArgVal) NULL },
X	   { XtNleft, (XtArgVal) XtChainLeft },
X	   { XtNright, (XtArgVal) XtChainLeft },
X	   { XtNtop, (XtArgVal) XtChainTop },
X	   { XtNbottom, (XtArgVal) XtChainTop }
X
X	};
X	static XtCallbackRec callbackList[] = { {NULL, NULL}, {NULL, NULL} };
X	static Arg toggleargs[] = { 
X	   { XtNlabel, (XtArgVal)NULL },
X	   { XtNstate,(XtArgVal)XtToggleOff },
X	   { XtNfromHoriz, (XtArgVal) NULL },
X	   { XtNfromVert, (XtArgVal) NULL },
X	   { XtNleft, (XtArgVal) XtChainLeft },
X	   { XtNright, (XtArgVal) XtChainLeft },
X	   { XtNtop, (XtArgVal) XtChainTop },
X	   { XtNbottom, (XtArgVal) XtChainTop }
X
X	};
X
X	XtSetArg( popargs[0], XtNborderWidth, 2 );
X
X	listshell = XtCreatePopupShell("listshell",
X	   		overrideShellWidgetClass,
X			toplevel, popargs, XtNumber(popargs));
X
X	listpane = XtCreateManagedWidget( "listpaned", vPanedWidgetClass, 
X			listshell, paneargs , XtNumber(paneargs) );
X	listrow1 = XtCreateManagedWidget("listrow1", boxWidgetClass, 
X			listpane, NULL,0);
X	listrow2 = XtCreateManagedWidget("listrow2", boxWidgetClass, 
X			listpane, NULL,0);
X	makeCommandButton(listrow1, "Apply", DoApply);
X	makeCommandButton(listrow1, "Cancel", DoCancel);
X
X	optform = XtCreateManagedWidget("sorting",formWidgetClass, 
X		listrow2, optformlist, XtNumber(optformlist));
X
X		/* define option menu for sorting files */
X	optionargs[0].value = (XtArgVal)"Select Sorting Option:";
X	sortoption = XtCreateManagedWidget("sorting", optionWidgetClass, 
X		optform, optionargs, XtNumber(optionargs));
X	XtOptionAddOption(sortoption, "File Name", TRUE);
X	XtOptionAddOption(sortoption, "File Size", FALSE);
X	XtOptionAddOption(sortoption, "Date", FALSE);
X
X		/* define option menu for printing owner/group */
X	optionargs[0].value = (XtArgVal)"Print Owner/Group Name:";
X	optionargs[2].value = (XtArgVal)sortoption;
X	owneroption = XtCreateManagedWidget("owner", optionWidgetClass, 
X		optform, optionargs, XtNumber(optionargs));
X	XtOptionAddOption(owneroption, "Owner Name", TRUE);
X	XtOptionAddOption(owneroption, "Group name", FALSE);
X
X		/* define toggle for printing . files */
X	toggleargs[0].value = (XtArgVal)"Print Dot Files";
X	toggleargs[3].value = (XtArgVal)sortoption;
X	dottoggle = XtCreateManagedWidget("owner", toggleWidgetClass, 
X		optform, toggleargs, XtNumber(toggleargs));
X
X	XtSetMappedWhenManaged(listshell, FALSE);
X	XtRealizeWidget(listshell);
X}
X
Xdisplay_listoptions(caller)
XWidget caller;
X{
X	if (listshell == NULL) {
X	   build_listoptions();
X	   optioncaller = caller;
X	}
X
X	disp_option = 1;
X	move_popup(listshell, caller);
X	change_sensitive(caller, FALSE);
X	XtMapWidget(listshell);
X	XtPopup(listshell, XtGrabNonexclusive);
X}
X
X/*********************************
X* routines for scanning the directory *
X***********************************/
X
Xfree_direct(dfiles, numdfiles)
Xstruct afile ***dfiles;
Xint *numdfiles;
X{
X	register int i;
X	register struct afile **listfiles = *dfiles;
X
X	if (listfiles != (struct afile **)NULL) {
X	   for (i = 0; i < *numdfiles; i++) free(listfiles[i]);
X	   *numdfiles = 0;
X	   free(listfiles);
X	   *dfiles = (struct afile **)NULL;
X	}
X}
X
X
X/* ARGSUSED */
Xint prepare_list(dirname, dir, dfiles, numdfiles, nameprepend)
Xchar * dirname;
Xshort dir;
Xstruct afile ***dfiles;
Xint *numdfiles;
Xchar *nameprepend;
X{
X	if (dir != 0) direction = dir;
X	if ( (*numdfiles = my_scandir(dirname, dfiles, getfiles,
X			 sortfunc[currentsort-1], nameprepend) ) < 0) {
X	   disp_message("\nList: current directory?");
X	   return (-1);
X	}
X	return(0);
X}
X
X/* ARGSUSED */
Xgetfiles(dp)
Xregister struct direct *dp;
X{
X	if (!currentdotfiles && (dp->d_name)[0] == '.') return 0;
X	if (! strcmp(dp->d_name, ".") ||  ! strcmp(dp->d_name, "..")) return 0;
X	if (re_exec(dp->d_name)) return 1;
X	else return 0;
X}
X
X/* ARGSUSED */
Xmy_scandir(dirname, namelist, select, dcomp, nameprepend)
Xchar *dirname;
Xstruct afile *(*namelist[]);
Xint (*select)(), (*dcomp)();
Xchar *nameprepend;
X{
X	register struct direct *d;
X	register struct afile *p, **names;
X	register int j;
X	int nitems, cc;
X	register char *cp1, *cp2;
X	struct stat stb;
X	struct stat fbuf;
X	u_short elemlength;
X	long arraysz;
X	DIR *dirp;
X	char path[MAXNAME + 1];
X	int prelength = (nameprepend == NULL) ? 0 : (strlen(nameprepend)+1);
X
X	if ((dirp = opendir(dirname)) == NULL)
X		return(-1);
X	if (fstat(dirp->dd_fd, &stb) < 0)
X		return(-1);
X
X	/*
X	 * estimate the array size by taking the size of the directory file
X	 * and dividing it by a multiple of the minimum size entry. 
X	 */
X	arraysz = (stb.st_size / 24);
X	names = (struct afile **)XtMalloc(arraysz * sizeof(struct afile *));
X
X	nitems = 0;
X	while ((d = readdir(dirp)) != NULL) {
X	   if (select != NULL && !(*select)(d))
X		continue;	/* just selected names */
X		/*
X		 * Make a minimum size copy of the data
X		 */
X	   elemlength = MYDIRSIZ(d, prelength);
X	   p = (struct afile *)XtMalloc(elemlength);
X	   p->d_marked = 0;
X	   p->d_ino = d->d_ino;
X	   p->d_reclen = elemlength;
X	   p->d_namlen = d->d_namlen + prelength;
X	   sprintf(path, "%s/%s", dirname, d->d_name);
X
X	   if (nameprepend != (char *)NULL) {
X	   	for (cp1 = p->d_name, cp2 = nameprepend; 
X						*cp1++ = *cp2++; );
X		*(cp1 - 1) = '/';
X	   	for (cp2 = d->d_name; *cp1++ = *cp2++; );
X	   	if (stat(path, &fbuf) ) return(-1);
X			/* no stats file is found */
X	   }
X	   else {
X		for (cp1 = p->d_name, cp2 = d->d_name; *cp1++ = *cp2++; ); 
X
X	   	if (lstat(path, &fbuf) ) {
X		   disp_message("\nList: stats file for %s", d->d_name);
X		   return(-1);
X	   	}
X	   }
X
X	   p->d_size = fbuf.st_size;
X	   p->d_nlink = fbuf.st_nlink;
X
X	   switch(fbuf.st_mode & S_IFMT) {
X	   case S_IFDIR:  p->d_type = 'd'; break;
X	   case S_IFBLK:  p->d_type = 'b'; p->d_size = fbuf.st_rdev; break;
X	   case S_IFCHR:  p->d_type = 'c'; p->d_size = fbuf.st_rdev; break;
X	   case S_IFSOCK: p->d_type = 's'; p->d_size = 0; break;
X	   case S_IFLNK:  p->d_type = 'l'; break;
X	   default:       p->d_type = '-'; break;
X	   }
X
X	   j = 0;
X	   if (fbuf.st_mode & 0400) 
X		p->d_access[j++] = 'r'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0200) 
X		p->d_access[j++] = 'w'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0100) 
X		p->d_access[j++] = 'x'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0040) 
X		p->d_access[j++] = 'r'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0020) 
X		p->d_access[j++] = 'w'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0010) 
X		p->d_access[j++] = 'x'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0004) 
X		p->d_access[j++] = 'r'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0002) 
X		p->d_access[j++] = 'w'; else p->d_access[j++] = '-';
X	   if (fbuf.st_mode & 0001) 
X		p->d_access[j++] = 'x'; else p->d_access[j++] = '-';
X	   p->d_access[j] = '\0';
X
X	   p->d_ctime = fbuf.st_ctime;
X	   p->d_uid = fbuf.st_uid;
X	   p->d_gid = fbuf.st_gid;
X
X		/*
X		 * Check to make sure the array has space left and
X		 * realloc the maximum size.
X		 */
X	   if (++nitems >= arraysz) {
X		if (fstat(dirp->dd_fd, &stb) < 0)
X				return(-1);	/* just might have grown */
X		arraysz = stb.st_size / 12;
X		names = (struct afile **)XtRealloc((char *)names,
X				arraysz * sizeof(struct afile *));
X	   }
X	   names[nitems-1] = p;
X	}
X	closedir(dirp);
X	if (nitems && dcomp != NULL)
X		qsort(names, nitems, sizeof(struct afile *), dcomp);
X	*namelist = names;
X	return(nitems);
X}
X
X/*
X * Alphabetic order comparison routine
X */
X/* ARGSUSED */
Xint my_alphasort(d1, d2)
X	struct afile **d1, **d2;
X{
X	return(direction * strcmp((*d1)->d_name, (*d2)->d_name));
X}
X
X/*
X * file size order comparison routine
X */
X/* ARGSUSED */
Xint filesizesort(d1, d2)
X	struct afile **d1, **d2;
X{
X	int i;
X
X	if ( (*d1)->d_size < (*d2)->d_size ) i = (int)direction * (-1);
X	else if ( (*d1)->d_size > (*d2)->d_size ) i = (int)direction;
X	else i = 0;
X	return(i);
X}
X
X/*
X * file date order comparison routine
X */
X/* ARGSUSED */
Xint datesort(d1, d2)
X	struct afile **d1, **d2;
X{
X	int i;
X
X	if ( (*d1)->d_ctime < (*d2)->d_ctime ) i = (int)direction * (-1);
X	else if ( (*d1)->d_ctime > (*d2)->d_ctime ) i = (int)direction;
X	else i = 0;
X	return(i);
X}
END_OF_FILE
if test 11063 -ne `wc -c <'scandir.c'`; then
    echo shar: \"'scandir.c'\" unpacked with wrong size!
fi
# end of 'scandir.c'
fi
if test -f 'toggle.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'toggle.c'\"
else
echo shar: Extracting \"'toggle.c'\" \(8583 characters\)
sed "s/^X//" >'toggle.c' <<'END_OF_FILE'
X/* Systems Sciences Laboratory, Webster Research Center */
X
Xstatic char *PROGRAM_information[] =
X{
X    "Copyright (c) 1988 Xerox Corporation.  All rights reserved.",
X    "$Header$",
X    "$Locker$"
X}
X;
X
X/*
X * Copyright protection claimed includes all forms and matters of copyrightable
X * material and information now allowed by statutory or judicial lay or
X * herinafter granted, including without limitation, material generated from
X * the software programs which are displayed on the screen such as icons,
X * screen display looks, etc.
X */
X
X
X/*
X * toggle.c - Toggle widget
X *
X */
X
X
X#include <stdio.h>
X#include <X11/Xos.h>
X#include <ctype.h>
X#include <X11/StringDefs.h>
X#include <X11/IntrinsicP.h>
X#include <X11/XawMisc.h>
X#include "toggleP.h"
X
X/* Private Data */
X
Xextern void Initialize();
Xextern Boolean SetValues();
Xextern void Toggle();
Xextern void Unhighlight();
Xextern void Highlight();
Xextern void Notify();
Xextern void ClassInitialize();
X
X
Xstatic char toggleTranslations[] =
X    "<Btn1Up>:		toggle() notify()\n\
X     <EnterWindow>:	highlight() \n\
X     <LeaveWindow>:	unhighlight()";
X
X
X#define offset(field) XtOffset(ToggleWidget, field)
Xstatic Dimension defwidth = 0;
Xstatic XtState defState = XtToggleOff;
X
Xstatic XtResource resources[] = { 
X   {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
X      offset(simple.cursor), XtRString, "hand2"},
X   {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
X      offset(core.border_width), XtRDimension, (caddr_t)&defwidth},
X   {XtNstate, XtCState, XtRState, sizeof(XtState), 
X      offset(toggle.state), XtRState, (caddr_t)&defState},
X};
X#undef offset
X
Xstatic XtActionsRec toggleactionsList[] =
X{
X  {"toggle",		Toggle},
X  {"notify",		Notify},
X  {"highlight",	Highlight},
X  {"unhighlight",	Unhighlight},
X};
X
X  /* ...ClassData must be initialized at compile time.  Must
X     initialize all substructures.  (Actually, last two here
X     need not be initialized since not used.)
X  */
XToggleClassRec toggleClassRec = {
X  {
X    (WidgetClass) &commandClassRec,	/* superclass		  */	
X    "Toggle",				/* class_name		  */
X    sizeof(ToggleRec),			/* size			  */
X    ClassInitialize,			/* class_initialize	  */
X    NULL,				/* class_part_initialize  */
X    FALSE,				/* class_inited		  */
X    Initialize,			/* initialize		  */
X    NULL,				/* initialize_hook	  */
X    XtInheritRealize,			/* realize		  */
X    toggleactionsList,			/* actions		  */
X    XtNumber(toggleactionsList),	/* num_actions		  */
X    resources,				/* resources		  */
X    XtNumber(resources),		/* resource_count	  */
X    NULLQUARK,				/* xrm_class		  */
X    FALSE,				/* compress_motion	  */
X    TRUE,				/* compress_exposure	  */
X    TRUE,				/* compress_enterleave    */
X    FALSE,				/* visible_interest	  */
X    NULL,				/* destroy		  */
X    XtInheritResize,			/* resize		  */
X    XtInheritExpose,			/* expose		  */
X    SetValues,				/* set_values		  */
X    NULL,				/* set_values_hook	  */
X    XtInheritSetValuesAlmost,		/* set_values_almost	  */
X    NULL,				/* get_values_hook	  */
X    NULL,				/* accept_focus		  */
X    XtVersion,				/* version		  */
X    NULL,				/* callback_private	  */
X    toggleTranslations,		/* tm_table		  */
X    NULL,				/* query_geometry	  */
X    XtInheritDisplayAccelerator,	/* display_accelerator	  */
X    NULL,				/* extension	  	  */
X  },  /* CoreClass fields initialization */
X  {
X    0,                                     /* field not used    */
X  },  /* LabelClass fields initialization */
X  {
X    0,                                     /* field not used    */
X  },  /* CommandClass fields initialization */
X  {
X    0,                                     /* field not used    */
X  },  /* ToggleClass fields initialization */
X};
X
X  /* for public consumption */
XWidgetClass toggleWidgetClass = (WidgetClass) &toggleClassRec;
X
X/****************************************************************
X *
X * Private Procedures
X *
X ****************************************************************/
X
Xstatic void CvtStringToState();
X
Xstatic XrmQuark	XrmQEtoggleon;
Xstatic XrmQuark	XrmQEtoggleoff;
X
Xstatic void ClassInitialize()
X{
X
X    XrmQEtoggleon   = XrmStringToQuark("toggleon");
X    XrmQEtoggleoff = XrmStringToQuark("toggleoff");
X
X    XtAddConverter( XtRString, XtRState, CvtStringToState, NULL, 0 );
X} /* ClassInitialize */
X
X/* ARGSUSED */
Xstatic void CvtStringToState(args, num_args, fromVal, toVal)
XXrmValuePtr *args;		/* unused */
XCardinal	*num_args;	/* unused */
XXrmValuePtr fromVal;
XXrmValuePtr toVal;
X{
X    static XtState e;
X    XrmQuark q;
X    char *s = (char *) fromVal->addr;
X    char lowerName[1000];
X    int i;
X
X    if (s == NULL) return;
X
X    for (i=0; i<=strlen(s); i++) {
X        char c = s[i];
X	lowerName[i] = isupper(c) ? (char) tolower(c) : c;
X    }
X
X    q = XrmStringToQuark(lowerName);
X
X    toVal->size = sizeof(XtState);
X    toVal->addr = (caddr_t) &e;
X
X    if (q == XrmQEtoggleon)  { e = XtToggleOn; return; }
X    if (q == XrmQEtoggleoff) { e = XtToggleOff; return; }
X
X    toVal->size = 0;
X    toVal->addr = NULL;
X};
X
X/* ARGSUSED */
Xstatic void Initialize(request, new)
XWidget request, new;
X{
X	ToggleWidget tw = (ToggleWidget)new;
X
X	tw->command.set = (int)tw->toggle.state;
X	if (tw->toggle.state == XtToggleOn)
X	   tw->label.normal_GC = tw->command.inverse_GC;
X} 
X
Xstatic Region HighlightRegion(cbw)
X    ToggleWidget cbw;
X{
X    static Region outerRegion = NULL, innerRegion, emptyRegion;
X    XRectangle rect;
X
X    if (outerRegion == NULL) {
X	/* save time by allocating scratch regions only once. */
X	outerRegion = XCreateRegion();
X	innerRegion = XCreateRegion();
X	emptyRegion = XCreateRegion();
X    }
X
X    rect.x = rect.y = 0;
X    rect.width = cbw->core.width;
X    rect.height = cbw->core.height;
X    XUnionRectWithRegion( &rect, emptyRegion, outerRegion );
X    rect.x = rect.y =  cbw->command.highlight_thickness;
X    rect.width -= cbw->command.highlight_thickness * 2;
X    rect.height -= cbw->command.highlight_thickness * 2;
X    XUnionRectWithRegion( &rect, emptyRegion, innerRegion );
X    XSubtractRegion( outerRegion, innerRegion, outerRegion );
X    return outerRegion;
X}
X/***************************
X*
X*  Action Procedures
X*
X***************************/
X
X/* ARGSUSED */
Xstatic void Toggle(w,event,params,num_params)
X     Widget w;
X     XEvent *event;
X     String *params;		/* unused */
X     Cardinal *num_params;	/* unused */
X{
X	ToggleWidget tw = (ToggleWidget)w;
X
X	if (tw->toggle.state == XtToggleOn) {
X	   tw->toggle.state = XtToggleOff;
X	   tw->command.set = FALSE;
X	   tw->label.normal_GC = tw->command.normal_GC;
X	   tw->command.highlighted = TRUE; 
X	}
X	else {
X	   tw->toggle.state = XtToggleOn;
X	   tw->command.set = TRUE;
X	   tw->label.normal_GC = tw->command.inverse_GC;
X	}
XXClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0, TRUE);
X/*	(tw->core.widget_class->core_class.expose)(w, event, NULL);*/
X}
X
X/* ARGSUSED */
Xstatic void Notify(w,event,params,num_params)
XWidget w;
XXEvent *event;
XString *params;		/* unused */
XCardinal *num_params;		/* unused */
X{
X	ToggleWidget tw = (ToggleWidget)w;
X	if (tw->command.callbacks != NULL)
X         XtCallCallbacks(w, XtNcallback, tw->toggle.state);
X	(tw->core.widget_class->core_class.expose)(w, event, NULL);
X}
X
X/* ARGSUSED */
Xstatic void Highlight(w,event,params,num_params)
XWidget w;
XXEvent *event;
XString *params;		/* unused */
XCardinal *num_params;	/* unused */
X{
X	ToggleWidget tw = (ToggleWidget)w;
X
X	if (tw->command.set == FALSE)  {
X	   tw->command.highlighted = TRUE;
X	   (tw->core.widget_class->core_class.expose)(w, event,
X		 HighlightRegion(tw));
X	}
X}
X
X/* ARGSUSED */
Xstatic void Unhighlight(w,event,params,num_params)
XWidget w;
XXEvent *event;
XString *params;		/* unused */
XCardinal *num_params;	/* unused */
X{
X	ToggleWidget tw = (ToggleWidget)w;
X
X	tw->command.highlighted = FALSE;
X	if (tw->command.set == FALSE) {
X	   (tw->core.widget_class->core_class.expose)(w, event,
X	   	HighlightRegion(tw));
X	}
X}
X
X
X/*
X * Set specified arguments into widget
X */
X/* ARGSUSED */
Xstatic Boolean SetValues (current, request, new)
XWidget current, request, new;
X{
X	ToggleWidget tw = (ToggleWidget)current;
X	ToggleWidget tnew = (ToggleWidget)new;
X
X	if (tnew->toggle.state != tw->toggle.state) {
X		/* the resource XtNstate is modified */
X	   tnew->command.set = !(tw->command.set);
X	}
X	else if (tnew->core.sensitive != tw->core.sensitive  
X		&& tnew->core.sensitive) {
X		/* the resource XtNsensitive is modified */
X	   tnew->command.set = (Boolean)tw->toggle.state;
X	}
X	else return FALSE;
X
X	if (tnew->toggle.state == XtToggleOn)
X	   tnew->label.normal_GC = tnew->command.inverse_GC;
X	else
X	   tnew->label.normal_GC = tnew->command.normal_GC;
X
X	return TRUE;
X}
END_OF_FILE
if test 8583 -ne `wc -c <'toggle.c'`; then
    echo shar: \"'toggle.c'\" unpacked with wrong size!
fi
# end of 'toggle.c'
fi
if test -f 'xfilebrowser.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfilebrowser.c'\"
else
echo shar: Extracting \"'xfilebrowser.c'\" \(8220 characters\)
sed "s/^X//" >'xfilebrowser.c' <<'END_OF_FILE'
X/* Systems Sciences Laboratory, Webster Research Center */
X
Xstatic char *PROGRAM_information[] =
X{
X    "Copyright (c) 1988 Xerox Corporation.  All rights reserved.",
X    "$Header$",
X    "$Locker$"
X}
X;
X
X/*
X * Copyright protection claimed includes all forms and matters of copyrightable
X * material and information now allowed by statutory or judicial lay or
X * herinafter granted, including without limitation, material generated from
X * the software programs which are displayed on the screen such as icons,
X * screen display looks, etc.
X */
X
X#include "xfilebrowser.h"
X#include "xbrowser.icon"
X
X
Xchar *filepattern;
Xchar *searchpattern;
Xchar *curdirectory;
Xchar *oldpattern;
Xchar *cmdline;
X
Xstruct afile **files = NULL;
XSearchElement **hitfiles = NULL;
Xint numfiles = 0;
Xint numhitfiles = 0;
Xint allowedit = 0;
X
XWidget toplevel;
XWidget outer;
XWidget Row1;
XWidget Row2;
XWidget Row3;
X
XWidget messwidget;	/* text widget for displaying messages */
XWidget dirwidget;	/* label widget for current directory */
XWidget listwidget;	/* text widget for directory listing */
XWidget grepwidget;	/* text widget for searched files */
X
XWidget quitbutton;	/* command button for quit */
XWidget listbutton;	/* command button for list */
XWidget editbutton;	/* command button for edit file selected
X			in directory listing */
XWidget parentdirbutton;	/* command button for selecting
X				parent directory */
XWidget shellbutton;	/* command button for invoking shell */
XWidget copybutton;	/* command button for invoking copy */
XWidget renamebutton;	/* command button for invoking rename */
XWidget deletebutton;	/* command button for invoking delete on files */
X
XWidget fpatwindow;	/* string box for providing the file pattern
X			used to list directories */
X
XWidget grepbutton;	/* command button for invoking grep on files */
XWidget grepwindow;	/* string box to specify the grep search pattern */
XWidget grepeditbutton;	/* command button for edit file selected
X			in list of searched files */
X
XDisplay *curdisplay;
XXtTextSource messsource, listsource, grepsource;
X
Xint viewEdit;
X
Xstatic XtResource resources[] = {
X   {"viewEdit", "ViewEdit", XtRBoolean, sizeof(int),
X         (Cardinal)&viewEdit, XtRString, "False"}
X};
X
XmakeButtonsAndBoxes()
X{
X	Cursor hand;
X	static XtTextSelectType listselect[] = {
X		XtselectLine, XtselectAll, XtselectNull, XtselectNull};
X
X	static Arg paneargs[] = {
X	   { XtNallowResize, (XtArgVal)True },
X	};
X	static Arg ListArgs[] = {
X	   { XtNtextSource, NULL },
X	   { XtNtextSink, NULL },
X         { XtNcursor, NULL },
X	   { XtNtextOptions , 
X		(XtArgVal)(scrollVertical | scrollHorizontal | resizeWidth) },
X	   { XtNselectTypes, (XtArgVal)listselect }, 
X	};
X	static Arg MessArgs[] = {
X	   { XtNtextSource, NULL },
X	   { XtNtextSink, NULL },
X	   { XtNtextOptions, (XtArgVal)(scrollVertical | wordBreak) },
X	};
X	static Arg labelArgs[] = {
X	   { XtNjustify, (XtArgVal)XtJustifyCenter },
X	   { XtNlabel, 	NULL },
X	};
X	static Arg grepArgs[] = {
X	   { XtNtextSource, NULL },
X	   { XtNtextSink, NULL },
X         { XtNcursor, NULL },
X	   { XtNtextOptions , 
X		(XtArgVal)(scrollVertical | scrollHorizontal | resizeWidth) },
X	   { XtNselectTypes, (XtArgVal)listselect }, 
X	}; 
X
X
X	outer = XtCreateManagedWidget( "vpaned", vPanedWidgetClass, toplevel,
X                                  paneargs , XtNumber(paneargs) );
X	XtPanedSetRefigureMode(outer, FALSE);
X
X	/* create first row */
X	Row1 = XtCreateManagedWidget("row1", boxWidgetClass, outer, NULL,0);
X	quitbutton 	= makeCommandButton(Row1, "Quit", DoQuit);
X	listbutton 	= makeCommandButton(Row1, "List", DoList);
X	ModCommand_Init(listbutton);
X
X	editbutton 	= makeCommandButton(Row1, "View/Edit", DoEdit);
X	ModCommand_Init(editbutton);
X	parentdirbutton = makeCommandButton(Row1, "Parent", DoParent);
X	ModCommand_Init(parentdirbutton);
X	shellbutton 	= makeCommandButton(Row1, "Shell", DoShell);
X	ModCommand_Init(shellbutton);
X
X	copybutton 	= makeCommandButton(Row1, "Copy", DoCopy);
X	renamebutton 	= makeCommandButton(Row1, "Move", DoRename);
X	deletebutton 	= makeCommandButton(Row1, "Delete", DoDelete);
X
X	/* create second row */
X	Row2 = XtCreateManagedWidget("row2", boxWidgetClass, outer, NULL,0);
X	fpatwindow = makeStringBox(Row2, filepattern, 254);
X
X	/* create label for current directory */
X	labelArgs[1].value = (XtArgVal)curdirectory;
X	dirwidget = XtCreateManagedWidget("labelWindow",labelWidgetClass, 
X		outer, labelArgs, XtNumber(labelArgs)); 
X	XtPanedSetMinMax((Widget)dirwidget, 14, 14);
X
X	/* create message window */
X	messsource = TCreateApAsSource();
X	MessArgs[0].value = (XtArgVal)messsource;
X	MessArgs[1].value = (XtArgVal)XtAsciiSinkCreate(outer, NULL, 0);
X	messwidget =  XtCreateManagedWidget("messageWindow",
X		textWidgetClass, outer, MessArgs, XtNumber(MessArgs));
X	XtPanedSetMinMax((Widget) messwidget, 40, 40);
X
X		/* create cursor hand */
X	hand = XCreateFontCursor(curdisplay, XC_hand1);
X
X	/* create text for displaying directory listings */
X	listsource = TCreateApAsSource();
X	ListArgs[0].value = (XtArgVal)listsource;
X	ListArgs[1].value = (XtArgVal)XtAsciiSinkCreate(outer, NULL, 0);
X	ListArgs[2].value = (XtArgVal)hand;
X	listwidget =  XtCreateManagedWidget("listWindow", 
X		textWidgetClass, outer, ListArgs, XtNumber(ListArgs));
X	XtPanedSetMinMax((Widget) listwidget, 250, 65535);
X	Modtext_Init(listwidget);
X
X	/* create third row */
X	Row3 = XtCreateManagedWidget("row3", boxWidgetClass, outer, NULL,0);
X	grepeditbutton 	= makeCommandButton(Row3, "View/Edit", DoGrepEdit);
X	ModCommand_Init(grepeditbutton);
X	grepbutton 	= makeCommandButton(Row3, "Grep", DoGrep);
X	ModCommand_Init(grepbutton);
X	grepwindow 	= makeStringBox(Row3, searchpattern, 120);
X
X	/* create text for displaying directory listings */
X	grepsource = TCreateApAsSource();
X	grepArgs[0].value = (XtArgVal)grepsource;
X	grepArgs[1].value = (XtArgVal)XtAsciiSinkCreate(outer, NULL, 0);
X	grepArgs[2].value = (XtArgVal)hand;
X	grepwidget =  XtCreateManagedWidget("grepWindow", 
X		textWidgetClass, outer, grepArgs, XtNumber(grepArgs));
X	XtPanedSetMinMax((Widget) grepwidget, 150, 65535);
X	Modtext_Init(grepwidget);
X
X	{
X	   static Dimension boxHeight;
X	   static Arg getargs[] = {
X		{ XtNheight, (XtArgVal)&boxHeight }
X	   };
X
X	XtGetValues(quitbutton, getargs, XtNumber(getargs));
X	boxHeight += 8;
X	XtPanedSetMinMax((Widget) Row1, boxHeight, 65535);
X	XtPanedSetMinMax((Widget) Row2, boxHeight, 65535);
X	XtPanedSetMinMax((Widget) Row3, boxHeight, 65535);
X	}
X
X	XtPanedSetRefigureMode(outer, TRUE); 
X}
X
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X	char *cwd;
X	Pixmap icon;
X	Arg iconargs[1];
X   
X	static Dimension width, height;
X 	static Arg args[]={
X	   {XtNwidth, (XtArgVal) &width},
X	   {XtNheight, (XtArgVal)&height} };
X	static Arg setargs[]={
X         {XtNwidth, 500},
X         {XtNheight,700} };
X
X	filepattern = XtMalloc(255);
X	searchpattern = XtMalloc(255);
X	curdirectory = XtMalloc(255);
X	oldpattern = XtMalloc(64);
X	cmdline = XtCalloc(1024, 1);
X
X	toplevel = XtInitialize( "xbrowser", "XBrowser", 
X		NULL, 0, &argc, argv);
X	XtGetValues(toplevel, args, XtNumber(args));
X	if(!width || !height){
X	   XtSetValues(toplevel, setargs, XtNumber(setargs));
X	}
X
X	XtGetApplicationResources(toplevel, 0, resources,
X                                  XtNumber(resources),NULL, 0);
X	curdisplay = XtDisplay(toplevel);
X
X	if ( (cwd = getcwd((char *)NULL, 255)) == (char *)NULL)
X         XtError("\nxbrowser: cannot get current directory");
X
X	if (argv[1]) {
X	   strcpy(curdirectory, cwd);
X	   get_dirpat(argv[1], curdirectory, filepattern);
X	}
X      else get_dirpat(cwd, curdirectory, filepattern);
X
X	strcpy(oldpattern, filepattern);
X	reset_ownercache();
X
X	makeButtonsAndBoxes();
X
X	XtRealizeWidget(toplevel);
X	XDefineCursor( XtDisplay(toplevel), XtWindow(toplevel),
X		XCreateFontCursor(XtDisplay(toplevel), XC_left_ptr) );
X	setup_iconname();
X
X	/* define icon pixmap */
X	icon = XCreateBitmapFromData(curdisplay, 
X			DefaultRootWindow(curdisplay),
X			xbrowser_bits,
X			xbrowser_width,
X			xbrowser_height);
X	XtSetArg(iconargs[0], XtNiconPixmap, (XtArgVal)icon);
X	XtSetValues(toplevel, iconargs, XtNumber(iconargs));
X
X	create_log(); /* create log window; it must be created before
X			the popup window for the list options; otherwise
X			it does not create the scrollbar correctly;
X			I have no idea why */
X
X	XtMainLoop();
X}
X
END_OF_FILE
if test 8220 -ne `wc -c <'xfilebrowser.c'`; then
    echo shar: \"'xfilebrowser.c'\" unpacked with wrong size!
fi
# end of 'xfilebrowser.c'
fi
echo shar: End of archive 2 \(of 3\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x