home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2557 < prev    next >
Encoding:
Text File  |  1992-11-18  |  50.1 KB  |  1,898 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!sgiblab!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!pandonia!jan
  3. From: jan@pandonia.canberra.edu.au (Jan Newmarch)
  4. Subject: X11/Motif file manager - part 03 of 17
  5. Message-ID: <1992Nov19.052217.25569@csc.canberra.edu.au>
  6. Sender: news@csc.canberra.edu.au
  7. Organization: University of Canberra
  8. Date: Thu, 19 Nov 92 05:22:17 GMT
  9. Lines: 1887
  10.  
  11.  
  12.  
  13. #!/bin/sh
  14. # this is part.03 (part 3 of a multipart archive)
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file xmfm/DirMgr.c continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 3; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping xmfm/DirMgr.c'
  32. else
  33. echo 'x - continuing file xmfm/DirMgr.c'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'xmfm/DirMgr.c' &&
  35. X
  36. X                     F I L T E R    R O U T I N E S
  37. X
  38. X *---------------------------------------------------------------------------*/
  39. X
  40. int DirectoryMgrFilterName
  41. #ifdef UseFunctionPrototypes
  42. X    (DirEntry *de, char *fsm)
  43. #else
  44. X    (de,fsm)
  45. DirEntry *de;
  46. char *fsm;
  47. X
  48. #endif
  49. {
  50. #ifndef    NO_REGEXP
  51. X    return(RegExpMatch(DirEntryFileName(de),fsm));
  52. #else
  53. X    return(TRUE);
  54. #endif
  55. } /* End DirectoryMgrFilterName */
  56. SHAR_EOF
  57. echo 'File xmfm/DirMgr.c is complete' &&
  58. chmod 0644 xmfm/DirMgr.c ||
  59. echo 'restore of xmfm/DirMgr.c failed'
  60. Wc_c="`wc -c < 'xmfm/DirMgr.c'`"
  61. test 12374 -eq "$Wc_c" ||
  62.     echo 'xmfm/DirMgr.c: original size 12374, current size' "$Wc_c"
  63. rm -f _shar_wnt_.tmp
  64. fi
  65. # ============= xmfm/Directory.c ==============
  66. if test -f 'xmfm/Directory.c' -a X"$1" != X"-c"; then
  67.     echo 'x - skipping xmfm/Directory.c (File already exists)'
  68.     rm -f _shar_wnt_.tmp
  69. else
  70. > _shar_wnt_.tmp
  71. echo 'x - extracting xmfm/Directory.c (Text)'
  72. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/Directory.c' &&
  73. /****************************************************************************
  74. X
  75. X        Directory.c
  76. X
  77. X    This file contains the C code that implements the directory
  78. X    iteration and file information subsystem.
  79. X
  80. X    This code is intended to be used as a convenient, machine
  81. X    independent interface to iterate through the contents of a
  82. X    directory.
  83. X
  84. X ****************************************************************************/
  85. X
  86. #include "Directory.h"
  87. #include "RegExp.h"
  88. X
  89. /*--------------------------------------------------------------------------*
  90. X
  91. X        L O W    L E V E L    D I R E C T O R Y    I N T E R F A C E
  92. X
  93. X *--------------------------------------------------------------------------*/
  94. X
  95. int DirectoryOpen
  96. #ifdef UseFunctionPrototypes
  97. X    (char *dir_name, Directory *dp)
  98. #else
  99. X    (dir_name,dp)
  100. char *dir_name;
  101. Directory *dp;
  102. X
  103. #endif
  104. {
  105. X    DirectoryDir(dp) = opendir(dir_name);
  106. X    if (DirectoryDir(dp) == NULL) return(FALSE);
  107. X    if (DirectoryPathExpand(dir_name,DirectoryPath(dp)) == NULL)
  108. X    {
  109. X        closedir(DirectoryDir(dp));
  110. X        return(FALSE);
  111. X    }
  112. X    return(TRUE);
  113. } /* End DirectoryOpen */
  114. X
  115. X
  116. void DirectoryRestart
  117. #ifdef UseFunctionPrototypes
  118. X    (Directory *dp)
  119. #else
  120. X    (dp)
  121. Directory *dp;
  122. X
  123. #endif
  124. {
  125. X    rewinddir(DirectoryDir(dp));
  126. } /* End DirectoryRestart */
  127. X
  128. X
  129. void DirectoryClose
  130. #ifdef UseFunctionPrototypes
  131. X    (Directory *dp)
  132. #else
  133. X    (dp)
  134. Directory *dp;
  135. X
  136. #endif
  137. {
  138. X    closedir(DirectoryDir(dp));
  139. } /* End DirectoryClose */
  140. X
  141. X
  142. long DirectoryTellPosition
  143. #ifdef UseFunctionPrototypes
  144. X    (Directory *dp)
  145. #else
  146. X    (dp)
  147. Directory *dp;
  148. X
  149. #endif
  150. {
  151. X    return(telldir(DirectoryDir(dp)));
  152. } /* End DirectoryTellPosition */
  153. X
  154. X
  155. void DirectorySetPosition
  156. #ifdef UseFunctionPrototypes
  157. X    (Directory *dp, long int pos)
  158. #else
  159. X    (dp,pos)
  160. Directory *dp;
  161. long pos;
  162. X
  163. #endif
  164. {
  165. X    seekdir(dp,pos);
  166. } /* End DirectorySetPosition */
  167. X
  168. X
  169. int DirectoryReadNextEntry
  170. #ifdef UseFunctionPrototypes
  171. X    (Directory *dp, DirEntry *de)
  172. #else
  173. X    (dp,de)
  174. Directory *dp;
  175. DirEntry *de;
  176. X
  177. #endif
  178. {
  179. X    u_short orig_file_type;
  180. X    static struct dirent *_ep;
  181. X    static struct stat _lstats,_stats,_dstats;
  182. X    char full_path[MAXPATHLEN + 2];
  183. X    char temp_path[MAXPATHLEN + 2];
  184. X
  185. X    _ep = readdir(DirectoryDir(dp));
  186. X    if (_ep == NULL) return(FALSE);
  187. X    strcpy(DirEntryFileName(de),_ep->d_name);
  188. X    strcpy(full_path,DirectoryPath(dp));
  189. X    strcat(full_path,DirEntryFileName(de));
  190. X
  191. X    if (lstat(full_path,&_lstats) != 0) return(FALSE);
  192. X
  193. X    orig_file_type = _lstats.st_mode & S_IFMT;
  194. X    switch (orig_file_type)
  195. X    {
  196. X        case S_IFDIR:
  197. X        DirEntryType(de) = F_TYPE_DIR;
  198. X        break;
  199. X        case S_IFREG:
  200. X        DirEntryType(de) = F_TYPE_FILE;
  201. X        break;
  202. X        case S_IFCHR:
  203. X        DirEntryType(de) = F_TYPE_CHAR_SPECIAL;
  204. X        break;
  205. X        case S_IFBLK:
  206. X        DirEntryType(de) = F_TYPE_BLOCK_SPECIAL;
  207. X        break;
  208. X        case S_IFLNK:
  209. X        DirEntryType(de) = F_TYPE_SYM_LINK;
  210. X        break;
  211. X        case S_IFSOCK:
  212. X        DirEntryType(de) = F_TYPE_SOCKET;
  213. X        break;
  214. #ifdef S_IFIFO
  215. X        case S_IFIFO:
  216. X        DirEntryType(de) = F_TYPE_FIFO;
  217. X        break;
  218. #endif
  219. X        default:
  220. X        DirEntryType(de) = orig_file_type;
  221. X        break;
  222. X    }
  223. X
  224. X    DirEntryIsBrokenLink(de) = FALSE;
  225. X    DirEntryIsDirectoryLink(de) = FALSE;
  226. X    if (DirEntryIsSymLink(de))            /* Symbolic Link */
  227. X    {
  228. X        if (stat(full_path,&_stats) != 0)    /* Can't Stat File */
  229. X        {
  230. X            DirEntryIsBrokenLink(de) = TRUE;
  231. X            _stats = _lstats;
  232. X        }
  233. X            else                /* Link Not Broken */
  234. X        {
  235. #ifdef SLOW_DIRLINK_TEST
  236. X            if (DirectoryPathExpand(full_path,temp_path) != NULL)
  237. X            {
  238. #else
  239. X            if ((_stats.st_mode & S_IFMT) == S_IFDIR)
  240. X            {
  241. #endif
  242. X                DirEntryIsDirectoryLink(de) = TRUE;
  243. X            }
  244. X
  245. X        }
  246. X    }
  247. X        else                    /* Not Symbolic Link */
  248. X    {
  249. X        _stats = _lstats;
  250. X    }
  251. X
  252. X    FileInfoOrigMode(DirEntrySelfInfo(de)) = _lstats.st_mode;
  253. X    FileInfoProt(DirEntrySelfInfo(de)) = _lstats.st_mode & 0777;
  254. X    FileInfoUserID(DirEntrySelfInfo(de)) = _lstats.st_uid;
  255. X    FileInfoGroupID(DirEntrySelfInfo(de)) = _lstats.st_gid;
  256. X    FileInfoFileSize(DirEntrySelfInfo(de)) = _lstats.st_size;
  257. X    FileInfoLastAccess(DirEntrySelfInfo(de)) = _lstats.st_atime;
  258. X    FileInfoLastModify(DirEntrySelfInfo(de)) = _lstats.st_mtime;
  259. X    FileInfoLastStatusChange(DirEntrySelfInfo(de)) = _lstats.st_ctime;
  260. X
  261. X    FileInfoOrigMode(DirEntryActualInfo(de)) = _stats.st_mode;
  262. X    FileInfoProt(DirEntryActualInfo(de)) = _stats.st_mode & 0777;
  263. X    FileInfoUserID(DirEntryActualInfo(de)) = _stats.st_uid;
  264. X    FileInfoGroupID(DirEntryActualInfo(de)) = _stats.st_gid;
  265. X    FileInfoFileSize(DirEntryActualInfo(de)) = _stats.st_size;
  266. X    FileInfoLastAccess(DirEntryActualInfo(de)) = _stats.st_atime;
  267. X    FileInfoLastModify(DirEntryActualInfo(de)) = _stats.st_mtime;
  268. X    FileInfoLastStatusChange(DirEntryActualInfo(de)) = _stats.st_ctime;
  269. X
  270. X    return(TRUE);
  271. } /* End DirectoryReadNextEntry */
  272. X
  273. X
  274. char *DirectoryPathExpand
  275. #ifdef UseFunctionPrototypes
  276. X    (char *old_path, char *new_path)
  277. #else
  278. X    (old_path,new_path)
  279. char *old_path,*new_path;
  280. X
  281. #endif
  282. {
  283. X    register char *p;
  284. X    char path[MAXPATHLEN + 2];
  285. X
  286. X    if (getwd(path) == NULL) return(NULL);
  287. X    if (chdir(old_path) != 0) return(NULL);
  288. X    if (getwd(new_path) == NULL) strcpy(new_path,old_path);
  289. X    if (chdir(path) != 0) return(NULL);
  290. X    for (p = new_path; *p != '\0'; p++);
  291. X    if ((p != new_path) && *(p - 1) != '/')
  292. X    {
  293. X        *p++ = '/';
  294. X        *p = '\0';
  295. X    }
  296. X    return(new_path);
  297. } /* End DirectoryPathExpand */
  298. X
  299. X
  300. /*---------------------------------------------------------------------------*
  301. X
  302. X             D I R E C T O R Y    E N T R Y    R O U T I N E S
  303. X
  304. X *---------------------------------------------------------------------------*/
  305. X
  306. void DirEntryDump
  307. #ifdef UseFunctionPrototypes
  308. X    (FILE *fp, DirEntry *de)
  309. #else
  310. X    (fp,de)
  311. FILE *fp;
  312. DirEntry *de;
  313. X
  314. #endif
  315. {
  316. X    fprintf(fp,"%20s, Size %7d, Prot %3o\n",
  317. X        DirEntryFileName(de),DirEntryFileSize(de),DirEntryProt(de));
  318. } /* End DirEntryDump */
  319. SHAR_EOF
  320. chmod 0644 xmfm/Directory.c ||
  321. echo 'restore of xmfm/Directory.c failed'
  322. Wc_c="`wc -c < 'xmfm/Directory.c'`"
  323. test 5543 -eq "$Wc_c" ||
  324.     echo 'xmfm/Directory.c: original size 5543, current size' "$Wc_c"
  325. rm -f _shar_wnt_.tmp
  326. fi
  327. # ============= xmfm/RegExp.c ==============
  328. if test -f 'xmfm/RegExp.c' -a X"$1" != X"-c"; then
  329.     echo 'x - skipping xmfm/RegExp.c (File already exists)'
  330.     rm -f _shar_wnt_.tmp
  331. else
  332. > _shar_wnt_.tmp
  333. echo 'x - extracting xmfm/RegExp.c (Text)'
  334. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/RegExp.c' &&
  335. /****************************************************************************
  336. X
  337. X    RegExp.c
  338. X
  339. X    This file contains the C code for the regular expression
  340. X    matching code.
  341. X
  342. X    The routines supported act as a more friendly, user level
  343. X    interface to the regexp regular expression matching system.
  344. X
  345. X ****************************************************************************/
  346. X
  347. #include "RegExp.h"
  348. #ifndef NO_REGEXP
  349. #include <regexp.h>
  350. #endif
  351. X
  352. void RegExpCompile
  353. #ifdef UseFunctionPrototypes
  354. X    (char *regexp, char *fsm_ptr, int fsm_length)
  355. #else
  356. X    (regexp,fsm_ptr,fsm_length)
  357. char *regexp,*fsm_ptr;
  358. int fsm_length;
  359. X
  360. #endif
  361. {
  362. #ifndef NO_REGEXP
  363. X    compile(regexp,fsm_ptr,&(fsm_ptr[fsm_length]),'\0');
  364. #endif
  365. } /* End RegExpCompile */
  366. X
  367. X
  368. int RegExpMatch
  369. #ifdef UseFunctionPrototypes
  370. X    (char *string, char *fsm_ptr)
  371. #else
  372. X    (string,fsm_ptr)
  373. char *string,*fsm_ptr;
  374. X
  375. #endif
  376. {
  377. #ifndef NO_REGEXP
  378. X    if (advance(string,fsm_ptr) != 0)
  379. X        return(TRUE);
  380. X        else
  381. X        return(FALSE);
  382. #else
  383. X    return(TRUE);
  384. #endif
  385. } /* End RegExpMatch */
  386. X
  387. X
  388. void _RegExpError
  389. #ifdef UseFunctionPrototypes
  390. X    (int val)
  391. #else
  392. X    (val)
  393. int val;
  394. X
  395. #endif
  396. {
  397. X    fprintf(stderr,"Regular Expression Error %d\n",val);
  398. X    exit(-1);
  399. } /* End _RegExpError */
  400. X
  401. X
  402. void RegExpPatternToRegExp
  403. #ifdef UseFunctionPrototypes
  404. X    (char *pattern, char *reg_exp)
  405. #else
  406. X    (pattern,reg_exp)
  407. char *pattern,*reg_exp;
  408. X
  409. #endif
  410. {
  411. X    int in_bracket;
  412. X
  413. X    in_bracket = 0;
  414. X    while (*pattern != '\0')
  415. X    {
  416. X        if (in_bracket)
  417. X        {
  418. X            if (*pattern == ']') in_bracket = 0;
  419. X            *reg_exp++ = *pattern++;
  420. X        }
  421. X            else
  422. X        {
  423. X            switch (*pattern)
  424. X            {
  425. X                case '[':
  426. X                in_bracket = 1;
  427. X                *reg_exp++ = '[';
  428. X                break;
  429. X                case '?':
  430. X                *reg_exp++ = '.';
  431. X                break;
  432. X                case '*':
  433. X                *reg_exp++ = '.';
  434. X                *reg_exp++ = '*';
  435. X                break;
  436. X                case '.':
  437. X                *reg_exp++ = '\\';
  438. X                *reg_exp++ = '.';
  439. X                break;
  440. X                default:
  441. X                *reg_exp++ = *pattern;
  442. X                break;
  443. X            }
  444. X            ++ pattern;
  445. X        }
  446. X    }
  447. X    *reg_exp++ = '$';
  448. X    *reg_exp++ = '\0';
  449. } /* End RegExpPatternToRegExp */
  450. SHAR_EOF
  451. chmod 0644 xmfm/RegExp.c ||
  452. echo 'restore of xmfm/RegExp.c failed'
  453. Wc_c="`wc -c < 'xmfm/RegExp.c'`"
  454. test 1948 -eq "$Wc_c" ||
  455.     echo 'xmfm/RegExp.c: original size 1948, current size' "$Wc_c"
  456. rm -f _shar_wnt_.tmp
  457. fi
  458. # ============= xmfm/applicat.c ==============
  459. if test -f 'xmfm/applicat.c' -a X"$1" != X"-c"; then
  460.     echo 'x - skipping xmfm/applicat.c (File already exists)'
  461.     rm -f _shar_wnt_.tmp
  462. else
  463. > _shar_wnt_.tmp
  464. echo 'x - extracting xmfm/applicat.c (Text)'
  465. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/applicat.c' &&
  466. /*************************************************************************
  467. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/applicat.c,v $
  468. X * Author: Jan Newmarch
  469. X * Last modified: $Date: 1992/11/17 00:35:34 $
  470. X * Version: $Revision: 1.10 $
  471. X * Purpose: Create the application windows and set up callbacks
  472. X *
  473. X * Revision history:
  474. X *    4 Aug 92    added filter stuff to ResetFilesInPanes
  475. X *    4 Aug 92    added R5 hooks to allow editres to look at this applic
  476. X *    5 Aug 92    put Toolbars in scrolled windows, 
  477. X *            to stop clipping on resize
  478. X *    5 Aug 92    set dir label above panes only, instead of across form
  479. X *    6 Aug 92    removed scrolled windows from Toolbars,
  480. X *            reset dir label as before. let left edge of
  481. X *            toolbars be free
  482. X *    16 Oct 92    caddr_t changed to XtPointer
  483. X *       3 Nov 92       lint-ed
  484. X *    11 Nov 92    follow symbolic links to show dirs as dirs, not files.
  485. X *            Moved Rogers drag 'n drop to drag.c
  486. X ************************************************************************/ 
  487. X
  488. #include "copyright.h"
  489. X
  490. /*************************************************************************
  491. X * System includes
  492. X ************************************************************************/ 
  493. #include <sys/types.h>
  494. #include <sys/stat.h>
  495. X
  496. /*************************************************************************
  497. X * Local includes
  498. X ************************************************************************/ 
  499. #include "xmvararg.h"
  500. #include "DirMgr.h"
  501. #include "const.h"
  502. #include "types.h"
  503. X
  504. #ifdef RDD
  505. #include "rdd.h"
  506. #endif /* RDD */
  507. X
  508. /*************************************************************************
  509. X * Functions exported
  510. X ************************************************************************/ 
  511. extern Widget CreateApplication (
  512. #ifdef UseFunctionPrototypes
  513. X    Widget parent
  514. #endif
  515. );
  516. extern void ResetFilesInPanes (
  517. #ifdef UseFunctionPrototypes
  518. X    dir_pane_info *dpi
  519. #endif
  520. );
  521. extern void ClearToolbar (
  522. #ifdef UseFunctionPrototypes
  523. X    Widget *toolbar
  524. #endif
  525. );
  526. X
  527. /*************************************************************************
  528. X * Variables exported
  529. X ************************************************************************/ 
  530. X
  531. /*************************************************************************
  532. X * Extern functions
  533. X ************************************************************************/ 
  534. extern Widget CreateMenu (
  535. #ifdef UseFunctionPrototypes
  536. X    Widget parent, XtPointer user_data
  537. #endif
  538. );
  539. extern void FileButtonPressedCB (
  540. #ifdef UseFunctionPrototypes
  541. X    Widget w, XtPointer client_data, XtPointer call_data
  542. #endif
  543. );
  544. extern void FileButtonReleasedCB (
  545. #ifdef UseFunctionPrototypes
  546. X    Widget w, XtPointer client_data, XtPointer call_data
  547. #endif
  548. );
  549. extern void FileToolButtonPressedCB (
  550. #ifdef UseFunctionPrototypes
  551. X    Widget w, XtPointer client_data, XtPointer call_data
  552. #endif
  553. );
  554. X
  555. #ifdef ALLOW_EDITRES
  556. extern void _XEditResCheckMessages ();
  557. #endif /* ALLOW_EDITRES */
  558. X
  559. #ifdef MOTIF_DD
  560. extern  void MotifDDRegisterToolbar (
  561. #ifdef UseFunctionPrototypes
  562. X    Widget button
  563. #endif
  564. );
  565. #endif /* MOTIF_DD */
  566. X
  567. #ifdef RDD
  568. extern void DirDrop (
  569. #ifdef UseFunctionPrototypes
  570. X    Widget w, XtPointer call, XtPointer client_data
  571. #endif
  572. );
  573. extern void ExecutableDrop (
  574. #ifdef UseFunctionPrototypes
  575. X    Widget w, XtPointer call, XtPointer client_data
  576. #endif
  577. );
  578. extern void MainWindowDrop (
  579. #ifdef UseFunctionPrototypes
  580. X    Widget w, XtPointer call, XtPointer client_data
  581. #endif
  582. );
  583. extern void ToolbarDrop (
  584. #ifdef UseFunctionPrototypes
  585. X    Widget w, XtPointer call, XtPointer client_data
  586. #endif
  587. );
  588. #endif /* RDD */
  589. X
  590. /*************************************************************************
  591. X * Extern variables
  592. X ************************************************************************/ 
  593. extern GC gc;
  594. extern GC gc_reversed;
  595. extern file_action *actions;
  596. X
  597. #ifdef RDD
  598. extern XtTranslations trans_table;
  599. #endif /* RDD */
  600. X
  601. #ifdef MOTIF_DD
  602. extern XtTranslations trans_table;
  603. #endif /* MOTIF_DD */
  604. X
  605. /*************************************************************************
  606. X * Forward functions
  607. X ************************************************************************/ 
  608. Widget CreateApplication (
  609. #ifdef UseFunctionPrototypes
  610. X    Widget parent
  611. #endif
  612. );    /*  create main window        */ 
  613. DirectoryMgr *GetFilesInDir (
  614. #ifdef UseFunctionPrototypes
  615. X    void
  616. #endif
  617. );
  618. X
  619. X
  620. /*************************************************************************
  621. X * Local variables
  622. X ************************************************************************/ 
  623. XXmString empty_string;
  624. X
  625. X
  626. /* #define SIZE_KLUDGE */
  627. X
  628. X
  629. /*************************************************************************
  630. X * Function: SetGeometry ()
  631. X * Purpose: set the geometry of components in the form
  632. X * In parameters: directory_label, files_toolbar, dirs_toobar, pane
  633. X * Function result:
  634. X * Precondition: all args are non-null children of a form
  635. X * Postcondition: all args are set in the following geometry
  636. X *        --------------------------
  637. X *             |               dir label  |
  638. X *             |--------------------------|
  639. X *             | files       |            |
  640. X *             | toolbar     |  pane      |
  641. X *             |-------------|            |
  642. X *             | dirs        |            |
  643. X *             | toolbar     |            |
  644. X *              --------------------------
  645. X ************************************************************************/ 
  646. static void
  647. SetGeometry 
  648. #ifdef UseFunctionPrototypes
  649. X    (Widget directory_label, Widget files_toolbar, Widget dirs_toolbar, Widget pane)
  650. #else
  651. X    (directory_label, files_toolbar, dirs_toolbar, pane)
  652. X    Widget directory_label;
  653. X    Widget files_toolbar;
  654. X    Widget dirs_toolbar;
  655. X    Widget pane;
  656. X
  657. #endif
  658. {
  659. X    XtVaSetValues (directory_label,
  660. X            XmNtopAttachment,    (XtArgVal) XmATTACH_FORM,
  661. X            XmNleftAttachment,    (XtArgVal) XmATTACH_FORM,
  662. X            XmNrightAttachment,    (XtArgVal) XmATTACH_FORM,
  663. X            NULL);
  664. X
  665. X    XtVaSetValues (files_toolbar,
  666. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  667. X            XmNtopWidget,        (XtArgVal) directory_label,
  668. X            XmNleftAttachment,    (XtArgVal) XmATTACH_FORM,
  669. X            XmNbottomAttachment,    (XtArgVal) XmATTACH_POSITION,
  670. X            XmNbottomPosition,    (XtArgVal) 45,
  671. X            NULL);
  672. X
  673. X    XtVaSetValues (dirs_toolbar,
  674. X            XmNtopAttachment,    (XtArgVal) XmATTACH_POSITION,
  675. X            XmNtopPosition,        (XtArgVal) 50,
  676. X            XmNleftAttachment,    (XtArgVal) XmATTACH_FORM,
  677. X                        XmNbottomAttachment,    (XtArgVal) XmATTACH_FORM,
  678. X            NULL);
  679. X
  680. X    XtVaSetValues (pane,
  681. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  682. X            XmNtopWidget,        (XtArgVal) directory_label,
  683. X            XmNleftAttachment,    (XtArgVal) XmATTACH_WIDGET,
  684. X            XmNleftWidget,        (XtArgVal) files_toolbar,
  685. X            XmNrightAttachment,    (XtArgVal) XmATTACH_FORM,
  686. X            XmNbottomAttachment,    (XtArgVal) XmATTACH_FORM,
  687. X            NULL);
  688. }
  689. X
  690. /*************************************************************************
  691. X * Function: CreateFilesToolbar ()
  692. X * Purpose: create the files toolbar and populate it with toolbar buttons
  693. X * In parameters: form, dpi
  694. X * Function result: files toolbar widget
  695. X * Precondition: form is non-null
  696. X * Postcondition: toolbar + buttons created, each button has dpi in user data
  697. X ************************************************************************/ 
  698. static Widget
  699. CreateFilesToolbar 
  700. #ifdef UseFunctionPrototypes
  701. X    (Widget form, dir_pane_info *dpi)
  702. #else
  703. X    (form, dpi)
  704. X    Widget form;
  705. X    dir_pane_info *dpi;
  706. X
  707. #endif
  708. {
  709. X    Widget    button,
  710. X        files_toolbar,
  711. X        *files_toolbar_buttons;
  712. X    int     i;
  713. X    tool_button_info *tbi;
  714. X        
  715. X    files_toolbar_buttons = (Widget *) XtMalloc (sizeof (Widget) *
  716. X                        FILES_TOOLBAR_SIZE);
  717. X    dpi -> files_toolbar = files_toolbar_buttons;
  718. X
  719. X    files_toolbar = XmVaCreateRowColumn (form, "files_toolbar",
  720. X            XmNpacking,        (XtArgVal) XmPACK_COLUMN,
  721. X            XmNorientation,        (XtArgVal) XmHORIZONTAL,
  722. #ifdef SIZE_KLUDGE
  723. X            /* set to 4 when we only show 3 is because of
  724. X               dummy widget in 4th row */
  725. X            XmNnumColumns,         (XtArgVal) 4,
  726. #else
  727. X                        XmNnumColumns,          (XtArgVal) 3,
  728. #endif /*SIZE_KLUDGE*/
  729. X            XmNadjustLast,        (XtArgVal) False,
  730. X            NULL);
  731. X    XtManageChild (files_toolbar);
  732. X
  733. X    for (i = 0; i < FILES_TOOLBAR_SIZE; i++)
  734. X    {
  735. X        tbi = (tool_button_info *) XtMalloc (sizeof (tool_button_info));
  736. X        tbi -> dpi = dpi;
  737. X
  738. X        button =
  739. X        files_toolbar_buttons[i] =
  740. X            XmVaCreatePushButton (files_toolbar, "file_button",
  741. X                XmNlabelString, (XtArgVal) empty_string,
  742. X                XmNuserData, (XtArgVal) tbi,
  743. X                NULL);
  744. X        XtAddCallback (button,
  745. X            XmNactivateCallback, FileToolButtonPressedCB,
  746. X            NULL);
  747. X        XtManageChild (button);
  748. X        XtSetSensitive (button, False);
  749. X
  750. #ifdef RDD
  751. X        rddAddDropHandler (button,
  752. X                ToolbarDrop, NULL);
  753. #endif /* RDD */
  754. X
  755. #ifdef MOTIF_DD
  756. X                MotifDDRegisterToolbar (button);
  757. #endif /* MOTIF_DD */
  758. X    }
  759. X
  760. #ifdef SIZE_KLUDGE
  761. X    {    /* kludge to force the row column to give
  762. X           us the size buttons we want.  It doesn't
  763. X           tamper with the size of DrawButtons
  764. X        */
  765. X
  766. X         Widget dummy;
  767. X        dummy = XmVaCreateDrawnButton (files_toolbar, "dummy",
  768. X                XmNmappedWhenManaged, (XtArgVal) False,
  769. X                NULL);
  770. X        XtManageChild (dummy);
  771. X    }
  772. #endif /*SIZE_KLUDGE */
  773. X
  774. X    return files_toolbar;
  775. }
  776. X
  777. /*************************************************************************
  778. X * Function: ClearToolbar ()
  779. X * Purpose: empty out the files toolbar of any actions
  780. X * In parameters: toolbar
  781. X * Function result: 
  782. X * Precondition: 
  783. X * Postcondition: all toolbar buttons show empty string
  784. X ************************************************************************/ 
  785. void
  786. ClearToolbar 
  787. #ifdef UseFunctionPrototypes
  788. X    (Widget *toolbar)
  789. #else
  790. X    (toolbar)
  791. X    Widget *toolbar;
  792. X
  793. #endif
  794. {
  795. X    int i;
  796. X    
  797. X    for (i = 0; i < FILES_TOOLBAR_SIZE; i++)
  798. X    {
  799. X        if ( !XtIsSensitive (*toolbar))
  800. X            return;    
  801. X        XtVaSetValues (*toolbar,
  802. X                XmNlabelString, empty_string,
  803. X                NULL);
  804. X        XtSetSensitive (*toolbar, False);
  805. X        toolbar++;
  806. X    }
  807. }
  808. X
  809. /*************************************************************************
  810. X * Function: CreateDirsToolbar ()
  811. X * Purpose: create the dirs toolbar and populate it with toolbar buttons
  812. X * In parameters: form, dpi
  813. X * Function result: dirs toolbar widget
  814. X * Precondition: form is non-null
  815. X * Postcondition: toolbar + buttons created, each button has dpi in user data
  816. X ************************************************************************/ 
  817. static Widget
  818. CreateDirsToolbar 
  819. #ifdef UseFunctionPrototypes
  820. X    (Widget form, dir_pane_info *dpi)
  821. #else
  822. X    (form, dpi)
  823. X    Widget form;
  824. X    dir_pane_info *dpi;
  825. X
  826. #endif
  827. {
  828. X    Widget    button,
  829. X        dirs_toolbar,
  830. X        *dirs_toolbar_buttons;
  831. X    int    i;
  832. X    tool_button_info *tbi;
  833. X
  834. X    dirs_toolbar_buttons = (Widget *) XtMalloc (sizeof (Widget) *
  835. X                        DIRS_TOOLBAR_SIZE);
  836. X    dpi -> dirs_toolbar = dirs_toolbar_buttons;
  837. X
  838. X    dirs_toolbar = XmVaCreateRowColumn (form, "dirs_toolbar",
  839. X            XmNpacking,        (XtArgVal) XmPACK_COLUMN,
  840. X            XmNorientation,        (XtArgVal) XmHORIZONTAL,
  841. #ifdef SIZE_KLUDGE
  842. X            /* set to 4 when we only show 3 is because of
  843. X               dummy widget in 4th row */
  844. X            XmNnumColumns,         (XtArgVal) 4,
  845. #else
  846. X                        XmNnumColumns,          (XtArgVal) 3,
  847. #endif /*SIZE_KLUDGE*/
  848. X                        XmNadjustLast,           (XtArgVal) False,
  849. X            NULL);
  850. X    XtManageChild (dirs_toolbar);
  851. X
  852. X    for (i = 0; i < DIRS_TOOLBAR_SIZE; i++)
  853. X    {    tbi = (tool_button_info *) XtMalloc (sizeof (tool_button_info));
  854. X        tbi -> dpi = dpi;
  855. X
  856. X        button =
  857. X        dirs_toolbar_buttons[i] =
  858. X            XmVaCreatePushButton (dirs_toolbar, "dir_button",
  859. X                XmNlabelString, (XtArgVal) empty_string,
  860. X                XmNuserData, (XtArgVal) tbi,
  861. X                NULL);
  862. X        XtAddCallback (button,
  863. X            XmNactivateCallback, FileToolButtonPressedCB,
  864. X            NULL);
  865. X        XtManageChild (button);
  866. X        XtSetSensitive (button, False);
  867. X
  868. #ifdef RDD
  869. X        rddAddDropHandler (button,
  870. X                ToolbarDrop, NULL);
  871. #endif /* RDD */
  872. X
  873. #ifdef MOTIF_DD
  874. X                MotifDDRegisterToolbar (button);
  875. #endif /* MOTIF_DD */
  876. X    }
  877. X
  878. #ifdef SIZE_KLUDGE
  879. X    {    /* kludge to force the row column to give
  880. X           us the size buttons we want.  It doesn't
  881. X           tamper with the size of DrawButtons
  882. X        */
  883. X         Widget dummy;
  884. X        dummy = XmVaCreateDrawnButton (dirs_toolbar, "dummy",
  885. X                XmNmappedWhenManaged, (XtArgVal) False,
  886. X                NULL);
  887. X        XtManageChild (dummy);
  888. X    }
  889. #endif /*SIZE_KLUDGE*/
  890. X
  891. X    return dirs_toolbar;
  892. }
  893. X
  894. #ifdef ALLOW_ROWCOL_RESIZE
  895. /*************************************************************************
  896. X * Function: ScrolledWindowResized ()
  897. X * Purpose: the scrolled window containing files has changed in size.
  898. X *    Need to rearrange widgets in it.
  899. X * In parameters: w, event, args, num_args
  900. X * Function result: 
  901. X * Precondition: 
  902. X * Postcondition: number of columns is maximum for new width
  903. X ************************************************************************/
  904. X
  905. /* ARGSUSED */ 
  906. static void
  907. ScrolledWindowResized 
  908. #ifdef UseFunctionPrototypes
  909. X    (Widget w, XEvent *event, char **args, Cardinal *num_args)
  910. #else
  911. X    (w, event, args, num_args)
  912. X    Widget w;
  913. X    XEvent *event;
  914. X    char **args;
  915. X    Cardinal *num_args;
  916. X
  917. #endif
  918. {       Dimension pane_width, button_width;
  919. X        int num_columns;
  920. X        Widget button;
  921. X        dir_pane_info *dpi;
  922. X
  923. #ifdef DEBUG
  924. X    fprintf (stderr, "resize on scrolled widget to width %d height %d\n",
  925. X            (XConfigureEvent *) event -> width,
  926. X            (XConfgureEvent *) event -> height);
  927. #endif
  928. X
  929. X        XtVaGetValues (w,
  930. X                        XmNuserData, &dpi,
  931. X                        XmNwidth, &pane_width,
  932. X                        NULL);
  933. X
  934. X        /* find a non-null button, or give up */
  935. X        if (dpi -> files_buttons != NULL)
  936. X                button = dpi -> files_buttons -> widget;
  937. X        else if (dpi -> dirs_buttons != NULL)
  938. X                button = dpi -> dirs_buttons -> widget;
  939. X
  940. X        else if (dpi -> executables_buttons != NULL)
  941. X                button = dpi -> executables_buttons -> widget;
  942. X
  943. X        else return;
  944. X
  945. X        XtVaGetValues (button, XmNwidth, &button_width, NULL);
  946. X
  947. X        num_columns = (int) (pane_width / button_width);
  948. X
  949. #ifdef DEBUG
  950. X        fprintf (stderr, "number of columns in panes set to %d\n",
  951. X                        num_columns);
  952. #endif /* DEBUG */
  953. X
  954. X        /* set the numColumns in each pane */
  955. X        XtVaSetValues (dpi -> executables_pane,
  956. X                        XmNnumColumns, (XtArgVal) num_columns,
  957. X                        XmNpacking, (XtArgVal) XmPACK_COLUMN,
  958. X                        NULL);
  959. X        XtVaSetValues (dpi -> files_pane,
  960. X                        XmNnumColumns, (XtArgVal) num_columns,
  961. X                        XmNpacking, (XtArgVal) XmPACK_COLUMN,
  962. X                       NULL);
  963. X        XtVaSetValues (dpi -> dirs_pane,
  964. X                        XmNnumColumns, (XtArgVal) num_columns,
  965. X                        XmNpacking, (XtArgVal) XmPACK_COLUMN,
  966. X                        NULL);
  967. }
  968. #endif /* ALLOW_ROWCOL_RESIZE */
  969. X
  970. /*************************************************************************
  971. X * Function: CreatePane ()
  972. X * Purpose: create files, directories display area
  973. X * In parameters: form, dpi
  974. X * Function result: pane widget
  975. X * Side effects; fields in dpi point to 3 pane children
  976. X * Precondition: form is non-null
  977. X * Postcondition: pane created with children in this geometric relation
  978. X *                --------------
  979. X *               | executables  |
  980. X *               | pane         |
  981. X *                --------------
  982. X *               | files pane   |
  983. X *                --------------
  984. X *               | dirs pane    |
  985. X *                --------------
  986. X ************************************************************************/ 
  987. static Widget
  988. CreatePane 
  989. #ifdef UseFunctionPrototypes
  990. X    (Widget form, dir_pane_info *dpi)
  991. #else
  992. X    (form, dpi)
  993. X    Widget form;
  994. X    dir_pane_info *dpi;
  995. X
  996. #endif
  997. {
  998. X    Widget    pane,
  999. X        dirs_pane,
  1000. X        files_pane,
  1001. X        executables_pane,
  1002. X        rc1, rc2, rc3,
  1003. X        file_filter_label,
  1004. X        dir_filter_label,
  1005. X        executable_filter_label,
  1006. X        sw1, sw2, sw3;
  1007. X    XtActionsRec actions_rec;
  1008. X    XtTranslations trans_table;
  1009. X
  1010. #ifdef ALLOW_ROWCOL_RESIZE
  1011. X    /* the action called by this is to allow the number of columns
  1012. X       to be dynamically reset when the enclosing pane is resized.
  1013. X       It throws up a RowCol bug under Motif 1.1.0
  1014. X    */
  1015. X    /* we need to spot when the user horizontally resizes panes
  1016. X       to reset number of columns of files shown */
  1017. X        actions_rec.string = "resize";
  1018. X        actions_rec.proc = ScrolledWindowResized;
  1019. X
  1020. X    XtAddActions (&actions_rec, 1);
  1021. X    trans_table = XtParseTranslationTable ("<Configure>: resize()");
  1022. #endif /* ALLOW_ROWCOL_RESIZE */
  1023. X
  1024. X    pane = XmVaCreatePanedWindow (form, "pane",
  1025. X            NULL);
  1026. X
  1027. X    /* create the executable files section */
  1028. X    /* a row column of a label and a row column of drawn buttons */
  1029. X
  1030. X    rc1 = XmVaCreatePanedWindow (pane, "exec_rc", 
  1031. X                        XmNsashHeight, (XtArgVal) 1,
  1032. X                        XmNseparatorOn, (XtArgVal) False,
  1033. X                        XmNspacing, (XtArgVal) 0,
  1034. X                        XmNuserData, (XtArgVal) dpi,
  1035. X                        NULL);
  1036. X
  1037. X    executable_filter_label = XmVaCreateLabel (rc1,
  1038. X                    "executable_filter_label",
  1039. X                    NULL);
  1040. X
  1041. X    sw1 = XmVaCreateScrolledWindow (rc1, "exec_sw",
  1042. X            XmNscrollingPolicy, (XtArgVal) XmAUTOMATIC,
  1043. X                        XmNuserData, (XtArgVal) dpi,
  1044. X            NULL);
  1045. X
  1046. #ifdef ALLOW_ROWCOL_RESIZE
  1047. X    /* look for configure (resize) events on one of the panes */
  1048. X    XtOverrideTranslations (sw1, trans_table);
  1049. #endif /* ALLOW_ROWCOL_RESIZE */
  1050. X
  1051. X    executables_pane = XmVaCreateRowColumn (sw1, "executables_pane",
  1052. X                       NULL);
  1053. X    {    /* kludge to force the row column to give
  1054. X           us the size buttons we want.  It doesn't
  1055. X           tamper with the size of DrawButtons
  1056. X        */
  1057. X         Widget dummy;
  1058. X        dummy = XmVaCreateDrawnButton (executables_pane, "dumm",
  1059. X                XmNmappedWhenManaged, (XtArgVal) False,
  1060. X                NULL);
  1061. X        XtManageChild (dummy);
  1062. X        XtUnmanageChild (dummy);
  1063. X    }
  1064. X    XtVaSetValues (sw1,
  1065. X            XmNworkWindow, (XtArgVal) executables_pane,
  1066. X            NULL);
  1067. X
  1068. X    /* create the ordinary files section */
  1069. X    /* a row column of a label and a row column of drawn buttons */
  1070. X
  1071. X    rc2 = XmVaCreatePanedWindow (pane, "file_rc", 
  1072. X                        XmNsashHeight, (XtArgVal) 1,
  1073. X                        XmNseparatorOn, (XtArgVal) False,
  1074. X                        XmNspacing, (XtArgVal) 0,
  1075. X                        NULL);
  1076. X
  1077. X    file_filter_label = XmVaCreateLabel (rc2,
  1078. X                    "file_filter_label",
  1079. X                    NULL);
  1080. X
  1081. X    sw2 = XmVaCreateScrolledWindow (rc2, "file_sw",
  1082. X            XmNscrollingPolicy, (XtArgVal) XmAUTOMATIC,
  1083. X            NULL);
  1084. X
  1085. X    files_pane = XmVaCreateRowColumn (sw2, "files_pane",
  1086. X                          NULL);
  1087. X
  1088. X    XtVaSetValues (sw2,
  1089. X            XmNworkWindow, (XtArgVal) files_pane,
  1090. X            NULL);
  1091. X
  1092. X    /* create the directories section */
  1093. X    /* a row column of a label and a row column (in a scrolled window)
  1094. X       of drawn buttons */
  1095. X
  1096. X    rc3 = XmVaCreatePanedWindow (pane, "dir_rc", 
  1097. X                        XmNsashHeight, (XtArgVal) 1,
  1098. X                        XmNseparatorOn, (XtArgVal) False,
  1099. X                        XmNspacing, (XtArgVal) 0,
  1100. X                        NULL);
  1101. X
  1102. X    dir_filter_label = XmVaCreateLabel (rc3,
  1103. X                    "dir_filter_label",
  1104. X                    NULL);
  1105. X
  1106. X    sw3 = XmVaCreateScrolledWindow (rc3, "dir_sw",
  1107. X            XmNscrollingPolicy, (XtArgVal) XmAUTOMATIC,
  1108. X            NULL);
  1109. X
  1110. X    dirs_pane = XmVaCreateRowColumn (sw3, "dirs_pane",
  1111. X             NULL);
  1112. X
  1113. X    XtVaSetValues (sw3,
  1114. X            XmNworkWindow, (XtArgVal) dirs_pane,
  1115. X            NULL);
  1116. X
  1117. X    XtManageChild (executables_pane);
  1118. X    XtManageChild (executable_filter_label);
  1119. X    XtManageChild (rc1);
  1120. X    XtManageChild (sw1);
  1121. X
  1122. X    XtManageChild (files_pane);
  1123. X    XtManageChild (file_filter_label);
  1124. X    XtManageChild (rc2);
  1125. X    XtManageChild (sw2);
  1126. X
  1127. X    XtManageChild (dirs_pane);
  1128. X    XtManageChild (dir_filter_label);
  1129. X    XtManageChild (rc3);
  1130. X    XtManageChild (sw3);
  1131. X
  1132. X    dpi -> executables_pane = executables_pane;
  1133. X    dpi -> files_pane = files_pane;
  1134. X    dpi -> dirs_pane = dirs_pane;
  1135. X        dpi -> file_filter_label = file_filter_label;
  1136. X        dpi -> dir_filter_label = dir_filter_label;
  1137. X        dpi -> executable_filter_label = executable_filter_label;
  1138. X
  1139. X    return pane;
  1140. }
  1141. X
  1142. /*************************************************************************
  1143. X * Function: CreateApplication ()
  1144. X * Purpose: create a toplevel widget
  1145. X * In parameters: parent
  1146. X * Function result: toplevel widget in managed state
  1147. X * Precondition: parent is non-null widget
  1148. X * Postcondition: widget hierarchy set up and managed
  1149. X ************************************************************************/ 
  1150. Widget CreateApplication 
  1151. #ifdef UseFunctionPrototypes
  1152. X    (Widget parent)
  1153. #else
  1154. X    (parent)  
  1155. Widget        parent;        /*  parent widget    */ 
  1156. X
  1157. #endif
  1158. X    Widget        main,
  1159. X            form,
  1160. X            directory_label,
  1161. X            pane,
  1162. X            menu,
  1163. X            dirs_toolbar,
  1164. X            files_toolbar;
  1165. X    char    str[128];
  1166. X    DirectoryMgr *files;
  1167. X    dir_pane_info *dpi;
  1168. X
  1169. #ifdef ALLOW_EDITRES
  1170. X    XtAddEventHandler (parent, (EventMask) 0, True,
  1171. X                _XEditResCheckMessages, NULL);
  1172. #endif
  1173. X
  1174. X    empty_string = XmStringCreateSimple ("           ");
  1175. X
  1176. X    dpi = (dir_pane_info *) XtMalloc (sizeof (dir_pane_info));
  1177. X
  1178. X    main = XmVaCreateMainWindow (parent, "main", 
  1179. X            XmNuserData, (XtArgVal) dpi,
  1180. X            NULL);
  1181. #ifdef RDD
  1182. /*    seems to override other drops 
  1183. X    rddAddDropHandler (main,
  1184. X                MainWindowDrop, NULL);
  1185. */
  1186. #endif /* RDD */
  1187. X
  1188. X    form = XmVaCreateForm (main, "form",
  1189. X            NULL);
  1190. X
  1191. X
  1192. X    directory_label = XmVaCreateLabel (form, "directory_label",
  1193. X                    NULL);
  1194. X    files_toolbar = CreateFilesToolbar (form, dpi);
  1195. X
  1196. X    dirs_toolbar = CreateDirsToolbar (form, dpi);
  1197. X
  1198. X    pane = CreatePane (form, dpi);
  1199. X
  1200. X    files = GetFilesInDir ();
  1201. X    dpi -> dirs_buttons = NULL;
  1202. X    dpi -> files_buttons = NULL;
  1203. X    dpi -> executables_buttons = NULL;
  1204. X
  1205. X    menu = CreateMenu (main, (XtPointer) dpi);
  1206. X
  1207. X    XtManageChild (menu);
  1208. X    XtManageChild (dirs_toolbar);
  1209. X    XtManageChild (files_toolbar);
  1210. X    XtManageChild (pane);
  1211. X    XtManageChild (directory_label);
  1212. X    XtManageChild (form);
  1213. X    XtManageChild (main);
  1214. X
  1215. X    SetGeometry (directory_label, files_toolbar, dirs_toolbar, pane);
  1216. X
  1217. X    /* set up the user data stuff */
  1218. X    dpi -> directory_label = directory_label;
  1219. X    dpi -> directory_manager = files;
  1220. X    dpi -> file_selected = NULL;
  1221. X    dpi -> file_button_selected = NULL;
  1222. X    dpi -> dir_selected = NULL;
  1223. X    dpi -> executable_selected = NULL;
  1224. X    dpi -> toplevel = parent;
  1225. X        dpi -> run_dialog = NULL;
  1226. X        dpi -> info_dialog = NULL;
  1227. X
  1228. X    XmMainWindowSetAreas (main, menu, NULL, NULL, NULL, form);
  1229. X
  1230. X    return (main);
  1231. X
  1232. X
  1233. /*************************************************************************
  1234. X * Function: GetFilesInDir ()
  1235. X * Purpose: return a list of files in current directory
  1236. X * Function result: list of files
  1237. X * Precondition: none
  1238. X * Postcondition: list of files returned
  1239. X ************************************************************************/ 
  1240. DirectoryMgr *GetFilesInDir 
  1241. #ifdef UseFunctionPrototypes
  1242. X    (void)
  1243. #else
  1244. X    ()
  1245. X
  1246. #endif
  1247. {
  1248. X        DirectoryMgr *dm;
  1249. X    char path[MAXPATHLEN];
  1250. X
  1251. X    getcwd (path, MAXPATHLEN);
  1252. X
  1253. X    dm = DirectoryMgrSimpleOpen(path,DIR_MGR_SORT_NAME_DIRS_FIRST, (char *)NULL);
  1254. X        if (dm == NULL)
  1255. X        {
  1256. X                fprintf(stderr,"Can't open directory mgr for '%s'\n",path);
  1257. X                exit(-1);
  1258. X        }
  1259. X    return (dm);
  1260. }
  1261. X
  1262. #ifdef OLD_CODE
  1263. /*************************************************************************
  1264. X * Function: SetFilesInPane ()
  1265. X * Purpose: Set up the file names in buttons in each of the panes
  1266. X * In parameters: dm, dirs_pane, executables_pane, files_pane, dpi
  1267. X * Out parameters: dpi contents changed by indirection
  1268. X * Precondition: directory list in dm, 3 non-null pane widgets,
  1269. X *               dpi points to existing structure
  1270. X * Postcondition: some fields in dpi filled in, panes populated with
  1271. X *                buttons of file names
  1272. X ************************************************************************/ 
  1273. int
  1274. SetFilesInPanes (dm, dirs_pane, executables_pane, files_pane, dpi)
  1275. X    DirectoryMgr *dm;
  1276. X    Widget dirs_pane;
  1277. X    Widget files_pane;
  1278. X    dir_pane_info *dpi;
  1279. {
  1280. X        DirEntry *de;
  1281. X    Widget button;
  1282. X    aWidgetList *dbi, *fbi, *xbi;
  1283. X    pane_button_info *pbi;
  1284. X
  1285. X    while (1)
  1286. X        {
  1287. X                de = DirectoryMgrNextEntry(dm);
  1288. X                if (de == NULL) break;
  1289. X
  1290. X        pbi = (pane_button_info *)
  1291. X            XtMalloc (sizeof (pane_button_info));
  1292. X        pbi -> name = de -> filename;
  1293. X        pbi -> dpi = dpi;
  1294. X
  1295. X
  1296. X        /* place dirs in dir pane */
  1297. X        if (DirEntryIsDir (de) ||
  1298. X            DirEntryIsSymLink (de) &&
  1299. X                S_ISDIR (FileInfoOrigMode (DirEntryActualInfo (de))))
  1300. X        {
  1301. X            pbi -> file_type = DIR_TYPE;
  1302. X            button = XmVaCreatePushButton (dirs_pane,
  1303. X                    de -> filename,
  1304. X                    XmNuserData, (XtArgVal) pbi,
  1305. X                    NULL);
  1306. X            /* link into list */
  1307. X            if (dpi -> dirs_buttons == NULL)
  1308. X            {    dpi -> dirs_buttons =
  1309. X                dbi = (aWidgetList *)
  1310. X                    XtMalloc (sizeof (aWidgetList));
  1311. X            } else {
  1312. X                dbi -> next = (aWidgetList *)
  1313. X                         XtMalloc (sizeof (aWidgetList));
  1314. X                dbi = dbi -> next;
  1315. X            }
  1316. X            dbi -> widget = button;
  1317. X            dbi -> next = NULL;
  1318. X
  1319. X            XtAddCallback (button, XmNarmCallback,
  1320. X                        FileButtonPressedCB,
  1321. X                        NULL);
  1322. X            XtAddCallback (button,
  1323. X                XmNactivateCallback, FileButtonReleasedCB,
  1324. X                NULL);
  1325. X        }
  1326. X        /* and executables in executables pane */
  1327. X        else if ((FileInfoProt( DirEntryActualInfo (de))
  1328. X                & (S_IXUSR | S_IXOTH | S_IXGRP)) != 0)
  1329. X        {
  1330. X            pbi -> file_type = EXECUTABLE_TYPE;
  1331. X            button = XmVaCreatePushButton (executables_pane,
  1332. X                    de -> filename,
  1333. X                    XmNuserData, (XtArgVal) pbi,
  1334. X                    NULL);
  1335. X            /* link into list */
  1336. X            if (dpi -> executables_buttons == NULL)
  1337. X            {    dpi -> executables_buttons =
  1338. X                xbi = (aWidgetList *)
  1339. X                    XtMalloc (sizeof (aWidgetList));
  1340. X            } else {
  1341. X                xbi -> next = (aWidgetList *)
  1342. X                         XtMalloc (sizeof (aWidgetList));
  1343. X                xbi = xbi -> next;
  1344. X            }
  1345. X            xbi -> widget = button;
  1346. X            xbi -> next = NULL;
  1347. X
  1348. X            XtAddCallback (button, XmNarmCallback,
  1349. X                        FileButtonPressedCB,
  1350. X                        NULL);
  1351. X            XtAddCallback (button,
  1352. X                XmNactivateCallback, FileButtonReleasedCB,
  1353. X                NULL);
  1354. X        }
  1355. X        /* everything else in files pane */
  1356. X        else
  1357. X        {
  1358. X            pbi -> file_type = FILE_TYPE;
  1359. X            button = XmVaCreatePushButton (files_pane,
  1360. X                    de -> filename,
  1361. X                    XmNuserData, (XtArgVal) pbi,
  1362. X                    NULL);
  1363. X
  1364. X            /* link into list */
  1365. X            if (dpi -> files_buttons == NULL)
  1366. X            {    dpi -> files_buttons =
  1367. X                fbi = (aWidgetList *)
  1368. X                    XtMalloc (sizeof (aWidgetList));
  1369. X            } else {
  1370. X                fbi -> next = (aWidgetList *)
  1371. X                         XtMalloc (sizeof (aWidgetList));
  1372. X                fbi = fbi -> next;
  1373. X            }
  1374. X            fbi -> widget = button;
  1375. X            fbi -> next = NULL;
  1376. X            XtAddCallback (button, XmNarmCallback,
  1377. X                        FileButtonPressedCB,
  1378. X                        NULL);
  1379. X            XtAddCallback (button,
  1380. X                XmNactivateCallback, FileButtonReleasedCB,
  1381. X                NULL);
  1382. X        }
  1383. X        XtManageChild (button);
  1384. X        }
  1385. }
  1386. #endif /* OLD_CODE */
  1387. X
  1388. X
  1389. /*************************************************************************
  1390. X * Function: DrawnButtonExposedCB ()
  1391. X * Purpose: handle expose events on file buttons
  1392. X * In parameters: button, client_data, call_data
  1393. X * Function returns:
  1394. X * Precondition: expose event generated for w
  1395. X * Postcondition: label redrawn
  1396. X *************************************************************************/
  1397. X
  1398. /* ARGSUSED */
  1399. void
  1400. DrawnButtonExposedCB 
  1401. #ifdef UseFunctionPrototypes
  1402. X    (Widget button, XtPointer client_data, XtPointer call_data)
  1403. #else
  1404. X    (button, client_data, call_data)
  1405. X    Widget button;
  1406. X    XtPointer client_data, call_data;
  1407. X
  1408. #endif
  1409. {    pane_button_info *pbi;
  1410. X    Dimension height;
  1411. X
  1412. X    XtVaGetValues (button,
  1413. X            XmNuserData, (XtArgVal) &pbi,
  1414. X            XmNheight, (XtArgVal) &height,
  1415. X            NULL);
  1416. X
  1417. X    XDrawImageString (XtDisplay (button),
  1418. X            XtWindow (button),
  1419. X            pbi -> gc, 0, (int) height - 5, 
  1420. X            pbi -> name,
  1421. X            strlen (pbi -> name));
  1422. }
  1423. X
  1424. /*************************************************************************
  1425. X * Function: set_pixmap ()
  1426. X * Purpose: set the visual pixmap for this file type
  1427. X * In parameters: button, name, file_type
  1428. X * Function returns:
  1429. X * Side effects: pbi for this button has pixmap, insensitive_pixmap set
  1430. X * Precondition: none 
  1431. X * Postcondition: pixmap set as labelPixmap resource
  1432. X *************************************************************************/
  1433. static void
  1434. set_pixmap 
  1435. #ifdef UseFunctionPrototypes
  1436. X    (Widget button, char *name, char file_type)
  1437. #else
  1438. X    (button, name, file_type)
  1439. X    Widget button;
  1440. X    char *name;
  1441. X    char file_type;
  1442. X
  1443. #endif
  1444. {
  1445. X    Pixmap pixmap, pixmap_reversed;
  1446. X    file_action *pfa;
  1447. X    Pixel fg, bg;
  1448. X    pane_button_info *pbi;
  1449. X
  1450. X    /* find existing colours used in button */
  1451. X    XtVaGetValues (button,
  1452. X            XmNforeground, &fg,
  1453. X            XmNbackground, &bg,
  1454. X            NULL);
  1455. X
  1456. X        /* find file pattern matching this name */
  1457. X        pfa = actions;
  1458. X        while (pfa != NULL)
  1459. X                if (pfa -> file_type == file_type &&
  1460. X                        RegExpMatch (name, pfa -> fsm_ptr))
  1461. X                        break;
  1462. X                else    pfa = pfa -> next;
  1463. X
  1464. X        if (pfa == NULL)
  1465. X        {
  1466. X        fprintf (stderr, "cant find pattern for %s\n", name);
  1467. X        return;
  1468. X        }
  1469. X
  1470. X    /* destroy old pixmaps */
  1471. X    XtVaGetValues (button,
  1472. X            XmNuserData, (XtArgVal) &pbi,
  1473. X            NULL);
  1474. X    XmDestroyPixmap (XtScreen (button), pbi -> pixmap);
  1475. X    XmDestroyPixmap (XtScreen (button), pbi -> pixmap_reversed);
  1476. X
  1477. X    /* find the pixmap for this file */
  1478. X    pixmap = XmGetPixmap ( XtScreen (button),
  1479. X                pfa -> pixmap, fg, bg);
  1480. X    pixmap_reversed = XmGetPixmap ( XtScreen (button),
  1481. X                pfa -> pixmap, bg, fg);
  1482. X
  1483. X    if (pixmap == XmUNSPECIFIED_PIXMAP)
  1484. X    {    fprintf (stderr, "cant find pixmap %s\n", pfa -> pixmap);
  1485. X        /* reasonable default */
  1486. X        pixmap = XmGetPixmap ( XtScreen (button),
  1487. X                    "xlogo32", fg, bg);
  1488. X        pixmap_reversed = XmGetPixmap ( XtScreen (button),
  1489. X                    "xlogo32", bg, fg);
  1490. X    }
  1491. X        
  1492. X    XtVaSetValues (button,
  1493. X            XmNlabelPixmap, (XtArgVal) pixmap,
  1494. X            NULL);
  1495. X    pbi -> pixmap = pixmap;
  1496. X    pbi -> pixmap_reversed = pixmap_reversed;
  1497. }
  1498. X
  1499. /*************************************************************************
  1500. X * Function: new_pane_button ()
  1501. X * Purpose: crete a new button in one of the panes
  1502. X * In parameters: de, dpi, file_type
  1503. X * Function returns: new node of a widget list 
  1504. X * Precondition: 
  1505. X * Postcondition: new node created with callbacks set
  1506. X *************************************************************************/
  1507. aWidgetList *
  1508. new_pane_button 
  1509. #ifdef UseFunctionPrototypes
  1510. X    (char *filename, char *button_name, dir_pane_info *dpi, Widget parent, char file_type)
  1511. #else
  1512. X    (filename, button_name, dpi, parent, file_type)
  1513. X    char *filename;
  1514. X    char *button_name;
  1515. X    dir_pane_info *dpi;
  1516. X    Widget parent;
  1517. X    char file_type;
  1518. X
  1519. #endif
  1520. {
  1521. X    pane_button_info *pbi;
  1522. X    Widget button;
  1523. X    aWidgetList *dbi;
  1524. X    static Pixmap label_bug_pixmap = NULL;
  1525. X
  1526. X    /* set information needed for this button */
  1527. X    pbi = (pane_button_info *)
  1528. X        XtMalloc (sizeof (pane_button_info));
  1529. X    pbi -> name = filename;
  1530. X    pbi -> dpi = dpi;
  1531. X    pbi -> file_type = file_type;
  1532. X    pbi -> pixmap = XmUNSPECIFIED_PIXMAP;
  1533. X    pbi -> pixmap_reversed = XmUNSPECIFIED_PIXMAP;
  1534. X    pbi -> gc = gc;
  1535. X    pbi -> gc_reversed = gc_reversed;
  1536. X
  1537. X    /* if recompute_size == True, and we don't have a pixmap
  1538. X       set at create time, then it always takes its size as 0x0.
  1539. X       This is (at least) a Motif 1.1.0 fix, that sets a dummy one
  1540. X    */
  1541. X    if (label_bug_pixmap == NULL)
  1542. X    {    Pixel fg, bg;
  1543. X
  1544. X        XtVaGetValues (parent,
  1545. X                XmNforeground, (XtArgVal) &fg,
  1546. X                XmNbackground, (XtArgVal) &bg,
  1547. X                NULL);
  1548. X        label_bug_pixmap = XmGetPixmap (XtScreen (parent),
  1549. X                    "xlogo32", bg, fg);
  1550. X    }
  1551. X
  1552. X    button = XmVaCreateDrawnButton (parent,
  1553. X                button_name,
  1554. X                XmNuserData, (XtArgVal) pbi,
  1555. X                XmNlabelType, (XtArgVal) XmPIXMAP,
  1556. X                XmNlabelPixmap, (XtArgVal) label_bug_pixmap,
  1557. X                XmNmultiClick, (XtArgVal) XmMULTICLICK_KEEP,
  1558. X                XmNrecomputeSize, (XtArgVal) False,
  1559. #ifdef RDD
  1560. X                XmNtranslations, (XtArgVal) trans_table,
  1561. #endif /* RDD */
  1562. #ifdef MOTIF_DD
  1563. X                XmNtranslations, (XtArgVal) trans_table,
  1564. #endif /* MOTIF_DD */
  1565. X                NULL);
  1566. X    /* create a new node for list */
  1567. X    dbi = (aWidgetList *)
  1568. X            XtMalloc (sizeof (aWidgetList));
  1569. X    dbi -> widget = button;
  1570. X    dbi -> next = NULL;
  1571. X
  1572. X    XtAddCallback (button, XmNarmCallback,
  1573. X                FileButtonPressedCB,
  1574. X                NULL);
  1575. X    XtAddCallback (button, XmNactivateCallback,
  1576. X                FileButtonReleasedCB,
  1577. X                NULL);
  1578. X    XtAddCallback (button, XmNexposeCallback,
  1579. X                DrawnButtonExposedCB,
  1580. X                NULL);
  1581. X    XtManageChild (button);
  1582. X
  1583. X    set_pixmap (button, pbi -> name, file_type);
  1584. X
  1585. X    return dbi;
  1586. }
  1587. X
  1588. /*************************************************************************
  1589. X * Function: reset_label ()
  1590. X * Purpose: change the label in a widget
  1591. X * In parameters: w, label
  1592. X * Out parameters: 
  1593. X * Precondition: w is a child of Label.
  1594. X * Postcondition: w has label set
  1595. X *************************************************************************/
  1596. void
  1597. reset_label 
  1598. #ifdef UseFunctionPrototypes
  1599. X    (Widget w, char *label, char file_type)
  1600. #else
  1601. X    (w, label, file_type)
  1602. X    Widget w;
  1603. X    char * label;
  1604. X    char file_type;
  1605. X
  1606. #endif
  1607. {    XmString xmstr;
  1608. X    pane_button_info *pbi;
  1609. X
  1610. X    /* reset the label in the button */
  1611. X    xmstr = XmStringCreateSimple (label);
  1612. X    XtVaSetValues (w,
  1613. X            XmNlabelString, (XtArgVal) xmstr,
  1614. X            NULL);
  1615. X    XmStringFree (xmstr);
  1616. X
  1617. X    /* reset the name in the button info */
  1618. X    XtVaGetValues (w, XmNuserData, &pbi);
  1619. X    pbi -> name = label;
  1620. X
  1621. X    set_pixmap (w, label, file_type);
  1622. }
  1623. X
  1624. /*************************************************************************
  1625. X * Function: SetDirectoryLabel ()
  1626. X * Purpose: set the current dir path in the Label widget showing above panes
  1627. X * In parameters:  dir_label, dm
  1628. X * Out parameters: 
  1629. X * Precondition: 
  1630. X * Postcondition: labelString in dir_label set to current dir
  1631. X ************************************************************************/ 
  1632. static void
  1633. SetDirectoryLabel 
  1634. #ifdef UseFunctionPrototypes
  1635. X    (Widget dir_label, DirectoryMgr *dm)
  1636. #else
  1637. X    (dir_label, dm)
  1638. X    Widget dir_label;
  1639. X    DirectoryMgr *dm;
  1640. X
  1641. #endif
  1642. {
  1643. X    char *dir;
  1644. X    XmString xmdir;
  1645. X    char full_dir[MAXPATHLEN];
  1646. X
  1647. X    dir = DirectoryPath (DirectoryMgrDir (dm));
  1648. X    strcpy (full_dir, "Directory: ");
  1649. X    strcat (full_dir, dir);
  1650. X    xmdir = XmStringCreateSimple (full_dir);
  1651. X    XtVaSetValues (dir_label,
  1652. X            XmNlabelString, xmdir,
  1653. X            NULL);
  1654. X    XmStringFree (xmdir);
  1655. }
  1656. X
  1657. X
  1658. /*************************************************************************
  1659. X * Function: ResetFilesInPane ()
  1660. X * Purpose: Set up the file names in buttons in each of the panes
  1661. X * In parameters:  dpi
  1662. X * Out parameters: dpi contents changed by indirection
  1663. X * Precondition: directory list in dm, 3 non-null pane widgets,
  1664. X *               dpi points to existing structure
  1665. X * Postcondition: some fields in dpi filled in, panes populated with
  1666. X *                buttons of file names
  1667. X ************************************************************************/ 
  1668. void
  1669. ResetFilesInPanes 
  1670. #ifdef UseFunctionPrototypes
  1671. X    (dir_pane_info *dpi)
  1672. #else
  1673. X    (dpi)
  1674. X    dir_pane_info *dpi;
  1675. X
  1676. #endif
  1677. {
  1678. X    DirectoryMgr *dm;
  1679. X        DirEntry *de;
  1680. X    aWidgetList *dbi, *fbi, *xbi;
  1681. X    Bool first_dbi = True;
  1682. X    Bool first_fbi = True;
  1683. X    Bool first_xbi = True;
  1684. X
  1685. X    dm = dpi -> directory_manager;
  1686. X    dbi = dpi -> dirs_buttons;
  1687. X    fbi = dpi -> files_buttons;
  1688. X    xbi = dpi -> executables_buttons;
  1689. X
  1690. X    SetDirectoryLabel (dpi -> directory_label, dm);
  1691. X
  1692. X    /* turn off visibility to stop flickering */
  1693. X    XtUnmapWidget (XtParent (dpi -> files_pane));
  1694. X    XtUnmapWidget (XtParent (dpi -> executables_pane));
  1695. X    XtUnmapWidget (XtParent (dpi -> dirs_pane));
  1696. X
  1697. X        /* ensure we are at the beginning of the directory list */
  1698. X        DirectoryMgrRestart (dm);
  1699. X
  1700. X    while ( (de = DirectoryMgrNextEntry(dm)) != NULL)
  1701. X        {
  1702. X        /* explanation of grotty code:
  1703. X           there are three lists of buttons, and buttons are
  1704. X           added to or modified in each list.  A procedure is
  1705. X           not used because parameterisation looks grotty.
  1706. X           For each list, there are four cases, like this:
  1707. X
  1708. X           if list is NULL, create new button, with trailing
  1709. X            pointer set to it
  1710. X           else if list is non-NULL, but you are at the beginning,
  1711. X                change the label of first button
  1712. X                and keep the pointer set to it
  1713. X           else if next button is NULL, create next button and set
  1714. X                pointer to it
  1715. X           else move to next button and change its label
  1716. X        */
  1717. X
  1718. X        /* place dirs in dir pane */
  1719. X        if (DirEntryIsDir (de) ||
  1720. X            DirEntryIsSymLink (de) &&
  1721. X                S_ISDIR (FileInfoOrigMode (DirEntryActualInfo (de))))
  1722. X        {
  1723. X            /* does it match pattern? else discard it */
  1724. X            if ( !RegExpMatch (DirEntryFileName (de),
  1725. X                    dpi -> dir_filter_regexp))
  1726. X                continue;
  1727. X
  1728. X            if (dpi -> dirs_buttons == NULL) 
  1729. X            {    /* create another button with its info */
  1730. X                dpi -> dirs_buttons =
  1731. X                dbi = new_pane_button (de -> filename,
  1732. X                            "dir_pane_button", dpi,
  1733. X                            dpi -> dirs_pane,
  1734. X                            DIR_TYPE);
  1735. #ifdef RDD
  1736. X                rddAddDropHandler (dbi -> widget,
  1737. X                    DirDrop, NULL);
  1738. #endif /* RDD */
  1739. X                first_dbi = False;
  1740. X            }
  1741. X            else if (first_dbi)
  1742. X            {    reset_label (dbi -> widget,
  1743. X                        de -> filename,
  1744. X                        DIR_TYPE);
  1745. X                first_dbi = False;
  1746. X                XtManageChild (dbi -> widget);
  1747. X            }
  1748. X            else if (dbi -> next == NULL)
  1749. X            {
  1750. X                dbi -> next = new_pane_button (de -> filename,
  1751. X                            "dir_pane_button",
  1752. X                            dpi,
  1753. X                            dpi -> dirs_pane,
  1754. X                            DIR_TYPE);
  1755. X                dbi = dbi -> next;
  1756. #ifdef RDD
  1757. X                rddAddDropHandler (dbi -> widget,
  1758. X                    DirDrop, NULL);
  1759. #endif /* RDD */
  1760. X            } else
  1761. X            {
  1762. X                dbi = dbi -> next;
  1763. X                reset_label (dbi -> widget,
  1764. X                        de -> filename,
  1765. X                        DIR_TYPE);
  1766. X                /* in case it was unmanaged by earlier dir change */
  1767. X                XtManageChild (dbi -> widget);
  1768. X            }
  1769. X        }
  1770. X        /* and executables in executables pane */
  1771. X        else if ((FileInfoOrigMode( DirEntryActualInfo (de))
  1772. X                & (S_IXUSR | S_IXOTH | S_IXGRP)) != 0)
  1773. X        {
  1774. X            /* does it match pattern? else discard it */
  1775. X            if ( !RegExpMatch (DirEntryFileName (de),
  1776. X                    dpi -> executable_filter_regexp))
  1777. X                continue;
  1778. X
  1779. X            if (dpi -> executables_buttons == NULL) 
  1780. X            {    /* create another button with its info */
  1781. X                dpi -> executables_buttons =
  1782. X                xbi = new_pane_button (de -> filename,
  1783. X                            "exec_pane_button", dpi,
  1784. X                            dpi -> executables_pane,
  1785. X                            EXECUTABLE_TYPE);
  1786. #ifdef RDD
  1787. X                rddAddDropHandler (xbi -> widget,
  1788. X                    ExecutableDrop, NULL);
  1789. #endif /* RDD */
  1790. X                first_xbi = False;
  1791. X            }
  1792. X            else if (first_xbi)
  1793. X            {    reset_label (xbi -> widget,
  1794. X                        de -> filename,
  1795. X                        EXECUTABLE_TYPE);
  1796. X                first_xbi = False;
  1797. X                XtManageChild (xbi -> widget);
  1798. X            }
  1799. X            else if (xbi -> next == NULL)
  1800. X            {
  1801. X                xbi -> next = new_pane_button (de -> filename,
  1802. X                            "exec_pane_button",
  1803. X                            dpi,
  1804. X                            dpi -> executables_pane,
  1805. X                            EXECUTABLE_TYPE);
  1806. X                xbi = xbi -> next;
  1807. #ifdef RDD
  1808. X                rddAddDropHandler (xbi -> widget,
  1809. X                    ExecutableDrop, NULL);
  1810. #endif /* RDD */
  1811. X            } else
  1812. X            {
  1813. X                xbi = xbi -> next;
  1814. X                reset_label (xbi -> widget,
  1815. X                        de -> filename,
  1816. X                        EXECUTABLE_TYPE);
  1817. X
  1818. X                /* in case it was unmanaged by earlier dir change */
  1819. X                XtManageChild (xbi -> widget);
  1820. X            }
  1821. X        }
  1822. X        /* everything else in files pane */
  1823. X        else
  1824. X        /* does it match pattern? else discard it */
  1825. X        if (RegExpMatch (DirEntryFileName (de),
  1826. X                dpi -> file_filter_regexp))
  1827. X        {
  1828. X            if (dpi -> files_buttons == NULL) 
  1829. X            {    /* create another button with its info */
  1830. X                dpi -> files_buttons =
  1831. X                fbi = new_pane_button (de -> filename,
  1832. X                            "file_pane_button", dpi,
  1833. X                            dpi -> files_pane,
  1834. X                            FILE_TYPE);
  1835. X                first_fbi = False;
  1836. X            }
  1837. X            else if (first_fbi)
  1838. X            {    reset_label (fbi -> widget,
  1839. X                        de -> filename,
  1840. X                        FILE_TYPE);
  1841. X                first_fbi = False;
  1842. X                XtManageChild (fbi -> widget);
  1843. X            }
  1844. X            else if (fbi -> next == NULL)
  1845. X            {
  1846. X                fbi -> next = new_pane_button (de -> filename,
  1847. X                            "file_pane_button",
  1848. X                            dpi,
  1849. X                            dpi -> files_pane,
  1850. X                            FILE_TYPE);
  1851. X                fbi = fbi -> next;
  1852. X            } else
  1853. X            {
  1854. X                fbi = fbi -> next;
  1855. X                reset_label (fbi -> widget,
  1856. X                        de -> filename,
  1857. X                        FILE_TYPE);
  1858. X                XtManageChild (fbi -> widget);
  1859. X            }
  1860. X        }
  1861. X        }
  1862. X    /* if the new lists are shorter than the old ones, there will
  1863. X       be buttons left over that should have no contents. They
  1864. X       have to be unmanaged. First, advance trailing pointers */
  1865. X    if (!first_dbi && dbi != NULL) dbi = dbi -> next;
  1866. X    if (!first_xbi && xbi != NULL) xbi = xbi -> next;
  1867. X    if (!first_fbi && fbi != NULL) fbi = fbi -> next;
  1868. X
  1869. X    while (dbi != NULL)
  1870. X    {
  1871. X        XtUnmanageChild (dbi -> widget);
  1872. X        dbi = dbi -> next;
  1873. X    }
  1874. X    while (xbi != NULL)
  1875. X    {
  1876. X        XtUnmanageChild (xbi -> widget);
  1877. X        xbi = xbi -> next;
  1878. X    }
  1879. X    while (fbi != NULL)
  1880. X    {
  1881. X        XtUnmanageChild (fbi -> widget);
  1882. X        fbi = fbi -> next;
  1883. SHAR_EOF
  1884. true || echo 'restore of xmfm/applicat.c failed'
  1885. fi
  1886. echo 'End of  part 3'
  1887. echo 'File xmfm/applicat.c is continued in part 4'
  1888. echo 4 > _shar_seq_.tmp
  1889. exit 0
  1890. --
  1891. +----------------------+---+
  1892.   Jan Newmarch, Information Science and Engineering,
  1893.   University of Canberra, PO Box 1, Belconnen, Act 2616
  1894.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  1895.