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