help.c revision 1abf7346
1/* $XConsortium: help.c,v 1.10 94/04/17 20:43:53 dave Exp $ */
2/*
3
4Copyright (c) 1987, 1988  X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining
7a copy of this software and associated documentation files (the
8"Software"), to deal in the Software without restriction, including
9without limitation the rights to use, copy, modify, merge, publish,
10distribute, sublicense, and/or sell copies of the Software, and to
11permit persons to whom the Software is furnished to do so, subject to
12the following conditions:
13
14The above copyright notice and this permission notice shall be included
15in all copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
21OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23OTHER DEALINGS IN THE SOFTWARE.
24
25Except as contained in this notice, the name of the X Consortium shall
26not be used in advertising or otherwise to promote the sale, use or
27other dealings in this Software without prior written authorization
28from the X Consortium.
29
30*/
31/* $XFree86$ */
32
33/*
34 * xman - X window system manual page display program.
35 * Author:    Chris D. Peterson, MIT Project Athena
36 * Created:   January 19, 1988
37 */
38
39#include "globals.h"
40
41extern Atom wm_delete_window;	/* in main.c */
42
43/*	Function Name: MakeHelpWidget.
44 *	Description: This function creates the help widget so that it will be
45 *                   ready to be displayed.
46 *	Arguments: none.
47 *	Returns: none.
48 */
49
50Boolean
51MakeHelpWidget(void)
52{
53
54  ManpageGlobals * man_globals;	/* The psuedo global structure. */
55
56  if (help_widget != NULL)	/* If we already have a help widget.
57				   then do not create one. */
58    return(TRUE);
59
60  man_globals = InitPsuedoGlobals();
61
62  CreateManpageWidget(man_globals, HELPNAME, FALSE);
63  help_widget = man_globals->This_Manpage;
64
65  if (OpenHelpfile(man_globals) == FALSE) {
66    XtDestroyWidget(help_widget);
67    help_widget = NULL;
68    return(FALSE);
69  }
70
71  ChangeLabel(man_globals->label, "Xman Help");
72
73  XtManageChild( man_globals->manpagewidgets.manpage );
74  XtRealizeWidget(  help_widget );
75  SaveGlobals( man_globals->This_Manpage, man_globals );
76  AddCursor( help_widget, resources.cursors.manpage);
77
78/*
79 * Set up ICCCM delete window.
80 */
81  XtOverrideTranslations
82      (man_globals->This_Manpage,
83       XtParseTranslationTable ("<Message>WM_PROTOCOLS: RemoveThisManpage()"));
84  (void) XSetWMProtocols (XtDisplay(man_globals->This_Manpage),
85			  XtWindow(man_globals->This_Manpage),
86			  &wm_delete_window, 1);
87
88  return(TRUE);
89}
90
91/*	Function Name: OpenHelpfile
92 *	Description: opens the helpfile.
93 *	Arguments: man_globals - the psuedo globals structure.
94 *	Returns: False if no helpfile was found.
95 */
96
97Boolean
98OpenHelpfile(ManpageGlobals * man_globals)
99{
100  FILE * help_file_ptr;
101
102  if( (help_file_ptr = fopen(resources.help_file, "r")) == NULL ) {
103    PopupWarning(man_globals,
104		 "Could not open help file, NO HELP WILL BE AVALIABLE.");
105    return(FALSE);
106  }
107
108  OpenFile(man_globals, help_file_ptr);
109  return(TRUE);
110}
111