home *** CD-ROM | disk | FTP | other *** search
- /* Systems Sciences Laboratory, Webster Research Center */
-
- static char *PROGRAM_information[] =
- {
- "Copyright (c) 1988 Xerox Corporation. All rights reserved.",
- "$Header$",
- "$Locker$"
- }
- ;
-
- /*
- * Copyright protection claimed includes all forms and matters of copyrightable
- * material and information now allowed by statutory or judicial lay or
- * herinafter granted, including without limitation, material generated from
- * the software programs which are displayed on the screen such as icons,
- * screen display looks, etc.
- */
-
- #include "xfilebrowser.h"
-
- Widget confirmwidget = NULL;
- static Widget confirmshell = NULL;
- static Widget extpromptwidget = NULL; /* specifies the form widget
- in case a prompt with toggle was created */
- static Widget extoutwidget;
- static Widget extdiagwidget;
-
- static Widget logshell = NULL;
- static Widget loglabel;
- static Widget logpane;
- static Widget logbox;
- static Widget logtext;
-
- static short disp_prompt = 0;
-
- check_confirm()
- {
- return disp_prompt;
- }
-
- check_prompt()
- {
- return disp_prompt;
- }
-
-
-
- /* ARGSUSED */
- change_sensitive(w, value)
- Widget w;
- Boolean value;
- {
- XtSetSensitive(listbutton, value);
- XtSetSensitive(editbutton, value);
- XtSetSensitive(parentdirbutton, value);
- XtSetSensitive(renamebutton, value);
- XtSetSensitive(deletebutton, value);
- XtSetSensitive(shellbutton, value);
- XtSetSensitive(copybutton, value);
- XtSetSensitive(grepbutton, value);
- XtSetSensitive(grepeditbutton, value);
- }
-
- /* ARGSUSED */
- confirmyes(w, client_data, call_data)
- Widget w;
- caddr_t client_data, call_data;
- {
- DialogData *data = (DialogData *)client_data;
-
- destroyconfirm(data, (*data->yes));
- }
-
- /* ARGSUSED */
- confirmno(w, client_data, call_data)
- Widget w;
- caddr_t client_data, call_data;
- {
- DialogData *data = (DialogData *)client_data;
-
- destroyconfirm(data, (*data->no));
- }
-
- /* ARGSUSED */
- confirmcancel(w, client_data, call_data)
- Widget w;
- caddr_t client_data, call_data;
- {
- DialogData *data = (DialogData *)client_data;
-
- destroyconfirm(data, (*data->cancel));
- }
-
- /* ARGSUSED */
- destroyconfirm(data, func)
- DialogData *data;
- int (*func)();
- {
- change_sensitive(data->w, TRUE);
- XtPopdown(confirmshell);
- disp_prompt = 0;
-
- extpromptwidget = NULL;
- XtDestroyWidget(confirmshell);
- confirmshell = NULL;
- /* I tried to reuse the previous popup shell for new
- dialog widgets; but after the first use the dialog buttons
- of my dialog widget were never displayed; it displayed
- only the label of the dialog box */
-
- func(data);
- }
-
- int move_popup(w, caller)
- Widget w, caller;
- {
- Dimension widthw, heightw;
- Position callerx, callery;
- int wx, wy;
- Window parentcaller, child;
- Screen *screen;
-
- getsize(w, &widthw, &heightw);
- getpos(caller, &callerx, &callery);
- parentcaller = XtWindow(XtParent(caller));
- screen = XtScreen(caller);
- if (XTranslateCoordinates(curdisplay, parentcaller, screen->root,
- (int)callerx, (int)callery, &wx, &wy, &child) == BadWindow)
- return(-1);
- wx += 5; wy += 5;
-
- if ( (wx + widthw) >= screen->width)
- wx = screen->width - widthw - 10;
- if ( (wy + heightw) >= screen->height)
- wy = screen->height - heightw - 10;
-
- XtMoveWidget(w, (Position)wx, (Position)wy);
- return(0);
- }
-
- /* ARGSUSED */
- int position_dialog(dialog, caller)
- Widget dialog, caller;
- {
- XtSetMappedWhenManaged(dialog, FALSE);
- XtRealizeWidget(dialog);
-
- move_popup(dialog, caller);
-
- change_sensitive(caller, FALSE);
- XtMapWidget(dialog);
- return(0);
- }
-
- /* ARGSUSED */
- int create_confirm(data, str)
- DialogData *data;
- char *str;
- {
- Arg args[1];
- Arg popargs[1];
-
- if (disp_prompt) return(-1);
-
- disp_prompt = 1;
- XtSetArg( popargs[0], XtNborderWidth, 2 );
-
-
- confirmshell = XtCreatePopupShell("popupshell",
- overrideShellWidgetClass,
- toplevel, popargs, XtNumber(popargs));
-
- XtSetArg( args[0], XtNlabel, str );
-
- confirmwidget = XtCreateManagedWidget("confirm", dialogWidgetClass,
- confirmshell, args, XtNumber(args) );
- XtDialogAddButton(confirmwidget, "yes", confirmyes, (caddr_t)data);
- XtDialogAddButton(confirmwidget, "no", confirmno, (caddr_t)data);
- XtDialogAddButton(confirmwidget, "cancel", confirmcancel, (caddr_t)data);
-
- if (position_dialog(confirmshell, data->w) == -1) {
- XtDestroyWidget(confirmshell);
- confirmwidget = NULL;
- confirmshell = NULL;
- }
- XtPopup(confirmshell, XtGrabNonexclusive);
- return(0);
- }
-
-
- /* ARGSUSED */
- promptok(w, client_data, call_data)
- Widget w;
- caddr_t client_data, call_data;
- {
- DialogData *data = (DialogData *)client_data;
- Arg togargs[1];
- XtState extstate;
-
- data->answer = XtDialogGetValueString(confirmwidget);
- if (extpromptwidget != NULL) {
- XtSetArg(togargs[0], XtNstate, (XtArgVal)&extstate);
- XtGetValues(extdiagwidget, togargs, (Cardinal)1);
- data->diag = (Boolean)extstate;
-
- XtSetArg(togargs[0], XtNstate, (XtArgVal)&extstate);
- XtGetValues(extoutwidget, togargs, (Cardinal)1);
- data->out = (Boolean)extstate;
- }
- else data->diag = data->out = FALSE;
-
- destroyconfirm(data, (*data->yes));
- }
-
- /* ARGSUSED */
- promptcancel(w, client_data, call_data)
- Widget w;
- caddr_t client_data, call_data;
- {
- DialogData *data = (DialogData *)client_data;
-
- destroyconfirm(data, (*data->cancel));
- }
-
- /* ARGSUSED */
- int create_prompt(data, str, defvalue)
- DialogData *data;
- char *str, *defvalue;
- {
- Arg args[2];
- Arg popargs[1];
-
- if (disp_prompt) return(-1);
- disp_prompt = 1;
-
- XtSetArg( popargs[0], XtNborderWidth, 2 );
-
- /* confirmshell = XtCreatePopupShell("promptshell",
- transientShellWidgetClass,
- toplevel, popargs, XtNumber(popargs));*/
- confirmshell = XtCreatePopupShell("promptshell",
- topLevelShellWidgetClass,
- toplevel, popargs, XtNumber(popargs));
-
- XtSetArg( args[0], XtNlabel, str );
- XtSetArg( args[1], XtNvalue, defvalue );
-
- confirmwidget = XtCreateManagedWidget("confirm", dialogWidgetClass,
- confirmshell, args, XtNumber(args) );
- XtDialogAddButton(confirmwidget, "ok", promptok, (caddr_t)data);
- XtDialogAddButton(confirmwidget, "cancel", promptcancel, (caddr_t)data);
-
- if (position_dialog(confirmshell, data->w) == -1) {
- XtDestroyWidget(confirmshell);
- confirmwidget = NULL;
- confirmshell = NULL;
- }
- XtPopup(confirmshell, XtGrabNonexclusive);
- return(0);
- }
-
- /* ARGSUSED */
- /* creates a prompt window which contains a dialog widget as well as two
- * toggle widgets defining if the output/diagnostics should be returned
- */
- int create_toggleprompt(data, str, defvalue)
- DialogData *data;
- char *str, *defvalue;
- {
- Arg args[3];
- Arg popargs[1];
- Arg toggleargs[6];
-
- if (disp_prompt) return(-1);
- disp_prompt = 1;
-
- XtSetArg( popargs[0], XtNborderWidth, 2 );
-
- /* confirmshell = XtCreatePopupShell("toggleshell",
- transientShellWidgetClass,
- toplevel, popargs, XtNumber(popargs));*/
- confirmshell = XtCreatePopupShell("toggleshell",
- topLevelShellWidgetClass,
- toplevel, popargs, XtNumber(popargs));
- extpromptwidget = XtCreateManagedWidget("form", formWidgetClass,
- confirmshell, NULL, 0);
-
- XtSetArg( args[0], XtNlabel, str );
- XtSetArg( args[1], XtNvalue, defvalue );
- XtSetArg( args[2], XtNborderWidth, 0 );
-
- confirmwidget = XtCreateManagedWidget("confirm", dialogWidgetClass,
- extpromptwidget, args, XtNumber(args) );
- XtDialogAddButton(confirmwidget, "ok", promptok, (caddr_t)data);
- XtDialogAddButton(confirmwidget, "cancel", promptcancel, (caddr_t)data);
-
- /* create the two toggle buttons "Return Diagnostic"
- * and "Return Output" */
- XtSetArg( toggleargs[0], XtNfromVert, (XtArgVal)confirmwidget );
- XtSetArg( toggleargs[1], XtNfromHoriz, (XtArgVal)NULL);
- XtSetArg( toggleargs[2], XtNleft, (XtArgVal)XtChainLeft);
- XtSetArg( toggleargs[3], XtNright, (XtArgVal)XtChainLeft);
- XtSetArg( toggleargs[4], XtNstate, (XtArgVal)XtToggleOff );
- extoutwidget = XtCreateManagedWidget( "Return Output",
- toggleWidgetClass, extpromptwidget, toggleargs,
- XtNumber(toggleargs) - 1 );
-
- XtSetArg( toggleargs[0], XtNfromVert, (XtArgVal)confirmwidget );
- XtSetArg( toggleargs[1], XtNfromHoriz, (XtArgVal)extoutwidget );
- XtSetArg( toggleargs[2], XtNleft, (XtArgVal)XtChainLeft);
- XtSetArg( toggleargs[3], XtNright, (XtArgVal)XtChainLeft);
- XtSetArg( toggleargs[4], XtNstate, (XtArgVal)XtToggleOn);
- XtSetArg( toggleargs[5], XtNhorizDistance, (XtArgVal)20);
- extdiagwidget = XtCreateManagedWidget( "Return Diagnostic",
- toggleWidgetClass, extpromptwidget, toggleargs,
- XtNumber(toggleargs) );
-
- if (position_dialog(confirmshell, data->w) == -1) {
- XtDestroyWidget(confirmshell);
- confirmshell = NULL;
- extpromptwidget = NULL;
- }
- XtPopup(confirmshell, XtGrabNonexclusive);
- return(0);
- }
-
-
- /* ARGSUSED */
- logquit()
- {
- XtPopdown(logshell);
- XtSetSensitive(outer, TRUE);
- return;
- }
-
- create_log()
- {
- Arg popargs[1];
-
- static Arg textargs[] = {
- { XtNfile, (XtArgVal)"/dev/null"},
- { XtNeditType, (XtArgVal)XttextRead },
- { XtNtextOptions, (XtArgVal)(wordBreak | scrollVertical) },
- };
-
- static Arg labelargs[] = {
- { XtNjustify, (XtArgVal)XtJustifyCenter },
- { XtNlabel, NULL },
- };
-
-
- if (logshell != NULL) return;
- XtSetArg( popargs[0], XtNborderWidth, 2 );
-
- /* logshell = XtCreatePopupShell("logshell",
- transientShellWidgetClass,
- toplevel, popargs, XtNumber(popargs));*/
- logshell = XtCreatePopupShell("logshell",
- topLevelShellWidgetClass,
- toplevel, popargs, XtNumber(popargs));
-
- logpane = XtCreateManagedWidget("pane", vPanedWidgetClass,
- logshell, (ArgList)NULL, 0);
- logbox = XtCreateManagedWidget("box", boxWidgetClass,
- logpane, (ArgList)NULL,0);
- makeCommandButton(logbox, "Quit", logquit);
- loglabel = XtCreateManagedWidget("labelWindow",labelWidgetClass,
- logpane, labelargs, XtNumber(labelargs));
- logtext = XtCreateManagedWidget("data", asciiDiskWidgetClass,
- logpane, textargs, XtNumber(textargs));
-
- }
-
- /* ARGSUSED */
- log_popup(label, file)
- char *label, *file;
- {
- XtTextSource old, new;
-
- static Arg textargs[] = {
- { XtNfile, NULL},
- { XtNeditType, (XtArgVal)XttextRead },
- { XtNtextOptions, (XtArgVal)(wordBreak | scrollVertical) },
- };
-
- static Arg labelargs[] = {
- { XtNjustify, (XtArgVal)XtJustifyCenter },
- { XtNlabel, NULL },
- };
-
- textargs[0].value = (XtArgVal)file;
- labelargs[1].value = (XtArgVal)label;
-
-
- if (logshell == NULL) create_log();
- old = XtTextGetSource(logtext);
- new = XtDiskSourceCreate(logtext, textargs, XtNumber(textargs));
- XtTextSetSource(logtext, new, 0);
- XtDiskSourceDestroy(old);
- XtSetValues(loglabel, labelargs, XtNumber(labelargs));
-
- XtSetSensitive(outer, FALSE);
- XtPopup(logshell, XtGrabExclusive);
- return(0);
- }
-
-