dtwm: basic multihead(xinerama only) support
[oweals/cde.git] / cde / programs / dtcreate / af_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: af_aux.c /main/6 1998/04/06 13:14:19 mgreess $ */
24 /******************************************************************************/
25 /*                                                                            */
26 /* af_aux - auxiliary functions for add filetype                              */
27 /*                                                                            */
28 /* Functions to get/set values from/to interface.                             */
29 /* Callback routines for AF interface.                                        */
30 /*                                                                            */
31 /******************************************************************************/
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <sys/signal.h>
36 #include <errno.h>
37 #include <unistd.h>
38 #include <X11/cursorfont.h>
39 #include <X11/Xlib.h>
40 #include <X11/Xatom.h>
41 #include <Xm/Xm.h>
42 #include <Xm/TextF.h>
43 #include <Xm/RowColumnP.h>
44 #include <Xm/MessageB.h>
45 #include <Xm/FileSB.h>
46 #include <Xm/List.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
60 #include "dtcreate.h"
61 #include "af_aux.h"
62 #include "cmncbs.h"
63 #include "cmnutils.h"
64 #include "cmnrtns.h"
65 #include "ErrorDialog.h"
66 #include "FileCharacteristics.h"
67
68 /******************************************************************************/
69 /*                                                                            */
70 /*  External Variables                                                        */
71 /*                                                                            */
72 /******************************************************************************/
73
74 /******************************************************************************/
75 /*                                                                            */
76 /*  Variables                                                                 */
77 /*                                                                            */
78 /******************************************************************************/
79
80 /******************************************************************************/
81 /*                                                                            */
82 /*         CALLBACK FUNCTIONS                                                 */
83 /*                                                                            */
84 /******************************************************************************/
85
86 /******************************************************************************/
87 /*                                                                            */
88 /* get_selected_filetype_icon - determines which filetype icon is currently   */
89 /*                              selected.                                     */
90 /*                                                                            */
91 /* INPUT: none                                                                */
92 /* OUTPUT: Widget wid - id of selected icon gadget                            */
93 /*                                                                            */
94 /******************************************************************************/
95 Widget get_selected_filetype_icon (void)
96 {
97   if (!last_filetype_pushed) {
98     last_filetype_pushed = AF_MED_IconGadget;
99   }
100   return (last_filetype_pushed);
101 }
102
103 /******************************************************************************/
104 /*                                                                            */
105 /* activateCB_filetype_icon                                                   */
106 /*                                                                            */
107 /* INPUT: Widget wid - id of icon gadget                                      */
108 /*        XtPointer client_data - not used                                    */
109 /*        XmPushButtonCallbackStruct *cbs - not used                          */
110 /* OUTPUT: none                                                               */
111 /*                                                                            */
112 /******************************************************************************/
113 void activateCB_filetype_icon (Widget wid, XtPointer client_data,
114                                DtIconCallbackStruct *cbs)
115 {
116   Time    lts, mct = 0;
117   static  Time prev_lts = 0;
118
119   if (cbs->reason == XmCR_ACTIVATE) {
120
121 #ifdef DEBUG
122     printf("In activate_filetype_icon callback.\n");
123 #endif
124     if (last_filetype_pushed && (last_filetype_pushed != wid)) {
125        XtVaSetValues(XtParent(last_filetype_pushed), XmNborderWidth, 0, NULL);
126     }
127     XtVaSetValues(XtParent(wid), XmNborderWidth, ICON_BORDER_WIDTH, NULL);
128
129     last_filetype_pushed = wid;
130
131     /********************************************************************/
132     /* This is the support needed to provide double-click functionality */
133     /* to the icon gadgets.  When double-clicked, the icon editor will  */
134     /* be launched.                                                     */
135     /********************************************************************/
136     XtVaSetValues(wid, XmNpushButtonClickTime, 0, NULL);
137
138     lts = XtLastTimestampProcessed(XtDisplay(wid));
139     mct = XtGetMultiClickTime(XtDisplay(wid));
140
141     if ((prev_lts + mct) > lts) {
142        prev_lts = XtLastTimestampProcessed(XtDisplay(wid));
143     } else {
144        prev_lts = XtLastTimestampProcessed(XtDisplay(wid));
145        return;
146     }
147
148 #ifdef DEBUG
149     printf("DblClick icon callback.\n");
150 #endif
151
152     activateCB_edit_icon(wid, (XtPointer)CA_FILETYPE_ICONS,
153         (XmPushButtonCallbackStruct *)cbs /* unused anyway */);
154
155   }
156
157   return;
158 }
159
160 /******************************************************************************/
161 /*                                                                            */
162 /*   readAFFromGUI -                                                          */
163 /*                                                                            */
164 /*                                                                            */
165 /*                                                                            */
166 /******************************************************************************/
167 void readAFFromGUI (FiletypeData *pFiletypedata)
168 {
169   getAF_FiletypeName(pFiletypedata);
170   getAF_HelpText(pFiletypedata);
171   getAF_OpenCmd(pFiletypedata);
172   getAF_PrintCmd(pFiletypedata);
173   getAF_Icons(pFiletypedata);
174
175   return;
176 }
177
178 /******************************************************************************/
179 /*                                                                            */
180 /* getAF_FiletypeName - get name of filetype family                           */
181 /*                                                                            */
182 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
183 /* OUTPUT: none                                                               */
184 /*                                                                            */
185 /******************************************************************************/
186 void getAF_FiletypeName (FiletypeData *pFiletypedata)
187 {
188   GetWidgetTextString(AF_FileTypeNameTextField, &(pFiletypedata->pszName));
189   return;
190 }
191
192 /******************************************************************************/
193 /*                                                                            */
194 /* getAF_HelpText - retrieve the Help text for the filetype                   */
195 /*                                                                            */
196 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
197 /* OUTPUT: none                                                               */
198 /*                                                                            */
199 /******************************************************************************/
200 void getAF_HelpText (FiletypeData *pFiletypedata)
201 {
202   GetWidgetTextString(AF_FiletypeHelpText, &(pFiletypedata->pszHelp));
203   return;
204 }
205
206 /******************************************************************************/
207 /*                                                                            */
208 /* getAF_Icons - store temporary icon names.                                  */
209 /*                                                                            */
210 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
211 /* OUTPUT: none                                                               */
212 /*                                                                            */
213 /******************************************************************************/
214 void getAF_Icons(FiletypeData *pFiletypedata)
215 {
216   IconData  *pIconData;
217
218   /***************************************************************/
219   /* Medium Pixmap                                               */
220   /***************************************************************/
221   pIconData = GetIconDataFromWid(AF_MED_IconGadget);
222   if ( (pIconData->pmDirtyBit) &&
223        (pIconData->pmFileName) &&
224        (strlen(pIconData->pmFileName)) ) {
225      pFiletypedata->pszMedPmIcon = XtMalloc(strlen(pIconData->pmFileName) + 1);
226      if (pFiletypedata->pszMedPmIcon) {
227         strcpy(pFiletypedata->pszMedPmIcon, pIconData->pmFileName);
228      }
229   }
230   pIconData->pmDirtyBit = False;
231   strcpy(pIconData->pmFileName, "");
232
233   /***************************************************************/
234   /* Medium Bitmap                                               */
235   /***************************************************************/
236   if ( (pIconData->bmDirtyBit) &&
237        (pIconData->bmFileName) &&
238        (strlen(pIconData->bmFileName)) ) {
239      pFiletypedata->pszMedBmIcon = XtMalloc(strlen(pIconData->bmFileName) + 1);
240      if (pFiletypedata->pszMedBmIcon) {
241         strcpy(pFiletypedata->pszMedBmIcon, pIconData->bmFileName);
242      }
243   }
244   pIconData->bmDirtyBit = False;
245   strcpy(pIconData->bmFileName, "");
246
247   /***************************************************************/
248   /* Tiny Pixmap                                                 */
249   /***************************************************************/
250   pIconData = GetIconDataFromWid(AF_TINY_IconGadget);
251   if ( (pIconData->pmDirtyBit) &&
252        (pIconData->pmFileName) &&
253        (strlen(pIconData->pmFileName)) ) {
254      pFiletypedata->pszTinyPmIcon = XtMalloc(strlen(pIconData->pmFileName) + 1);
255      if (pFiletypedata->pszTinyPmIcon) {
256         strcpy(pFiletypedata->pszTinyPmIcon, pIconData->pmFileName);
257      }
258   }
259   pIconData->pmDirtyBit = False;
260   strcpy(pIconData->pmFileName, "");
261
262   /***************************************************************/
263   /* Tiny Bitmap                                                 */
264   /***************************************************************/
265   if ( (pIconData->bmDirtyBit) &&
266        (pIconData->bmFileName) &&
267        (strlen(pIconData->bmFileName)) ) {
268      pFiletypedata->pszTinyBmIcon = XtMalloc(strlen(pIconData->bmFileName) + 1);
269      if (pFiletypedata->pszTinyBmIcon) {
270         strcpy(pFiletypedata->pszTinyBmIcon, pIconData->bmFileName);
271      }
272   }
273   pIconData->bmDirtyBit = False;
274   strcpy(pIconData->bmFileName, "");
275
276
277 #if 0
278   Widget    AF_wids[2];
279   int       i;
280
281
282   AF_wids[0] = AF_MED_IconGadget;
283   AF_wids[1] = AF_TINY_IconGadget;
284
285   for (i=0; i < 2; i++) {
286      /* pixmap */
287      pIconData = GetIconDataFromWid(AF_wids[i]);
288      if ( (pIconData->pmDirtyBit) &&
289           (pIconData->pmFileName) &&
290           (strlen(pIconData->pmFileName)) ) {
291         pFiletypedata->pszMedPmIcon = XtMalloc(strlen(pIconData->pmFileName) + 1);
292         if (pFiletypedata->pszMedPmIcon) {
293            strcpy(pFiletypedata->pszMedPmIcon, pIconData->pmFileName);
294         }
295      }
296      pIconData->pmDirtyBit = False;
297      strcpy(pIconData->pmFileName, "");
298
299      /* bitmap */
300      if ( (pIconData->bmDirtyBit) &&
301           (pIconData->bmFileName) &&
302           (strlen(pIconData->bmFileName)) ) {
303         pFiletypedata->pszMedBmIcon = XtMalloc(strlen(pIconData->bmFileName) + 1);
304         if (pFiletypedata->pszMedBmIcon) {
305            strcpy(pFiletypedata->pszMedBmIcon, pIconData->bmFileName);
306         }
307      }
308      pIconData->bmDirtyBit = False;
309      strcpy(pIconData->bmFileName, "");
310   }
311 #endif
312
313
314 }
315
316 /******************************************************************************/
317 /*                                                                            */
318 /* getAF_OpenCmd - retrieve the Open command string                           */
319 /*                                                                            */
320 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
321 /* OUTPUT: none                                                               */
322 /*                                                                            */
323 /******************************************************************************/
324 void getAF_OpenCmd (FiletypeData *pFiletypedata)
325 {
326   GetWidgetTextString(AF_OpenCmdText, &(pFiletypedata->pszOpenCmd));
327   return;
328 }
329
330 /******************************************************************************/
331 /*                                                                            */
332 /* getAF_PrintCmd - retrieve Print command string                             */
333 /*                                                                            */
334 /* INPUT: FiletypeData *pFiletypedata - pointer to filetype data structure    */
335 /* OUTPUT: none                                                               */
336 /*                                                                            */
337 /******************************************************************************/
338 void getAF_PrintCmd (FiletypeData *pFiletypedata)
339 {
340   GetWidgetTextString(AF_FiletypePrintCmdTextField, &(pFiletypedata->pszPrintCmd));
341   return;
342 }
343
344 /******************************************************************************/
345 /*                                                                            */
346 /* init_AddFiletype_dialog_fields                                             */
347 /*                                                                            */
348 /* INPUT:  FiletypeData * - pointer to FiletypeData structure                 */
349 /* OUTPUT: none                                                               */
350 /*                                                                            */
351 /******************************************************************************/
352 void init_AddFiletype_dialog_fields(FiletypeData *pFtD)
353 {
354   char *pszIconFileName = (char *)NULL;
355   char *pszTmpFile;
356
357   if (pFtD->pszName) {
358      PutWidgetTextString(AF_FileTypeNameTextField, pFtD->pszName);
359   }
360
361   ParseAndUpdateID(pFtD);
362
363   if (pFtD->pszHelp) {
364      PutWidgetTextString(AF_FiletypeHelpText, pFtD->pszHelp);
365   }
366
367   if (pFtD->pszIcon) {
368
369      if (bShowPixmaps) {
370
371         /*************************/
372         /* Medium Pixmap         */
373         /*************************/
374         if (pFtD->pszMedPmIcon) {
375            SET_ICONGADGET_ICON(AF_MED_IconGadget, pFtD->pszMedPmIcon);
376         } else {
377            pszIconFileName = (char *)NULL;
378            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtMEDIUM);
379            pszTmpFile = GetCorrectIconType(pszIconFileName);
380            SET_ICONGADGET_ICON(AF_MED_IconGadget, pszTmpFile);
381            if (pszIconFileName) XtFree(pszIconFileName);
382            if (pszTmpFile) XtFree(pszTmpFile);
383         }
384
385         /*************************/
386         /* Tiny Pixmap           */
387         /*************************/
388         if (pFtD->pszTinyPmIcon) {
389            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pFtD->pszTinyPmIcon);
390         } else {
391            pszIconFileName = (char *)NULL;
392            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
393            pszTmpFile = GetCorrectIconType(pszIconFileName);
394            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
395            if (pszIconFileName) XtFree(pszIconFileName);
396            if (pszTmpFile) XtFree(pszTmpFile);
397         }
398      } else {
399         /*************************/
400         /* Medium Pixmap         */
401         /*************************/
402         if (pFtD->pszMedBmIcon) {
403            SET_ICONGADGET_ICON(AF_MED_IconGadget, pFtD->pszMedBmIcon);
404         } else {
405            pszIconFileName = (char *)NULL;
406            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtMEDIUM);
407            pszTmpFile = GetCorrectIconType(pszIconFileName);
408            SET_ICONGADGET_ICON(AF_MED_IconGadget, pszTmpFile);
409            if (pszIconFileName) XtFree(pszIconFileName);
410            if (pszTmpFile) XtFree(pszTmpFile);
411         }
412
413         /*************************/
414         /* Tiny Pixmap           */
415         /*************************/
416         if (pFtD->pszTinyBmIcon) {
417            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pFtD->pszTinyBmIcon);
418         } else {
419            pszIconFileName = (char *)NULL;
420            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
421            pszTmpFile = GetCorrectIconType(pszIconFileName);
422            SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
423            if (pszIconFileName) XtFree(pszIconFileName);
424            if (pszTmpFile) XtFree(pszTmpFile);
425         }
426      }
427
428
429 #if 0
430         /*************************/
431         /* Tiny Pixmap           */
432         /*************************/
433         pszIconFileName = (char *)NULL;
434         if (pFtD->pszTinyPmIcon) {
435            pszTmpFile = pFtD->pszTinyPmIcon;
436         } else {
437            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
438            pszTmpFile = pszIconFileName;
439         }
440         SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
441         if (pszIconFileName) XtFree(pszIconFileName);
442
443      } else {
444
445         /*************************/
446         /* Medium Bitmap         */
447         /*************************/
448         pszIconFileName = (char *)NULL;
449         if (pFtD->pszMedBmIcon) {
450            pszTmpFile = pFtD->pszMedBmIcon;
451         } else {
452            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtMEDIUM);
453            pszTmpFile = pszIconFileName;
454         }
455         SET_ICONGADGET_ICON(AF_MED_IconGadget, pszTmpFile);
456         if (pszIconFileName) XtFree(pszIconFileName);
457
458         /*************************/
459         /* Tiny Bitmap           */
460         /*************************/
461         pszIconFileName = (char *)NULL;
462         if (pFtD->pszTinyBmIcon) {
463            pszTmpFile = pFtD->pszTinyBmIcon;
464         } else {
465            FIND_ICONGADGET_ICON(pFtD->pszIcon, pszIconFileName, DtTINY);
466            pszTmpFile = pszIconFileName;
467         }
468         SET_ICONGADGET_ICON(AF_TINY_IconGadget, pszTmpFile);
469         if (pszIconFileName) XtFree(pszIconFileName);
470      }
471 #endif
472
473   }
474
475   if (pFtD->pszOpenCmd) {
476      PutWidgetTextString(AF_OpenCmdText, pFtD->pszOpenCmd);
477   }
478   if (pFtD->pszPrintCmd) {
479      PutWidgetTextString(AF_FiletypePrintCmdTextField, pFtD->pszPrintCmd);
480   }
481
482   return;
483 }
484
485 /******************************************************************************/
486 /*                                                                            */
487 /* clear_AddFiletype_dialog_fields                                            */
488 /*                                                                            */
489 /* INPUT:  FiletypeData * - pointer to FiletypeData structure                 */
490 /* OUTPUT: none                                                               */
491 /*                                                                            */
492 /******************************************************************************/
493 void clear_AddFiletype_dialog_fields(void)
494 {
495   /*char pszFile[MAXBUFSIZE];*/
496
497   clear_text(AF_FileTypeNameTextField);
498   clear_text(AF_IdCharacteristicsText);
499   clear_text(AF_FiletypeHelpText);
500   createCB_IconGadget(AF_MED_IconGadget, FALSE, Medium_Icon);
501   createCB_IconGadget(AF_TINY_IconGadget, FALSE, Tiny_Icon);
502   /*
503   SET_ICONGADGET_ICON_AND_EXT(AF_MED_IconGadget, af_med_icon_default, pszFile);
504   SET_ICONGADGET_ICON_AND_EXT(AF_TINY_IconGadget, af_tiny_icon_default, pszFile);
505   */
506   clear_text(AF_OpenCmdText);
507   clear_text(AF_FiletypePrintCmdTextField);
508
509   return;
510 }
511
512 /******************************************************************************/
513 /*                                                                            */
514 /* free_Filetypedata                                                          */
515 /*                                                                            */
516 /* INPUT:  FiletypeData * - pointer to FiletypeData structure                 */
517 /* OUTPUT: none                                                               */
518 /*                                                                            */
519 /******************************************************************************/
520 void free_Filetypedata(FiletypeData *pFtD)
521 {
522   char buffer[MAXFILENAME];
523
524 #ifdef DEBUG
525   printf("Free FiletypeData structure\n"); /* debug */
526 #endif
527
528   if (pFtD->pszName) XtFree(pFtD->pszName);
529 #if DEBUG
530   printf("Freed Name\n");
531 #endif
532
533   if (pFtD->pszIcon) XtFree(pFtD->pszIcon);
534   if (pFtD->pszMedPmIcon) {
535 #if DEBUG
536      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszMedPmIcon);  /* debug */
537 #endif
538      unlink(pFtD->pszMedPmIcon);
539      XtFree(pFtD->pszMedPmIcon);
540   }
541   if (pFtD->pszMedBmIcon) {
542 #if DEBUG
543      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszMedBmIcon);  /* debug */
544 #endif
545      unlink(pFtD->pszMedBmIcon);
546      /**** remove the mask if it exists ****/
547      sprintf(buffer, "%s_m", pFtD->pszMedBmIcon);
548      unlink(buffer);
549      XtFree(pFtD->pszMedBmIcon);
550   }
551   if (pFtD->pszTinyPmIcon) {
552 #if DEBUG
553      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszTinyPmIcon);  /* debug */
554 #endif
555      unlink(pFtD->pszTinyPmIcon);
556      XtFree(pFtD->pszTinyPmIcon);
557   }
558   if (pFtD->pszTinyBmIcon) {
559 #if DEBUG
560      printf("free_Filetypedata: unlink '%s'\n", pFtD->pszTinyBmIcon);  /* debug */
561 #endif
562      unlink(pFtD->pszTinyBmIcon);
563      /**** remove the mask if it exists ****/
564      sprintf(buffer, "%s_m", pFtD->pszTinyBmIcon);
565      unlink(buffer);
566      XtFree(pFtD->pszTinyBmIcon);
567   }
568
569   if (pFtD->pszHelp) XtFree(pFtD->pszHelp);
570   if (pFtD->pszOpenCmd) XtFree(pFtD->pszOpenCmd);
571   if (pFtD->pszPrintCmd) XtFree(pFtD->pszPrintCmd);
572   if (pFtD->pszPattern) XtFree(pFtD->pszPattern);
573   if (pFtD->pszPermissions) XtFree(pFtD->pszPermissions);
574   if (pFtD->pszContents) XtFree(pFtD->pszContents);
575   XtFree((char *) pFtD);
576   return;
577 }
578
579 /******************************************************************************/
580 /*                                                                            */
581 /* AddFiletypeToList                                                          */
582 /*                                                                            */
583 /* INPUT:  none                                                               */
584 /* OUTPUT: none                                                               */
585 /*                                                                            */
586 /******************************************************************************/
587 void AddFiletypeToList(void)
588 {
589   if (!XmListItemExists(CA_FiletypesList, XmStringCreateSimple(XmTextFieldGetString(AF_FileTypeNameTextField)))) {
590     XmListAddItem(CA_FiletypesList, XmStringCreateSimple(XmTextFieldGetString(AF_FileTypeNameTextField)), 0);
591   }
592 }
593
594 /******************************************************************************/
595 /*                                                                            */
596 /* UpdateFiletypeDataArray                                                    */
597 /*                                                                            */
598 /* INPUT:  none                                                               */
599 /* OUTPUT: none                                                               */
600 /*                                                                            */
601 /******************************************************************************/
602 void UpdateFiletypeDataArray(FiletypeData *pFtD)
603 {
604   FiletypeData  **papArray;
605   int           i;
606
607   /**************************************************************************/
608   /* Add this structure to the filetype array in the ActionData structure.  */
609   /**************************************************************************/
610   papArray = (FiletypeData **) XtMalloc(sizeof(FiletypeData *) * (AD.cFiletypes + 1));
611   for (i=0; i < AD.cFiletypes; i++) {
612      papArray[i] = AD.papFiletypes[i];
613   }
614   papArray[AD.cFiletypes] = pFtD;
615   if (AD.papFiletypes) {
616     XtFree((char *) AD.papFiletypes);
617   }
618   AD.papFiletypes = papArray;
619   AD.cFiletypes++;
620 }
621
622 /******************************************************************************/
623 /*                                                                            */
624 /* AddFiletypeCheckFields                                                     */
625 /*                                                                            */
626 /* INPUT:  none                                                               */
627 /* OUTPUT: FALSE  - no errors found                                           */
628 /*         TRUE   - found errors                                              */
629 /*                                                                            */
630 /******************************************************************************/
631 Boolean AddFiletypeCheckFields(void)
632 {
633
634   char    *ptr = (char *)NULL;
635   Boolean bError = FALSE;
636   char    *msgPtr, *errPtr;
637
638   /**************************************************************************/
639   /* Check if filetype name is present.                                     */
640   /**************************************************************************/
641   if (!bError) {
642      ptr = (char *)NULL;
643      GetWidgetTextString(AF_FileTypeNameTextField, &ptr);
644 #ifdef DEBUG
645      printf("Filetype Family Name = '%s'\n", ptr);
646 #endif
647      if (!ptr) {
648         msgPtr = GETMESSAGE(8, 10, "The Datatype Family Name is missing.\n\
649 Enter a name in the 'Name of Datatype Family' field.");
650         errPtr = XtNewString(msgPtr);
651         display_error_message(AddFiletype, errPtr);
652         XtFree(errPtr);
653         XmProcessTraversal(AF_FileTypeNameTextField, XmTRAVERSE_CURRENT);
654         bError = TRUE;
655      } else {
656         XtFree(ptr);
657      }
658   }
659
660   /**************************************************************************/
661   /* Check if identifying characteristics are present.                      */
662   /**************************************************************************/
663   if (!bError) {
664      ptr = (char *)NULL;
665      GetWidgetTextString(AF_IdCharacteristicsText, &ptr);
666 #ifdef DEBUG
667      printf("Identifying Chars = '%s'\n", ptr);
668 #endif
669      if (!ptr) {
670         msgPtr = GETMESSAGE(8, 15,
671              "The Identifying Characteristics are missing.\n\
672 You must specify the characteristics before the datatype\n\
673 can be created. Select the Edit button next to the\n\
674 Identifying Characteristics list to specify the characteristics.");
675         errPtr = XtNewString(msgPtr);
676         display_error_message(AddFiletype, errPtr);
677         XtFree(errPtr);
678         XmProcessTraversal(AF_IdCharacteristicsEdit, XmTRAVERSE_CURRENT);
679         bError = TRUE;
680      } else {
681         XtFree(ptr);
682      }
683   }
684
685   return(bError);
686 }
687