]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormFiledialog.C
Bugfixes: checkboxes to radiobuttons (from J�rgen S) and remove a little
[lyx.git] / src / frontends / xforms / FormFiledialog.C
1 /**
2  * \file FormFiledialog.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author unknown
7  * \author John Levon
8  */
9
10 #include <config.h>
11
12 #include <unistd.h>
13 #include <cstdlib>
14 #include <pwd.h>
15 #include <grp.h>
16 //#include <cstring>
17 #include <map>
18 #include <algorithm>
19
20 using std::map;
21 using std::max;
22 using std::sort;
23
24 #include "frontends/Alert.h"
25 #include "support/FileInfo.h"
26 #include "support/lyxlib.h"
27 #include "support/lstrings.h"
28 #include "gettext.h"
29 #include "frontends/Dialogs.h"
30 #include "xforms_helpers.h"
31
32
33 #ifdef HAVE_ERRNO_H
34 #include <cerrno>
35 #endif
36
37 #if HAVE_DIRENT_H
38 # include <dirent.h>
39 # define NAMLEN(dirent) strlen((dirent)->d_name)
40 #else
41 # define dirent direct
42 # define NAMLEN(dirent) (dirent)->d_namlen
43 # if HAVE_SYS_NDIR_H
44 #  include <sys/ndir.h>
45 # endif
46 # if HAVE_SYS_DIR_H
47 #  include <sys/dir.h>
48 # endif
49 # if HAVE_NDIR_H
50 #  include <ndir.h>
51 # endif
52 #endif
53
54 #if TIME_WITH_SYS_TIME
55 # include <sys/time.h>
56 # include <ctime>
57 #else
58 # if HAVE_SYS_TIME_H
59 #  include <sys/time.h>
60 # else
61 #  include <ctime>
62 # endif
63 #endif
64
65 // FIXME: should be autoconfiscated
66 #ifdef BROKEN_HEADERS
67 extern "C" int gettimeofday(struct timeval *, struct timezone *);
68 #endif
69
70 #ifdef __GNUG__
71 #pragma implementation
72 #endif
73
74 #include "support/filetools.h"
75 #include "FormFiledialog.h"
76
77 namespace {
78
79 // six months, in seconds
80 long const SIX_MONTH_SEC = 6L * 30L * 24L * 60L * 60L;
81 //static
82 long const ONE_HOUR_SEC = 60L * 60L;
83
84 extern "C" {
85         
86         static
87         int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev)
88         {
89                 return FileDialog::Private::CancelCB(fl, xev);
90         }
91         
92         static
93         void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data)
94         {
95                 FileDialog::Private::DoubleClickCB(ob, data);
96         }
97
98         static
99         void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data)
100         {
101                 FileDialog::Private::FileDlgCB(ob, data);
102         }
103
104 }
105
106 } // namespace anon
107
108
109 // *** User cache class implementation
110 /// User cache class definition
111 class UserCache {
112 public:
113         /// seeks user name from group ID
114         string const & find(uid_t ID) const {
115                 Users::const_iterator cit = users.find(ID);
116                 if (cit == users.end()) {
117                         add(ID);
118                         return users[ID];
119                 }
120                 return cit->second;
121         }
122 private:
123         ///
124         void add(uid_t ID) const;
125         ///
126         typedef map<uid_t, string> Users;
127         ///
128         mutable Users users;
129 };
130
131
132 void UserCache::add(uid_t ID) const
133 {
134         string pszNewName;
135         struct passwd * pEntry;
136         
137         // gets user name
138         if ((pEntry = getpwuid(ID)))
139                 pszNewName = pEntry->pw_name;
140         else {
141                 pszNewName = tostr(ID);
142         }
143         
144         // adds new node
145         users[ID] = pszNewName;
146 }       
147
148
149 /// Group cache class definition
150 class GroupCache {
151 public:
152         /// seeks group name from group ID
153         string const & find(gid_t ID) const ;
154 private:
155         ///
156         void add(gid_t ID) const;
157         ///
158         typedef map<gid_t, string> Groups;
159         ///
160         mutable Groups groups;
161 };
162
163
164 string const & GroupCache::find(gid_t ID) const
165 {
166         Groups::const_iterator cit = groups.find(ID);
167         if (cit == groups.end()) {
168                 add(ID);
169                 return groups[ID];
170         }
171         return cit->second;
172 }
173
174
175 void GroupCache::add(gid_t ID) const
176 {
177         string pszNewName;
178         struct group * pEntry;
179         
180         // gets user name
181         if ((pEntry = getgrgid(ID))) pszNewName = pEntry->gr_name;
182         else {
183                 pszNewName = tostr(ID);
184         }
185         // adds new node
186         groups[ID] = pszNewName;
187 }
188
189
190 namespace {
191
192 // local instances
193 UserCache lyxUserCache;
194 GroupCache lyxGroupCache;
195
196 } // namespace anon
197
198
199 // compares two LyXDirEntry objects content (used for sort)
200 class comp_direntry {
201 public:
202         int operator()(DirEntry const & r1,
203                        DirEntry const & r2) const ;
204 };
205         int comp_direntry::operator()(DirEntry const & r1,
206                        DirEntry const & r2) const {
207                 bool r1d = suffixIs(r1.pszName, '/');
208                 bool r2d = suffixIs(r2.pszName, '/');
209                 if (r1d && !r2d) return 1;
210                 if (!r1d && r2d) return 0;
211                 return r1.pszName < r2.pszName;
212         }
213
214
215 // *** FileDialog::Private class implementation
216
217 // static members
218 FD_form_filedialog * FileDialog::Private::pFileDlgForm = 0;
219 FileDialog::Private * FileDialog::Private::pCurrentDlg = 0;
220
221
222 // Reread: updates dialog list to match class directory
223 void FileDialog::Private::Reread()
224 {
225         // Opens directory
226         DIR * pDirectory = ::opendir(pszDirectory.c_str());
227         if (!pDirectory) {
228                 Alert::err_alert(_("Warning! Couldn't open directory."),
229                              pszDirectory);
230                 pszDirectory = lyx::getcwd();
231                 pDirectory = ::opendir(pszDirectory.c_str());
232         }
233
234         // Clear the present namelist
235         direntries.clear();
236
237         // Updates display
238         fl_hide_object(pFileDlgForm->List);
239         fl_clear_browser(pFileDlgForm->List);
240         fl_set_input(pFileDlgForm->DirBox, pszDirectory.c_str());
241
242         // Splits complete directory name into directories and compute depth
243         iDepth = 0;
244         string line, Temp;
245         char szMode[15];
246         string File = pszDirectory;
247         if (File != "/") {
248                 File = split(File, Temp, '/');
249         }
250         while (!File.empty() || !Temp.empty()) {
251                 string dline = "@b"+line + Temp + '/';          
252                 fl_add_browser_line(pFileDlgForm->List, dline.c_str());
253                 File = split(File, Temp, '/');
254                 line += ' ';
255                 ++iDepth;
256         }
257
258         // Parses all entries of the given subdirectory
259         time_t curTime = time(0);
260         rewinddir(pDirectory);
261         struct dirent * pDirEntry;
262         while ((pDirEntry = readdir(pDirectory))) {
263                 bool isLink = false, isDir = false;
264
265                 // If the pattern doesn't start with a dot, skip hidden files
266                 if (!pszMask.empty() && pszMask[0] != '.' &&
267                     pDirEntry->d_name[0] == '.')
268                         continue;
269
270                 // Gets filename
271                 string fname = pDirEntry->d_name;
272
273                 // Under all circumstances, "." and ".." are not wanted
274                 if (fname == "." || fname == "..")
275                         continue;
276
277                 // gets file status
278                 File = AddName(pszDirectory, fname);
279
280                 FileInfo fileInfo(File, true);
281
282                 // can this really happen?
283                 if (!fileInfo.isOK())
284                         continue;
285                 
286                 fileInfo.modeString(szMode);
287                 unsigned int nlink = fileInfo.getNumberOfLinks();
288                 string user =   lyxUserCache.find(fileInfo.getUid());
289                 string group = lyxGroupCache.find(fileInfo.getGid());
290
291                 time_t modtime = fileInfo.getModificationTime();
292                 string Time = ctime(&modtime);
293                 
294                 if (curTime > modtime + SIX_MONTH_SEC
295                     || curTime < modtime + ONE_HOUR_SEC) {
296                         // The file is fairly old or in the future. POSIX says
297                         // the cutoff is 6 months old. Allow a 1 hour slop
298                         // factor for what is considered "the future", to
299                         // allow for NFS server/client clock disagreement.
300                         // Show the year instead of the time of day.
301                         Time.erase(10, 9);
302                         Time.erase(15, string::npos);
303                 } else {
304                         Time.erase(16, string::npos);
305                 }
306
307                 string Buffer = string(szMode) + ' ' +
308                         tostr(nlink) + ' ' +
309                         user + ' ' +
310                         group + ' ' +
311                         Time.substr(4, string::npos) + ' ';
312
313                 Buffer += pDirEntry->d_name;
314                 Buffer += fileInfo.typeIndicator();
315
316                 if ((isLink = fileInfo.isLink())) {
317                         string Link;
318
319                         if (LyXReadLink(File, Link)) {
320                                 Buffer += " -> ";
321                                 Buffer += Link;
322
323                                 // This gives the FileType of the file that
324                                 // is really pointed too after resolving all
325                                 // symlinks. This is not necessarily the same
326                                 // as the type of Link (which could again be a
327                                 // link). Is that intended?
328                                 //                              JV 199902
329                                 fileInfo.newFile(File);
330                                 if (fileInfo.isOK())
331                                         Buffer += fileInfo.typeIndicator();
332                                 else
333                                         continue;
334                         }
335                 }
336
337                 // filters files according to pattern and type
338                 if (fileInfo.isRegular()
339                     || fileInfo.isChar()
340                     || fileInfo.isBlock()
341                     || fileInfo.isFifo()) {
342                         if (!regexMatch(fname, pszMask))
343                                 continue;
344                 } else if (!(isDir = fileInfo.isDir()))
345                         continue;
346
347                 DirEntry tmp;
348
349                 // Note pszLsEntry is an string!
350                 tmp.pszLsEntry = Buffer;
351                 // creates used name
352                 string temp = fname;
353                 if (isDir) temp += '/';
354
355                 tmp.pszName = temp;
356                 // creates displayed name
357                 temp = pDirEntry->d_name;
358                 if (isLink)
359                         temp += '@';
360                 else
361                         temp += fileInfo.typeIndicator();
362                 tmp.pszDisplayed = temp;
363
364                 direntries.push_back(tmp);
365         }
366
367         closedir(pDirectory);
368
369         // Sort the names
370         sort(direntries.begin(), direntries.end(), comp_direntry());
371         
372         // Add them to directory box
373         for (DirEntries::const_iterator cit = direntries.begin();
374              cit != direntries.end(); ++cit) {
375                 string const temp = line + cit->pszDisplayed;
376                 fl_add_browser_line(pFileDlgForm->List, temp.c_str());
377         }
378         fl_set_browser_topline(pFileDlgForm->List, iDepth);
379         fl_show_object(pFileDlgForm->List);
380         iLastSel = -1;
381 }
382
383
384 // SetDirectory: sets dialog current directory
385 void FileDialog::Private::SetDirectory(string const & Path)
386 {
387         
388         string tmp;
389
390         if (Path.empty()) 
391                 tmp = lyx::getcwd();
392         else
393                 tmp = MakeAbsPath(ExpandPath(Path), pszDirectory);
394  
395         // must check the directory exists
396         DIR * pDirectory = ::opendir(tmp.c_str());
397         if (!pDirectory) {
398                 Alert::err_alert(_("Warning! Couldn't open directory."), tmp);
399         } else {
400                 ::closedir(pDirectory);
401                 pszDirectory = tmp;
402         }
403 }
404
405
406 // SetMask: sets dialog file mask
407 void FileDialog::Private::SetMask(string const & NewMask)
408 {
409         pszMask = NewMask;
410         fl_set_input(pFileDlgForm->PatBox, pszMask.c_str());
411 }
412
413
414 // SetInfoLine: sets dialog information line
415 void FileDialog::Private::SetInfoLine(string const & Line)
416 {
417         pszInfoLine = Line;
418         fl_set_object_label(pFileDlgForm->FileInfo, pszInfoLine.c_str());
419 }
420
421
422 FileDialog::Private::Private()
423 {
424         pszDirectory = MakeAbsPath(string("."));
425         pszMask = '*';
426
427         // Creates form if necessary.
428         if (!pFileDlgForm) {
429                 pFileDlgForm = build_filedialog();
430                 // Set callbacks. This means that we don't need a patch file
431                 fl_set_object_callback(pFileDlgForm->DirBox,
432                                        C_LyXFileDlg_FileDlgCB, 0);
433                 fl_set_object_callback(pFileDlgForm->PatBox,
434                                        C_LyXFileDlg_FileDlgCB, 1);
435                 fl_set_object_callback(pFileDlgForm->List,
436                                        C_LyXFileDlg_FileDlgCB, 2);
437                 fl_set_object_callback(pFileDlgForm->Filename,
438                                        C_LyXFileDlg_FileDlgCB, 3);
439                 fl_set_object_callback(pFileDlgForm->Rescan,
440                                        C_LyXFileDlg_FileDlgCB, 10);
441                 fl_set_object_callback(pFileDlgForm->Home,
442                                        C_LyXFileDlg_FileDlgCB, 11);
443                 fl_set_object_callback(pFileDlgForm->User1,
444                                        C_LyXFileDlg_FileDlgCB, 12);
445                 fl_set_object_callback(pFileDlgForm->User2,
446                                        C_LyXFileDlg_FileDlgCB, 13);
447                 
448                 // Make sure pressing the close box doesn't crash LyX. (RvdK)
449                 fl_set_form_atclose(pFileDlgForm->form,
450                                     C_LyXFileDlg_CancelCB, 0);
451                 // Register doubleclick callback
452                 fl_set_browser_dblclick_callback(pFileDlgForm->List,
453                                                  C_LyXFileDlg_DoubleClickCB,
454                                                  0);
455         }
456         fl_hide_object(pFileDlgForm->User1);
457         fl_hide_object(pFileDlgForm->User2);
458
459         r_ = Dialogs::redrawGUI.connect(SigC::slot(this, &FileDialog::Private::redraw));
460 }
461
462
463 FileDialog::Private::~Private()
464 {
465         r_.disconnect();
466 }
467
468
469 void FileDialog::Private::redraw()
470 {
471         if (pFileDlgForm->form && pFileDlgForm->form->visible)
472                 fl_redraw_form(pFileDlgForm->form);
473 }
474
475
476 // SetButton: sets file selector user button action
477 void FileDialog::Private::SetButton(int iIndex, string const & pszName,
478                            string const & pszPath)
479 {
480         FL_OBJECT * pObject;
481         string * pTemp;
482
483         if (iIndex == 0) {
484                 pObject = pFileDlgForm->User1;
485                 pTemp = &pszUserPath1;
486         } else if (iIndex == 1) {                       
487                 pObject = pFileDlgForm->User2;
488                 pTemp = &pszUserPath2;
489         } else return;
490
491         if (!pszName.empty()) {
492                 fl_set_object_label(pObject, idex(pszName.c_str()));
493                 fl_set_button_shortcut(pObject, scex(pszName.c_str()), 1);
494                 fl_show_object(pObject);
495                 *pTemp = pszPath;
496         } else {
497                 fl_hide_object(pObject);
498                 pTemp->erase();
499         }
500 }
501
502
503 // GetDirectory: gets last dialog directory
504 string const FileDialog::Private::GetDirectory() const
505 {
506         if (!pszDirectory.empty())
507                 return pszDirectory;
508         else
509                 return string(".");
510 }
511
512
513 // RunDialog: handle dialog during file selection
514 bool FileDialog::Private::RunDialog()
515 {
516         force_cancel = false;
517         force_ok = false;
518         
519         // event loop
520         while (true) {
521                 FL_OBJECT * pObject = fl_do_forms();
522
523                 if (pObject == pFileDlgForm->Ready) {
524                         if (HandleOK())
525                                 return true;
526                 } else if (pObject == pFileDlgForm->Cancel
527                            || force_cancel)
528                         return false;
529                 else if (force_ok)
530                         return true;
531         }
532 }
533
534
535 // XForms objects callback (static)
536 void FileDialog::Private::FileDlgCB(FL_OBJECT *, long lArgument)
537 {
538         if (!pCurrentDlg) return;
539
540         switch (lArgument) {
541
542         case 0: // get directory
543                 pCurrentDlg->SetDirectory(fl_get_input(pFileDlgForm->DirBox));
544                 pCurrentDlg->Reread();
545                 break;
546
547         case 1: // get mask
548                 pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
549                 pCurrentDlg->Reread();
550                 break;
551
552         case 2: // list
553                 pCurrentDlg->HandleListHit();
554                 break;  
555
556         case 10: // rescan
557                 pCurrentDlg->SetDirectory(fl_get_input(pFileDlgForm->DirBox));
558                 pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
559                 pCurrentDlg->Reread();
560                 break;
561
562         case 11: // home
563                 pCurrentDlg->SetDirectory(GetEnvPath("HOME"));
564                 pCurrentDlg->SetMask(fl_get_input(pFileDlgForm->PatBox));
565                 pCurrentDlg->Reread();
566                 break;
567
568         case 12: // user button 1
569                 pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath1);
570                 pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
571                                                   ->PatBox));
572                 pCurrentDlg->Reread();
573                 break;
574
575         case 13: // user button 2
576                 pCurrentDlg->SetDirectory(pCurrentDlg->pszUserPath2);
577                 pCurrentDlg->SetMask(fl_get_input(pFileDlgForm
578                                                   ->PatBox));
579                 pCurrentDlg->Reread();
580                 break;
581
582         }
583 }
584
585
586 // Handle callback from list
587 void FileDialog::Private::HandleListHit()
588 {
589         // set info line
590         int const iSelect = fl_get_browser(pFileDlgForm->List);
591         if (iSelect > iDepth)  {
592                 SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
593         } else {
594                 SetInfoLine(string());
595         }
596 }
597
598
599 // Callback for double click in list
600 void FileDialog::Private::DoubleClickCB(FL_OBJECT *, long)
601 {
602         if (pCurrentDlg->HandleDoubleClick())
603                 // Simulate click on OK button
604                 pCurrentDlg->Force(false);
605 }
606
607
608 // Handle double click from list
609 bool FileDialog::Private::HandleDoubleClick()
610 {
611         string pszTemp;
612
613         // set info line
614         bool isDir = true;
615         int const iSelect = fl_get_browser(pFileDlgForm->List);
616         if (iSelect > iDepth)  {
617                 pszTemp = direntries[iSelect - iDepth - 1].pszName;
618                 SetInfoLine(direntries[iSelect - iDepth - 1].pszLsEntry);
619                 if (!suffixIs(pszTemp, '/')) {
620                         isDir = false;
621                         fl_set_input(pFileDlgForm->Filename, pszTemp.c_str());
622                 }
623         } else if (iSelect != 0) {
624                 SetInfoLine(string());
625         } else
626                 return true;
627
628         // executes action
629         if (isDir) {
630                 string Temp;
631
632                 // builds new directory name
633                 if (iSelect > iDepth) {
634                         // Directory deeper down
635                         // First, get directory with trailing /
636                         Temp = fl_get_input(pFileDlgForm->DirBox);
637                         if (!suffixIs(Temp, '/'))
638                                 Temp += '/';
639                         Temp += pszTemp;
640                 } else {
641                         // Directory higher up
642                         Temp.erase();
643                         for (int i = 0; i < iSelect; ++i) {
644                                 string piece = fl_get_browser_line(pFileDlgForm->List, i+1);
645                                 // The '+2' is here to count the '@b' (JMarc)
646                                 Temp += piece.substr(i + 2);
647                         }
648                 }
649
650                 // assigns it
651                 SetDirectory(Temp);
652                 Reread();
653                 return false;
654         }
655         return true;
656 }
657
658
659 // Handle OK button call
660 bool FileDialog::Private::HandleOK()
661 {
662         // mask was changed
663         string pszTemp = fl_get_input(pFileDlgForm->PatBox);
664         if (pszTemp != pszMask) {
665                 SetMask(pszTemp);
666                 Reread();
667                 return false;
668         }
669
670         // directory was changed
671         pszTemp = fl_get_input(pFileDlgForm->DirBox);
672         if (pszTemp!= pszDirectory) {
673                 SetDirectory(pszTemp);
674                 Reread();
675                 return false;
676         }
677         
678         // Handle return from list
679         int const select = fl_get_browser(pFileDlgForm->List);
680         if (select > iDepth) {
681                 string const temp = direntries[select - iDepth - 1].pszName;
682                 if (!suffixIs(temp, '/')) {
683                         // If user didn't type anything, use browser
684                         string const name =
685                                 fl_get_input(pFileDlgForm->Filename);
686                         if (name.empty()) {
687                                 fl_set_input(pFileDlgForm->Filename, temp.c_str());
688                         }
689                         return true;
690                 }
691         }
692
693         // Emulate a doubleclick
694         return HandleDoubleClick();
695 }
696
697
698 // Handle Cancel CB from WM close
699 int FileDialog::Private::CancelCB(FL_FORM *, void *)
700 {
701         // Simulate a click on the cancel button
702         pCurrentDlg->Force(true);
703         return FL_IGNORE;
704 }
705
706
707 // Simulates a click on OK/Cancel
708 void FileDialog::Private::Force(bool cancel)
709 {
710         if (cancel) {
711                 force_cancel = true;
712                 fl_set_button(pFileDlgForm->Cancel, 1);
713         } else {
714                 force_ok = true;
715                 fl_set_button(pFileDlgForm->Ready, 1);
716         }
717         // Start timer to break fl_do_forms loop soon
718         fl_set_timer(pFileDlgForm->timer, 0.1);
719 }
720
721
722 // Select: launches dialog and returns selected file
723 string const FileDialog::Private::Select(string const & title,
724                                          string const & path,
725                                          string const & mask,
726                                          string const & suggested)
727 {
728         // handles new mask and path
729         bool isOk = true;
730         if (!mask.empty()) {
731                 SetMask(mask);
732                 isOk = false;
733         }
734         if (!path.empty()) {
735                 SetDirectory(path);
736                 isOk = false;
737         }
738         if (!isOk) Reread();
739
740         // highlight the suggested file in the browser, if it exists.
741         int sel = 0;
742         string const filename = OnlyFilename(suggested);
743         if (!filename.empty()) {
744                 for (int i = 0;
745                      i < fl_get_browser_maxline(pFileDlgForm->List); ++i) {
746                         string s =
747                                 fl_get_browser_line(pFileDlgForm->List, i + 1);
748                         s = strip(frontStrip(s));
749                         if (s == filename) {
750                                 sel = i + 1;
751                                 break;
752                         }
753                 }
754         }
755         
756         if (sel != 0) fl_select_browser_line(pFileDlgForm->List, sel);
757         int const top = max(sel - 5, 1);
758         fl_set_browser_topline(pFileDlgForm->List, top);
759
760         // checks whether dialog can be started
761         if (pCurrentDlg) return string();
762         pCurrentDlg = this;
763
764         // runs dialog
765         SetInfoLine(string());
766         fl_set_input(pFileDlgForm->Filename, suggested.c_str());
767         fl_set_button(pFileDlgForm->Cancel, 0);
768         fl_set_button(pFileDlgForm->Ready, 0);
769         fl_set_focus_object(pFileDlgForm->form, pFileDlgForm->Filename);
770         fl_deactivate_all_forms();
771         fl_show_form(pFileDlgForm->form,
772                      FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
773                      title.c_str());
774
775         isOk = RunDialog();
776         
777         fl_hide_form(pFileDlgForm->form);
778         fl_activate_all_forms();
779         pCurrentDlg = 0;
780
781         // Returns filename or string() if no valid selection was made
782         if (!isOk || !fl_get_input(pFileDlgForm->Filename)[0]) return string();
783
784         pszFileName = fl_get_input(pFileDlgForm->Filename);
785
786         if (!AbsolutePath(pszFileName)) {
787                 pszFileName = AddName(fl_get_input(pFileDlgForm->DirBox),
788                                       pszFileName);
789         }
790         return pszFileName;
791 }