1 /* $XConsortium: HelpP.c /main/4 1995/11/02 14:40:13 rswiston $ */
2 /************************************<+>*************************************
3 ****************************************************************************
7 * COMPONENT_NAME: Desktop File Manager (dtfile)
9 * Description: Processing functions for the help dialog.
11 * FUNCTIONS: DTHelpClose
21 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
22 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
23 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
24 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
26 ****************************************************************************
27 ************************************<+>*************************************/
29 #include <sys/types.h>
37 #include <Dt/Connect.h>
38 #include <Dt/HourGlass.h>
40 #include "SharedProcs.h"
42 #include <Dt/HelpDialog.h>
50 /******** Static Function Declarations ********/
52 static void MainWindowHelpClose(
53 XtPointer client_data,
54 DialogData *old_dialog_data,
55 DialogData *new_dialog_data) ;
56 static void MainWinHyperLink(
60 static void TrashHelpClose(
61 XtPointer client_data,
62 DialogData *old_dialog_data,
63 DialogData *new_dialog_data) ;
64 static void TrashHyperLink(
68 static void DTHelpClose(
69 XtPointer client_data,
70 DialogData *old_dialog_data,
71 DialogData *new_dialog_data) ;
72 static void DTHyperLink(
77 /******** End Static Function Declarations ********/
81 /************************************************************************
84 * Used to display a primary or a hyperlink help dialog
86 ************************************************************************/
91 XtPointer topLevelRec,
93 DialogData *dialogData,
106 DialogData * fmDialogData;
107 FileMgrData * fileMgrData;
112 * DialogData is not NULL, if doing a restore session */
113 if (dialogData == NULL)
115 /* We are not restoring a session, so get the default values */
116 dialogData = _DtGetDefaultDialogData(help_dialog);
118 /* Add to the array of visible help annotation dialogs for this view */
119 fmDialogData = _DtGetInstanceData(topLevelRec);
120 fileMgrData = (FileMgrData *) fmDialogData->data;
122 if (dialogType == MAIN_HELP_DIALOG)
124 fileMgrData->primaryHelpDialog = dialogData;
128 /* Hyperlink help window */
129 _DtAddOneSubdialog (dialogData,
130 &fileMgrData->secondaryHelpDialogList,
131 &fileMgrData->secondaryHelpDialogCount);
134 helpData = (HelpData *)dialogData->data;
135 helpData->idString = XtNewString(idString);
136 helpData->volString = XtNewString(volString);
137 helpData->topicTitle = XtNewString(topicTitle);
138 helpData->fileType = XtNewString(fileType);
139 helpData->helpType = helpType;
142 _DtShowDialog(parentShell, NULL, topLevelRec, dialogData,
143 NULL, NULL, MainWindowHelpClose, topLevelRec, NULL, False,
146 /* lets set the title appropriately */
147 fmDialogData = _DtGetInstanceData(topLevelRec);
148 fileMgrData = (FileMgrData *) fmDialogData->data;
149 helpData = (HelpData *)dialogData->data;
150 if(fileMgrData->title == NULL || fileMgrData->helpVol == NULL ||
151 strcmp(fileMgrData->helpVol, DTFILE_HELP_NAME) == 0 ||
152 strcmp(helpData->volString, "Help4Help") == 0)
154 if(fileMgrData->title)
156 tmpStr = GETMESSAGE(29,2, "%s Help");
157 helpName = (char *)XtMalloc(strlen(fileMgrData->title) +
159 sprintf(helpName, tmpStr, fileMgrData->title);
160 XtSetArg(args[0], XmNtitle, helpName);
164 XtSetArg(args[0], XmNtitle, (GETMESSAGE(29,1, "File Manager Help")));
170 tmpStr = GETMESSAGE(29,2, "%s Help");
171 helpName = (char *)XtMalloc(strlen(fileMgrData->title) +
173 sprintf(helpName, tmpStr, fileMgrData->title);
174 XtSetArg(args[0], XmNtitle, helpName);
176 helpRec = (HelpRec *)_DtGetDialogInstance(dialogData);
177 XtSetValues(XtParent(helpRec->helpDialog), args, 1);
181 /* Add hyperlink callback */
182 XtRemoveAllCallbacks(helpRec->helpDialog, DtNhyperLinkCallback);
183 XtAddCallback(helpRec->helpDialog, DtNhyperLinkCallback,
184 MainWinHyperLink, topLevelRec);
190 /************************************************************************
192 * MainWindowHelpClose
193 * Callback function invoked from the help dialog's close button.
195 ************************************************************************/
199 XtPointer client_data,
200 DialogData *old_dialog_data,
201 DialogData *new_dialog_data )
204 FileMgrRec * fileMgrRec = (FileMgrRec *) client_data;
205 FileMgrData * fileMgrData;
206 DialogData * dialog_data;
210 dialog_data = _DtGetInstanceData((XtPointer)fileMgrRec);
211 fileMgrData = (FileMgrData *)dialog_data->data;
213 /* Remove the dialog data from the top level window's list */
214 if (old_dialog_data == fileMgrData->primaryHelpDialog)
216 fileMgrData->primaryHelpDialog = NULL;
220 _DtHideOneSubdialog( old_dialog_data,
221 &fileMgrData->secondaryHelpDialogList,
222 &fileMgrData->secondaryHelpDialogCount);
225 _DtHideDialog(old_dialog_data, False);
226 _DtFreeDialogData(old_dialog_data);
227 _DtFreeDialogData(new_dialog_data);
232 /************************************************************************
235 * Callback function responsible for handling a hyperlink help
236 * request for a help window associated with a main window view.
238 ************************************************************************/
243 XtPointer clientData,
247 FileMgrRec * fileMgrRec = (FileMgrRec *)clientData;
248 DtHelpDialogCallbackStruct * hyperData;
250 hyperData = (DtHelpDialogCallbackStruct *)callData;
251 if (hyperData->hyperType == DtHELP_LINK_JUMP_NEW)
253 ShowHelpDialog(fileMgrRec->shell, (XtPointer)fileMgrRec,
255 NULL, hyperData->locationId,
256 hyperData->helpVolume, NULL, NULL, DtHELP_TYPE_TOPIC);
261 /************************************************************************
263 * ShowTrashHelpDialog
264 * Used to display a primary or a hyperlink help dialog for trash
267 ************************************************************************/
273 DialogData *dialogData,
283 /* Get the default values */
284 dialogData = _DtGetDefaultDialogData(help_dialog);
286 if (dialogType == MAIN_HELP_DIALOG)
288 primaryTrashHelpDialog = dialogData;
292 /* Hyperlink help window */
293 _DtAddOneSubdialog (dialogData,
294 &secondaryTrashHelpDialogList,
295 &secondaryTrashHelpDialogCount);
298 helpData = (HelpData *)dialogData->data;
299 helpData->idString = XtNewString(idString);
300 helpData->volString = XtNewString(volString);
301 helpData->helpType = DtHELP_TYPE_TOPIC;
303 _DtShowDialog(parentShell, NULL, NULL, dialogData, NULL, NULL, TrashHelpClose,
304 NULL, NULL, False, False, NULL, NULL);
306 /* lets set the title appropriately */
307 XtSetArg(args[0], XmNtitle, (GETMESSAGE(29,9, "Trash Can Help")));
308 helpRec = (HelpRec *)_DtGetDialogInstance(dialogData);
309 XtSetValues(XtParent(helpRec->helpDialog), args, 1);
311 /* Add hyperlink callback */
312 helpRec = (HelpRec *)_DtGetDialogInstance(dialogData);
313 XtRemoveAllCallbacks(helpRec->helpDialog, DtNhyperLinkCallback);
314 XtAddCallback(helpRec->helpDialog, DtNhyperLinkCallback,
315 TrashHyperLink, NULL);
321 /************************************************************************
324 * Callback function invoked from the help dialog's close button,
325 * for the Trash help dialogs.
327 ************************************************************************/
331 XtPointer client_data,
332 DialogData *old_dialog_data,
333 DialogData *new_dialog_data )
339 /* Remove the dialog data from the trash window's list */
340 if (old_dialog_data == primaryTrashHelpDialog)
342 primaryTrashHelpDialog = NULL;
346 _DtHideOneSubdialog( old_dialog_data,
347 &secondaryTrashHelpDialogList,
348 &secondaryTrashHelpDialogCount);
351 _DtHideDialog(old_dialog_data, False);
352 _DtFreeDialogData(old_dialog_data);
353 _DtFreeDialogData(new_dialog_data);
358 /************************************************************************
361 * Callback function responsible for handling a hyperlink help
362 * request for a help window associated with the trash window.
364 ************************************************************************/
369 XtPointer clientData,
373 DtHelpDialogCallbackStruct * hyperData;
375 hyperData = (DtHelpDialogCallbackStruct *)callData;
376 if (hyperData->hyperType == DtHELP_LINK_JUMP_NEW)
378 ShowTrashHelpDialog(trashShell, HYPER_HELP_DIALOG, NULL,
379 hyperData->locationId, hyperData->helpVolume);
384 /************************************************************************
387 * Used to display a primary or a hyperlink help dialog
389 ************************************************************************/
396 DialogData *dialogData,
410 * DialogData is not NULL, if doing a restore session */
411 if (dialogData == NULL)
413 /* We are not restoring a session, so get the default values */
414 dialogData = _DtGetDefaultDialogData(help_dialog);
416 /* Add to the array of visible help annotation dialogs for this view */
417 if (dialogType == MAIN_HELP_DIALOG)
419 desktop_data->workspaceData[workspaceNum]->primaryHelpDialog =
424 WorkspaceRec * wsInfo;
426 /* Hyperlink help window */
427 wsInfo = desktop_data->workspaceData[workspaceNum];
428 _DtAddOneSubdialog (dialogData,
429 &wsInfo->secondaryHelpDialogList,
430 &wsInfo->secondaryHelpDialogCount);
433 helpData = (HelpData *)dialogData->data;
434 helpData->idString = XtNewString(idString);
435 helpData->volString = XtNewString(volString);
436 helpData->topicTitle = XtNewString(topicTitle);
437 helpData->fileType = XtNewString(fileType);
438 helpData->helpType = helpType;
441 _DtShowDialog(parentShell, NULL, NULL, dialogData, NULL, NULL,
442 DTHelpClose, (XtPointer)workspaceNum,
443 desktop_data->workspaceData[workspaceNum]->name,
444 False, False, NULL, NULL);
446 /* lets set the title appropriately */
447 XtSetArg(args[0], XmNtitle, (GETMESSAGE(29,1, "File Manager Help")));
448 helpRec = (HelpRec *)_DtGetDialogInstance(dialogData);
449 XtSetValues(XtParent(helpRec->helpDialog), args, 1);
451 /* Add hyperlink callback */
452 helpRec = (HelpRec *)_DtGetDialogInstance(dialogData);
453 XtRemoveAllCallbacks(helpRec->helpDialog, DtNhyperLinkCallback);
454 XtAddCallback(helpRec->helpDialog, DtNhyperLinkCallback,
455 DTHyperLink, (XtPointer)workspaceNum);
461 /************************************************************************
464 * Callback function invoked from the help dialog's close button.
466 ************************************************************************/
470 XtPointer client_data,
471 DialogData *old_dialog_data,
472 DialogData *new_dialog_data )
475 int workspaceNum = (int) client_data;
478 WorkspaceRec * wsInfo;
480 wsInfo = desktop_data->workspaceData[workspaceNum];
482 /* Remove the dialog data from the top level window's list */
483 if (old_dialog_data == wsInfo->primaryHelpDialog)
485 wsInfo->primaryHelpDialog = NULL;
489 _DtHideOneSubdialog( old_dialog_data,
490 &wsInfo->secondaryHelpDialogList,
491 &wsInfo->secondaryHelpDialogCount);
494 _DtHideDialog(old_dialog_data, False);
495 _DtFreeDialogData(old_dialog_data);
496 _DtFreeDialogData(new_dialog_data);
501 /************************************************************************
504 * Callback function responsible for handling a hyperlink help
505 * request for a help window associated with a main window view.
507 ************************************************************************/
512 XtPointer clientData,
516 int workspaceNum = (int) clientData;
517 DtHelpDialogCallbackStruct * hyperData;
519 hyperData = (DtHelpDialogCallbackStruct *)callData;
520 if (hyperData->hyperType == DtHELP_LINK_JUMP_NEW)
522 ShowDTHelpDialog(NULL, workspaceNum, HYPER_HELP_DIALOG,
523 NULL, hyperData->locationId,
524 hyperData->helpVolume, NULL, NULL, DtHELP_TYPE_TOPIC);