Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtcreate / icon_selection_dialog.c
1 /* $XConsortium: icon_selection_dialog.c /main/10 1996/10/15 13:39:13 rswiston $ */
2 /*******************************************************************************
3         icon_selection_dialog.c
4
5        Associated Header file: icon_selection_dialog.h
6 *******************************************************************************/
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <sys/stat.h>
12
13 #if defined(USL) || defined(__uxp__)
14 #define S_ISLNK(mode) ((mode & S_IFMT) == S_IFLNK)
15 #endif
16
17 #include <Xm/Xm.h>
18 #include <Xm/MwmUtil.h>
19 #include <Xm/DialogS.h>
20 #include <Xm/MenuShell.h>
21 #include <Xm/List.h>
22 #include <Xm/ScrolledW.h>
23 #include <Xm/Label.h>
24 #include <Xm/Text.h>
25 #include <Xm/TextF.h>
26 #include <Xm/SeparatoG.h>
27 #include <Xm/PushB.h>
28 #include <Xm/Form.h>
29 #include <Xm/RowColumn.h>
30 #include <Xm/MessageB.h>
31 #include <X11/cursorfont.h>
32
33 #include <Dt/Icon.h>
34
35 #include "dtcreate.h"
36 #include "UxXt.h"
37 #include "cmncbs.h"
38 #include "cmnrtns.h"
39 #include "cmnutils.h"
40
41 /*******************************************************************************
42        Includes, Defines, and Global variables from the Declarations Editor:
43 *******************************************************************************/
44
45 #include <sys/types.h> /* for directory routines */
46 #ifdef _KERNEL
47 #undef _KERNEL
48 #endif
49 #include <dirent.h>    /* includes sys/dir.h */
50
51 #include <Xm/ScrolledW.h>
52 #include <Dt/Icon.h>
53 /*#include "Container.h"*/
54
55 static  char *selected_icon_name = (char *)NULL;
56 static  Widget selected_icon = (Widget)NULL;
57 static  int icon_count = 0;
58 char    *main_filter;
59 char    *file_filter_global;
60 DtIconGadget **icons_in_container = NULL;
61
62
63 int myscandir(char *, struct dirent ***, int (), int ());
64 int get_top_b1_position (int buttoncount);
65 int get_top_b2_position (int buttoncount);
66 void load_directories_list (char **dirlist);
67 char *get_initial_filter (void);
68 void load_filter_text_field (char *filter);
69 char *update_filter (char *filter);
70 void apply_filter (char *filter);
71 char *initialize_filter (char *filter_end);
72 struct dirent **build_dirent_list (char *filter, int *filecount);
73 void update_container_contents (char *filter);
74 void free_container_contents (void);
75 int new_name_select(struct dirent *, char *);
76 /*int name_select(struct dirent *);*/
77 static  void    selectionCB_icon_scrolled_container ( Widget UxWidget,
78                                                   XtPointer UxClientData,
79                                                   XtPointer UxCallbackArg);
80 static  void    calc_bottom_attachment( Widget UxWidget,
81                                         XtPointer UxClientData,
82                                         XtPointer UxCallbackArg);
83
84 /*******************************************************************************
85        The following header file defines the context structure.
86 *******************************************************************************/
87
88 #define CONTEXT_MACRO_ACCESS 1
89 #include "icon_selection_dialog.h"
90 #undef CONTEXT_MACRO_ACCESS
91
92
93 /*******************************************************************************
94 Auxiliary code from the Declarations Editor:
95 *******************************************************************************/
96
97 /*********************************************************************/
98 /* auxfuncs - icon selection dialog auxiliary functions              */
99 /*********************************************************************/
100
101 /***************************************************************************/
102 /*                                                                         */
103 /*  myscandir                                                              */
104 /*                                                                         */
105 /***************************************************************************/
106 int myscandir(char *pszDirName, struct dirent ***NameList, int Select(), int Compare())
107
108 {
109   DIR            *dirptr;
110   struct dirent  *dp;
111   struct dirent  *dptmp;
112   int            count = 0;
113   /* int            size = 0; */
114   struct dirent  **adirent;
115 #define          AINCREMENT  ((int)512)
116   int            sizeArray = AINCREMENT;
117   char           *msgPtr, *fmtPtr, *errPtr;
118
119   if (!(dirptr = opendir(pszDirName))) {
120      /* INTERNATIONALIZE */
121      msgPtr = "Could not open the following directory:";
122      fmtPtr = "%s\n   %s";
123      errPtr = XtMalloc((strlen(msgPtr) + strlen(fmtPtr) +
124                         strlen(pszDirName) + 1) * sizeof(char));
125      sprintf(errPtr, fmtPtr, msgPtr, pszDirName);
126      display_error_message(CreateActionAppShell, errPtr);
127      XtFree(errPtr);
128      return(0);
129   }
130
131 #if 0
132   size = sizeof(void *) * 1024;
133   *NameList = (struct dirent **)malloc(sizeof(void *) * 1024);
134 #endif
135
136   adirent = (struct dirent **)malloc(sizeof(void *) * sizeArray);
137   for (dp = readdir(dirptr); dp != NULL; dp = readdir(dirptr)) {
138
139 #if 0
140      if ((*Select)(dp, pszDirName)) {
141         (*NameList)[count] = dp;
142      if ((*Select)(dp)) {
143 #endif
144
145      if ((*Select)(dp, pszDirName)) {
146         dptmp = (struct dirent *)malloc(sizeof(struct dirent) + strlen(dp->d_name) + 1);
147         memcpy(dptmp, dp, sizeof(struct dirent));
148         strcpy(dptmp->d_name, dp->d_name);
149         adirent[count] = dptmp;
150         count++;
151         if (count == (sizeArray - 1)) {
152            adirent = (struct dirent **)realloc(adirent, (sizeof(void *) * (sizeArray + AINCREMENT)));
153            if (adirent) {
154               sizeArray += AINCREMENT;
155            }
156         }
157      }
158   }
159
160   *NameList = adirent;
161   closedir(dirptr);
162   return(count);
163 }
164
165 /***************************************************************************/
166 /*                                                                         */
167 /* build_dirent_list - builds a list of icon files to be displayed         */
168 /*                   in a container                                        */
169 /* Input: char *filter - directory in which to search for files            */
170 /* Output: struct dirent **namelist - list of files                        */
171 /*                                                                         */
172 /***************************************************************************/
173 struct dirent **build_dirent_list (char *filter, int *filecount)
174
175 {
176   char           *dirname, *dirname_end;
177   DIR            *dirptr;
178   struct dirent  **namelist;
179   char           *msgPtr, *fmtPtr, *errPtr;
180
181   /********************************************************************/
182   /* initialize filecount and namelist                                */
183   /********************************************************************/
184   *filecount = 0;
185   namelist = NULL;
186
187   /********************************************************************/
188   /* get length of file filter and create a copy                      */
189   /********************************************************************/
190   dirname = (char *)calloc (strlen(filter)+1, sizeof(char));
191
192 #ifdef DEBUG
193   if (!dirname) {
194     printf("error callocing memory for dirname\n");
195     printf("dirname of size: %i\n", strlen(dirname));
196   }
197 #endif
198
199   dirname = strcpy (dirname, filter);
200
201   /********************************************************************/
202   /* strip wildcard from end of directory name                        */
203   /********************************************************************/
204   dirname_end = strrchr (dirname, '/');
205   dirname_end[1] = '\0';
206
207   /********************************************************************/
208   /* build list of file name that match the wildcard string           */
209   /********************************************************************/
210   dirptr = (DIR *)opendir (dirname);
211
212   if (dirptr) {
213
214      *filecount = myscandir (dirname, &namelist, new_name_select, NULL);
215
216 #ifdef DEBUG
217      printf("# of icons = %d\n", *filecount);
218 #endif
219      closedir (dirptr);
220   } else {
221      /* INTERNATIONALIZE */
222      msgPtr = "Could not open the following directory:";
223      fmtPtr = "%s\n   %s";
224      errPtr = XtMalloc((strlen(msgPtr) + strlen(fmtPtr) +
225                         strlen(dirname) + 1) * sizeof(char));
226      sprintf(errPtr, fmtPtr, msgPtr, dirname);
227      display_error_message(CreateActionAppShell, errPtr);
228      XtFree(errPtr);
229      namelist = NULL;
230   }
231
232 #ifdef DEBUG
233   printf ("Freeing dirname, sizeof: %ld\n", (long)sizeof(dirname));
234 #endif
235
236   free (dirname);
237   return (namelist);
238 }
239
240 /***************************************************************************/
241 /*                                                                         */
242 /*  new_name_select - determines if file is included in list of icon       */
243 /*                files to be displayed in a container                     */
244 /*  Input: struct dirent *dir_entry - directory entry structure            */
245 /*  Output: (int)found - >0 if file name accepted, 0 otherwise             */
246 /*                                                                         */
247 /***************************************************************************/
248 int new_name_select (struct dirent *dir_entry, char *pszdir_name)
249 {
250   struct stat stat_buffer;
251   char        filename[256];
252
253   /***********************************************************************/
254   /* This will only filter the icons of the filter size which by default */
255   /* is medium icons.                                                    */
256   /***********************************************************************/
257   if (strstr(dir_entry->d_name, file_filter_global)) {
258      sprintf(filename, "%s%s", pszdir_name, dir_entry->d_name);
259      if (!stat(filename, &stat_buffer)) {
260         if ( (S_ISREG(stat_buffer.st_mode)) ||
261              (S_ISLNK(stat_buffer.st_mode)) ) {
262            return(1);
263         }
264      }
265   }
266   return(0);
267
268 #if 0
269   /***********************************************************************/
270   /* This is the new filter to get all three sizes of icons.             */
271   /***********************************************************************/
272   if (bShowPixmaps) {
273     if ( (strstr(dir_entry->d_name, ".l.pm")) ||
274          (strstr(dir_entry->d_name, ".m.pm")) ||
275          (strstr(dir_entry->d_name, ".t.pm")) ) {
276        sprintf(filename, "%s%s", pszdir_name, dir_entry->d_name);
277        if (!stat(filename, &stat_buffer)) {
278           if ( (S_ISREG(stat_buffer.st_mode)) ||
279                (S_ISLNK(stat_buffer.st_mode)) ) {
280              return(1);
281           }
282        }
283     }
284   } else {
285     if ( (strstr(dir_entry->d_name, ".l.bm")) ||
286          (strstr(dir_entry->d_name, ".m.bm")) ||
287          (strstr(dir_entry->d_name, ".t.bm")) ) {
288        sprintf(filename, "%s%s", pszdir_name, dir_entry->d_name);
289        if (!stat(filename, &stat_buffer)) {
290           if ( (S_ISREG(stat_buffer.st_mode)) ||
291                (S_ISLNK(stat_buffer.st_mode)) ) {
292              return(1);
293           }
294        }
295     }
296   }
297   return(0);
298 #endif
299
300 }
301
302 #if 0
303 /***************************************************************************/
304 /*                                                                         */
305 /*  new_name_select - determines if file is included in list of icon       */
306 /*                files to be displayed in a container                     */
307 /*  Input: struct dirent *dir_entry - directory entry structure            */
308 /*  Output: (int)found - >0 if file name accepted, 0 otherwise             */
309 /*                                                                         */
310 /***************************************************************************/
311 int new_name_select (struct dirent *dir_entry, char *pszdir_name)
312 {
313   struct stat stat_buffer;
314   char        filename[256];
315
316   if (strstr(dir_entry->d_name, file_filter_global)) {
317      sprintf(filename, "%s%s", pszdir_name, dir_entry->d_name);
318      if (!stat(filename, &stat_buffer)) {
319         if ( (S_ISREG(stat_buffer.st_mode)) ||
320              (S_ISLNK(stat_buffer.st_mode)) ) {
321            return(1);
322         }
323      }
324   }
325   return(0);
326 }
327 #endif
328
329 /***************************************************************************/
330 /*                                                                         */
331 /* int get_top_b1_position - determine position of button                  */
332 /* INPUT: int buttoncount - number of buttons in row                       */
333 /* OUTPUT: int position - position of left edge of button                  */
334 /*                                                                         */
335 /***************************************************************************/
336 int get_top_b1_position (int buttoncount)
337 {
338   int position;
339
340   switch (buttoncount) {
341           case 1: position = 38; break;
342           case 2: position = 14; break;
343           case 3: position =  8; break;
344           default : position = 0;
345           };
346   return (position);
347 }
348
349
350 /***************************************************************************/
351 /*                                                                         */
352 /* int get_top_b2_position - determine position of button                  */
353 /* INPUT: int buttoncount - number of buttons in row                       */
354 /* OUTPUT: int position - position of left edge of button                  */
355 /*                                                                         */
356 /***************************************************************************/
357 int get_top_b2_position (int buttoncount)
358 {
359   int position;
360
361   switch (buttoncount) {
362           case 2: position = 60; break;
363           case 3: position = 40; break;
364           default : position = 0;
365           };
366   return (position);
367 }
368
369
370 /***************************************************************************/
371 /*                                                                         */
372 /*  void load_directories_list - load scrolled list with directory         */
373 /*                               names                                     */
374 /*  Input: char **dirlist - list of text strings                           */
375 /*  Output: none                                                           */
376 /*                                                                         */
377 /***************************************************************************/
378 void load_directories_list (char **dirlist)
379 {
380   XmStringTable xmstringlist;
381   int stringcount = 0;
382   int i;
383
384   /******************************************************************/
385   /* get number of directories in list                              */
386   /******************************************************************/
387   stringcount = countItems (dirlist);
388
389   /******************************************************************/
390   /* convert strings to xmstrings                                   */
391   /******************************************************************/
392   xmstringlist = (XmStringTable) TextStringsToXmStrings (dirlist);
393
394   /******************************************************************/
395   /* put xmstrings in list                                          */
396   /******************************************************************/
397   XtVaSetValues (dir_scrolled_list, XmNitems, xmstringlist,
398                  XmNitemCount, stringcount, NULL);
399
400   XmListSelectPos(dir_scrolled_list, 1, False);
401   /******************************************************************/
402   /* free xmstrings array                                           */
403   /******************************************************************/
404   for (i=0; i < stringcount; i++) {
405      XmStringFree(xmstringlist[i]);
406   }
407   free(xmstringlist);
408
409   return;
410 }
411
412 /***************************************************************************/
413 /*                                                                         */
414 /*  void initialize_filter - build path/wildcard filter                    */
415 /*  Input: none                                                            */
416 /*  Output: char *initial_filter                                           */
417 /*                                                                         */
418 /***************************************************************************/
419 char *initialize_filter (char *filter_end)
420 {
421   char *filter, *initial_filter;
422   int filter_length, filter_end_length;
423   int add_slash = 0;
424
425   /******************************************************************/
426   /* initial filter string is first directory in list               */
427   /******************************************************************/
428   filter = get_initial_filter ();
429
430   /******************************************************************/
431   /* determine space needed                                         */
432   /******************************************************************/
433   filter_length = strlen(filter);
434   if ((filter[filter_length-1] == '/') && (filter_end[0] == '/')) {
435      filter_end++;
436   } else {
437      if (!(filter[filter_length-1] == '/') && !(filter_end[0] == '/')) {
438          add_slash = 1;
439          filter_length++;
440      }
441   }
442
443   filter_end_length = strlen(filter_end);
444
445   /******************************************************************/
446   /* allocate space and put string in initial filter                */
447   /******************************************************************/
448   initial_filter = (char *)calloc (filter_length + filter_end_length + 1,
449                                  sizeof(char));
450 #ifdef DEBUG
451   if (!initial_filter) printf("Error callocing memory in initialize_filter.\n");
452 #endif
453   initial_filter = strcpy (initial_filter, filter);
454   if (add_slash) initial_filter[filter_length-1] = '/';
455   initial_filter = strcat (initial_filter, filter_end);
456
457   return(initial_filter);
458 }
459
460 /***************************************************************************/
461 /*                                                                         */
462 /*  char *get_initial_filter - get value of first file filter              */
463 /*  Input: none                                                            */
464 /*  Output: char *new_filter - string containing filter                    */
465 /*                                                                         */
466 /***************************************************************************/
467 char *get_initial_filter (void)
468 {
469   char *new_filter;
470
471   /******************************************************************/
472   /* initial filter is first one in directory list                  */
473   /******************************************************************/
474   new_filter = (char *)directories_list[0];
475   return (new_filter);
476 }
477
478 /***************************************************************************/
479 /*                                                                         */
480 /*  char *update_filter - put main filter end on new main filter           */
481 /*  Input: char *filter - new filter from which gets main filter end       */
482 /*  Output: char *new_filter - new main filter                             */
483 /*                                                                         */
484 /***************************************************************************/
485 char *update_filter (char *filter)
486 {
487   char *filter_end, *new_filter, *main_end;
488   char *fe_ptr, *ffg_ptr;
489
490   /******************************************************************/
491   /* get new end                                                    */
492   /******************************************************************/
493   main_end = strrchr (main_filter, '/');
494   filter_end = (char *)calloc(strlen(main_end)+1, sizeof(char));
495
496 #ifdef DEBUG
497   if (!filter_end)
498      printf("Error callocing memory for filter_end in update_filter.\n");
499 #endif
500
501   filter_end = strcpy (filter_end, main_end);
502
503   /******************************************************************/
504   /* determine what filter should be depending on icon type (pm/bm) */
505   /******************************************************************/
506   if (fe_ptr = strrchr(filter_end, EXT_DELIMITER)) {
507      ffg_ptr = strrchr(file_filter_global, EXT_DELIMITER);
508      if (bShowPixmaps) {
509         if ((int)strlen(fe_ptr) >= (int)strlen(PIXMAP_EXT)) {
510            strcpy(fe_ptr, PIXMAP_EXT);
511         }
512         if ( (ffg_ptr) && ((int)strlen(ffg_ptr) >= (int)strlen(PIXMAP_EXT)) ) {
513            strcpy(ffg_ptr, PIXMAP_EXT);
514         }
515      } else {
516         if ((int)strlen(fe_ptr) >= (int)strlen(BITMAP_EXT)) {
517            strcpy(fe_ptr, BITMAP_EXT);
518         }
519         if ( (ffg_ptr) && ((int)strlen(ffg_ptr) >= (int)strlen(BITMAP_EXT)) ) {
520            strcpy(ffg_ptr, BITMAP_EXT);
521         }
522      }
523   }
524
525   /******************************************************************/
526   /* find old end on main filter and delete it                      */
527   /******************************************************************/
528   main_end = memset (main_end, '\0', strlen(main_end));
529
530   /******************************************************************/
531   /* allocate space for new filter                                  */
532   /******************************************************************/
533   new_filter = (char *)calloc (strlen(filter) +
534                              strlen(filter_end) + 1, sizeof(char));
535 #ifdef DEBUG
536   if (!new_filter)
537      printf("Error callocing memory for new_filter in update_filter.\n");
538 #endif
539
540   new_filter = strcpy (new_filter, filter);
541
542   /******************************************************************/
543   /* put new end on filter                                          */
544   /******************************************************************/
545   new_filter = strcat (new_filter, filter_end);
546
547   /******************************************************************/
548   /* display new file filter in text field                          */
549   /******************************************************************/
550   load_filter_text_field (new_filter);
551
552   /******************************************************************/
553   /* free resources                                                 */
554   /******************************************************************/
555   free(filter_end);
556
557   return (new_filter);
558 }
559
560 /***************************************************************************/
561 /*                                                                         */
562 /*  void apply_filter - apply filter to create a list of files and         */
563 /*                      display files in scrolled list                     */
564 /*  Input: char *filter - file filter to use                               */
565 /*  Output: none                                                           */
566 /*                                                                         */
567 /***************************************************************************/
568 void apply_filter (char *filter)
569 {
570   char *old_main;
571
572   /******************************************************************/
573   /* Get length of main file filter and create a copy               */
574   /******************************************************************/
575   old_main = (char *)calloc (strlen(main_filter)+1, sizeof(char));
576
577 #ifdef DEBUG
578   if (!old_main) printf("Calloc error for old_main, in apply filter.\n");
579 #endif
580
581   old_main = strcpy (old_main, main_filter);
582
583   /******************************************************************/
584   /* Update main filter to reflect changes made by user             */
585   /******************************************************************/
586   main_filter = update_filter (filter);
587
588   /******************************************************************/
589   /* if the filter has changed, update container with new icons     */
590   /******************************************************************/
591   if (strcmp (old_main, main_filter)) {
592
593      /******************************************************************/
594      /* Turn on the hour glass                                         */
595      /******************************************************************/
596      TurnOnHourGlassAllWindows();
597
598      /******************************************************************/
599      /* Since we are changing to a new directory, clear out the        */
600      /* globals and clear the selected icon text string.               */
601      /******************************************************************/
602      if (selected_icon) {
603         _DtIconSetState(selected_icon, FALSE, FALSE);
604         selected_icon = (Widget)NULL;
605      }
606      if (selected_icon_name) {
607         XtFree(selected_icon_name);
608         selected_icon_name = (char *)NULL;
609      }
610      XmTextFieldSetString (icon_name_text_field, "");
611
612      /******************************************************************/
613      /* Update the container icon gadgets                              */
614      /******************************************************************/
615      update_container_contents (main_filter);
616
617      /******************************************************************/
618      /* Turn off the hour glass                                        */
619      /******************************************************************/
620      TurnOffHourGlassAllWindows();
621   }
622
623 #ifdef DEBUG
624   printf ("Freeing old_main, sizeof: %ld\n", (long)sizeof(old_main));
625 #endif
626
627   free (old_main);
628   return;
629 }
630
631
632 /***************************************************************************/
633 /*                                                                         */
634 /*  void load_filter_text_field - display file filter text                 */
635 /*  Input: char *filter - file filter text string                          */
636 /*  Output: none                                                           */
637 /*                                                                         */
638 /***************************************************************************/
639 void load_filter_text_field (char *filter)
640 {
641   if (use_filter_field) {
642      /* display file filter in text field */
643      XmTextFieldSetString (filter_text_field, filter);
644      /* set cursor to end of string */
645      XmTextSetInsertionPosition (filter_text_field, strlen(filter));
646   }
647   return;
648 }
649
650
651 /***************************************************************************/
652 /*                                                                         */
653 /*  void update_container_contents - create new icon gadgets which         */
654 /*                             correspont to the new filter                */
655 /*  Input: char *filter - file filter text string                          */
656 /*  Output: none                                                           */
657 /*                                                                         */
658 /***************************************************************************/
659 void  update_container_contents (char *filter)
660 {
661   char          *path, *pathend;
662   char          iconfile[MAXFILENAME];
663   int           namecount, lcv;
664   struct dirent **filelist;
665   int           count, old_count;
666   int           n;
667   Arg           args[10];
668   XmString      xmstring;
669   char          *ptr;
670
671   XtUnmanageChild (icon_scrolled_container);
672   /* free_container_contents (); */
673
674   path = (char *)calloc (strlen(filter)+1, sizeof(char));
675
676 #ifdef DEBUG
677   if (!path) printf("Calloc error for path, in update_container_contents.\n");
678 #endif
679
680   path = strcpy (path, filter);
681   pathend = strrchr (path, '/');
682   pathend[1] = '\0';
683
684   /******************************************************************/
685   /* Get number of icon files and list of file names                */
686   /******************************************************************/
687   filelist = build_dirent_list (filter, &namecount);
688
689   /******************************************************************/
690   /* Set up argument list                                           */
691   /******************************************************************/
692   n = 0;
693   /*
694   XtSetArg(args[n], XmNimageName, "/usr/dt/appconfig/icons/C/Dtactn.m.pm"); n++;
695   */
696   XtSetArg(args[n], XmNimageName, NULL); n++;
697   XtSetArg(args[n], XmNfillMode, XmFILL_SELF); n++;
698   XtSetArg(args[n], XmNbehavior, XmICON_TOGGLE); n++;
699   XtSetArg(args[n], XmNrecomputeSize, TRUE); n++;
700   XtSetArg(args[n], XmNfillOnArm, TRUE); n++;
701   XtSetArg(args[n], XmNtraversalOn, TRUE); n++;
702
703   /******************************************************************/
704   /* Need at least one icon for the empty directory icon.           */
705   /******************************************************************/
706   if (namecount) {
707      count = namecount;
708   } else {
709      count = 1;
710   }
711
712   /******************************************************************/
713   /* create any additional icon gadgets                             */
714   /******************************************************************/
715   if (count > icon_count) {
716      old_count = icon_count;
717      icon_count = count;
718      icons_in_container = (DtIconGadget **)realloc
719                                       (icons_in_container,
720                                       (icon_count+1) * sizeof(DtIconGadget *));
721      /*memset(&(icons_in_container[icon_count]), 0, sizeof(DtIconGadget *));*/
722      for (lcv = old_count; lcv < icon_count; lcv++) {
723         icons_in_container[lcv] =
724         /*(DtIconGadget *)XtCreateManagedWidget (filelist[lcv]->d_name,*/
725           (DtIconGadget *)XtCreateManagedWidget ("IconGadget",
726                             dtIconGadgetClass, (Widget)icon_scrolled_container,
727                             args, n);
728           XtAddCallback((Widget) icons_in_container[lcv], XmNcallback,
729                        (XtCallbackProc) selectionCB_icon_scrolled_container,
730                        (XtPointer) NULL);
731
732 #ifdef DEBUG
733        if (!icons_in_container[lcv])
734           printf("Error creating icon gadget, in update_container_contents\n");
735 #endif
736
737 #if 0
738        if (!icons_in_container[lcv]) {
739           printf ("Could not allocate memory to create new icon\n", lcv);
740        }
741 #endif
742
743 #ifdef DEBUG
744        } else {
745           printf ("Created icon #%i\n", lcv);
746        }
747 #endif
748
749      }  /* end for */
750   }     /* end if (count > icon_count) */
751
752   /******************************************************************/
753   /* load icon gadgets with information                             */
754   /******************************************************************/
755   if (namecount) {
756     /****************************************************************/
757     /* The following flush call is a work-around for a known motif  */
758     /* bug.  This is here in the application because motif will not */
759     /* correct this bug because doing so would impair performance.  */
760     /* Therefore, I am forced to add this call to the code.         */
761     /* The problem this fixes is that when new icons are added to   */
762     /* the filesystem after the application is already up and       */
763     /* running, the icon gadgets to not see them.                   */
764     /****************************************************************/
765     XmeFlushIconFileCache(NULL);
766
767     for (lcv = 0; lcv < count; lcv++) {
768        sprintf (iconfile, "%s%s", path, filelist[lcv]->d_name);
769        ptr = strstr(filelist[lcv]->d_name, ".m.");
770        if (ptr) {
771           *ptr = '\0';
772        }
773        xmstring = XmStringCreateLocalized(filelist[lcv]->d_name);
774        XtVaSetValues ((Widget) icons_in_container[lcv],
775                              XmNstring,        xmstring,
776                              XmNimageName,     iconfile,
777                              NULL);
778        XtManageChild((Widget) icons_in_container [lcv]);
779        XmStringFree(xmstring);
780
781 #ifdef DEBUG
782       printf ("Loading icon gadget #%i\n", lcv);
783 #endif
784
785     }  /* end for */
786
787   /******************************************************************/
788   /* This is the empty directory case                               */
789   /******************************************************************/
790   } else {
791        strcpy(iconfile, GETMESSAGE(11, 60, "[Empty]"));
792        xmstring = XmStringCreateLocalized(iconfile);
793        XtVaSetValues ((Widget) icons_in_container[0],
794                              XmNstring,        xmstring,
795                              XmNimageName,     (char *)NULL,
796                              NULL);
797        XtManageChild((Widget) icons_in_container[0]);
798        XmStringFree(xmstring);
799   }
800
801   /******************************************************************/
802   /* unmanage any spare icon gadgets                                */
803   /******************************************************************/
804   for (lcv = count; lcv < icon_count; lcv++) {
805      XtUnmanageChild ((Widget) icons_in_container[lcv]);
806   }
807
808   /******************************************************************/
809   /* free dirent list                                               */
810   /******************************************************************/
811   for (lcv = 0; lcv < namecount; lcv++) {
812      free (filelist[lcv]);
813   }
814   if (namecount) {
815      free (filelist);
816   }
817
818   XtManageChild (icon_scrolled_container);
819   return;
820
821 }
822
823 #ifdef _ICONSELECTOR_DESTROY_ENABLED
824 /***************************************************************************/
825 /*                                                                         */
826 /*  void free_container_contents - free icon gadgets in container          */
827 /*  Input: none                                                            */
828 /*  Output: none                                                           */
829 /*                                                                         */
830 /***************************************************************************/
831 void  free_container_contents (void)
832 {
833   int    lcv = 0;
834   char   *filename;
835   Pixmap icon_pixmap;
836   Screen *screen_id;
837
838   if (icons_in_container) {
839      screen_id = XtScreen (icons_in_container[0]);
840      lcv = 0;
841      while (icons_in_container[lcv]) {
842 #if 0
843        XtVaGetValues (icons_in_container[lcv], XmNimageName, &filename,
844                       XmNpixmap, &icon_pixmap, NULL);
845        XmDestroyPixmap (screen_id, icon_pixmap);
846
847        XtVaSetValues (icons_in_container[lcv], XmNpixmap, NULL, NULL);
848 #endif
849        XtDestroyWidget (icons_in_container[lcv]);
850        /*
851        icons_in_container[lcv]=NULL;
852        */
853        lcv++;
854      }  /* end while icons_in_container */
855      free (icons_in_container);
856      icons_in_container = NULL;
857   }
858
859 #ifdef DEBUG
860   printf ("In free_container_contents...\n");
861   printf ("Just destroyed all %i icons.\n", lcv);
862 #endif
863
864   icon_count = 0;
865
866   return;
867 }
868 #endif
869
870 #if 0
871 /***************************************************************************/
872 /*                                                                         */
873 /*  void load_new_filter - displays selected directory string as           */
874 /*                         new filter base                                 */
875 /*  Input: char *new_filter - new directory string to use as filter        */
876 /*  Output: none                                                           */
877 /*                                                                         */
878 /***************************************************************************/
879 void load_new_filter (char *new_filter)
880 {
881 /* no longer need old filter */
882 free (main_filter);
883
884 /* create space for new filter */
885 main_filter = (char *)calloc (strlen(new_filter)+3, sizeof (char));
886 #ifdef DEBUG
887 if (!main_filter) printf("Calloc error for main_filter, in load_new_filter.\n");
888 #endif
889 /* copy new filter and add filter end */
890 main_filter = strcpy (main_filter, new_filter);
891 main_filter = strcat (main_filter, "/*");
892 /* display new filter */
893 load_filter_text_field (main_filter);
894
895 return;
896 }
897 #endif
898
899 /*****************************************************************************/
900 /*       The following are callback functions.                               */
901 /*****************************************************************************/
902
903 /***************************************************************************/
904 /*                                                                         */
905 /*   calc_bottom_attachment                                                */
906 /*                                                                         */
907 /*                                                                         */
908 /***************************************************************************/
909 static  void    calc_bottom_attachment( Widget UxWidget,
910                                              XtPointer UxClientData,
911                                              XtPointer UxCallbackArg )
912 {
913   _UxCicon_selection_dialog *UxSaveCtx, *UxContext;
914
915   UxSaveCtx = UxIcon_selection_dialogContext;
916   UxIcon_selection_dialogContext = UxContext =
917                   (_UxCicon_selection_dialog *) UxGetContext( UxWidget );
918   {
919     if (numberOfTopButtons > 0) {
920        XtVaSetValues (UxWidget, XmNbottomWidget, top_button_form, NULL);
921     } else if (use_icon_name_field) {
922        XtVaSetValues (UxWidget, XmNbottomWidget, icon_name_textfield_label, NULL);
923     } else XtVaSetValues (UxWidget, XmNbottomWidget, separatorGadget1, NULL);
924   }
925   return;
926 }
927
928 /***************************************************************************/
929 /*                                                                         */
930 /*  activateCB_bottom_button                                               */
931 /*                                                                         */
932 /*                                                                         */
933 /***************************************************************************/
934 /* default cb for bottom buttons */
935 static  void    activateCB_bottom_button( Widget UxWidget,
936                                              XtPointer UxClientData,
937                                              XtPointer UxCallbackArg )
938 {
939   _UxCicon_selection_dialog *UxSaveCtx, *UxContext;
940
941   UxSaveCtx = UxIcon_selection_dialogContext;
942   UxIcon_selection_dialogContext = UxContext =
943                   (_UxCicon_selection_dialog *) UxGetContext( UxWidget );
944   {
945
946   }
947   return;
948 }
949 /******************************************************************************/
950 /* activateCB_NoFindIconDialog_ChangeNameButton                               */
951 /******************************************************************************/
952 void    activateCB_NoFindIconDialog_ChangeNameButton( Widget  UxWidget,
953                                         XtPointer UxClientData,
954                                         XtPointer UxCallbackArg)
955
956 {
957   XtDestroyWidget(UxWidget);
958 }
959
960 /******************************************************************************/
961 /* activateCB_NoFindIconDialog_NameOKButton                                   */
962 /******************************************************************************/
963 void    activateCB_NoFindIconDialog_NameOKButton( Widget  UxWidget,
964                                         XtPointer UxClientData,
965                                         XtPointer UxCallbackArg)
966
967 {
968   char *basename = (char *)NULL;
969
970   TurnOnHourGlassAllWindows();
971   if (bottom_button_one_cb) {
972      GetWidgetTextString(icon_name_text_field, &basename);
973      bottom_button_one_cb(UxWidget,
974                          (XtPointer)basename, UxCallbackArg);
975      if (basename) XtFree(basename);
976   }
977   TurnOffHourGlassAllWindows();
978   UxPopdownInterface (IconSelector);
979   XtDestroyWidget(UxWidget);
980 }
981
982 /******************************************************************************/
983 /* display_nofindicon_message - display cant find icons error dialog          */
984 /* INPUT:  Widget parent - parent to position error dialog new                */
985 /* OUTPIT: none                                                               */
986 /******************************************************************************/
987 void display_nofindicon_message (Widget parent)
988 {
989   Widget dialog;
990   Widget widChild;
991   char   buffer[512];
992
993   dialog = XmCreateErrorDialog(parent, "nofindiconDialog", NULL, 0);
994
995   widChild = XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON);
996   XtVaSetValues(widChild,
997                 RES_CONVERT( XmNlabelString, "Change Name"),
998                 NULL);
999
1000   widChild = XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON);
1001   XtVaSetValues(widChild,
1002                 RES_CONVERT( XmNlabelString, "Name OK"),
1003                 NULL);
1004
1005   XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
1006
1007   XtAddCallback( dialog, XmNokCallback,
1008           (XtCallbackProc) activateCB_NoFindIconDialog_ChangeNameButton,
1009           (XtPointer) NULL );
1010   XtAddCallback( dialog, XmNcancelCallback,
1011           (XtCallbackProc) activateCB_NoFindIconDialog_NameOKButton,
1012           (XtPointer) NULL );
1013
1014   /*********  WARNING - this needs to be translated !!! ***********/
1015   strcpy(buffer, "There is no set of icons with that filename in the icon folders.\n");
1016   strcat(buffer, "Move the icons into one of the icon folers, then select \"Name OK\".\n");
1017   strcat(buffer, "Or, to select a different set of icons, select \"Change Name\".\n");
1018   strcat(buffer, "\nIf you are a software developer creating a registration package,\n");
1019   strcat(buffer, "ignore this message and select \"Name OK\".");
1020   XtVaSetValues (dialog,
1021                  RES_CONVERT(XmNdialogTitle, GETMESSAGE(6, 31, "Create Action - Error")),
1022                  RES_CONVERT(XmNmessageString, buffer),
1023                  NULL);
1024
1025   XtManageChild (dialog);
1026   return;
1027 }
1028
1029 /***************************************************************************/
1030 /*                                                                         */
1031 /*  activateCB_bottom_button1                                              */
1032 /*                                                                         */
1033 /*                                                                         */
1034 /***************************************************************************/
1035 /*  cb for bottom button 1 = OK */
1036 static  void    activateCB_bottom_button1( Widget UxWidget,
1037                                              XtPointer UxClientData,
1038                                              XtPointer UxCallbackArg )
1039 {
1040   _UxCicon_selection_dialog *UxSaveCtx, *UxContext;
1041
1042   UxSaveCtx = UxIcon_selection_dialogContext;
1043   UxIcon_selection_dialogContext = UxContext =
1044                   (_UxCicon_selection_dialog *) UxGetContext( UxWidget );
1045   {
1046     char *basename = (char *)NULL;
1047     char *fullname = (char *)NULL;
1048     char *msgPtr, *errPtr;
1049
1050     GetWidgetTextString(icon_name_text_field, &basename);
1051     if (basename) {
1052        if (strchr(basename, '/')) {
1053           /**** WARNING - this needs to be in a message catalog in the future ****/
1054           /* INTERNATIONALIZE */
1055           msgPtr = "Invalid Icon filename.\n\
1056 Pathnames are not valid in the \"Enter Icon Filename\" field.\n\
1057 Enter only the name of the icon without the path or extensions.";
1058           errPtr = XtNewString(msgPtr);
1059           display_error_message(IconSelector, errPtr);
1060           XtFree(errPtr);
1061        } else {
1062           FIND_ICONGADGET_ICON(basename, fullname, DtMEDIUM);
1063           if ( (fullname) && (check_file_exists(fullname)) ) {
1064              TurnOnHourGlassAllWindows();
1065              if (bottom_button_one_cb) {
1066                 bottom_button_one_cb(UxWidget,
1067                                     (XtPointer)fullname, UxCallbackArg);
1068              }
1069              TurnOffHourGlassAllWindows();
1070              UxPopdownInterface (IconSelector);
1071              if (basename) XtFree(basename);
1072           } else {
1073              display_nofindicon_message(IconSelector);
1074           }
1075        }
1076     } else {
1077        msgPtr = GETMESSAGE(11, 50, "The Icon Filename is invalid.\n\
1078 Please enter a valid icon file name in the\n'Enter Icon Filename' field.");
1079        errPtr = XtNewString(msgPtr);
1080        display_error_message(IconSelector, errPtr);
1081        XtFree(errPtr);
1082     }
1083   }
1084   return;
1085
1086 #if 0   /*************  old code *********************/
1087     char *pszIconFileName = (char *)NULL;
1088     char    buffer[MAXBUFSIZE];
1089
1090     GetWidgetTextString(icon_name_text_field, &pszIconFileName);
1091     if ( (pszIconFileName) && (check_file_exists(pszIconFileName)) ) {
1092        TurnOnHourGlassAllWindows();
1093        if (bottom_button_one_cb) {
1094           bottom_button_one_cb(UxWidget,
1095                               (XtPointer)pszIconFileName, UxCallbackArg);
1096        }
1097 #ifdef _ICONSELECTOR_DESTROY_ENABLED
1098        free_container_contents ();
1099        if (selected_icon_name) {
1100           XtFree(selected_icon_name);
1101        }
1102        selected_icon_name = (char *)NULL;
1103        XtDestroyWidget (XtParent(icon_selection_dialog));
1104        IconSelector = (Widget)NULL;
1105        TurnOffHourGlassAllWindows();
1106 #else
1107        TurnOffHourGlassAllWindows();
1108        UxPopdownInterface (IconSelector);
1109 #endif  /* _ICONSELECTOR_DESTROY_ENABLED */
1110        XtFree(pszIconFileName);
1111     } else {
1112        strcpy(buffer, GETMESSAGE(11, 50, "The Icon Filename is invalid.\nPlease enter a valid icon file name in the\n'Enter Icon Filename' field."));
1113        display_error_message(IconSelector, buffer);
1114     }
1115   }
1116
1117 #if 0
1118     if (selected_icon_name) {
1119       TurnOnHourGlassAllWindows();
1120       if (bottom_button_one_cb) {
1121          bottom_button_one_cb(UxWidget,
1122                              (XtPointer)selected_icon_name, UxCallbackArg);
1123       }
1124 #ifdef _ICONSELECTOR_DESTROY_ENABLED
1125       free_container_contents ();
1126       XtFree(selected_icon_name);
1127       selected_icon_name = (char *)NULL;
1128       XtDestroyWidget (XtParent(icon_selection_dialog));
1129       IconSelector = (Widget)NULL;
1130       TurnOffHourGlassAllWindows();
1131 #else
1132       TurnOffHourGlassAllWindows();
1133       UxPopdownInterface (IconSelector);
1134 #endif  /* _ICONSELECTOR_DESTROY_ENABLED */
1135     }
1136   }
1137 #endif
1138   return;
1139 #endif  /*************  old code *********************/
1140
1141 }
1142
1143 /***************************************************************************/
1144 /*                                                                         */
1145 /*   activateCB_bottom_button2                                             */
1146 /*                                                                         */
1147 /*                                                                         */
1148 /***************************************************************************/
1149 /*  cb for bottom button 2 = CANCEL */
1150 static  void    activateCB_bottom_button2( Widget UxWidget,
1151                                              XtPointer UxClientData,
1152                                              XtPointer UxCallbackArg )
1153 {
1154   _UxCicon_selection_dialog *UxSaveCtx, *UxContext;
1155
1156   UxSaveCtx = UxIcon_selection_dialogContext;
1157   UxIcon_selection_dialogContext = UxContext =
1158                   (_UxCicon_selection_dialog *) UxGetContext( UxWidget );
1159   {
1160 #ifdef _ICONSELECTOR_DESTROY_ENABLED
1161     free_container_contents ();
1162     XtDestroyWidget (XtParent(icon_selection_dialog));
1163     IconSelector = (Widget)NULL;
1164 #else
1165     UxPopdownInterface (IconSelector);
1166 #endif  /* _ICONSELECTOR_DESTROY_ENABLED */
1167   }
1168   return;
1169 }
1170
1171 /***************************************************************************/
1172 /*                                                                         */
1173 /*  activateCB_bottom_button3                                              */
1174 /*                                                                         */
1175 /*                                                                         */
1176 /***************************************************************************/
1177 /* default cb for bottom button3 = HELP */
1178 static  void    activateCB_bottom_button3( Widget UxWidget,
1179                                              XtPointer UxClientData,
1180                                              XtPointer UxCallbackArg )
1181 {
1182   _UxCicon_selection_dialog *UxSaveCtx, *UxContext;
1183
1184   UxSaveCtx = UxIcon_selection_dialogContext;
1185   UxIcon_selection_dialogContext = UxContext =
1186                   (_UxCicon_selection_dialog *) UxGetContext( UxWidget );
1187   {
1188     DisplayHelpDialog(UxWidget, (XtPointer)HELP_ICONSELECTOR, UxCallbackArg);
1189   }
1190   return;
1191 }
1192
1193 /***************************************************************************/
1194 /*                                                                         */
1195 /*   activateCB_filter_text_field                                          */
1196 /*                                                                         */
1197 /*                                                                         */
1198 /***************************************************************************/
1199 static  void    activateCB_filter_text_field( Widget UxWidget,
1200                                              XtPointer UxClientData,
1201                                              XtPointer UxCallbackArg )
1202 {
1203   _UxCicon_selection_dialog *UxSaveCtx, *UxContext;
1204   UxSaveCtx = UxIcon_selection_dialogContext;
1205   UxIcon_selection_dialogContext = UxContext =
1206                   (_UxCicon_selection_dialog *) UxGetContext( UxWidget );
1207   {
1208     char *filter;
1209
1210     filter = XmTextFieldGetString (UxWidget);
1211     apply_filter (filter);
1212   }
1213   UxIcon_selection_dialogContext = UxSaveCtx;
1214 }
1215
1216 /***************************************************************************/
1217 /*                                                                         */
1218 /*  defaultActionCB_dir_scrolled_list                                      */
1219 /*                                                                         */
1220 /*                                                                         */
1221 /***************************************************************************/
1222 static  void    defaultActionCB_dir_scrolled_list( Widget UxWidget,
1223                                                   XtPointer UxClientData,
1224                                                   XtPointer UxCallbackArg )
1225 {
1226   _UxCicon_selection_dialog *UxSaveCtx, *UxContext;
1227
1228   UxSaveCtx = UxIcon_selection_dialogContext;
1229   UxIcon_selection_dialogContext = UxContext =
1230                   (_UxCicon_selection_dialog *) UxGetContext( UxWidget );
1231   {
1232     XmListCallbackStruct *listcb;
1233     char *filter;
1234
1235     listcb = (XmListCallbackStruct *) UxCallbackArg;
1236     filter = (char *)XmStringToText (listcb->item);
1237     apply_filter (filter);
1238  /* XtManageChild (icon_scrolled_win);  */
1239   }
1240   UxIcon_selection_dialogContext = UxSaveCtx;
1241 }
1242
1243 /***************************************************************************/
1244 /*                                                                         */
1245 /*  selectionCB_icon_scrolled_container                                    */
1246 /*                                                                         */
1247 /***************************************************************************/
1248 static  void    selectionCB_icon_scrolled_container ( Widget UxWidget,
1249                                                   XtPointer UxClientData,
1250                                                   XtPointer UxCallbackArg )
1251 {
1252   char     *filename;
1253   XmString  xmbasename;
1254   char     *basename;
1255
1256   XtVaGetValues (UxWidget, XmNimageName, &filename, NULL);
1257 #ifdef DEBUG
1258   printf("In icon callback for '%s'\n", filename);
1259 #endif
1260   if (use_icon_name_field) {
1261      XtVaGetValues (UxWidget, XmNstring, &xmbasename, NULL);
1262      basename = XmStringToText(xmbasename);
1263      XmTextFieldSetString (icon_name_text_field, basename);
1264      if (basename) free(basename);
1265   }
1266   if (selected_icon_name) {
1267      if (selected_icon != UxWidget) {
1268         _DtIconSetState(selected_icon, FALSE, FALSE);
1269      }
1270      XtFree(selected_icon_name);
1271      selected_icon_name = (char *)NULL;
1272   }
1273   if (filename) {
1274      selected_icon_name = XtMalloc(strlen(filename) + 1);
1275      selected_icon_name = strcpy(selected_icon_name, filename);
1276   } else {
1277      selected_icon_name = (char *)NULL;
1278   }
1279   selected_icon = UxWidget;
1280
1281   return;
1282 }
1283
1284 /***************************************************************************/
1285 /*                                                                         */
1286 /*  resizeCB_clipWindow                                                    */
1287 /*                                                                         */
1288 /***************************************************************************/
1289 void    resizeCB_clipWindow( Widget UxWidget,
1290                              XtPointer UxClientData,
1291                              XtPointer UxCallbackArg )
1292 {
1293   Widget     widvScrollbar;
1294   Widget     widRowColumn;
1295   int        increment;
1296   Dimension  height;
1297
1298   XtVaGetValues(XtParent(UxWidget), XmNverticalScrollBar, &widvScrollbar, NULL);
1299   widRowColumn = (Widget)UxClientData;
1300   XtVaGetValues(widRowColumn, XmNheight, &height, NULL);
1301
1302 #ifdef DEBUG
1303   printf("height = %d\n", height);
1304   printf("icon_count = %d\n", icon_count);
1305 #endif
1306
1307   increment = (int)height / icon_count;
1308   XtVaSetValues(widvScrollbar, XmNincrement, increment, NULL);
1309
1310   return;
1311
1312 }
1313
1314 /***************************************************************************/
1315 /*                                                                         */
1316 /*  _Uxbuild_icon_selection_dialog                                         */
1317 /*                                                                         */
1318 /*                                                                         */
1319 /***************************************************************************/
1320 static Widget   _Uxbuild_icon_selection_dialog(void)
1321 {
1322         Widget          _UxParent;
1323         char            *UxTmp0;
1324         int             nbutton = 0;
1325         int             ntotalbuttons = numberOfBottomButtons;
1326 #define TIGHTNESS       20
1327         Arg             args[20];
1328         int             i=0;
1329         Widget          widclipWindow;
1330
1331         /* Creation of icon_selection_dialog */
1332         _UxParent = UxParent;
1333         if ( _UxParent == NULL )
1334         {
1335                 _UxParent = UxTopLevel;
1336         }
1337
1338         _UxParent = XtVaCreatePopupShell( "icon_selection_dialog_shell",
1339                         xmDialogShellWidgetClass, _UxParent,
1340                         XmNx, 18,
1341                         XmNy, 116,
1342                         XmNwidth, 610,
1343                         XmNheight, 534,
1344                         XmNshellUnitType, XmPIXELS,
1345                         XmNkeyboardFocusPolicy, XmEXPLICIT,
1346                         XmNtitle, "icon_selection_dialog",
1347                         NULL );
1348
1349         UxTmp0 = dialog_title ? (char *)dialog_title : "Icon Selection Window";
1350
1351         icon_selection_dialog = XtVaCreateWidget( "icon_selection_dialog",
1352                         xmFormWidgetClass,
1353                         _UxParent,
1354                         XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
1355                         XmNwidth, 550,
1356                         XmNheight, 534,
1357                         XmNunitType, XmPIXELS,
1358                         RES_CONVERT( XmNdialogTitle, UxTmp0 ),
1359                         XmNautoUnmanage, FALSE,
1360                         XmNdefaultPosition, FALSE,
1361                         NULL );
1362         UxPutContext( icon_selection_dialog, (char *) UxIcon_selection_dialogContext );
1363
1364         /*******************************************************************/
1365         /* Set up help callback                                            */
1366         /*******************************************************************/
1367         XtAddCallback( icon_selection_dialog, XmNhelpCallback,
1368                 (XtCallbackProc) helpCB_general,
1369                 (XtPointer) HELP_ICONSELECTOR );
1370
1371
1372         /* Creation of bottom_button_form */
1373         bottom_button_form = XtVaCreateManagedWidget( "bottom_button_form",
1374                         xmFormWidgetClass,
1375                         icon_selection_dialog,
1376                         XmNskipAdjust, TRUE,
1377                         XmNfractionBase, ((TIGHTNESS * ntotalbuttons) - 1),
1378
1379                         XmNleftOffset, 10,
1380                         XmNleftAttachment, XmATTACH_FORM,
1381                         XmNrightOffset, 10,
1382                         XmNrightAttachment, XmATTACH_FORM,
1383                         XmNbottomOffset, 20,
1384                         XmNbottomAttachment, XmATTACH_FORM,
1385
1386                         NULL );
1387         UxPutContext( bottom_button_form, (char *) UxIcon_selection_dialogContext );
1388
1389
1390         UxTmp0 = bottom_button_one_label ? (char *)bottom_button_one_label : GETMESSAGE(6, 10, "OK");
1391
1392         /* Creation of bottom_button1 = OK */
1393         bottom_button1 = XtVaCreateManagedWidget( "bottom_button1",
1394                         xmPushButtonWidgetClass,
1395                         bottom_button_form,
1396                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1397
1398                         XmNleftAttachment, nbutton ?
1399                                             XmATTACH_POSITION : XmATTACH_FORM,
1400                         XmNleftPosition, TIGHTNESS * nbutton,
1401                         XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
1402                                              XmATTACH_POSITION : XmATTACH_FORM,
1403                         XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
1404
1405                         NULL );
1406         nbutton++;
1407         XtAddCallback( bottom_button1, XmNactivateCallback,
1408                 (XtCallbackProc) activateCB_bottom_button1,
1409                 (XtPointer) NULL );
1410
1411         UxPutContext( bottom_button1, (char *) UxIcon_selection_dialogContext );
1412
1413         UxTmp0 = bottom_button_two_label ? (char *)bottom_button_two_label : GETMESSAGE(6, 12, "Cancel");
1414
1415         /* Creation of bottom_button2 = CANCEL */
1416         bottom_button2 = XtVaCreateManagedWidget( "bottom_button2",
1417                         xmPushButtonWidgetClass,
1418                         bottom_button_form,
1419                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1420
1421                         XmNleftAttachment, nbutton ?
1422                                             XmATTACH_POSITION : XmATTACH_FORM,
1423                         XmNleftPosition, TIGHTNESS * nbutton,
1424                         XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
1425                                              XmATTACH_POSITION : XmATTACH_FORM,
1426                         XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
1427
1428                         NULL );
1429         nbutton++;
1430         XtAddCallback( bottom_button2, XmNactivateCallback,
1431                 (XtCallbackProc) bottom_button_two_cb ?
1432                       bottom_button_two_cb : activateCB_bottom_button2,
1433                 (XtPointer) UxIcon_selection_dialogContext );
1434
1435         UxPutContext( bottom_button2, (char *) UxIcon_selection_dialogContext );
1436
1437         UxTmp0 = bottom_button_three_label ? (char *)bottom_button_three_label : GETMESSAGE(6, 13, "Help");
1438
1439         /* Creation of bottom_button3 = HELP */
1440         bottom_button3 = XtVaCreateManagedWidget( "bottom_button3",
1441                         xmPushButtonWidgetClass,
1442                         bottom_button_form,
1443                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1444                         XmNuserData, icon_selection_dialog,
1445
1446                         XmNleftAttachment, nbutton ?
1447                                             XmATTACH_POSITION : XmATTACH_FORM,
1448                         XmNleftPosition, TIGHTNESS * nbutton,
1449                         XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
1450                                              XmATTACH_POSITION : XmATTACH_FORM,
1451                         XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
1452
1453                         NULL );
1454         nbutton++;
1455         XtAddCallback( bottom_button3, XmNactivateCallback,
1456                 (XtCallbackProc) bottom_button_three_cb ?
1457                       bottom_button_three_cb : activateCB_bottom_button3,
1458                 (XtPointer) UxIcon_selection_dialogContext );
1459
1460         UxPutContext( bottom_button3, (char *) UxIcon_selection_dialogContext );
1461
1462         UxTmp0 = bottom_button_four_label ? (char *)bottom_button_four_label : GETMESSAGE(12, 10, "Filter");
1463
1464         /* Creation of bottom_button4 */
1465         bottom_button4 = XtVaCreateManagedWidget( "bottom_button4",
1466                         xmPushButtonWidgetClass,
1467                         bottom_button_form,
1468                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1469
1470                         XmNleftAttachment, nbutton ?
1471                                             XmATTACH_POSITION : XmATTACH_FORM,
1472                         XmNleftPosition, TIGHTNESS * nbutton,
1473                         XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
1474                                              XmATTACH_POSITION : XmATTACH_FORM,
1475                         XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
1476
1477                         NULL );
1478         nbutton++;
1479         XtAddCallback( bottom_button4, XmNactivateCallback,
1480                 (XtCallbackProc) bottom_button_four_cb ?
1481                       bottom_button_four_cb : activateCB_bottom_button,
1482                 (XtPointer) UxIcon_selection_dialogContext );
1483
1484         UxPutContext( bottom_button4, (char *) UxIcon_selection_dialogContext );
1485
1486
1487         /* Creation of separatorGadget1 */
1488         separatorGadget1 = XtVaCreateManagedWidget( "separatorGadget1",
1489                         xmSeparatorGadgetClass,
1490                         icon_selection_dialog,
1491                         XmNx, 0,
1492                         XmNy, 490,
1493                         XmNrightOffset, 1,
1494                         XmNrightAttachment, XmATTACH_FORM,
1495                         XmNleftOffset, 1,
1496                         XmNleftAttachment, XmATTACH_FORM,
1497                         XmNbottomOffset, 10,
1498                         XmNbottomWidget, bottom_button_form,
1499                         XmNbottomAttachment, XmATTACH_WIDGET,
1500                         NULL );
1501         UxPutContext( separatorGadget1, (char *) UxIcon_selection_dialogContext );
1502
1503
1504         /* Creation of icon_name_text_field */
1505         icon_name_text_field = XtVaCreateManagedWidget( "icon_name_text_field",
1506                         xmTextFieldWidgetClass,
1507                         icon_selection_dialog,
1508                         XmNx, 9,
1509                         XmNy, 440,
1510                         XmNbottomOffset, 10,
1511                         XmNbottomWidget, separatorGadget1,
1512                         XmNbottomAttachment, XmATTACH_WIDGET,
1513                         XmNrightOffset, 10,
1514                         XmNrightAttachment, XmATTACH_FORM,
1515                         XmNleftOffset, 10,
1516                         XmNleftAttachment, XmATTACH_FORM,
1517                         NULL );
1518         UxPutContext( icon_name_text_field, (char *) UxIcon_selection_dialogContext );
1519         ISD_SelectedIconTextField = icon_name_text_field;
1520
1521         UxTmp0 = name_field_title ? (char *)name_field_title : GETMESSAGE(11, 12, "Enter Icon Filename");
1522
1523         /* Creation of icon_name_textfield_label */
1524         icon_name_textfield_label = XtVaCreateManagedWidget( "icon_name_textfield_label",
1525                         xmLabelWidgetClass,
1526                         icon_selection_dialog,
1527                         XmNx, 9,
1528                         XmNy, 410,
1529                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1530                         XmNbottomOffset, 0,
1531                         XmNbottomWidget, icon_name_text_field,
1532                         XmNbottomAttachment, XmATTACH_WIDGET,
1533                         XmNleftOffset, 0,
1534                         XmNleftWidget, icon_name_text_field,
1535                         XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
1536                         XmNalignment, XmALIGNMENT_BEGINNING,
1537                         NULL );
1538         UxPutContext( icon_name_textfield_label, (char *) UxIcon_selection_dialogContext );
1539
1540         UxTmp0 = filter_field_title ? (char *)filter_field_title : GETMESSAGE(12, 10, "Filter");
1541
1542         /* Creation of filter_textfield_label */
1543         filter_textfield_label = XtVaCreateManagedWidget( "filter_textfield_label",
1544                         xmLabelWidgetClass,
1545                         icon_selection_dialog,
1546                         XmNx, 10,
1547                         XmNy, 10,
1548                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1549                         XmNalignment, XmALIGNMENT_BEGINNING,
1550                         XmNtopOffset, 10,
1551                         XmNtopAttachment, XmATTACH_FORM,
1552                         XmNleftOffset, 10,
1553                         XmNleftAttachment, XmATTACH_FORM,
1554                         NULL );
1555         UxPutContext( filter_textfield_label, (char *) UxIcon_selection_dialogContext );
1556
1557
1558         /* Creation of filter_text_field */
1559         filter_text_field = XtVaCreateManagedWidget( "filter_text_field",
1560                         xmTextFieldWidgetClass,
1561                         icon_selection_dialog,
1562                         XmNx, 10,
1563                         XmNy, 40,
1564                         XmNtopOffset, 0,
1565                         XmNtopWidget, filter_textfield_label,
1566                         XmNtopAttachment, XmATTACH_WIDGET,
1567                         XmNrightOffset, 10,
1568                         XmNrightAttachment, XmATTACH_FORM,
1569                         XmNleftOffset, 10,
1570                         XmNleftAttachment, XmATTACH_FORM,
1571                         NULL );
1572         XtAddCallback( filter_text_field, XmNactivateCallback,
1573                 (XtCallbackProc) activateCB_filter_text_field,
1574                 (XtPointer) UxIcon_selection_dialogContext );
1575
1576         UxPutContext( filter_text_field, (char *) UxIcon_selection_dialogContext );
1577
1578         UxTmp0 = directory_title ? (char *)directory_title : GETMESSAGE(11, 30, "Icon Folders");
1579
1580         /* Creation of directory_list_label */
1581         directory_list_label = XtVaCreateManagedWidget( "directory_list_label",
1582                         xmLabelWidgetClass,
1583                         icon_selection_dialog,
1584                         XmNx, 0,
1585                         XmNy, 90,
1586                         XmNlabelType, XmSTRING,
1587                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1588                         XmNalignment, XmALIGNMENT_BEGINNING,
1589                         XmNtopOffset, 10,
1590                         XmNtopWidget, filter_text_field,
1591                         XmNtopAttachment, use_filter_field ? XmATTACH_WIDGET : XmATTACH_FORM,
1592                         XmNleftOffset, 10,
1593                         XmNleftAttachment, XmATTACH_FORM,
1594                         NULL );
1595         UxPutContext( directory_list_label, (char *) UxIcon_selection_dialogContext );
1596
1597         UxTmp0 = container_title ? (char *)container_title : GETMESSAGE(11, 11, "Icon Files");
1598
1599         /* Creation of icon_container_label */
1600         icon_container_label = XtVaCreateManagedWidget( "icon_container_label",
1601                         xmLabelWidgetClass,
1602                         icon_selection_dialog,
1603                         XmNx, 281,
1604                         XmNy, 90,
1605                         XmNlabelType, XmSTRING,
1606                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1607                         XmNalignment, XmALIGNMENT_BEGINNING,
1608                         XmNtopOffset, 10,
1609                         XmNtopWidget, filter_text_field,
1610                         XmNtopAttachment, XmATTACH_WIDGET,
1611                         XmNleftAttachment, XmATTACH_POSITION,
1612                         XmNleftPosition, 55,
1613                         NULL );
1614         UxPutContext( icon_container_label, (char *) UxIcon_selection_dialogContext );
1615
1616
1617         /* Creation of top_button_form */
1618         top_button_form = XtVaCreateManagedWidget( "top_button_form",
1619                         xmFormWidgetClass,
1620                         icon_selection_dialog,
1621                         XmNresizePolicy, XmRESIZE_NONE,
1622                         XmNx, 10,
1623                         XmNy, 290,
1624                         XmNbottomOffset, 10,
1625                         XmNbottomWidget, use_icon_name_field ? icon_name_textfield_label : separatorGadget1,
1626                         XmNbottomAttachment, XmATTACH_WIDGET,
1627                         XmNrightOffset, 1,
1628                         XmNrightAttachment, XmATTACH_FORM,
1629                         XmNleftOffset, 1,
1630                         XmNleftAttachment, XmATTACH_FORM,
1631                         NULL );
1632         UxPutContext( top_button_form, (char *) UxIcon_selection_dialogContext );
1633
1634         UxTmp0 = top_button_one_label ? (char *)top_button_one_label : "No_Label";
1635
1636         /* Creation of top_button1 */
1637         top_button1 = XtVaCreateManagedWidget( "top_button1",
1638                         xmPushButtonWidgetClass,
1639                         top_button_form,
1640                         XmNx, 40,
1641                         XmNy, 0,
1642                         XmNleftOffset, 0,
1643                         XmNbottomAttachment, XmATTACH_FORM,
1644                         XmNleftAttachment, XmATTACH_POSITION,
1645                         XmNtopOffset, 0,
1646                         XmNleftPosition, get_top_b1_position (numberOfTopButtons),
1647                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1648                         NULL );
1649         XtAddCallback( top_button1, XmNactivateCallback,
1650                 (XtCallbackProc) top_button_one_cb,
1651                 (XtPointer) UxIcon_selection_dialogContext );
1652
1653         UxPutContext( top_button1, (char *) UxIcon_selection_dialogContext );
1654
1655         UxTmp0 = top_button_two_label ? (char *)top_button_two_label : "No_Label";
1656
1657         /* Creation of top_button2 */
1658         top_button2 = XtVaCreateManagedWidget( "top_button2",
1659                         xmPushButtonWidgetClass,
1660                         top_button_form,
1661                         XmNx, 220,
1662                         XmNy, 0,
1663                         XmNleftOffset, 0,
1664                         XmNtopOffset, 0,
1665                         XmNleftPosition, get_top_b2_position (numberOfTopButtons),
1666                         XmNbottomAttachment, XmATTACH_FORM,
1667                         XmNleftAttachment, XmATTACH_POSITION,
1668                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1669                         NULL );
1670         XtAddCallback( top_button2, XmNactivateCallback,
1671                 (XtCallbackProc) top_button_two_cb,
1672                 (XtPointer) UxIcon_selection_dialogContext );
1673
1674         UxPutContext( top_button2, (char *) UxIcon_selection_dialogContext );
1675
1676         UxTmp0 = top_button_three_label ? (char *)top_button_three_label : "No_Label";
1677
1678         /* Creation of top_button3 */
1679         top_button3 = XtVaCreateManagedWidget( "top_button3",
1680                         xmPushButtonWidgetClass,
1681                         top_button_form,
1682                         XmNx, 310,
1683                         XmNy, 0,
1684                         RES_CONVERT( XmNlabelString, UxTmp0 ),
1685                         XmNleftPosition, 72,
1686                         XmNleftOffset, 1,
1687                         XmNleftAttachment, XmATTACH_POSITION,
1688                         XmNbottomOffset, 0,
1689                         XmNbottomAttachment, XmATTACH_FORM,
1690                         NULL );
1691         XtAddCallback( top_button3, XmNactivateCallback,
1692                 (XtCallbackProc) top_button_three_cb,
1693                 (XtPointer) UxIcon_selection_dialogContext );
1694
1695         UxPutContext( top_button3, (char *) UxIcon_selection_dialogContext );
1696
1697         UxTmp0 = (char *)((numberOfTopButtons > 0) ? top_button_form : icon_name_textfield_label);
1698
1699         /* Creation of dir_scrolled_list */
1700         XtSetArg(args[i], XmNshadowThickness, 2); i++;
1701         XtSetArg(args[i], XmNlistSizePolicy, XmCONSTANT); i++;
1702
1703         XtSetArg(args[i], XmNleftOffset, 10); i++;
1704         XtSetArg(args[i], XmNleftAttachment, XmATTACH_FORM); i++;
1705         XtSetArg(args[i], XmNtopOffset, 0); i++;
1706         XtSetArg(args[i], XmNtopWidget, directory_list_label); i++;
1707         XtSetArg(args[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
1708         XtSetArg(args[i], XmNrightOffset, 20); i++;
1709         XtSetArg(args[i], XmNrightWidget, icon_container_label); i++;
1710         XtSetArg(args[i], XmNrightAttachment, XmATTACH_WIDGET); i++;
1711
1712         XtSetArg(args[i], XmNbottomOffset, 10); i++;
1713         if (numberOfTopButtons > 0) {
1714            XtSetArg(args[i], XmNbottomWidget, top_button_form); i++;
1715         } else if (use_icon_name_field) {
1716            XtSetArg(args[i], XmNbottomWidget, icon_name_textfield_label); i++;
1717         } else {
1718            XtSetArg(args[i], XmNbottomWidget, separatorGadget1); i++;
1719         }
1720         XtSetArg(args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
1721
1722         dir_scrolled_list = XmCreateScrolledList(icon_selection_dialog,
1723                                                 "dir_scrolled_list",
1724                                                 args,
1725                                                 i);
1726         XtVaSetValues(dir_scrolled_list,
1727                         XmNselectionPolicy, XmBROWSE_SELECT,
1728                         XmNvisibleItemCount, 15,
1729                         NULL );
1730         XtManageChild(dir_scrolled_list);
1731
1732         UxPutContext( dir_scrolled_list, (char *) UxIcon_selection_dialogContext );
1733         calc_bottom_attachment (dir_scrolled_list,
1734                                (XtPointer) UxIcon_selection_dialogContext,
1735                                (XtPointer) NULL);
1736         XtAddCallback( dir_scrolled_list, XmNdefaultActionCallback,
1737                 (XtCallbackProc) defaultActionCB_dir_scrolled_list,
1738                 (XtPointer) UxIcon_selection_dialogContext );
1739
1740         UxTmp0 = (char *)((numberOfTopButtons > 0) ? top_button_form : icon_name_textfield_label);
1741
1742         /* Creation of icon_scrolled_win */
1743         icon_scrolled_win = XtVaCreateManagedWidget( "icon_scrolled_win",
1744                         xmScrolledWindowWidgetClass,
1745                         icon_selection_dialog,
1746                         XmNscrollingPolicy, XmAUTOMATIC,
1747 /*                      XmNnavigationType, XmTAB_GROUP, */
1748                         XmNx, 282,
1749                         XmNy, 84,
1750                         XmNscrollBarDisplayPolicy, XmAS_NEEDED,
1751                         XmNrightOffset, 10,
1752                         XmNrightAttachment, XmATTACH_FORM,
1753                         XmNtopOffset, 0,
1754                         XmNtopWidget, icon_container_label,
1755                         XmNtopAttachment, XmATTACH_WIDGET,
1756                         XmNleftOffset, 0,
1757                         XmNleftWidget, icon_container_label,
1758                         XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
1759                         XmNbottomOffset, 10,
1760                         XmNbottomWidget, XmATTACH_NONE,
1761                         XmNbottomAttachment, XmATTACH_WIDGET,
1762                         NULL );
1763
1764
1765
1766
1767         UxPutContext( icon_scrolled_win, (char *) UxIcon_selection_dialogContext );
1768         calc_bottom_attachment (icon_scrolled_win,
1769                                (XtPointer) UxIcon_selection_dialogContext,
1770                                (XtPointer) NULL);
1771
1772         /* Creation of icon_scrolled_container */
1773         icon_scrolled_container = XtVaCreateManagedWidget( "icon_scrolled_container",
1774                         xmRowColumnWidgetClass,
1775                         icon_scrolled_win,
1776                         XmNnavigationType, XmTAB_GROUP,
1777                       /*XmNborderWidth, 1,*/
1778                       /*XmNnumColumns, 2,*/
1779                         XmNnumColumns, 1,
1780                         XmNorientation, XmVERTICAL,
1781                         XmNpacking, XmPACK_COLUMN,
1782                         XmNshadowThickness, 1,
1783                         NULL );
1784
1785         XtVaSetValues(icon_selection_dialog,
1786                         XmNcancelButton, bottom_button2,
1787                         NULL );
1788
1789         XtAddCallback( icon_selection_dialog, XmNdestroyCallback,
1790                       (XtCallbackProc) UxDestroyContextCB,
1791                       (XtPointer) UxIcon_selection_dialogContext);
1792
1793         XtVaGetValues (icon_scrolled_win, XmNclipWindow, &widclipWindow, NULL);
1794         XtAddCallback( widclipWindow, XmNresizeCallback,
1795                 (XtCallbackProc) resizeCB_clipWindow,
1796                 (XtPointer) icon_scrolled_container );
1797
1798         return ( icon_selection_dialog );
1799 }
1800
1801 /*******************************************************************************
1802        The following is the 'Interface function' which is the
1803        external entry point for creating this interface.
1804        This function should be called from your application or from
1805        a callback function.
1806 *******************************************************************************/
1807
1808 Widget  create_icon_selection_dialog(swidget    _UxUxParent,
1809         unsigned char   *_Uxdialog_title,
1810         unsigned char   *_Uxfilter_field_title,
1811         int     _Uxuse_filter_field,
1812         unsigned char   *_Uxfile_filter,
1813         unsigned char   *_Uxdirectory_title,
1814         unsigned char   **_Uxdirectories_list,
1815         unsigned char   *_Uxcontainer_title,
1816         int     _UxnumberOfTopButtons,
1817         unsigned char   *_Uxtop_button_one_label,
1818         void    (*_Uxtop_button_one_cb)(),
1819         unsigned char   *_Uxtop_button_two_label,
1820         void    (*_Uxtop_button_two_cb)(),
1821         unsigned char   *_Uxtop_button_three_label,
1822         void    (*_Uxtop_button_three_cb)(),
1823         int     _Uxuse_icon_name_field,
1824         unsigned char   *_Uxname_field_title,
1825         int     _UxnumberOfBottomButtons,
1826         unsigned char   *_Uxbottom_button_one_label,
1827         void    (*_Uxbottom_button_one_cb)(),
1828         unsigned char   *_Uxbottom_button_two_label,
1829         void    (*_Uxbottom_button_two_cb)(),
1830         unsigned char   *_Uxbottom_button_three_label,
1831         void    (*_Uxbottom_button_three_cb)(),
1832         unsigned char   *_Uxbottom_button_four_label,
1833         void    (*_Uxbottom_button_four_cb)() )
1834
1835
1836 {
1837         char                   *initial_filter;
1838         char                   *icon_file_name;
1839         Widget                  rtrn;
1840         int                     lcv;
1841         _UxCicon_selection_dialog *UxContext;
1842
1843         UxIcon_selection_dialogContext = UxContext =
1844                 (_UxCicon_selection_dialog *) UxNewContext( sizeof(_UxCicon_selection_dialog), False );
1845
1846         UxParent = _UxUxParent;
1847         dialog_title = _Uxdialog_title;
1848         filter_field_title = _Uxfilter_field_title;
1849         use_filter_field = _Uxuse_filter_field;
1850         file_filter = _Uxfile_filter;
1851         directory_title = _Uxdirectory_title;
1852         directories_list = _Uxdirectories_list;
1853         container_title = _Uxcontainer_title;
1854         numberOfTopButtons = _UxnumberOfTopButtons;
1855         top_button_one_label = _Uxtop_button_one_label;
1856         top_button_one_cb = _Uxtop_button_one_cb;
1857         top_button_two_label = _Uxtop_button_two_label;
1858         top_button_two_cb = _Uxtop_button_two_cb;
1859         top_button_three_label = _Uxtop_button_three_label;
1860         top_button_three_cb = _Uxtop_button_three_cb;
1861         use_icon_name_field = _Uxuse_icon_name_field;
1862         name_field_title = _Uxname_field_title;
1863         numberOfBottomButtons = _UxnumberOfBottomButtons;
1864         bottom_button_one_label = _Uxbottom_button_one_label;
1865         bottom_button_one_cb = _Uxbottom_button_one_cb;
1866         bottom_button_two_label = _Uxbottom_button_two_label;
1867         bottom_button_two_cb = _Uxbottom_button_two_cb;
1868         bottom_button_three_label = _Uxbottom_button_three_label;
1869         bottom_button_three_cb = _Uxbottom_button_three_cb;
1870         bottom_button_four_label = _Uxbottom_button_four_label;
1871         bottom_button_four_cb = _Uxbottom_button_four_cb;
1872
1873         rtrn = _Uxbuild_icon_selection_dialog();
1874
1875         switch (numberOfTopButtons){
1876                 case 0 : XtUnmanageChild (top_button_form); break;
1877                 case 1 : XtUnmanageChild (top_button2);
1878                 case 2 : XtUnmanageChild (top_button3);
1879         };
1880
1881         if (numberOfBottomButtons == 3)
1882            XtUnmanageChild (bottom_button4);
1883
1884         if (!use_filter_field) {
1885            XtUnmanageChild (filter_textfield_label);
1886            XtUnmanageChild (filter_text_field);
1887         }
1888
1889         if (!use_icon_name_field) {
1890            XtUnmanageChild (icon_name_textfield_label);
1891            XtUnmanageChild (icon_name_text_field);
1892         }
1893
1894         TurnOnHourGlassAllWindows();
1895
1896         /******************************************************************/
1897         /* save file_filter */
1898         /******************************************************************/
1899         file_filter_global = (char *)calloc(strlen((char *)file_filter)+1, sizeof(char));
1900
1901 #ifdef DEBUG
1902         if (!file_filter_global) printf("Calloc error for file_filter_global, in create_icon_selection_dialog.\n");
1903 #endif
1904
1905         if (file_filter[0] == '*')
1906            file_filter_global = strcpy(file_filter_global, (char *)&file_filter[1]);
1907         else
1908            file_filter_global = strcpy(file_filter_global, (char *)file_filter);
1909
1910         load_directories_list ((char **)directories_list);
1911         initial_filter = initialize_filter ((char *)file_filter);
1912
1913         /******************************************************************/
1914         /* save main_filter */
1915         /******************************************************************/
1916         main_filter = (char *)calloc(strlen(initial_filter)+1, sizeof(char));
1917
1918 #ifdef DEBUG
1919         if (!main_filter) printf("Calloc error for main_filter, in create_icon_selection_dialog.\n");
1920 #endif
1921
1922         main_filter = strcpy(main_filter, initial_filter);;
1923
1924         icons_in_container = NULL;
1925         icon_count = 0;
1926
1927         update_container_contents (initial_filter);
1928
1929         /******************************************************************/
1930         /* set selected_icon_name to first name in list                   */
1931         /******************************************************************/
1932 #if 0
1933         if (icons_in_container) {
1934            XtVaGetValues (icons_in_container[0], XmNimageName, &icon_file_name, NULL);
1935            XmTextFieldSetString (icon_name_text_field, icon_file_name);
1936            selected_icon_name = XtMalloc(strlen(icon_file_name) + 1);
1937            if (selected_icon_name)
1938               selected_icon_name = strcpy(selected_icon_name, icon_file_name);
1939         }
1940 #endif
1941
1942         load_filter_text_field (initial_filter);
1943
1944         TurnOffHourGlassAllWindows();
1945
1946         return(rtrn);
1947 }