help.c revision 1abf7346
11abf7346Smrg/* $XConsortium: help.c,v 1.10 94/04/17 20:43:53 dave Exp $ */
21abf7346Smrg/*
31abf7346Smrg
41abf7346SmrgCopyright (c) 1987, 1988  X Consortium
51abf7346Smrg
61abf7346SmrgPermission is hereby granted, free of charge, to any person obtaining
71abf7346Smrga copy of this software and associated documentation files (the
81abf7346Smrg"Software"), to deal in the Software without restriction, including
91abf7346Smrgwithout limitation the rights to use, copy, modify, merge, publish,
101abf7346Smrgdistribute, sublicense, and/or sell copies of the Software, and to
111abf7346Smrgpermit persons to whom the Software is furnished to do so, subject to
121abf7346Smrgthe following conditions:
131abf7346Smrg
141abf7346SmrgThe above copyright notice and this permission notice shall be included
151abf7346Smrgin all copies or substantial portions of the Software.
161abf7346Smrg
171abf7346SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
181abf7346SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
191abf7346SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
201abf7346SmrgIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
211abf7346SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
221abf7346SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
231abf7346SmrgOTHER DEALINGS IN THE SOFTWARE.
241abf7346Smrg
251abf7346SmrgExcept as contained in this notice, the name of the X Consortium shall
261abf7346Smrgnot be used in advertising or otherwise to promote the sale, use or
271abf7346Smrgother dealings in this Software without prior written authorization
281abf7346Smrgfrom the X Consortium.
291abf7346Smrg
301abf7346Smrg*/
311abf7346Smrg/* $XFree86$ */
321abf7346Smrg
331abf7346Smrg/*
341abf7346Smrg * xman - X window system manual page display program.
351abf7346Smrg * Author:    Chris D. Peterson, MIT Project Athena
361abf7346Smrg * Created:   January 19, 1988
371abf7346Smrg */
381abf7346Smrg
391abf7346Smrg#include "globals.h"
401abf7346Smrg
411abf7346Smrgextern Atom wm_delete_window;	/* in main.c */
421abf7346Smrg
431abf7346Smrg/*	Function Name: MakeHelpWidget.
441abf7346Smrg *	Description: This function creates the help widget so that it will be
451abf7346Smrg *                   ready to be displayed.
461abf7346Smrg *	Arguments: none.
471abf7346Smrg *	Returns: none.
481abf7346Smrg */
491abf7346Smrg
501abf7346SmrgBoolean
511abf7346SmrgMakeHelpWidget(void)
521abf7346Smrg{
531abf7346Smrg
541abf7346Smrg  ManpageGlobals * man_globals;	/* The psuedo global structure. */
551abf7346Smrg
561abf7346Smrg  if (help_widget != NULL)	/* If we already have a help widget.
571abf7346Smrg				   then do not create one. */
581abf7346Smrg    return(TRUE);
591abf7346Smrg
601abf7346Smrg  man_globals = InitPsuedoGlobals();
611abf7346Smrg
621abf7346Smrg  CreateManpageWidget(man_globals, HELPNAME, FALSE);
631abf7346Smrg  help_widget = man_globals->This_Manpage;
641abf7346Smrg
651abf7346Smrg  if (OpenHelpfile(man_globals) == FALSE) {
661abf7346Smrg    XtDestroyWidget(help_widget);
671abf7346Smrg    help_widget = NULL;
681abf7346Smrg    return(FALSE);
691abf7346Smrg  }
701abf7346Smrg
711abf7346Smrg  ChangeLabel(man_globals->label, "Xman Help");
721abf7346Smrg
731abf7346Smrg  XtManageChild( man_globals->manpagewidgets.manpage );
741abf7346Smrg  XtRealizeWidget(  help_widget );
751abf7346Smrg  SaveGlobals( man_globals->This_Manpage, man_globals );
761abf7346Smrg  AddCursor( help_widget, resources.cursors.manpage);
771abf7346Smrg
781abf7346Smrg/*
791abf7346Smrg * Set up ICCCM delete window.
801abf7346Smrg */
811abf7346Smrg  XtOverrideTranslations
821abf7346Smrg      (man_globals->This_Manpage,
831abf7346Smrg       XtParseTranslationTable ("<Message>WM_PROTOCOLS: RemoveThisManpage()"));
841abf7346Smrg  (void) XSetWMProtocols (XtDisplay(man_globals->This_Manpage),
851abf7346Smrg			  XtWindow(man_globals->This_Manpage),
861abf7346Smrg			  &wm_delete_window, 1);
871abf7346Smrg
881abf7346Smrg  return(TRUE);
891abf7346Smrg}
901abf7346Smrg
911abf7346Smrg/*	Function Name: OpenHelpfile
921abf7346Smrg *	Description: opens the helpfile.
931abf7346Smrg *	Arguments: man_globals - the psuedo globals structure.
941abf7346Smrg *	Returns: False if no helpfile was found.
951abf7346Smrg */
961abf7346Smrg
971abf7346SmrgBoolean
981abf7346SmrgOpenHelpfile(ManpageGlobals * man_globals)
991abf7346Smrg{
1001abf7346Smrg  FILE * help_file_ptr;
1011abf7346Smrg
1021abf7346Smrg  if( (help_file_ptr = fopen(resources.help_file, "r")) == NULL ) {
1031abf7346Smrg    PopupWarning(man_globals,
1041abf7346Smrg		 "Could not open help file, NO HELP WILL BE AVALIABLE.");
1051abf7346Smrg    return(FALSE);
1061abf7346Smrg  }
1071abf7346Smrg
1081abf7346Smrg  OpenFile(man_globals, help_file_ptr);
1091abf7346Smrg  return(TRUE);
1101abf7346Smrg}
111