11abf7346Smrg/*
21abf7346Smrg
31abf7346SmrgCopyright (c) 1987, 1988  X Consortium
41abf7346Smrg
51abf7346SmrgPermission is hereby granted, free of charge, to any person obtaining
61abf7346Smrga copy of this software and associated documentation files (the
71abf7346Smrg"Software"), to deal in the Software without restriction, including
81abf7346Smrgwithout limitation the rights to use, copy, modify, merge, publish,
91abf7346Smrgdistribute, sublicense, and/or sell copies of the Software, and to
101abf7346Smrgpermit persons to whom the Software is furnished to do so, subject to
111abf7346Smrgthe following conditions:
121abf7346Smrg
131abf7346SmrgThe above copyright notice and this permission notice shall be included
141abf7346Smrgin all copies or substantial portions of the Software.
151abf7346Smrg
161abf7346SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
171abf7346SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
181abf7346SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
191abf7346SmrgIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
201abf7346SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
211abf7346SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
221abf7346SmrgOTHER DEALINGS IN THE SOFTWARE.
231abf7346Smrg
241abf7346SmrgExcept as contained in this notice, the name of the X Consortium shall
251abf7346Smrgnot be used in advertising or otherwise to promote the sale, use or
261abf7346Smrgother dealings in this Software without prior written authorization
271abf7346Smrgfrom the X Consortium.
281abf7346Smrg
291abf7346Smrg*/
301abf7346Smrg
311abf7346Smrg/*
321abf7346Smrg * xman - X window system manual page display program.
331abf7346Smrg * Author:    Chris D. Peterson, MIT Project Athena
341abf7346Smrg * Created:   January 19, 1988
351abf7346Smrg */
361abf7346Smrg
371abf7346Smrg#include "globals.h"
381abf7346Smrg
391abf7346Smrg/*	Function Name: MakeHelpWidget.
401abf7346Smrg *	Description: This function creates the help widget so that it will be
411abf7346Smrg *                   ready to be displayed.
421abf7346Smrg *	Arguments: none.
431abf7346Smrg *	Returns: none.
441abf7346Smrg */
451abf7346Smrg
461abf7346SmrgBoolean
471abf7346SmrgMakeHelpWidget(void)
481abf7346Smrg{
491abf7346Smrg
506d36ef34Smrg    ManpageGlobals *man_globals;        /* The pseudo global structure. */
511abf7346Smrg
526d36ef34Smrg    if (help_widget != NULL)    /* If we already have a help widget.
536d36ef34Smrg                                   then do not create one. */
546d36ef34Smrg        return (TRUE);
551abf7346Smrg
566d36ef34Smrg    man_globals = InitPsuedoGlobals();
576d36ef34Smrg    if (man_globals == NULL)
586d36ef34Smrg        return (FALSE);
591abf7346Smrg
606d36ef34Smrg    CreateManpageWidget(man_globals, HELPNAME, FALSE);
616d36ef34Smrg    help_widget = man_globals->This_Manpage;
621abf7346Smrg
636d36ef34Smrg    if (OpenHelpfile(man_globals) == FALSE) {
646d36ef34Smrg        XtDestroyWidget(help_widget);
656d36ef34Smrg        help_widget = NULL;
666d36ef34Smrg        return (FALSE);
676d36ef34Smrg    }
681abf7346Smrg
696d36ef34Smrg    ChangeLabel(man_globals->label, "Xman Help");
706d36ef34Smrg
716d36ef34Smrg    XtManageChild(man_globals->manpagewidgets.manpage);
726d36ef34Smrg    XtRealizeWidget(help_widget);
736d36ef34Smrg    SaveGlobals(man_globals->This_Manpage, man_globals);
746d36ef34Smrg    AddCursor(help_widget, resources.cursors.manpage);
751abf7346Smrg
761abf7346Smrg/*
771abf7346Smrg * Set up ICCCM delete window.
781abf7346Smrg */
796d36ef34Smrg    XtOverrideTranslations
806d36ef34Smrg        (man_globals->This_Manpage,
816d36ef34Smrg         XtParseTranslationTable("<Message>WM_PROTOCOLS: RemoveThisManpage()"));
826d36ef34Smrg    (void) XSetWMProtocols(XtDisplay(man_globals->This_Manpage),
836d36ef34Smrg                           XtWindow(man_globals->This_Manpage),
846d36ef34Smrg                           &wm_delete_window, 1);
856d36ef34Smrg
866d36ef34Smrg    return (TRUE);
871abf7346Smrg}
881abf7346Smrg
891abf7346Smrg/*	Function Name: OpenHelpfile
901abf7346Smrg *	Description: opens the helpfile.
916d36ef34Smrg *	Arguments: man_globals - the pseudo globals structure.
921abf7346Smrg *	Returns: False if no helpfile was found.
931abf7346Smrg */
941abf7346Smrg
951abf7346SmrgBoolean
961abf7346SmrgOpenHelpfile(ManpageGlobals * man_globals)
971abf7346Smrg{
986d36ef34Smrg    FILE *help_file_ptr;
996d36ef34Smrg
1006d36ef34Smrg    if ((help_file_ptr = fopen(resources.help_file, "r")) == NULL) {
1016d36ef34Smrg        PopupWarning(man_globals,
1026d36ef34Smrg                     "Could not open help file, NO HELP WILL BE AVAILABLE.");
1036d36ef34Smrg        return (FALSE);
1046d36ef34Smrg    }
1056d36ef34Smrg
1066d36ef34Smrg    OpenFile(man_globals, help_file_ptr);
1076d36ef34Smrg    return (TRUE);
1081abf7346Smrg}
109