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