dtcm: Resolve 303 compiler warnings.
[oweals/cde.git] / cde / programs / dtcm / dtcm / help.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 /*******************************************************************************
24 **
25 **  help.c
26 **
27 **  $XConsortium: help.c /main/7 1996/04/19 15:47:41 rswiston $
28 **
29 **  RESTRICTED CONFIDENTIAL INFORMATION:
30 **
31 **  The information in this document is subject to special
32 **  restrictions in a confidential disclosure agreement between
33 **  HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34 **  document outside HP, IBM, Sun, USL, SCO, or Univel without
35 **  Sun's specific written approval.  This document and all copies
36 **  and derivative works thereof must be returned or destroyed at
37 **  Sun's request.
38 **
39 **  Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40 **
41 *******************************************************************************/
42
43 /*                                                                      *
44  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
45  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
46  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
47  * (c) Copyright 1993, 1994 Novell, Inc.                                *
48  */
49
50 #ifndef lint
51 static char sccsid[] = "@(#)help.c 1.19 95/03/28 Copyr 1991 Sun Microsystems, Inc.";
52 #endif
53
54 #include <EUSCompat.h>
55 #include <stdio.h>
56 #include <stdlib.h>
57 #include <sys/stat.h>
58 #include <sys/param.h> /* MAXPATHLEN defined here */
59 #ifdef SVR4
60 #include <sys/utsname.h> /* SYS_NMLN */
61 #endif /* SVR4 specific includes */
62 #include <dirent.h>
63 #include <ctype.h>
64 #include <string.h>
65 #include <sys/time.h>
66 #include <sys/signal.h>
67 #include <rpc/rpc.h>
68 #include <sys/resource.h>
69 #include <sys/wait.h>
70 #include <netinet/in.h>
71 #include <X11/Xlib.h>
72 #include <Xm/Xm.h>
73 #include <Xm/Form.h>
74 #include <Xm/LabelG.h>
75 #include <Xm/List.h>
76 #include <Xm/DialogS.h>
77 #include <Xm/PushBG.h>
78 #include <Xm/RowColumn.h>
79 #include <Xm/Scale.h>
80 #include <Xm/SeparatoG.h>
81 #include <Xm/TextF.h>
82 #include <Xm/Text.h>
83 #include <Xm/ToggleB.h>
84 #include <Xm/ToggleBG.h>
85 #include <Dt/HourGlass.h>
86 #include <Dt/HelpDialog.h>
87 #include "calendar.h"
88 #include "revision.h"
89 #include "help.h"
90 #include "props_pu.h"
91
92 static void display_help(Calendar *, ArgList, int);
93
94 static void
95 display_help(Calendar *c, ArgList args, int nargs)
96 {
97   if (!c->mainhelpdialog)
98   {
99     Arg oneArg;
100     char *title = XtNewString(catgets(c->DT_catd, 1, 1076, "Calendar : Help"));
101
102     XtSetArg(oneArg, XmNtitle, title);
103     c->mainhelpdialog =
104       (Widget)DtCreateHelpDialog(c->frame, "mainhelpdialog", &oneArg, 1);
105     XtFree(title);
106   }
107
108   XtSetValues(c->mainhelpdialog, args, nargs);
109   XtManageChild(c->mainhelpdialog);
110 }
111
112 void show_main_help(Widget w, XtPointer clientData, XtPointer cbs)
113 {
114         int             ac;
115         Arg             al[10];
116         Calendar        *c = calendar;
117         Props_pu        *p = (Props_pu *) c->properties_pu;
118         Widget          selWidget = NULL;
119         int             status = DtHELP_SELECT_ERROR;
120  
121         ac = 0;
122         XtSetArg(al[ac], DtNhelpType, DtHELP_TYPE_TOPIC); ac++;
123         switch ((intptr_t)clientData) {
124             case HELP_OVERVIEW:
125                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
126                 XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
127                 break;
128             case HELP_USINGHELP:
129                 XtSetArg(al[ac], DtNhelpVolume, "Help4Help"); ac++;
130                 XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
131                 break;
132             case HELP_TASKS:
133                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
134                 XtSetArg(al[ac], DtNlocationId, "TASKS"); ac++;
135                 break;
136             case HELP_REFERENCE:
137                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
138                 XtSetArg(al[ac], DtNlocationId, "REFERENCE"); ac++;
139                 break;
140             case HELP_ABOUTCALENDAR:
141                 XtSetArg(al[ac], DtNhelpVolume, "Help4Help"); ac++;
142                 XtSetArg(al[ac], DtNlocationId, "_COPYRIGHT"); ac++;
143                 break;
144             case HELP_TOC:
145                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
146                 XtSetArg(al[ac], DtNlocationId, "TOC"); ac++;
147                 break;
148             case HELP_ONITEM:
149                while (!XtIsSubclass(w, applicationShellWidgetClass))
150                    w = XtParent(w);
151  
152                status = DtHelpReturnSelectedWidgetId(w, 0, &selWidget);     
153                switch ((int)status)
154                   {
155                     case DtHELP_SELECT_ERROR:
156                       printf("%s", catgets(c->DT_catd, 1, 350, "Selection Error, cannot continue\n"));
157                     break;
158                     case DtHELP_SELECT_VALID:
159                       while (selWidget != NULL)
160                         {
161                           if ((XtHasCallbacks(selWidget, XmNhelpCallback)                                            == XtCallbackHasSome))
162                             {
163                                XtCallCallbacks((Widget)selWidget,
164                                                XmNhelpCallback,NULL);
165                                break;
166                             }
167                           else
168                            selWidget = XtParent(selWidget);
169                         }
170                     break;
171                     case DtHELP_SELECT_ABORT:
172                       return;
173
174                     case DtHELP_SELECT_INVALID:
175                       {
176                         char *title = XtNewString(catgets(c->DT_catd, 1, 110, "Calendar : Error - Help"));
177                         char *text = XtNewString(catgets(c->DT_catd, 1, 352, "You must select a component within your application."));
178                         char *ident1 = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
179                         dialog_popup(c->frame,
180                                      DIALOG_TITLE, title,
181                                      DIALOG_TEXT, text,
182                                      BUTTON_IDENT, 1, ident1,
183                                      DIALOG_IMAGE, p->xm_error_pixmap,
184                                      NULL);
185                         XtFree(ident1);
186                         XtFree(text);
187                         XtFree(title);
188                         return;
189                       }
190                   }
191  
192                break;
193  
194             default:
195                 XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
196                 XtSetArg(al[ac], DtNlocationId, "_HOMETOPIC"); ac++;
197                 break;
198         }
199
200         display_help(c, al, ac);
201 }
202
203 extern void
204 help_cb(Widget w, XtPointer clientData, XtPointer callData)
205 {
206         int ac;
207         Arg al[10];
208         Calendar *c = calendar;
209         char *locationid = (char *) clientData;
210
211         ac = 0;
212         XtSetArg(al[ac], DtNhelpType, DtHELP_TYPE_TOPIC); ac++;
213         XtSetArg(al[ac], DtNhelpVolume, "Calendar"); ac++;
214         XtSetArg(al[ac], DtNlocationId, locationid); ac++;
215
216         display_help(c, al, ac);
217 }
218
219 /* special case where we must determine the view */
220 extern void
221 help_view_cb(Widget w, XtPointer clientData, XtPointer callData)
222 {
223         Calendar *c = calendar;
224
225         switch (c->view->glance) {
226                 case dayGlance:
227                         help_cb(w, (XtPointer)CALENDAR_HELP_DAY_WINDOW, callData);
228                         break;
229                 case weekGlance:
230                         help_cb(w, (XtPointer)CALENDAR_HELP_WEEK_WINDOW, callData);
231                         break;
232                 case monthGlance:
233                         help_cb(w, (XtPointer)CALENDAR_HELP_MONTH_WINDOW, callData);
234                         break;
235                 default:
236                         break;
237         }
238 }