Remove apollo support
[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 libraries 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 /*
71  * #define statements
72  */
73
74 /*
75  * Global variables
76  */
77
78
79 /*
80  * Local Function Declarations
81  */
82
83 static void CloseHelpDialog (Widget, XtPointer, XtPointer);
84
85
86 \f
87 /*************************************<->*************************************
88  *
89  *  TopicHelpRequested ()
90  *
91  *
92  *  Description:
93  *  -----------
94  *  When a user requests help on a given topic - display that topic in a
95  *  new or cached help dialog
96  *
97  *
98  *  Inputs:
99  *  ------
100  *  client_data - the id that is sent to Cache Creek which tells it which
101  *              topic to display
102  *
103  * 
104  *  Outputs:
105  *  -------
106  *  None.
107  *
108  *
109  *  Comments:
110  *  --------
111  * 
112  *************************************<->***********************************/
113 void 
114 TopicHelpRequested(
115         Widget w,
116         XtPointer client_data,
117         XtPointer call_data )
118 {
119     int           i;
120
121     char          *locationId = (char *) client_data;
122     Widget        transientShell;
123     Arg         setArgs2[5];
124     int         n2;
125     Widget printButton = NULL;
126     Widget helpButton = NULL;
127     Widget backButton = NULL;
128     Widget okButton = NULL;
129
130     /*
131      * Find the shell to make this a transient for for
132      */
133     transientShell = w;
134     while(!XtIsSubclass(transientShell, shellWidgetClass))
135     {
136         transientShell = XtParent(transientShell);
137     }
138
139     if((smDD.smHelpDialog != NULL) && 
140        (XtIsManaged(smDD.smHelpDialog)))
141     {
142         return ;
143     }
144
145
146     /*
147      * Use the help dialog already created if it has been - otherwise
148      * create it
149      */
150     if (smDD.smHelpDialog != NULL)
151     {
152         i = 0;
153         XtSetArg(uiArgs[i], DtNlocationId,locationId);          i++;
154         XtSetValues(smDD.smHelpDialog, uiArgs, i);
155
156         i = 0;
157         XtSetArg(uiArgs[i], XmNtransientFor, transientShell);  i++;
158         XtSetValues(XtParent(smDD.smHelpDialog), uiArgs, i);
159   
160         XtManageChild(smDD.smHelpDialog);
161     }
162     else
163     {
164         i = 0;
165         XtSetArg(uiArgs[i], XmNtitle, GETMESSAGE(29, 1,
166           "Session Manager Help"));  i++;
167         XtSetArg (uiArgs[i],DtNhelpVolume, SM_HELP_VOLUME);     i++; 
168         XtSetArg (uiArgs[i],DtNhelpType, DtHELP_TYPE_TOPIC);     i++; 
169         XtSetArg (uiArgs[i], DtNlocationId,locationId);        i++;
170         smDD.smHelpDialog =  DtCreateHelpQuickDialog(smGD.topLevelWid,
171                                                       "helpWidget", uiArgs, i);
172
173         i = 0;
174         XtSetArg(uiArgs[i], XmNtransientFor, transientShell);  i++;
175         XtSetValues(XtParent(smDD.smHelpDialog), uiArgs, i);
176         
177         
178         XtAddCallback(smDD.smHelpDialog, DtNcloseCallback,
179                       CloseHelpDialog, NULL);
180
181         okButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
182                                           DtHELP_QUICK_CLOSE_BUTTON );
183         n2=0;
184         XtSetArg (setArgs2[n2], XmNlabelString, smDD.okString);    n2++;
185         XtSetValues(okButton, setArgs2, n2);
186
187         printButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
188                                              DtHELP_QUICK_PRINT_BUTTON );
189         helpButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
190                                             DtHELP_QUICK_HELP_BUTTON );
191         backButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
192                                             DtHELP_QUICK_BACK_BUTTON );
193         XtUnmanageChild(printButton);
194         XtUnmanageChild(helpButton);
195         XtUnmanageChild(backButton);
196         
197         XtAddCallback (XtParent(smDD.smHelpDialog), XmNpopupCallback,
198                        DialogUp, NULL);
199
200         XtManageChild(smDD.smHelpDialog);
201     }
202 }
203
204
205 \f
206 /*************************************<->*************************************
207  *
208  *  CloseHelpDialog ()
209  *
210  *
211  *  Description:
212  *  -----------
213  *  This callback is called when the user wishes to dismiss the help callback
214  *
215  *
216  *  Inputs:
217  *  ------
218  *  
219  * 
220  *  Outputs:
221  *  -------
222  *
223  *
224  *  Comments:
225  *  --------
226  * 
227  *************************************<->***********************************/
228 static void
229 CloseHelpDialog (Widget w,
230                  XtPointer clientData,
231                  XtPointer callData)
232 {
233     XtUnmanageChild(smDD.smHelpDialog);
234 }