Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtsession / SmHelp.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: SmHelp.c /main/4 1995/10/30 09:35:21 rswiston $ */
24 /*                                                                      *
25  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
26  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
27  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
28  * (c) Copyright 1993, 1994 Novell, Inc.                                *
29  */
30
31 /*************************************<+>*************************************
32  *****************************************************************************
33  **
34  **  File:        SmHelp.c
35  **
36  **  Project:     HP DT Session Manager (dtsession)
37  **
38  **  Description:
39  **  -----------
40  **  This module is in charge of all interaction between the session
41  **  manager and the help subsystem.  Anytime the user requests help,
42  **  it goes through this routine.
43  **
44  **
45  **
46  *******************************************************************
47  **  (c) Copyright Hewlett-Packard Company, 1990.  All rights are  
48  **  reserved.  Copying or other reproduction of this program      
49  **  except for archival purposes is prohibited without prior      
50  **  written consent of Hewlett-Packard Company.                     
51  ********************************************************************
52  **
53  **
54  **
55  *****************************************************************************
56  *************************************<+>*************************************/
57
58 #include <stdio.h>
59 #include <X11/Intrinsic.h>
60 #include <X11/Shell.h>
61 #include <Xm/Xm.h>
62 #include <Xm/MwmUtil.h>
63 #include <Dt/HelpQuickD.h>
64
65 #include "Sm.h"
66 #include "SmUI.h"
67 #include "SmHelp.h"
68 #include "SmGlobals.h"
69
70 #ifdef __apollo
71 #include <X11/apollosys.h>
72 #endif  /* __apollo */
73
74
75 /*
76  * #define statements
77  */
78
79 /*
80  * Global variables
81  */
82
83
84 /*
85  * Local Function Declarations
86  */
87
88 static void CloseHelpDialog (Widget, XtPointer, XtPointer);
89
90
91 \f
92 /*************************************<->*************************************
93  *
94  *  TopicHelpRequested ()
95  *
96  *
97  *  Description:
98  *  -----------
99  *  When a user requests help on a given topic - display that topic in a
100  *  new or cached help dialog
101  *
102  *
103  *  Inputs:
104  *  ------
105  *  client_data - the id that is sent to Cache Creek which tells it which
106  *              topic to display
107  *
108  * 
109  *  Outputs:
110  *  -------
111  *  None.
112  *
113  *
114  *  Comments:
115  *  --------
116  * 
117  *************************************<->***********************************/
118 void 
119 TopicHelpRequested(
120         Widget w,
121         XtPointer client_data,
122         XtPointer call_data )
123 {
124     int           i;
125
126     char          *locationId = (char *) client_data;
127     Widget        transientShell;
128     Arg         setArgs2[5];
129     int         n2;
130     Widget printButton = NULL;
131     Widget helpButton = NULL;
132     Widget backButton = NULL;
133     Widget okButton = NULL;
134
135     /*
136      * Find the shell to make this a transient for for
137      */
138     transientShell = w;
139     while(!XtIsSubclass(transientShell, shellWidgetClass))
140     {
141         transientShell = XtParent(transientShell);
142     }
143
144     if((smDD.smHelpDialog != NULL) && 
145        (XtIsManaged(smDD.smHelpDialog)))
146     {
147         return ;
148     }
149
150
151     /*
152      * Use the help dialog already created if it has been - otherwise
153      * create it
154      */
155     if (smDD.smHelpDialog != NULL)
156     {
157         i = 0;
158         XtSetArg(uiArgs[i], DtNlocationId,locationId);          i++;
159         XtSetValues(smDD.smHelpDialog, uiArgs, i);
160
161         i = 0;
162         XtSetArg(uiArgs[i], XmNtransientFor, transientShell);  i++;
163         XtSetValues(XtParent(smDD.smHelpDialog), uiArgs, i);
164   
165         XtManageChild(smDD.smHelpDialog);
166     }
167     else
168     {
169         i = 0;
170         XtSetArg(uiArgs[i], XmNtitle, GETMESSAGE(29, 1,
171           "Session Manager Help"));  i++;
172         XtSetArg (uiArgs[i],DtNhelpVolume, SM_HELP_VOLUME);     i++; 
173         XtSetArg (uiArgs[i],DtNhelpType, DtHELP_TYPE_TOPIC);     i++; 
174         XtSetArg (uiArgs[i], DtNlocationId,locationId);        i++;
175         smDD.smHelpDialog =  DtCreateHelpQuickDialog(smGD.topLevelWid,
176                                                       "helpWidget", uiArgs, i);
177
178         i = 0;
179         XtSetArg(uiArgs[i], XmNtransientFor, transientShell);  i++;
180         XtSetValues(XtParent(smDD.smHelpDialog), uiArgs, i);
181         
182         
183         XtAddCallback(smDD.smHelpDialog, DtNcloseCallback,
184                       CloseHelpDialog, NULL);
185
186         okButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
187                                           DtHELP_QUICK_CLOSE_BUTTON );
188         n2=0;
189         XtSetArg (setArgs2[n2], XmNlabelString, smDD.okString);    n2++;
190         XtSetValues(okButton, setArgs2, n2);
191
192         printButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
193                                              DtHELP_QUICK_PRINT_BUTTON );
194         helpButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
195                                             DtHELP_QUICK_HELP_BUTTON );
196         backButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
197                                             DtHELP_QUICK_BACK_BUTTON );
198         XtUnmanageChild(printButton);
199         XtUnmanageChild(helpButton);
200         XtUnmanageChild(backButton);
201         
202         XtAddCallback (XtParent(smDD.smHelpDialog), XmNpopupCallback,
203                        DialogUp, NULL);
204
205         XtManageChild(smDD.smHelpDialog);
206     }
207 }
208
209
210 \f
211 /*************************************<->*************************************
212  *
213  *  CloseHelpDialog ()
214  *
215  *
216  *  Description:
217  *  -----------
218  *  This callback is called when the user wishes to dismiss the help callback
219  *
220  *
221  *  Inputs:
222  *  ------
223  *  
224  * 
225  *  Outputs:
226  *  -------
227  *
228  *
229  *  Comments:
230  *  --------
231  * 
232  *************************************<->***********************************/
233 static void
234 CloseHelpDialog (Widget w,
235                  XtPointer clientData,
236                  XtPointer callData)
237 {
238     XtUnmanageChild(smDD.smHelpDialog);
239 }