Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtcreate / ca_aux.c
1 /* $TOG: ca_aux.c /main/10 1999/09/17 15:44:00 mgreess $ */
2 /******************************************************************************/
3 /*                                                                            */
4 /* ca_aux - auxiliary functions for create action                             */
5 /*                                                                            */
6 /* Functions to get/set values from/to interface.                             */
7 /* Callback routines for CA interface.                                        */
8 /*                                                                            */
9 /******************************************************************************/
10
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <sys/signal.h>
15 #include <errno.h>
16 #include <unistd.h>
17 #include <X11/cursorfont.h>
18 #include <X11/Xlib.h>
19 #include <X11/Xatom.h>
20 #include <Xm/Xm.h>
21 #include <Xm/TextF.h>
22 #include <Xm/RowColumnP.h>
23 #include <Xm/MessageB.h>
24 #include <Xm/FileSB.h>
25 #include <sys/stat.h>
26 #if defined(AIXV3)
27 #    include <sys/dir.h>
28 #else
29 #  if defined(__osf__) || defined(linux)
30 #    include <dirent.h>
31 #  else
32 #    include <sys/dirent.h>
33 #  endif
34 #endif
35
36 #include <Dt/Icon.h>
37 #include <Dt/IconFile.h>
38
39 #include "dtcreate.h"
40 #include "ca_aux.h"
41 #include "cmnutils.h"
42 #include "cmnrtns.h"
43 #include "CreateActionAppShell.h"
44 #include "Confirmed.h"
45
46 /******************************************************************************/
47 /*                                                                            */
48 /*  External Variables                                                        */
49 /*                                                                            */
50 /******************************************************************************/
51 extern Dimension wintypeheight, winheight, xprtheight, newheight;
52
53 /******************************************************************************/
54 /*                                                                            */
55 /*  Variables                                                                 */
56 /*                                                                            */
57 /******************************************************************************/
58 struct _ActionData *ca_local_struct;
59
60 /******************************************************************************/
61 /* readCAFromGUI - loads Action data structure with data read from            */
62 /*                 the GUI interface.                                         */
63 /*                                                                            */
64 /*                                                                            */
65 /******************************************************************************/
66 void readCAFromGUI (struct _ActionData *ca_struct)
67 {
68   getCAactionName (ca_struct);
69   getCAdblClkCmd (ca_struct);
70   getCAactionHelpText (ca_struct);
71      /*getCAfileTypes (ca_struct);*/
72   getCAactionOpensText (ca_struct);
73      /*getCAwindowType (ca_struct);*/
74      /*getCAactionIcons (ca_struct);*/
75      /*getCAexpertOption (ca_struct);*/
76   return;
77 }
78
79
80 /******************************************************************************/
81 /* writeCAToGUI - loads widgets with data stored in the integration           */
82 /*                data structure                                              */
83 /*                                                                            */
84 /*                                                                            */
85 /******************************************************************************/
86 void writeCAToGUI (struct _ActionData *pAD)
87 {
88   putCAactionName (pAD);
89   putCAactionIcons (pAD);
90   putCAdblClkCmd (pAD);
91   putCAactionHelpText (pAD);
92   putCAwindowType (pAD);
93   putCAactionOpensText (pAD);
94   putCAfileTypes (pAD);
95   putCAdropFiletypes(pAD);
96   return;
97 }
98
99
100 /******************************************************************************/
101 /* getCAactionName - retrieves the action name text string and stores         */
102 /*      the value in the ActionData structure                                 */
103 /* INPUT: _ActionData *ca_struct - Action data structure                      */
104 /* OUTPUT: none                                                               */
105 /******************************************************************************/
106 void getCAactionName (struct _ActionData *ca_struct)
107 {
108   GetWidgetTextString(CA_ActionNameTextField, &(AD.pszName));
109 }
110
111
112 /******************************************************************************/
113 /* getCAdblClkCmd - retrieves the double-click command text                   */
114 /*      string and stores the value in the ActionData structure               */
115 /* INPUT: _ActionData *ca_struct - Action data structure                      */
116 /* OUTPUT: none                                                               */
117 /******************************************************************************/
118 void getCAdblClkCmd (struct _ActionData *ca_struct)
119 {
120   GetWidgetTextString(CA_DblClkText, &(AD.pszCmd));
121 }
122
123
124 /******************************************************************************/
125 /* getCAactionHelpText - retrieves the help text string and stores            */
126 /*      the value in the ActionData structure                                 */
127 /* INPUT: _ActionData *ca_struct - Action data structure                      */
128 /* OUTPUT: none                                                               */
129 /******************************************************************************/
130 void getCAactionHelpText (struct _ActionData *ca_struct)
131 {
132   GetWidgetTextString(CA_HelpText, &(AD.pszHelp));
133 }
134
135 /******************************************************************************/
136 /* getCAactionOpensText - retrieves the "action opens" text                   */
137 /*      string and stores the value in the ActionData structure               */
138 /* INPUT: _ActionData *ca_struct - Action data structure                      */
139 /* OUTPUT: none                                                               */
140 /******************************************************************************/
141 void getCAactionOpensText (struct _ActionData *ca_struct)
142 {
143   GetWidgetTextString(CA_XprtActionOpenText, &(AD.pszPrompt));
144 }
145
146 /******************************************************************************/
147 /* putCAactionName - sets the action name text field in the GUI               */
148 /*       from the value in the ActionData structure                           */
149 /* INPUT: _ActionData *ca_struct - Action data structure                      */
150 /* OUTPUT: none                                                               */
151 /******************************************************************************/
152 void putCAactionName (struct _ActionData *ca_struct)
153 {
154   PutWidgetTextString(CA_ActionNameTextField, CA_ActionName(ca_struct));
155   return;
156 }
157
158 /******************************************************************************/
159 /* putCAdblClkCmd - sets the double-click command text                        */
160 /*      string in the GUI from the value in the ActionData structure          */
161 /* INPUT: _ActionData *ca_struct - Action data structure                      */
162 /* OUTPUT: none                                                               */
163 /******************************************************************************/
164 void putCAdblClkCmd (struct _ActionData *ca_struct)
165 {
166   PutWidgetTextString(CA_DblClkText, CA_DblClkAction(ca_struct));
167   return;
168 }
169
170 /******************************************************************************/
171 /* putCAactionHelpText - sets the help text string in the GUI from            */
172 /*      the value in the ActionData structure                                 */
173 /* INPUT: _ActionData *ca_struct - Action data structure                      */
174 /* OUTPUT: none                                                               */
175 /******************************************************************************/
176 void putCAactionHelpText (struct _ActionData *ca_struct)
177 {
178   PutWidgetTextString(CA_HelpText, CA_ActionHelpText(ca_struct));
179   return;
180 }
181
182 /******************************************************************************/
183 /* putCAfileTypes - sets the list of file types in the GUI from               */
184 /*      the values in the ActionData structure                                */
185 /* INPUT: _ActionData *ca_struct - Action data structure                      */
186 /* OUTPUT: none                                                               */
187 /******************************************************************************/
188 void putCAfileTypes (struct _ActionData *pAD)
189 {
190  pFiletypeData  pFtD;
191  int            i;
192
193   if (pAD->cFiletypes) {
194      for (i=0; i < pAD->cFiletypes; i++) {
195        if (!XmListItemExists(CA_FiletypesList,
196               XmStringCreateSimple((pAD->papFiletypes[i])->pszName))) {
197           XmListAddItem(CA_FiletypesList,
198             XmStringCreateSimple((pAD->papFiletypes[i])->pszName), i+1);
199        }
200      }
201   }
202
203   return;
204 }
205
206 /******************************************************************************/
207 /* putCAactionOpensText - sets the "action opens" text string in              */
208 /*      the GUE from the value in the ActionData structure                    */
209 /* INPUT: _ActionData *ca_struct - Action data structure                      */
210 /* OUTPUT: none                                                               */
211 /******************************************************************************/
212 void putCAactionOpensText (struct _ActionData *ca_struct)
213 {
214   PutWidgetTextString(CA_XprtActionOpenText, CA_ActionOpensText(ca_struct));
215   return;
216 }
217
218 /******************************************************************************/
219 /* putCAwindowType - sets the window type toggle status in the GUI            */
220 /*       from the value in the ActionData structure                           */
221 /* INPUT: _ActionData *ca_struct - Action data structure                      */
222 /* OUTPUT: none                                                               */
223 /******************************************************************************/
224 void putCAwindowType (struct _ActionData *ca_struct)
225 {
226   if (ca_struct->fsFlags & CA_WT_XWINDOWS) {
227      /*
228      XtVaSetValues(CA_WindowTypeArea,XmNmenuHistory,CA_WinTypeNoOutput,NULL);
229      */
230      XtVaSetValues(CA_WindowTypeArea, XmNmenuHistory, CA_WinTypeX, NULL);
231   } else if (ca_struct->fsFlags & CA_WT_TERM) {
232      XtVaSetValues(CA_WindowTypeArea,XmNmenuHistory,CA_WinTypeAutoClose,NULL);
233   } else if (ca_struct->fsFlags & CA_WT_PERMTERM) {
234      XtVaSetValues(CA_WindowTypeArea,XmNmenuHistory,CA_WinTypeManualClose,NULL);
235   } else {
236      /*XtVaSetValues(CA_WindowTypeArea,XmNmenuHistory,CA_WinTypeNoOutput,NULL);*/
237      XtVaSetValues(CA_WindowTypeArea, XmNmenuHistory, CA_WinTypeX, NULL);
238   }
239   return;
240 }
241
242 /******************************************************************************/
243 /* putCAactionIcons -                                                         */
244 /*       GUI from the value in the ActionData structure                       */
245 /* INPUT: _ActionData *ca_struct - Action data structure                      */
246 /* OUTPUT: none                                                               */
247 /******************************************************************************/
248 void putCAactionIcons (ActionData *pAD)
249 {
250   char   *pszIconFileName = (char *)NULL;
251   char   *ptr;
252   char   *msgPtr, *fmtPtr, *errPtr;
253
254   /**************************************************************************/
255   /* Since we only have the base name, we must find the icon within the     */
256   /* icon path, strip off the size and type extension, then set the icon    */
257   /* data and gadget with this new name - base name and path.               */
258   /**************************************************************************/
259   FIND_ICONGADGET_ICON(pAD->pszIcon, pszIconFileName, DtLARGE);
260   if (pszIconFileName) {
261      ptr = strstr(pszIconFileName, LARGE_EXT);
262      if (ptr) *ptr = '\0';
263      SetIconData(CA_LRG_IconGadget, pszIconFileName, Large_Icon);
264      XtFree(pszIconFileName);
265   } else {
266      msgPtr = GETMESSAGE(5, 95,
267        "Could not find the following icon file within the icon\n\
268 search path:");
269      fmtPtr = "%s\n   %s";
270      errPtr = XtMalloc((strlen(msgPtr) + strlen(fmtPtr) +
271                         strlen(pAD->pszIcon) + 1) * sizeof(char));
272      sprintf(errPtr, fmtPtr, msgPtr, pAD->pszIcon);
273      display_error_message(CreateActionAppShell, errPtr);
274      XtFree(errPtr);
275   }
276
277   FIND_ICONGADGET_ICON(pAD->pszIcon, pszIconFileName, DtMEDIUM);
278   if (pszIconFileName) {
279      ptr = strstr(pszIconFileName, MEDIUM_EXT);
280      if (ptr) *ptr = '\0';
281      SetIconData(CA_MED_IconGadget, pszIconFileName, Medium_Icon);
282      XtFree(pszIconFileName);
283   } else {
284      msgPtr = GETMESSAGE(5, 95,
285        "Could not find the following icon file within the icon\n\
286 search path:");
287      fmtPtr = "%s\n   %s";
288      errPtr = XtMalloc((strlen(msgPtr) + strlen(fmtPtr) +
289                         strlen(pAD->pszIcon) + 1) * sizeof(char));
290      sprintf(errPtr, fmtPtr, msgPtr, pAD->pszIcon);
291      display_error_message(CreateActionAppShell, errPtr);
292      XtFree(errPtr);
293   }
294
295   FIND_ICONGADGET_ICON(pAD->pszIcon, pszIconFileName, DtTINY);
296   if (pszIconFileName) {
297      ptr = strstr(pszIconFileName, TINY_EXT);
298      if (ptr) *ptr = '\0';
299      SetIconData(CA_TINY_IconGadget, pszIconFileName, Tiny_Icon);
300      XtFree(pszIconFileName);
301   } else {
302      msgPtr = GETMESSAGE(5, 95,
303        "Could not find the following icon file within the icon\n\
304 search path:");
305      fmtPtr = "%s\n   %s";
306      errPtr = XtMalloc((strlen(msgPtr) + strlen(fmtPtr) +
307                         strlen(pAD->pszIcon) + 1) * sizeof(char));
308      sprintf(errPtr, fmtPtr, msgPtr, pAD->pszIcon);
309      display_error_message(CreateActionAppShell, errPtr);
310      XtFree(errPtr);
311   }
312 }
313
314 /******************************************************************************/
315 /* putCAdropFiletypes -                                                       */
316 /*                                                                            */
317 /* INPUT: _ActionData *ca_struct - Action data structure                      */
318 /* OUTPUT: none                                                               */
319 /******************************************************************************/
320 void putCAdropFiletypes (ActionData *pAD)
321 {
322   Boolean  set = FALSE;
323
324   if (pAD->fsFlags & CA_DF_ONLYFTFILES) {
325      set = TRUE;
326   }
327   SET_TOGGLEBUTTON(CA_FiletypesInListToggle, set);
328   SET_TOGGLEBUTTON(CA_AllFiletypesToggle, !set);
329
330   return;
331 }
332
333 /******************************************************************************/
334 /* set_ca_dialog_height - adjusts height of create action dialog to exclude   */
335 /*                        height used by expert option section.               */
336 /* INPUT: none                                                                */
337 /* OUTPUT: none                                                               */
338 /******************************************************************************/
339 void set_ca_dialog_height (void)
340 {
341   Boolean showExpert = sessiondata.useSession && sessiondata.showExpert;
342
343   /* get height of window */
344   XtVaGetValues (CreateActionAppShell, XmNheight, &winheight, NULL);
345   /* get height of expert option form */
346   XtVaGetValues (XprtOptionForm, XmNheight, &xprtheight, NULL);
347   /* calculate height of window without expert option form */
348   newheight = winheight - xprtheight;
349
350   if (!showExpert)
351   {
352     /* remove attachment to expert option form */
353     XtVaSetValues (CA_Expand, XmNbottomAttachment, XmATTACH_NONE, NULL);
354     XtUnmanageChild (XprtOptionForm);
355
356     if (!sessiondata.useSession)
357     {
358       /* give window new height */
359       XtVaSetValues (CreateActionAppShell, XmNheight, newheight, NULL);
360     }
361
362     XtVaSetValues (CA_Expand, XmNbottomAttachment, XmATTACH_FORM, NULL);
363   }
364   else
365   {
366     XtVaSetValues (CA_Expand, RES_CONVERT(XmNlabelString,
367                                           GETMESSAGE(3, 52, "Basic")),
368                    NULL);
369   }
370
371   return;
372 }
373
374 /******************************************************************************/
375 /*                                                                            */
376 /*         CALLBACK FUNCTIONS                                                 */
377 /*                                                                            */
378 /******************************************************************************/
379
380 /******************************************************************************/
381 /*                                                                            */
382 /*                                                                            */
383 /*      Callbacks for Create Action 'File' menu                               */
384 /*                                                                            */
385 /*                                                                            */
386 /******************************************************************************/
387
388 /*****************************************************************************/
389 /*                                                                           */
390 /*  initAD                                                                   */
391 /*                                                                           */
392 /*                                                                           */
393 /*****************************************************************************/
394 void
395 initAD( ActionData *pAD )
396 {
397   memset(pAD, 0, sizeof(ActionData));
398   pAD->fsFlags |= CA_WT_XWINDOWS;
399   pAD->pszIcon = (char *)XtMalloc(strlen(ca_icon_default) + 1);
400   strcpy(pAD->pszIcon, ca_icon_default);
401 }
402
403 /******************************************************************************/
404 /* FreeAndClearAD - free all fields in AD, frees filetypes and array,         */
405 /*                  and zero's out all of the fields of the structure.        */
406 /* INPUT:  none                                                               */
407 /* OUTPUT: none                                                               */
408 /******************************************************************************/
409 void FreeAndClearAD (ActionData *pAD)
410 {
411   FiletypeData  *pFtD;
412   int           i;
413
414   if (pAD->pszName) XtFree(pAD->pszName);
415   if (pAD->pszIcon) XtFree(pAD->pszIcon);
416   if (pAD->pszCmd) XtFree(pAD->pszCmd);
417   if (pAD->pszHelp) XtFree(pAD->pszHelp);
418   if (pAD->pszPrompt) XtFree(pAD->pszPrompt);
419
420   if (pAD->papFiletypes) {
421      for (i=0; i < pAD->cFiletypes; i++) {
422         free_Filetypedata(pAD->papFiletypes[i]);
423      }
424      XtFree((char *)pAD->papFiletypes);
425   }
426   memset(pAD, 0, sizeof(ActionData));
427   return;
428
429 }
430
431 /******************************************************************************/
432 /* clear_CreateActionAppShell_fields                                          */
433 /*                                                                            */
434 /* INPUT:  none                                                               */
435 /* OUTPUT: none                                                               */
436 /******************************************************************************/
437 void clear_CreateActionAppShell_fields(void)
438 {
439   clear_text_field (ACTION_NAME);
440   clear_text_field (DBL_CLK_CMND);
441
442   XtVaSetValues(CA_WindowTypeArea, XmNmenuHistory, CA_WinTypeX, NULL);
443
444   clear_text_field (ACTION_OPENS_TEXT);
445   clear_text (ACTION_HELP_TXT);
446   delete_all_list_items (FILETYPES_FOR_ACTION);
447
448   createCB_IconGadget(CA_LRG_IconGadget, True, Large_Icon);
449   createCB_IconGadget(CA_MED_IconGadget, True, Medium_Icon);
450   createCB_IconGadget(CA_TINY_IconGadget, True, Tiny_Icon);
451
452   SET_TOGGLEBUTTON(CA_AllFiletypesToggle, TRUE);
453   SET_TOGGLEBUTTON(CA_FiletypesInListToggle, FALSE);
454
455   return;
456 }
457
458 /******************************************************************************/
459 /* activateCB_FileNew - clears the text and list widgets on the               */
460 /*                                create action main panel                    */
461 /* INPUT:  Widget wid - widget id                                             */
462 /*         XtPointer cdata - client data                                      */
463 /*         XtPointer cbs - callback structur                                  */
464 /* OUTPUT: none                                                               */
465 /******************************************************************************/
466 void activateCB_FileNew (Widget wid, XtPointer cdata,
467                          XtPointer cbstruct)
468 {
469   char          pszFile[MAXBUFSIZE];
470
471   /**************************************************************************/
472   /* Clear the fields in the gui and set fields to default.                 */
473   /**************************************************************************/
474   clear_CreateActionAppShell_fields();
475
476   /**************************************************************************/
477   /* Clear the pszFileToEdit global variable.                               */
478   /**************************************************************************/
479   pszFileToEdit = (char *)NULL;
480
481   /**************************************************************************/
482   /* Clear the fields within the ActionData structure and free any          */
483   /* FiletypeData structures.                                               */
484   /**************************************************************************/
485   FreeAndClearAD(&AD);
486
487   /**************************************************************************/
488   /* Initialize fields within the ActionData structure.                     */
489   /**************************************************************************/
490   initAD(&AD);
491
492   /**************************************************************************/
493   /* Get a new copy of AD.                                                  */
494   /**************************************************************************/
495   FreeAndClearAD(pMyCopyAD);
496   XtFree((char *)pMyCopyAD);
497   pMyCopyAD = copyAD(&AD);
498
499   return;
500 }
501
502
503 /******************************************************************************/
504 /* activateCB_FileOpen  -  Callback for the Open menu bar option that is      */
505 /*                         located within the File submenu.  This callback    */
506 /*                         pops up the File Selection dialog box.             */
507 /*                                                                            */
508 /* INPUT:  Widget wid - widget id                                             */
509 /*         XtPointer cdata - client data                                      */
510 /*         XtPointer cbs - callback structure                                 */
511 /*                                                                            */
512 /* OUTPUT: none                                                               */
513 /******************************************************************************/
514 void  activateCB_FileOpen(Widget wid, XtPointer cdata,
515                           XtPointer cbstruct)
516 {
517   Widget filter;
518
519   XtVaSetValues (OpenFile, RES_CONVERT(XmNdirMask, "~/.dt/types/*.dt"),
520                  RES_CONVERT(XmNdirSpec, "~/.dt/types/"),
521                  RES_CONVERT(XmNdirectory, "~/.dt/types/"),
522                  NULL);
523
524   filter = XmFileSelectionBoxGetChild (OpenFile, XmDIALOG_FILTER_TEXT);
525   /*XtVaSetValues (filter, XmNeditable, False, NULL);*/
526   UxPopupInterface (OpenFile, no_grab);
527   return;
528 }
529
530 /******************************************************************************/
531 /*                                                                            */
532 /* FreeResources                                                              */
533 /*                                                                            */
534 /* INPUT:  none                                                               */
535 /* OUTPUT: none                                                               */
536 /******************************************************************************/
537 void FreeResources ( void )
538 {
539   /**************************************************************************/
540   /* Clear the fields within the ActionData structure and free any          */
541   /* FiletypeData structures.                                               */
542   /**************************************************************************/
543   FreeAndClearAD(&AD);
544
545   /**************************************************************************/
546   /* Free my copy of AD.                                                    */
547   /**************************************************************************/
548   FreeAndClearAD(pMyCopyAD);
549   XtFree((char *)pMyCopyAD);
550
551   /********************************************************************/
552   /* Free temporary icon files                                        */
553   /********************************************************************/
554   RemoveTmpIconFiles();
555
556   return;
557 }
558
559 /******************************************************************************/
560 /*  activateCB_FileQuit                                                       */
561 /* INPUT:  Widget wid - widget id                                             */
562 /*         XtPointer cdata - client data                                      */
563 /*         XtPointer cbs - callback structur                                  */
564 /*  OUTPUT: none                                                              */
565 /******************************************************************************/
566 void activateCB_FileQuit (Widget wid, XtPointer cdata,
567                           XtPointer cbstruct)
568 {
569   char    *msgPtr;
570   char    *savePtr;
571   char    *noSavePtr;
572   char    *cancelPtr;
573
574   /**************************************************************************/
575   /* Get latest changes from main window.                                   */
576   /**************************************************************************/
577   readCAFromGUI(&AD);
578
579   /**************************************************************************/
580   /* Check if anything has changed.  If so ask if they really want to quit. */
581   /**************************************************************************/
582   if (compareAD(&AD, pMyCopyAD)) {
583      msgPtr = GETMESSAGE(5, 150, "Your current work has not been saved.");
584      msgPtr = XtNewString(msgPtr);
585
586      /* CDExc19439 - Save GETMESSAGE results to buffers since it can */
587      /* return an internal buffer which can be overwritten on each call. */
588      savePtr = XtNewString(GETMESSAGE(2, 25, "Save"));
589      noSavePtr = XtNewString(GETMESSAGE(5, 152, "Don't Save"));
590      cancelPtr = XtNewString(GETMESSAGE(5, 154, "Cancel Close"));
591
592      display_question_message(CreateActionAppShell, msgPtr,
593                              savePtr, (XtCallbackProc)saveCB_QuestionDialog,
594                              noSavePtr, nosaveCB_QuestionDialog,
595                              cancelPtr, cancelCB_QuestionDialog);
596
597      XtFree(cancelPtr);
598      XtFree(noSavePtr);
599      XtFree(savePtr);
600      XtFree(msgPtr);
601      return;
602   }
603
604   FreeResources();
605
606   exit(0);
607 }
608
609 /******************************************************************************/
610 /*                                                                            */
611 /*                                                                            */
612 /*      Callbacks for Create Action 'Options' menu                            */
613 /*                                                                            */
614 /*                                                                            */
615 /* void activateCB_ExpertOption ();                                           */
616 /*                                                                            */
617 /*                                                                            */
618 /******************************************************************************/
619
620
621 /******************************************************************************/
622 /* activateCB_ExpertOption - turn expert option on/off                        */
623 /* INPUT: Widget wid - widget id                                              */
624 /*        XtPointer client_data - client data                                 */
625 /*        XtPointer *cbs - callback data                                      */
626 /* OUTPUT: none                                                               */
627 /* Global Variables Accessed: (other than widgets)                            */
628 /* wintypeheight                                                              */
629 /******************************************************************************/
630 void activateCB_ExpertOption (Widget wid, XtPointer client_data,
631                               XtPointer *cbs)
632 {
633   Dimension  ca_width;
634
635   if (!XtIsManaged(XprtOptionForm)) {
636      /**********************************************************************/
637      /* Expand the window to show optional data.                           */
638      /**********************************************************************/
639      XtVaGetValues (CA_WindowTypeArea, XmNwidth, &ca_width, NULL);
640      XtVaSetValues (CA_Expand,
641                     XmNbottomAttachment, XmATTACH_NONE,
642                     NULL);
643      XtVaSetValues (XprtOptionForm,
644                     XmNbottomAttachment, XmATTACH_FORM,
645                     XmNleftAttachment, XmATTACH_FORM,
646                     XmNrightAttachment, XmATTACH_FORM,
647                     XmNwidth, ca_width,
648                     NULL);
649      XtManageChild (XprtOptionForm);
650      XtVaSetValues (CA_Expand,
651                     XmNbottomAttachment, XmATTACH_WIDGET,
652                     XmNbottomWidget, XprtOptionForm,
653                     XmNbottomOffset, 10,
654                   /*XmNlabelString, GETMESSAGE(3, 52, "Basic"),*/
655                     RES_CONVERT( XmNlabelString, GETMESSAGE(3, 52, "Basic")),
656                     NULL);
657      XtVaSetValues (CA_HelpTextWindow, XmNheight, wintypeheight, NULL);
658      /*XtVaSetValues (CA_WindowTypeArea, XmNheight, wintypeheight, NULL);*/
659   } else {
660      /**********************************************************************/
661      /* Shrink the window to hide optional data.                           */
662      /**********************************************************************/
663      XtVaSetValues (CA_Expand, XmNbottomAttachment, XmATTACH_NONE, NULL);
664      XtUnmanageChild (XprtOptionForm);
665      XtVaSetValues (CA_Expand,
666                     XmNbottomAttachment, XmATTACH_FORM,
667                     XmNbottomOffset, 15,
668                   /*XmNlabelString, GETMESSAGE(3, 50, "Advanced"),*/
669                     RES_CONVERT( XmNlabelString, GETMESSAGE(3, 50, "Advanced")),
670                     NULL);
671      XtVaSetValues (CA_HelpTextWindow, XmNheight, wintypeheight, NULL);
672      XtVaSetValues (CA_WindowTypeArea, XmNheight, wintypeheight, NULL);
673   }
674   return;
675 }
676
677 /******************************************************************************/
678 /*                                                                            */
679 /* valueChangedCB_ColorMonoOption - turn monochrome option on/off             */
680 /*                                                                            */
681 /* INPUT: Widget wid - widget id                                              */
682 /*        XtPointer client_data - client data                                 */
683 /*        XmToggleButtonCallbackStruct *tcb - callback data                   */
684 /* OUTPUT: none                                                               */
685 /*                                                                            */
686 /******************************************************************************/
687 void valueChangedCB_ColorMonoOption (Widget wid, XtPointer client_data,
688                               XmToggleButtonCallbackStruct *tcb)
689 {
690   int        toggle_set= tcb->set;
691   IconData   *pIconData;
692   Widget     widIcon;
693   Widget     widIcons[3];
694   int        i;
695
696   /***************************************************************************/
697   /* If set then change icons from pixmaps to bitmaps.                       */
698   /***************************************************************************/
699   if (toggle_set) {
700      bShowPixmaps = FALSE;
701   } else {
702      bShowPixmaps = TRUE;
703   }
704
705   /***************************************************************************/
706   /* Change icons for CA large, med, and tiny icons                          */
707   /***************************************************************************/
708   widIcons[0] = CA_LRG_IconGadget;
709   widIcons[1] = CA_MED_IconGadget;
710   widIcons[2] = CA_TINY_IconGadget;
711   for (i = 0; i < 3; i++) {
712      pIconData = GetIconDataFromWid(widIcons[i]);
713      if (pIconData) {
714         if (bShowPixmaps) {
715            SET_ICONGADGET_ICON(widIcons[i], pIconData->pmFileName);
716         } else {
717            SET_ICONGADGET_ICON(widIcons[i], pIconData->bmFileName);
718         }
719      }
720   }
721
722 }
723
724 /******************************************************************************/
725 /*                                                                            */
726 /* createCB_ColorMonoOption                                                   */
727 /*                                                                            */
728 /* INPUT: Widget wid - widget id                                              */
729 /* OUTPUT: none                                                               */
730 /*                                                                            */
731 /******************************************************************************/
732 void createCB_ColorMonoOption (Widget wid)
733 {
734   bShowPixmaps = TRUE;
735 #ifdef DEBUG
736   printf("bShowPixmaps = %d\n", (int)bShowPixmaps);
737 #endif
738   return;
739 }
740
741 /******************************************************************************/
742 /*                                                                            */
743 /*                                                                            */
744 /*      Callbacks for Create Action 'Help' menu                               */
745 /*                                                                            */
746 /*                                                                            */
747 /******************************************************************************/
748
749 /******************************************************************************/
750 /*                                                                            */
751 /*                                                                            */
752 /*      Callbacks for Create Action Panel Buttons                             */
753 /*                                                                            */
754 /*                                                                            */
755 /* void activateCB_action_icon ();                                            */
756 /*                                                                            */
757 /*                                                                            */
758 /******************************************************************************/
759
760 /******************************************************************************/
761 /*                                                                            */
762 /* activateCB_action_icon -                                                  */
763 /*                                                                            */
764 /* INPUT: Widget wid - id of icon gadget                                      */
765 /*        XtPointer client_data - not used                                    */
766 /*        XmPushButtonCallbackStruct *cbs - not used                          */
767 /* OUTPUT: none                                                               */
768 /*                                                                            */
769 /******************************************************************************/
770 void activateCB_action_icon (Widget wid, XtPointer client_data,
771                              DtIconCallbackStruct *cbs)
772 {
773   Time    lts, mct = 0;
774   static  Time prev_lts = 0;
775
776   if (cbs->reason == XmCR_ACTIVATE) {
777
778 #ifdef DEBUG
779     printf("In activate_action_icon callback.\n");
780 #endif
781     if (last_action_pushed && (last_action_pushed != wid)) {
782        XtVaSetValues(XtParent(last_action_pushed), XmNborderWidth, 0, NULL);
783     }
784     XtVaSetValues(XtParent(wid), XmNborderWidth, ICON_BORDER_WIDTH, NULL);
785
786     last_action_pushed = wid;
787
788     /********************************************************************/
789     /* This is the support needed to provide double-click functionality */
790     /* to the icon gadgets.  When double-clicked, the icon editor will  */
791     /* be launched.                                                     */
792     /********************************************************************/
793     XtVaSetValues(wid, XmNpushButtonClickTime, 0, NULL);
794
795     lts = XtLastTimestampProcessed(XtDisplay(wid));
796     mct = XtGetMultiClickTime(XtDisplay(wid));
797
798     if ((prev_lts + mct) > lts) {
799        prev_lts = XtLastTimestampProcessed(XtDisplay(wid));
800     } else {
801        prev_lts = XtLastTimestampProcessed(XtDisplay(wid));
802        return;
803     }
804
805 #ifdef DEBUG
806     printf("DblClick icon callback.\n");
807 #endif
808
809     activateCB_edit_icon(wid, CA_ACTION_ICONS, cbs);
810
811   }
812   return;
813 }
814
815 /******************************************************************************/
816 /* activateCB_add_filetype - bring up the Add Filetype dialog with correct    */
817 /*              dialog title.                                                 */
818 /* INPUT: Widget wid - not used                                               */
819 /*        XtPointer client_data - not used                                    */
820 /*        XmPushButtonCallbackStruct *cbs - not used                          */
821 /* OUTPUT: none                                                               */
822 /******************************************************************************/
823 void activateCB_add_filetype (Widget wid, XtPointer client_data,
824                               XmPushButtonCallbackStruct *cbs)
825 {
826   FiletypeData *pFtD;
827   char         *ptr;
828   char          tmpbuf[50];
829   char         *pre, *suf, *title;
830
831   if (!CreateActionAppShellCheckFields()) {
832
833 #ifdef DEBUG
834     printf("Allocating FiletypeData structure\n"); /* debug */
835 #endif
836
837     /******************************************************************/
838     /* Allocate FiletypeData structure                                */
839     /******************************************************************/
840     pFtD = (FiletypeData *)XtMalloc(sizeof(FiletypeData));
841     memset(pFtD, 0, sizeof(FiletypeData));
842
843     /******************************************************************/
844     /* Clear dialog fields                                            */
845     /******************************************************************/
846     clear_AddFiletype_dialog_fields();
847     clear_FileCharacteristics_dialog_fields();
848
849     /******************************************************************/
850     /* Create name for filetype                                       */
851     /******************************************************************/
852     memset(tmpbuf, 0, 50);
853     sprintf(tmpbuf, "%d", (AD.cFiletypes + 1));
854     ptr = (char *)XmTextFieldGetString(CA_ActionNameTextField);
855     pFtD->pszName = (char *)XtMalloc(strlen(ptr) + strlen("_FILE_") + strlen(tmpbuf) + 1);
856     sprintf(pFtD->pszName, "%s_FILE_%d", ptr, (AD.cFiletypes + 1));
857     XtFree(ptr);
858     XmTextFieldSetString(AF_FileTypeNameTextField, pFtD->pszName);
859
860     pFtD->pszIcon = (char *)XtMalloc(strlen(af_icon_default) + 1);
861     strcpy(pFtD->pszIcon, af_icon_default);
862
863     /******************************************************************/
864     /* Set Open command string                                        */
865     /******************************************************************/
866     /*
867     pFtD->pszOpenCmd = (char *)XmTextGetString(CA_DblClkText);
868     */
869     GetWidgetTextString(CA_DblClkText, &(pFtD->pszOpenCmd));
870     XmTextSetString(AF_OpenCmdText, pFtD->pszOpenCmd);
871
872     pre = GETMESSAGE(3, 10, "Create Action");
873     suf = GETMESSAGE(7, 10, "Add Datatype");
874     title = XtMalloc(strlen(pre) + strlen(suf) + 2);
875     sprintf(title, "%s - %s", pre, suf);
876
877     XtVaSetValues (AddFiletype,
878                    RES_CONVERT (XmNdialogTitle, title ),
879                    XmNuserData, pFtD,
880                    NULL);
881
882     XtFree(title);
883     UxPopupInterface (AddFiletype, no_grab);
884   }
885   return;
886 }
887
888
889 /******************************************************************************/
890 /* activateCB_edit_filetype - bring up the Add Filetype dialog with correct   */
891 /*              dialog title.                                                 */
892 /* INPUT: Widget wid - not used                                               */
893 /*        XtPointer client_data - not used                                    */
894 /*        XmPushButtonCallbackStruct *cbs - not used                          */
895 /* OUTPUT: none                                                               */
896 /******************************************************************************/
897 void activateCB_edit_filetype (Widget wid, XtPointer client_data,
898                               XmPushButtonCallbackStruct *cbs)
899 {
900   FiletypeData *pFtD;
901   int          *poslist, poscnt;
902   int          selecteditem;
903   char         *msgPtr1, *msgPtr2, *fmtPtr, *errPtr;
904   char         *pre, *suf, *title;
905
906   pre = GETMESSAGE(3, 10, "Create Action");
907   suf = GETMESSAGE(7, 11, "Edit Datatype");
908   title = XtMalloc(strlen(pre) + strlen(suf) + 2);
909   sprintf(title, "%s - %s", pre, suf);
910
911   /**************************************************************************/
912   /* Determine the selected list item.                                      */
913   /**************************************************************************/
914   if (XmListGetSelectedPos(CA_FiletypesList, &poslist, &poscnt)) {
915      selecteditem = *poslist;
916      selecteditem--;
917      if (selecteditem >= 0) {
918         pFtD = AD.papFiletypes[selecteditem];
919         pFtD->fsInternal |= CA_FT_EDIT;
920         GetWidgetTextString(CA_DblClkText, &(pFtD->pszOpenCmd));
921         clear_AddFiletype_dialog_fields();
922         init_AddFiletype_dialog_fields(pFtD);
923
924         /********************************************************************/
925         /* Pop up the AddFiletype dialog.                                   */
926         /********************************************************************/
927         XtVaSetValues (AddFiletype,
928                        RES_CONVERT (XmNdialogTitle, title),
929                        XmNuserData, pFtD,
930                        NULL);
931         UxPopupInterface (AddFiletype, no_grab);
932      }
933   } else {
934      msgPtr1 = XtNewString(GETMESSAGE(5, 120,
935                   "You have not selected a Datatype from the\n\
936 'Datatypes That Use This Action' list."));
937      msgPtr2 = XtNewString(GETMESSAGE(5, 130,
938                   "Please select the Datatype you would like to Edit."));
939      fmtPtr = "%s\n%s";
940      errPtr = XtMalloc((strlen(msgPtr1) + strlen(msgPtr2) +
941                         strlen(fmtPtr) + 1) * sizeof(char));
942      sprintf(errPtr, fmtPtr, msgPtr1, msgPtr2);
943      XtFree(msgPtr2);
944      XtFree(msgPtr1);
945      display_error_message(CreateActionAppShell, errPtr);
946      XtFree(errPtr);
947   }
948   XtFree(title);
949   return;
950 }
951
952 /******************************************************************************/
953 /*                                                                            */
954 /* get_selected_action_icon - determines which action icon is currently       */
955 /*                            selected.                                       */
956 /*                                                                            */
957 /* INPUT: none                                                                */
958 /* OUTPUT: Widget wid - id of selected icon gadget                            */
959 /*                                                                            */
960 /******************************************************************************/
961 Widget get_selected_action_icon (void)
962 {
963 #if 0
964   Widget wid;
965
966   if (_DtIconGetState(CA_LRG_IconGadget)) wid = CA_LRG_IconGadget;
967   else if (_DtIconGetState(CA_MED_IconGadget)) wid = CA_MED_IconGadget;
968   else if (_DtIconGetState(CA_TINY_IconGadget)) wid = CA_TINY_IconGadget;
969   else wid = CA_LRG_IconGadget;
970 #endif
971
972   if (!last_action_pushed) {
973     last_action_pushed = CA_LRG_IconGadget;
974   }
975   return (last_action_pushed);
976 }
977
978 /******************************************************************************/
979 /*                                                                            */
980 /* CreateActionAppShellCheckFields                                            */
981 /*                                                                            */
982 /* INPUT:  none                                                               */
983 /* OUTPUT: FALSE  - no errors found                                           */
984 /*         TRUE   - found errors                                              */
985 /*                                                                            */
986 /******************************************************************************/
987 Boolean CreateActionAppShellCheckFields(void)
988 {
989
990   char    *ptr = (char *)NULL;
991   char    *ptrPrompt = (char *)NULL;
992   Boolean bError = FALSE;
993   char    *msgPtr, *errPtr;
994
995   /**************************************************************************/
996   /* Check if action name is present.                                       */
997   /**************************************************************************/
998   if (!bError) {
999      ptr = (char *)NULL;
1000      GetWidgetTextString(CA_ActionNameTextField, &ptr);
1001 #ifdef DEBUG
1002      printf("Action Name = '%s'\n", ptr);
1003 #endif
1004      if (!ptr) {
1005         msgPtr = GETMESSAGE(5, 10, "The Action Name is missing.\n\
1006 Please enter a name in the 'Action Name' field.");
1007         errPtr = XtNewString(msgPtr);
1008         display_error_message(CreateActionAppShell, errPtr);
1009         XtFree(errPtr);
1010         XmProcessTraversal(CA_ActionNameTextField, XmTRAVERSE_CURRENT);
1011         bError = TRUE;
1012      } else {
1013         XtFree(ptr);
1014      }
1015   }
1016
1017   /**************************************************************************/
1018   /* Check if execute command is present.                                   */
1019   /**************************************************************************/
1020   if (!bError) {
1021      ptr = (char *)NULL;
1022      GetWidgetTextString(CA_DblClkText, &ptr);
1023 #ifdef DEBUG
1024      printf("Exec String = '%s'\n", ptr);
1025 #endif
1026      if (!ptr) {
1027         msgPtr = GETMESSAGE(5, 15, "The execute command is missing.\n\
1028 Please enter a command in the\n\
1029 'Command To Execute When Double-clicked' field.");
1030         errPtr = XtNewString(msgPtr);
1031         display_error_message(CreateActionAppShell, errPtr);
1032         XtFree(errPtr);
1033         XmProcessTraversal(CA_DblClkText, XmTRAVERSE_CURRENT);
1034         bError = TRUE;
1035      } else {
1036         /********************************************************************/
1037         /* Now check to see if there is a prompt string.  If so, make sure  */
1038         /* there is an argument variable within the exec string.            */
1039         /********************************************************************/
1040         GetWidgetTextString(CA_XprtActionOpenText, &ptrPrompt);
1041         if (ptrPrompt) {
1042            if (!strchr(ptr, '$')) {
1043               msgPtr = GETMESSAGE(5, 30, "A variable name is missing in the\n\
1044 'Command To Execute When Double-clicked' field.\n\
1045 Add a variable name for the label you have entered\n\
1046 in the 'When Action Opens, Ask Users for' field.\n\
1047 Valid variable names are $*, $1, $2, ..., $9.");
1048               errPtr = XtNewString(msgPtr);
1049               display_error_message(CreateActionAppShell, errPtr);
1050               XtFree(errPtr);
1051               XmProcessTraversal(CA_DblClkText, XmTRAVERSE_CURRENT);
1052               bError = TRUE;
1053            }
1054            XtFree(ptrPrompt);
1055         }
1056         XtFree(ptr);
1057      }
1058   }
1059
1060   /**************************************************************************/
1061   /* Check if droppable filetypes buttons are set correctly.                */
1062   /**************************************************************************/
1063   if (!bError) {
1064      if ((AD.fsFlags & CA_DF_ONLYFTFILES) && !(AD.papFiletypes)) {
1065         msgPtr = GETMESSAGE(5, 20,
1066                 "The 'Datatypes That Use This Action' list is empty.\n\
1067 You have selected 'Only Above List' in the 'Dropable\n\
1068 Datatypes' field.\n\
1069 Change the Dropable Datatype choice to 'All Datatypes'\n\
1070 or add at least one datatype to the list.");
1071         errPtr = XtNewString(msgPtr);
1072         display_error_message(CreateActionAppShell, errPtr);
1073         XtFree(errPtr);
1074         XmProcessTraversal(CA_AllFiletypesToggle, XmTRAVERSE_CURRENT);
1075         bError = TRUE;
1076      }
1077   }
1078
1079   return(bError);
1080 }
1081
1082 /******************************************************************************/
1083 /*                                                                            */
1084 /* copyString                                                                 */
1085 /*                                                                            */
1086 /* INPUT:                                                                     */
1087 /* OUTPUT:                                                                    */
1088 /*                                                                            */
1089 /*                                                                            */
1090 /******************************************************************************/
1091 char * copyString(char *string)
1092 {
1093   char *newstring;
1094
1095   if (string) {
1096      newstring = (char *)XtMalloc(strlen(string) + 1);
1097      strcpy(newstring, string);
1098   } else {
1099      newstring = (char *)NULL;
1100   }
1101   return(newstring);
1102 }
1103
1104 /******************************************************************************/
1105 /*                                                                            */
1106 /* copyFtD                                                                    */
1107 /*                                                                            */
1108 /* INPUT:                                                                     */
1109 /* OUTPUT:                                                                    */
1110 /*                                                                            */
1111 /*                                                                            */
1112 /******************************************************************************/
1113 FiletypeData * copyFtD(FiletypeData *pFtD)
1114 {
1115   FiletypeData *pcopyFtD;
1116
1117   pcopyFtD = (FiletypeData *)XtMalloc(sizeof(FiletypeData));
1118   memset(pcopyFtD, 0, sizeof(FiletypeData));
1119
1120   if (pFtD->pszName) {
1121      pcopyFtD->pszName = copyString(pFtD->pszName);
1122   }
1123   if (pFtD->pszIcon) {
1124      pcopyFtD->pszIcon = copyString(pFtD->pszIcon);
1125   }
1126   if (pFtD->pszHelp) {
1127      pcopyFtD->pszHelp = copyString(pFtD->pszHelp);
1128   }
1129   if (pFtD->pszOpenCmd) {
1130      pcopyFtD->pszOpenCmd = copyString(pFtD->pszOpenCmd);
1131   }
1132   if (pFtD->pszPrintCmd) {
1133      pcopyFtD->pszPrintCmd = copyString(pFtD->pszPrintCmd);
1134   }
1135   if (pFtD->pszPattern) {
1136      pcopyFtD->pszPattern = copyString(pFtD->pszPattern);
1137   }
1138   if (pFtD->pszPermissions) {
1139      pcopyFtD->pszPermissions = copyString(pFtD->pszPermissions);
1140   }
1141   if (pFtD->pszContents) {
1142      pcopyFtD->pszContents = copyString(pFtD->pszContents);
1143   }
1144
1145   pcopyFtD->sStart = pFtD->sStart;
1146   pcopyFtD->sEnd = pFtD->sEnd;
1147   pcopyFtD->fsFlags = pFtD->fsFlags;
1148   pcopyFtD->fsInternal = pFtD->fsInternal;
1149
1150   return(pcopyFtD);
1151 }
1152
1153 /******************************************************************************/
1154 /*                                                                            */
1155 /* copyAD                                                                     */
1156 /*                                                                            */
1157 /* INPUT:                                                                     */
1158 /* OUTPUT:                                                                    */
1159 /*                                                                            */
1160 /*                                                                            */
1161 /******************************************************************************/
1162 ActionData * copyAD(ActionData *pAD)
1163 {
1164   ActionData *pcopyAD;
1165   int i;
1166
1167   pcopyAD = (ActionData *)XtMalloc(sizeof(ActionData));
1168   if (!pcopyAD) {
1169      return((ActionData *)NULL);
1170   }
1171   memset(pcopyAD, 0, sizeof(ActionData));
1172
1173   if (pAD->pszName) {
1174      pcopyAD->pszName = copyString(pAD->pszName);
1175   }
1176   if (pAD->pszIcon) {
1177      pcopyAD->pszIcon = copyString(pAD->pszIcon);
1178   }
1179   if (pAD->pszCmd) {
1180      pcopyAD->pszCmd = copyString(pAD->pszCmd);
1181   }
1182   if (pAD->pszHelp) {
1183      pcopyAD->pszHelp = copyString(pAD->pszHelp);
1184   }
1185   if (pAD->pszPrompt) {
1186      pcopyAD->pszPrompt = copyString(pAD->pszPrompt);
1187   }
1188   if (pAD->papFiletypes) {
1189      pcopyAD->papFiletypes = (FiletypeData **) XtMalloc(sizeof(FiletypeData *) * (pAD->cFiletypes + 1));
1190      for (i=0; i < pAD->cFiletypes; i++) {
1191         pcopyAD->papFiletypes[i] = copyFtD(pAD->papFiletypes[i]);
1192      }
1193   }
1194   pcopyAD->cFiletypes = pAD->cFiletypes;
1195   pcopyAD->fsFlags = pAD->fsFlags;
1196   return(pcopyAD);
1197 }
1198 /******************************************************************************/
1199 /*                                                                            */
1200 /* compareStrings                                                             */
1201 /*                                                                            */
1202 /* INPUT:  two pointers to char *'s                                           */
1203 /* OUTPUT: 0  they are the same                                               */
1204 /*         1  they are different                                              */
1205 /*                                                                            */
1206 /******************************************************************************/
1207 Boolean compareStrings(char *pszStr1, char *pszStr2)
1208 {
1209   if (pszStr1 || pszStr2) {
1210      if (pszStr1) {
1211         if (pszStr2) {
1212            if (!strcmp(pszStr1, pszStr2)) {
1213               return(EQUAL);
1214            } else {
1215               return(NOT_EQUAL);
1216            }
1217         } else {
1218            return(NOT_EQUAL);
1219         }
1220      } else {
1221         return(NOT_EQUAL);
1222      }
1223   } else {
1224      return(EQUAL);
1225   }
1226 }
1227
1228 /******************************************************************************/
1229 /*                                                                            */
1230 /* compareFtD                                                                 */
1231 /*                                                                            */
1232 /* INPUT:  two pointers to FtD structures                                     */
1233 /* OUTPUT: 0  they are the same                                               */
1234 /*         1  they are different                                              */
1235 /*                                                                            */
1236 /******************************************************************************/
1237 Boolean compareFtD(FiletypeData *pFtD1, FiletypeData *pFtD2)
1238 {
1239   if (compareStrings(pFtD1->pszName, pFtD2->pszName)) {
1240      return(NOT_EQUAL);
1241   }
1242   if (compareStrings(pFtD1->pszIcon, pFtD2->pszIcon)) {
1243      return(NOT_EQUAL);
1244   }
1245   if (compareStrings(pFtD1->pszHelp, pFtD2->pszHelp)) {
1246      return(NOT_EQUAL);
1247   }
1248   if (compareStrings(pFtD1->pszOpenCmd, pFtD2->pszOpenCmd)) {
1249      return(NOT_EQUAL);
1250   }
1251   if (compareStrings(pFtD1->pszPrintCmd, pFtD2->pszPrintCmd)) {
1252      return(NOT_EQUAL);
1253   }
1254   if (compareStrings(pFtD1->pszPattern, pFtD2->pszPattern)) {
1255      return(NOT_EQUAL);
1256   }
1257   if (compareStrings(pFtD1->pszPermissions, pFtD2->pszPermissions)) {
1258      return(NOT_EQUAL);
1259   }
1260   if (compareStrings(pFtD1->pszContents, pFtD2->pszContents)) {
1261      return(NOT_EQUAL);
1262   }
1263   if (pFtD1->fsFlags != pFtD2->fsFlags) {
1264      return(NOT_EQUAL);
1265   }
1266   if (pFtD1->sStart != pFtD2->sStart) {
1267      return(NOT_EQUAL);
1268   }
1269   if (pFtD1->sEnd != pFtD2->sEnd) {
1270      return(NOT_EQUAL);
1271   }
1272
1273   return(EQUAL);
1274 }
1275
1276 /******************************************************************************/
1277 /*                                                                            */
1278 /* compareAD                                                                  */
1279 /*                                                                            */
1280 /* INPUT:  two pointers to AD structures                                      */
1281 /* OUTPUT: 0  they are the same                                               */
1282 /*         1  they are different                                              */
1283 /*                                                                            */
1284 /******************************************************************************/
1285 Boolean compareAD(ActionData *pAD1, ActionData *pAD2)
1286 {
1287   int i;
1288
1289   if (compareStrings(pAD1->pszName, pAD2->pszName)) {
1290      return(NOT_EQUAL);
1291   }
1292   if (compareStrings(pAD1->pszIcon, pAD2->pszIcon)) {
1293      return(NOT_EQUAL);
1294   }
1295   if (compareStrings(pAD1->pszCmd, pAD2->pszCmd)) {
1296      return(NOT_EQUAL);
1297   }
1298   if (compareStrings(pAD1->pszHelp, pAD2->pszHelp)) {
1299      return(NOT_EQUAL);
1300   }
1301   if (compareStrings(pAD1->pszPrompt, pAD2->pszPrompt)) {
1302      return(NOT_EQUAL);
1303   }
1304   if (pAD1->fsFlags != pAD2->fsFlags) {
1305      return(NOT_EQUAL);
1306   }
1307   if (pAD1->cFiletypes != pAD2->cFiletypes) {
1308      return(NOT_EQUAL);
1309   }
1310
1311   if (pAD1->papFiletypes) {
1312      for (i=0; i < pAD1->cFiletypes; i++) {
1313         if (compareFtD(pAD1->papFiletypes[i], pAD2->papFiletypes[i])) {
1314            return(NOT_EQUAL);
1315         }
1316      }
1317   }
1318
1319   return(EQUAL);
1320 }