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

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!zaphod.mps.ohio-state.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 06 of 17
  5. Message-ID: <1992Nov19.052301.25729@csc.canberra.edu.au>
  6. Sender: news@csc.canberra.edu.au
  7. Organization: University of Canberra
  8. Date: Thu, 19 Nov 92 05:23:01 GMT
  9. Lines: 1527
  10.  
  11.  
  12.  
  13. #!/bin/sh
  14. # this is part.06 (part 6 of a multipart archive)
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file xmfm/gotocb.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" != 6; 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/gotocb.c'
  32. else
  33. echo 'x - continuing file xmfm/gotocb.c'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'xmfm/gotocb.c' &&
  35. X
  36. /* ARGSUSED */
  37. void GotoOpenDirCB 
  38. #ifdef UseFunctionPrototypes
  39. X    (Widget w, XtPointer client_data, XtPointer call_data)
  40. #else
  41. X    (w, client_data, call_data)  
  42. Widget        w;        /*  widget id        */ 
  43. XXtPointer        client_data;    /*  data from applicaiton   */ 
  44. XXtPointer        call_data;
  45. X
  46. #endif
  47. {
  48. X    char *goto_dir;
  49. X    dir_pane_info *dpi;
  50. X
  51. X    GotoCurrentDir (w);
  52. X
  53. X    PromptDialog (w, "Open what directory?", True, &goto_dir);
  54. X    if (goto_dir == NULL)
  55. X        return;
  56. X    XtVaGetValues (w,
  57. X            XmNuserData, (XtArgVal) &dpi,
  58. X            NULL);
  59. X    builtin_opendir (goto_dir, dpi);
  60. X    XtFree (goto_dir);
  61. }
  62. SHAR_EOF
  63. echo 'File xmfm/gotocb.c is complete' &&
  64. chmod 0644 xmfm/gotocb.c ||
  65. echo 'restore of xmfm/gotocb.c failed'
  66. Wc_c="`wc -c < 'xmfm/gotocb.c'`"
  67. test 6666 -eq "$Wc_c" ||
  68.     echo 'xmfm/gotocb.c: original size 6666, current size' "$Wc_c"
  69. rm -f _shar_wnt_.tmp
  70. fi
  71. # ============= xmfm/help.c ==============
  72. if test -f 'xmfm/help.c' -a X"$1" != X"-c"; then
  73.     echo 'x - skipping xmfm/help.c (File already exists)'
  74.     rm -f _shar_wnt_.tmp
  75. else
  76. > _shar_wnt_.tmp
  77. echo 'x - extracting xmfm/help.c (Text)'
  78. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/help.c' &&
  79. /*************************************************************************
  80. X * File: help.c
  81. X * Author: Jan Newmarch
  82. X * Last modified: $Date: 1992/11/17 00:35:45 $
  83. X * Version: $Revision: 1.7 $
  84. X * Purpose: Handle the help buttons in the application menu
  85. X *
  86. X * Revision history:
  87. X *    16 Oct 92    caddr_t changed to XtPointer
  88. X *      3 Nov 92        lint-ed
  89. X ************************************************************************/ 
  90. X
  91. #include "copyright.h"
  92. X
  93. /*************************************************************************
  94. X * System includes
  95. X ************************************************************************/ 
  96. #include <stdio.h> 
  97. #include <string.h> 
  98. #include <X11/Intrinsic.h> 
  99. #include <Xm/Xm.h> 
  100. #include <Xm/MessageB.h> 
  101. X
  102. /*************************************************************************
  103. X * Local includes
  104. X ************************************************************************/ 
  105. #include "const.h"
  106. X
  107. /*************************************************************************
  108. X * Functions exported
  109. X ************************************************************************/ 
  110. extern void HelpCB (
  111. #ifdef UseFunctionPrototypes
  112. X    Widget w, XtPointer client_data, XtPointer call_data
  113. #endif
  114. );
  115. X
  116. /*************************************************************************
  117. X * Variables exported
  118. X ************************************************************************/ 
  119. X
  120. /*************************************************************************
  121. X * Extern variables
  122. X ************************************************************************/ 
  123. X
  124. /*************************************************************************
  125. X * Extern functions
  126. X ************************************************************************/ 
  127. X
  128. /*************************************************************************
  129. X * Forward functions
  130. X ************************************************************************/ 
  131. static Widget CreateHelp(
  132. #ifdef UseFunctionPrototypes
  133. X    Widget parent, char *message
  134. #endif
  135. );  
  136. X
  137. /*************************************************************************
  138. X * Local variables
  139. X ************************************************************************/ 
  140. X
  141. /*-------------------------------------------------------
  142. **    Help menu callbacks
  143. */
  144. X
  145. X
  146. /*************************************************************************
  147. X * Function: HelpCB ()
  148. X * Purpose: bring up a help dialog
  149. X * In parameters: w, help_msg, call_data
  150. X * Out parameters:
  151. X * Precondition: button in a help menu has been pressed
  152. X * Postcondition: help dialog with close button showing
  153. X ************************************************************************/ 
  154. X
  155. /* ARGSUSED */
  156. void HelpCB 
  157. #ifdef UseFunctionPrototypes
  158. X    (Widget w, XtPointer client_data, XtPointer call_data)
  159. #else
  160. X    (w, client_data, call_data)  
  161. Widget        w;        /*  widget id        */ 
  162. XXtPointer    client_data;    /*  data from applicaiton   */ 
  163. XXtPointer    call_data;    /*  data from widget class  */ 
  164. X
  165. #endif
  166. {
  167. X    Widget    message_box;        /*  MessageBox        */ 
  168. X    char *    help_msg = (char *) client_data; /*  data from applicaiton   */ 
  169. X
  170. X    /*    Create help window. 
  171. X    */ 
  172. X    message_box = CreateHelp (w, help_msg); 
  173. X    /*    Display help window. 
  174. X    */ 
  175. X    XtManageChild (message_box); 
  176. }
  177. /*************************************************************************
  178. X * Function: CloseCB()
  179. X * Purpose: destroy a dialog
  180. X * In parameters: w, client_data, call_data
  181. X * Out parameters:
  182. X * Precondition; Close button pressed in dialog
  183. X * Postcondition: dialog destroyed
  184. X ************************************************************************/ 
  185. X
  186. /* ARGSUSED */
  187. static void
  188. CloseCB  
  189. #ifdef UseFunctionPrototypes
  190. X    (Widget w, XtPointer client_data, XtPointer call_data)
  191. #else
  192. X    (w, client_data, call_data)  
  193. X    Widget        w;        /*  widget id        */ 
  194. X    XtPointer        client_data;    /*  font pointer    */ 
  195. X    XtPointer        call_data;    /*  data from widget class  */ 
  196. X
  197. #endif
  198. X    Widget        shell    = XtParent (w); 
  199. X    /*    Unmanage and destroy widgets. 
  200. X    */ 
  201. X    XtUnmanageChild (w); 
  202. X    XtDestroyWidget (shell); 
  203. X
  204. /*------------------------------------------------------------- 
  205. **        CreateHelp        - create help window 
  206. */ 
  207. /*************************************************************************
  208. X * Function: CreateHelp ()
  209. X * Purpose: create an unmanaged help dialog
  210. X * In parameters: parent, message
  211. X * Out parameters:
  212. X * Precondition: parent is non-null widget, message is non-null help string
  213. X * Postcondition: popup dialog showing help string exists 
  214. X *                in unmanaged state
  215. X ************************************************************************/ 
  216. X
  217. static Widget
  218. CreateHelp 
  219. #ifdef UseFunctionPrototypes
  220. X    (Widget parent, char *message)
  221. #else
  222. X    (parent, message)  
  223. X    Widget    parent;        /*  parent widget    */ 
  224. X    char *    message;    /* help message */
  225. X
  226. #endif
  227. X    Widget        button; 
  228. X    Widget        message_box;    /*  Message Dialog     */ 
  229. X    Arg        args[MAX_ARGS];    /*  arg list        */ 
  230. X    register int    n;        /*  arg count        */ 
  231. X    XmString    title_string; 
  232. X    XmString    message_string; 
  233. X    XmString    button_string; 
  234. X    /*    Set up strings
  235. X    */
  236. X    message_string = XmStringCreateLtoR (message, XmSTRING_DEFAULT_CHARSET); 
  237. X    button_string = XmStringCreateLtoR ("Close", XmSTRING_DEFAULT_CHARSET); 
  238. X    title_string = XmStringCreateLtoR ("xmfm help", XmSTRING_DEFAULT_CHARSET); 
  239. X
  240. X    /*    Create MessageBox dialog. 
  241. X    */ 
  242. X    n = 0; 
  243. X    XtSetArg (args[n], XmNdialogTitle, title_string);  n++; 
  244. X    XtSetArg (args[n], XmNokLabelString, button_string);  n++; 
  245. X    XtSetArg (args[n], XmNmessageString, message_string);  n++; 
  246. X    message_box = XmCreateMessageDialog (parent, "helpbox", args, n); 
  247. X
  248. X    XtAddCallback(message_box, XmNokCallback, CloseCB, NULL);
  249. X
  250. X     /* lose unwanted buttons 
  251. X    */
  252. X    button = XmMessageBoxGetChild (message_box, 
  253. X            XmDIALOG_CANCEL_BUTTON); 
  254. X    XtUnmanageChild (button); 
  255. X    button = XmMessageBoxGetChild (message_box, 
  256. X            XmDIALOG_HELP_BUTTON); 
  257. X    XtUnmanageChild (button); 
  258. X    /*    Free strings and return MessageBox. 
  259. X    */ 
  260. X    if (title_string) XtFree (title_string); 
  261. X    if (message_string) XtFree (message_string); 
  262. X    if (button_string) XtFree (button_string); 
  263. X    return (message_box); 
  264. }
  265. X
  266. SHAR_EOF
  267. chmod 0644 xmfm/help.c ||
  268. echo 'restore of xmfm/help.c failed'
  269. Wc_c="`wc -c < 'xmfm/help.c'`"
  270. test 6013 -eq "$Wc_c" ||
  271.     echo 'xmfm/help.c: original size 6013, current size' "$Wc_c"
  272. rm -f _shar_wnt_.tmp
  273. fi
  274. # ============= xmfm/help_mes.c ==============
  275. if test -f 'xmfm/help_mes.c' -a X"$1" != X"-c"; then
  276.     echo 'x - skipping xmfm/help_mes.c (File already exists)'
  277.     rm -f _shar_wnt_.tmp
  278. else
  279. > _shar_wnt_.tmp
  280. echo 'x - extracting xmfm/help_mes.c (Text)'
  281. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/help_mes.c' &&
  282. /*************************************************************************
  283. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/help_mes.c,v $
  284. X * Author: Jan Newmarch
  285. X * Last modified: $Date: 1992/11/17 00:35:46 $
  286. X * Version: $Revision: 1.7 $
  287. X * Purpose: file of help messages
  288. X *
  289. X * Revision history:
  290. X ************************************************************************/ 
  291. X
  292. #include "copyright.h"
  293. X
  294. /*************************************************************************
  295. X * System includes
  296. X ************************************************************************/ 
  297. X
  298. /*************************************************************************
  299. X * Local includes
  300. X ************************************************************************/ 
  301. X
  302. /*************************************************************************
  303. X * Functions exported
  304. X ************************************************************************/ 
  305. X
  306. /*************************************************************************
  307. X * Variables exported
  308. X ************************************************************************/ 
  309. extern char help_applic_text[]; 
  310. extern char help_menu_text[];
  311. extern char help_mouse_text[];  
  312. extern char help_keyboard_text[];
  313. extern char help_about_text[];
  314. extern char help_filter_text[];
  315. extern char help_bugs_text[];
  316. X
  317. /*************************************************************************
  318. X * Extern variables
  319. X ************************************************************************/ 
  320. X
  321. /*************************************************************************
  322. X * Extern functions
  323. X ************************************************************************/ 
  324. X
  325. /*************************************************************************
  326. X * Forward functions
  327. X ************************************************************************/ 
  328. X
  329. /*************************************************************************
  330. X * Local variables
  331. X ************************************************************************/ 
  332. /*    This is the text for the application help button in the main menu
  333. */
  334. char help_applic_text[] = 
  335. "xmfm is a file manager, that displays files in a directory.\n\
  336. The screen is divided into buttons on the left signalling\n\
  337. actions that you can perform on files, and three panes on\n\
  338. the right containing executable files, ordinary files and\n\
  339. directories resepectively. By selecting a file, you can choose\n\
  340. an action on it from the buttons on the left. Double clicking\n\
  341. on a file performs the default (first) action.\n\
  342. ";
  343. X
  344. /*    This is the text for the menu help button in the main menu
  345. */
  346. char help_menu_text[] = 
  347. "The menu buttons are \n\
  348. File \n\
  349. X - New file: create a new file in the directory\n\
  350. X - New directory: create a new directory\n\
  351. X - Close: close the current directory pane\n\
  352. X - Exit: terminate xmfm\n\
  353. \n\
  354. Goto\n\
  355. X - Chdir Home: change to home directory\n\
  356. X - Chdir directory...: change to a new directry\n\
  357. X - Open Home: open a new pane in the home directory\n\
  358. X - Open directory...: open a new pane in a new directory\n\
  359. ";
  360. X            
  361. X
  362. /*    This is the text for the mouse help button in the main menu
  363. */
  364. char help_mouse_text[] =  
  365. "Select a file by clickin on it.\n\
  366. Select an action by clicking on it.\n\
  367. Double click on a file to get the\n\
  368. default action (the first one).\n\
  369. Resize the panes by dragging the sash\n\
  370. to the right at the top of each pane.\n\
  371. ";
  372. X
  373. /*      This is the text for the filter help button in the main menu
  374. */
  375. char help_filter_text[] =
  376. "Filters control which files and directories are displayed.\n\
  377. They use shell pattern matches. Common filters are\n\
  378. X   *      matches any string (including the empty string)\n\
  379. X   ?      matches any single character\n\
  380. X   [...]  matches any one of the characters ...\n\
  381. X   [^...] matches anything except one of the characters ...\n\
  382. Examples:\n\
  383. X   *      all files are matched\n\
  384. X   *.c    all files ending in .c are matched\n\
  385. X   *.[ch] all files ending in .c or in .h are matched\n\
  386. X   [^.]*  all files except those beginning with . are matched\n\
  387. ";
  388. X  
  389. /*    This is the text for the keyboard help button in the main menu
  390. */
  391. char help_keyboard_text[] =
  392. "The Meta key is the `diamond' key either\n\
  393. side of the space bar. Press this in conjunction\n\
  394. with ordinary keys to get hot-key menu actions.\n\
  395. For example, Meta+H move to you Home directory.\n\
  396. \n\
  397. Press F1 to get context sensitive help\n\
  398. on any part of xmfm (not implemented)\n\
  399. ";
  400. X
  401. char help_about_text[] = "\
  402. X  xmfm (X/Motif file manager)\n\
  403. X         Version 1.6\n\
  404. X Copyright 1992 J.D. Newmarch\n\
  405. email: jan@ise.canberra.edu.au";
  406. X
  407. char help_bugs_text[] = "\
  408. If you find any new bugs in xmfm, please use email\n\
  409. to send them to\n\
  410. X        jan@pandonia\n\
  411. or\n\
  412. X        jan@ise.canberra.edu.au\n\
  413. \n\
  414. Currently known bugs/problems include:\n\
  415. X - drag and drop does not work.\n\
  416. X - when xmfm is resized horizontally, the number of\n\
  417. X   columns of files shown does not change to use\n\
  418. X   the new width.\n\
  419. X - when run across a network, a \"Run xterm\" does\n\
  420. X   not pick up the server you are using unless \n\
  421. X   the DISPLAY variable is set.\n\
  422. X - context sensitive help does not work.\n\
  423. X - $n patterns are not dealt with in Run commands\n\
  424. X - The shell used in Run is the Bourne shell only\n\
  425. ";
  426. SHAR_EOF
  427. chmod 0644 xmfm/help_mes.c ||
  428. echo 'restore of xmfm/help_mes.c failed'
  429. Wc_c="`wc -c < 'xmfm/help_mes.c'`"
  430. test 5243 -eq "$Wc_c" ||
  431.     echo 'xmfm/help_mes.c: original size 5243, current size' "$Wc_c"
  432. rm -f _shar_wnt_.tmp
  433. fi
  434. # ============= xmfm/info.c ==============
  435. if test -f 'xmfm/info.c' -a X"$1" != X"-c"; then
  436.     echo 'x - skipping xmfm/info.c (File already exists)'
  437.     rm -f _shar_wnt_.tmp
  438. else
  439. > _shar_wnt_.tmp
  440. echo 'x - extracting xmfm/info.c (Text)'
  441. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/info.c' &&
  442. /*************************************************************************
  443. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/info.c,v $
  444. X * Author: Jan Newmarch
  445. X * Last modified: $Date: 1992/11/17 00:35:47 $
  446. X * Version: $Revision: 1.2 $
  447. X * Purpose:
  448. X *
  449. X * Revision history:
  450. X *      22 Aug 92      made info dialog a per pane object, accessible via dpi
  451. X *    8  Sep 92      fixed bug that used run dialog instead of info dialog
  452. X *       3 Nov 92      lint-ed
  453. X *    11 Nov 92      follow symbolic links to actual info, ignore link file
  454. X *    12 Nov 92      file permissions can now be edited
  455. X ************************************************************************/ 
  456. X
  457. #include "copyright.h"
  458. X
  459. /*************************************************************************
  460. X * System includes
  461. X ************************************************************************/ 
  462. #include <pwd.h>
  463. #include <string.h>
  464. #include <Xm/SelectioB.h>
  465. #include <Xm/Label.h>
  466. #include <Xm/ToggleB.h>
  467. #include <Xm/RowColumn.h>
  468. #include <Xm/Form.h>
  469. #include <sys/types.h>
  470. #include <sys/stat.h>
  471. X
  472. /*************************************************************************
  473. X * Local includes
  474. X ************************************************************************/ 
  475. #include "const.h"
  476. #include "types.h"
  477. #include "xmvararg.h"
  478. #include "DirMgr.h"
  479. X
  480. /*************************************************************************
  481. X * Functions exported
  482. X ************************************************************************/ 
  483. void builtin_info (
  484. #ifdef UseFunctionPrototypes
  485. X    dir_pane_info *dpi
  486. #endif
  487. );
  488. X
  489. /*************************************************************************
  490. X * Variables exported
  491. X ************************************************************************/ 
  492. X
  493. /*************************************************************************
  494. X * Extern variables
  495. X ************************************************************************/ 
  496. X
  497. /*************************************************************************
  498. X * Extern functions
  499. X ************************************************************************/ 
  500. extern void WarningDialog (
  501. #ifdef UseFunctionPrototypes
  502. X    Widget parent, char *prompt, int modal, int *answer
  503. #endif
  504. );
  505. X
  506. /*************************************************************************
  507. X * Forward functions
  508. X ************************************************************************/ 
  509. X
  510. /*************************************************************************
  511. X * Local variables
  512. X ************************************************************************/ 
  513. #define EXECUTABLE(m)    ((m) & (S_IXUSR | S_IXGRP | S_IXOTH))
  514. static Widget    dialog = NULL;
  515. X
  516. /* its a bit gross having these all as static, but we have to keep them
  517. X   around somewhere if we are going to reuse the dialog instead of 
  518. X   recreating it each time
  519. */
  520. static    Widget    form,
  521. X                filename_label,
  522. X        filename,
  523. X                separator,
  524. X        size_label,
  525. X        size,
  526. X        owner_label,
  527. X        owner,
  528. X        description_label,
  529. X        description,
  530. X        perms_label,
  531. X        perms_rowcol,
  532. X        empty_label,
  533. X        read_label,
  534. X        write_label,
  535. X                exec_label,
  536. X        user_label,
  537. X        group_label,
  538. X        other_label,
  539. X        ur_toggle,
  540. X        uw_toggle,
  541. X        ux_toggle,
  542. X        gr_toggle,
  543. X        gw_toggle,
  544. X        gx_toggle,
  545. X        or_toggle,
  546. X        ow_toggle,
  547. X        ox_toggle;
  548. X
  549. static Bool mode_changed;    /* has the user changed file mode? */
  550. X
  551. /*************************************************************************
  552. X * Function       : OkCB ()
  553. X * Purpose         : change file mode if needed when ok button pressed
  554. X * In parameters   : w, client_data, call_data
  555. X * Out parameters  :
  556. X * Side effects    : 
  557. X * Function returns:
  558. X * Precondition    : 
  559. X * Postcondition   :
  560. X ************************************************************************/ 
  561. static void
  562. OkCB 
  563. #ifdef UseFunctionPrototypes
  564. X    (Widget w, XtPointer client_data, XtPointer call_data)
  565. #else
  566. X    (w, client_data, call_data)
  567. X    Widget w;
  568. X    XtPointer client_data;
  569. X    XtPointer call_data;
  570. X
  571. #endif
  572. {
  573. X    dir_pane_info *dpi;
  574. X    DirEntry *de;
  575. X    Boolean button_set;
  576. X    Arg args[1];
  577. X    char *file_selected;
  578. X    mode_t new_mode, old_mode;
  579. X
  580. #ifdef DEBUG
  581. X    fprintf ("mode_changed: %d\n", mode_changed);
  582. #endif
  583. X    if ( !mode_changed)
  584. X        return;
  585. X        
  586. X    new_mode = 0;
  587. X    /* build the new mode from the state of the mode buttons */
  588. X    XtSetArg (args[0], XmNset, &button_set);
  589. X    XtGetValues (ur_toggle, args, 1);
  590. X    if (button_set)
  591. X        new_mode |= S_IRUSR;
  592. X    XtGetValues (uw_toggle, args, 1);
  593. X    if (button_set)
  594. X        new_mode |= S_IWUSR;
  595. X    XtGetValues (ux_toggle, args, 1);
  596. X    if (button_set)
  597. X        new_mode |= S_IXUSR;
  598. X    XtGetValues (gr_toggle, args, 1);
  599. X    if (button_set)
  600. X        new_mode |= S_IRGRP;
  601. X    XtGetValues (gw_toggle, args, 1);
  602. X    if (button_set)
  603. X        new_mode |= S_IWGRP;
  604. X    XtGetValues (gx_toggle, args, 1);
  605. X    if (button_set)
  606. X        new_mode |= S_IXGRP;
  607. X    XtGetValues (or_toggle, args, 1);
  608. X    if (button_set)
  609. X        new_mode |= S_IROTH;
  610. X    XtGetValues (ow_toggle, args, 1);
  611. X    if (button_set)
  612. X        new_mode |= S_IWOTH;
  613. X    XtGetValues (ox_toggle, args, 1);
  614. X    if (button_set)
  615. X        new_mode |= S_IXOTH;
  616. X
  617. X    XtVaGetValues (w,
  618. X        XmNuserData, (XtArgVal) &dpi,
  619. X        NULL);
  620. X
  621. X    file_selected = dpi -> file_selected;
  622. X    DirectoryMgrGotoNamedItem (dpi -> directory_manager,
  623. X                    file_selected);
  624. X    de = DirectoryMgrCurrentEntry (dpi -> directory_manager);
  625. X
  626. X    /* has the user really made it different? */
  627. X    if (new_mode == FileInfoProt (DirEntryActualInfo (de)))
  628. X        return;        /* no they didn't */
  629. X
  630. X    /* actually change the mode */
  631. X    if (chmod (file_selected, new_mode) == -1)
  632. X        return;     /* oh well, couldn't change it */
  633. X
  634. X    /* reset our stored info */
  635. X    old_mode = FileInfoProt (DirEntryActualInfo (de));
  636. X    FileInfoProt (DirEntryActualInfo (de)) = new_mode;
  637. X
  638. X    /* if it is a dir, nothing left to do.
  639. X       if it is now executable but wasn't before, or vice
  640. X       versa, need to refresh panes
  641. X    */
  642. X    if (DirEntryIsDir (de) ||
  643. X        DirEntryIsSymLink (de) &&
  644. X            S_ISDIR (FileInfoOrigMode (DirEntryActualInfo (de))))
  645. X        return;
  646. X    if ((EXECUTABLE (old_mode) && ! EXECUTABLE (new_mode)) ||
  647. X        ( ! EXECUTABLE (old_mode) && EXECUTABLE (new_mode)))
  648. X        ResetPanesAndSelectFile (dpi, dpi -> file_selected);
  649. }
  650. X
  651. /*************************************************************************
  652. X * Function       : toggleCB ()
  653. X * Purpose         : set mode_changed to true
  654. X * In parameters   : w, client_data, call_data
  655. X * Out parameters  :
  656. X * Side effects    : 
  657. X * Function returns:
  658. X * Precondition    : 
  659. X * Postcondition   :
  660. X ************************************************************************/ 
  661. void
  662. toggleCB 
  663. #ifdef UseFunctionPrototypes
  664. X    (Widget w, XtPointer client_data, XtPointer call_data)
  665. #else
  666. X    (w, client_data, call_data)
  667. X    Widget w;
  668. X    XtPointer client_data;
  669. X    XtPointer call_data;
  670. X
  671. #endif
  672. {
  673. X    mode_changed = True;
  674. }
  675. X
  676. /*************************************************************************
  677. X * Function       : builtin_info ()
  678. X * Purpose         : display info on a file, such as size, permissions, etc
  679. X * In parameters   : dpi
  680. X * Out parameters  :
  681. X * Side effects    : creates and shows a file display dialog
  682. X * Function returns:
  683. X * Precondition    : 
  684. X * Postcondition   :
  685. X ************************************************************************/ 
  686. void
  687. builtin_info 
  688. #ifdef UseFunctionPrototypes
  689. X    (dir_pane_info *dpi)
  690. #else
  691. X    (dpi)
  692. X    dir_pane_info *dpi;
  693. X
  694. #endif
  695. {    
  696. X    DirEntry    *de;
  697. X    long        long_size;
  698. X    char        str_size[1024];
  699. X    XmString    xm_size;
  700. X    int        uid;
  701. X    struct passwd    *pw_entry;
  702. X    XmString    xm_pw_name;
  703. X    XmString    xm_file_selected;
  704. X        XmString        xm_description;
  705. X        static XmString    xm_empty;
  706. X    static short        permissions;
  707. X    static Bool        state;
  708. X    int        dummy;
  709. X    
  710. X
  711. X    if (dpi -> file_selected == NULL)
  712. X    {    WarningDialog (dpi -> toplevel,
  713. X            "Can only show information on a selected file",
  714. X            True, &dummy);
  715. X        return;
  716. X    }
  717. X        dialog = dpi -> info_dialog;
  718. X
  719. X    if (dialog == NULL)
  720. X    {
  721. X        xm_empty = XmStringCreateSimple ("");
  722. X        /* create a "prompt" dialog with the prompt bits left out */
  723. X        dialog = XmVaCreatePromptDialog (dpi -> file_button_selected,
  724. X                    "information",
  725. X                    NULL);
  726. X                dpi -> info_dialog = dialog;
  727. X        XtUnmanageChild ( 
  728. X            XmSelectionBoxGetChild (dialog, XmDIALOG_TEXT));
  729. X        XtUnmanageChild ( 
  730. X            XmSelectionBoxGetChild (dialog, XmDIALOG_SELECTION_LABEL));
  731. X        XtUnmanageChild ( 
  732. X            XmSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
  733. X
  734. X        XtAddCallback (dialog, XmNokCallback, OkCB, NULL);
  735. X    
  736. X        /* add the widget we want as the work area */
  737. X        form = XmVaCreateForm (dialog, "form",
  738. X                NULL);
  739. X        
  740. X        /* put stuff in the form */
  741. X        filename_label = XmVaCreateLabel (form, "Filename",
  742. X                NULL);
  743. #ifdef  FILENAME_IS_EDITABLE
  744. X        /* uses text string - in case we want to change filename.
  745. X           but it makes geometry harder */
  746. X        filename = XmVaCreateText (form, "filename",
  747. X                                XmNeditable, (XtArgVal) False,
  748. X                NULL);
  749. #else
  750. X        filename = XmVaCreateLabel (form, "filename",
  751. X                NULL);
  752. #endif /* FILENAME_IS_EDITABLE */
  753. X                separator = XmVaCreateSeparator (form, "separator",
  754. X                                XmNseparatorType, (XtArgVal) XmNO_LINE,
  755. X                                NULL);
  756. X        size_label = XmVaCreateLabel (form, "Size",
  757. X                NULL);
  758. X        size = XmVaCreateLabel (form, "size",
  759. X                NULL);
  760. X        owner_label = XmVaCreateLabel (form, "Owner",
  761. X                NULL);
  762. X        owner = XmVaCreateLabel (form, "owner",
  763. X                NULL);
  764. X        description_label = XmVaCreateLabel (form, "Description",
  765. X                NULL);
  766. X        description = XmVaCreateLabel (form, "description",
  767. X                                XmNalignment, (XtArgVal) XmALIGNMENT_BEGINNING,
  768. X                NULL);
  769. X        perms_label = XmVaCreateLabel (form, "Permissions",
  770. X                NULL);
  771. X        perms_rowcol = XmVaCreateForm (form, "perms_rowcol",
  772. /*                XmNpacking,     (XtArgVal) XmPACK_COLUMN,
  773. X                XmNnumColumns,  (XtArgVal) 4,
  774. X                XmNborderWidth, (XtArgVal) 1,
  775. X                                XmNisAligned,   (XtArgVal) False,
  776. */
  777. X                NULL);
  778. X        
  779. X        /* put stuff in the row col */
  780. X        empty_label = XmVaCreateLabel (perms_rowcol, "empty",
  781. X                NULL);
  782. X        read_label = XmVaCreateLabel (perms_rowcol, "read",
  783. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  784. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  785. X                                XmNtopPosition,    (XtArgVal) 25,
  786. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  787. X                                XmNleftPosition,   (XtArgVal) 0,
  788. X                                XmNrightAttachment,(XtArgVal) XmATTACH_POSITION,
  789. X                                XmNrightPosition,  (XtArgVal) 25,
  790. X                NULL);
  791. X        write_label = XmVaCreateLabel (perms_rowcol, "write",
  792. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  793. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  794. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  795. X                                XmNtopPosition,    (XtArgVal) 50,
  796. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  797. X                                XmNleftPosition,   (XtArgVal) 0,
  798. X                                XmNrightAttachment,(XtArgVal) XmATTACH_POSITION,
  799. X                                XmNrightPosition,  (XtArgVal) 25,
  800. X                NULL);
  801. X        exec_label = XmVaCreateLabel (perms_rowcol, "execute",
  802. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  803. X                                 XmNtopAttachment, (XtArgVal) XmATTACH_POSITION,
  804. X                                XmNtopPosition,    (XtArgVal) 75,
  805. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  806. X                                XmNleftPosition,   (XtArgVal) 0,
  807. X                                XmNrightAttachment,(XtArgVal) XmATTACH_POSITION,
  808. X                                XmNrightPosition,  (XtArgVal) 25,
  809. X                NULL);
  810. X    
  811. X        user_label = XmVaCreateLabel (perms_rowcol, "user",
  812. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  813. X                                XmNtopPosition,    (XtArgVal) 0,
  814. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  815. X                                XmNleftPosition,   (XtArgVal) 25,
  816. X                NULL);
  817. X        ur_toggle = XmVaCreateToggleButton (perms_rowcol, "ur",
  818. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  819. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  820. X                                XmNtopPosition,    (XtArgVal) 25,
  821. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  822. X                                XmNleftPosition,   (XtArgVal) 28,
  823. X                NULL);
  824. X        uw_toggle = XmVaCreateToggleButton (perms_rowcol, "uw",
  825. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  826. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  827. X                                XmNtopPosition,    (XtArgVal) 50,
  828. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  829. X                                XmNleftPosition,   (XtArgVal) 28,
  830. X                NULL);
  831. X        ux_toggle = XmVaCreateToggleButton (perms_rowcol, "ux",
  832. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  833. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  834. X                                XmNtopPosition,    (XtArgVal) 75,
  835. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  836. X                                XmNleftPosition,   (XtArgVal) 28,
  837. X                NULL);
  838. X
  839. X        group_label = XmVaCreateLabel (perms_rowcol, "group",
  840. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  841. X                                XmNtopPosition,    (XtArgVal) 0,
  842. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  843. X                                XmNleftPosition,   (XtArgVal) 50,
  844. X                NULL);
  845. X        gr_toggle = XmVaCreateToggleButton (perms_rowcol, "gr",
  846. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  847. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  848. X                                XmNtopPosition,    (XtArgVal) 25,
  849. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  850. X                                XmNleftPosition,   (XtArgVal) 53,
  851. X                NULL);
  852. X        gw_toggle = XmVaCreateToggleButton (perms_rowcol, "gw",
  853. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  854. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  855. X                                XmNtopPosition,    (XtArgVal) 50,
  856. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  857. X                                XmNleftPosition,   (XtArgVal) 53,
  858. X                NULL);
  859. X        gx_toggle = XmVaCreateToggleButton (perms_rowcol, "gx",
  860. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  861. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  862. X                                XmNtopPosition,    (XtArgVal) 75,
  863. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  864. X                                XmNleftPosition,   (XtArgVal) 53,
  865. X                NULL);
  866. X
  867. X        other_label = XmVaCreateLabel (perms_rowcol, "other",
  868. X                                XmNalignment, (XtArgVal) XmALIGNMENT_BEGINNING,
  869. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  870. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  871. X                                XmNtopPosition,    (XtArgVal) 0,
  872. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  873. X                                XmNleftPosition,   (XtArgVal) 75,
  874. X                NULL);
  875. X        or_toggle = XmVaCreateToggleButton (perms_rowcol, "or",
  876. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  877. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  878. X                                XmNtopPosition,    (XtArgVal) 25,
  879. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  880. X                                XmNleftPosition,   (XtArgVal) 78,
  881. X                NULL);
  882. X        ow_toggle = XmVaCreateToggleButton (perms_rowcol, "ow",
  883. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  884. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  885. X                                XmNtopPosition,    (XtArgVal) 50,
  886. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  887. X                                XmNleftPosition,   (XtArgVal) 78,
  888. X                NULL);
  889. X        ox_toggle = XmVaCreateToggleButton (perms_rowcol, "ox",
  890. X                                XmNalignment, (XtArgVal) XmALIGNMENT_END,
  891. X                                XmNtopAttachment,  (XtArgVal) XmATTACH_POSITION,
  892. X                                XmNtopPosition,    (XtArgVal) 75,
  893. X                                XmNleftAttachment, (XtArgVal) XmATTACH_POSITION,
  894. X                                XmNleftPosition,   (XtArgVal) 78,
  895. X                NULL);
  896. X
  897. X                /* make all these buttons insensitive */
  898. /*
  899. X                XtSetSensitive (ur_toggle, False);
  900. X                XtSetSensitive (uw_toggle, False);
  901. X                XtSetSensitive (ux_toggle, False);
  902. X                XtSetSensitive (gr_toggle, False);
  903. X                XtSetSensitive (gw_toggle, False);
  904. X                XtSetSensitive (gx_toggle, False);
  905. X                XtSetSensitive (or_toggle, False);
  906. X                XtSetSensitive (ow_toggle, False);
  907. X                XtSetSensitive (ox_toggle, False);
  908. */
  909. X        /* callbacks */
  910. X        XtAddCallback (ur_toggle, XmNarmCallback, toggleCB, NULL);
  911. X        XtAddCallback (uw_toggle, XmNarmCallback, toggleCB, NULL);
  912. X        XtAddCallback (ux_toggle, XmNarmCallback, toggleCB, NULL);
  913. X        XtAddCallback (gr_toggle, XmNarmCallback, toggleCB, NULL);
  914. X        XtAddCallback (gw_toggle, XmNarmCallback, toggleCB, NULL);
  915. X        XtAddCallback (gx_toggle, XmNarmCallback, toggleCB, NULL);
  916. X        XtAddCallback (or_toggle, XmNarmCallback, toggleCB, NULL);
  917. X        XtAddCallback (ow_toggle, XmNarmCallback, toggleCB, NULL);
  918. X        XtAddCallback (ox_toggle, XmNarmCallback, toggleCB, NULL);
  919. X    
  920. X    
  921. X        /* manage the lot */
  922. X        XtManageChild (filename_label);
  923. X        XtManageChild (filename);
  924. X                XtManageChild (separator);
  925. X        XtManageChild (size_label);
  926. X        XtManageChild (size);
  927. X        XtManageChild (owner_label);
  928. X        XtManageChild (owner);
  929. X        XtManageChild (description_label);
  930. X        XtManageChild (description);
  931. X        XtManageChild (perms_label);
  932. X        XtManageChild (empty_label);
  933. X        XtManageChild (read_label);
  934. X        XtManageChild (write_label);
  935. X                XtManageChild (exec_label);
  936. X        XtManageChild (user_label);
  937. X        XtManageChild (group_label);
  938. X        XtManageChild (other_label);
  939. X        XtManageChild (ur_toggle);
  940. X        XtManageChild (uw_toggle);
  941. X        XtManageChild (ux_toggle);
  942. X        XtManageChild (gr_toggle);
  943. X        XtManageChild (gw_toggle);
  944. X        XtManageChild (gx_toggle);
  945. X        XtManageChild (or_toggle);
  946. X        XtManageChild (ow_toggle);
  947. X        XtManageChild (ox_toggle);
  948. X        XtManageChild (perms_rowcol);
  949. X        XtManageChild (form);
  950. X    
  951. X        /* the geometry for this mess */
  952. X        XtVaSetValues (filename_label,
  953. X            XmNtopAttachment,    (XtArgVal) XmATTACH_FORM,
  954. X            XmNrightAttachment,    (XtArgVal) XmATTACH_POSITION,
  955. X            XmNrightPosition,    (XtArgVal) 40,
  956. X            NULL);
  957. X        XtVaSetValues (filename,
  958. X            XmNtopAttachment,    (XtArgVal) XmATTACH_FORM,
  959. X            XmNleftAttachment,    (XtArgVal) XmATTACH_POSITION,
  960. X            XmNleftPosition,        (XtArgVal) 41,
  961. X                        NULL);
  962. X        XtVaSetValues (separator,
  963. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  964. X            XmNtopWidget,            (XtArgVal) filename,
  965. X            NULL);
  966. X        XtVaSetValues (size_label,
  967. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  968. X            XmNtopWidget,        (XtArgVal) separator,
  969. X            XmNleftAttachment,    (XtArgVal) XmATTACH_FORM,
  970. X            NULL);
  971. X        XtVaSetValues (size,
  972. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  973. X            XmNtopWidget,        (XtArgVal) separator,
  974. X            XmNleftAttachment,    (XtArgVal) XmATTACH_WIDGET,
  975. X                        XmNleftWidget,          (XtArgVal) size_label,
  976. X             XmNrightAttachment,    (XtArgVal) XmATTACH_POSITION,
  977. X            XmNrightPosition,    (XtArgVal) 48,
  978. X            NULL);
  979. X        XtVaSetValues (owner_label,
  980. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  981. X            XmNtopWidget,        (XtArgVal) separator,
  982. X            XmNleftAttachment,    (XtArgVal) XmATTACH_POSITION,
  983. X            XmNleftPosition,        (XtArgVal) 50,
  984. X            NULL);
  985. X        XtVaSetValues (owner,
  986. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  987. X            XmNtopWidget,        (XtArgVal) separator,
  988. X            XmNleftAttachment,    (XtArgVal) XmATTACH_WIDGET,
  989. X            XmNleftWidget,        (XtArgVal) owner_label,
  990. X            NULL);
  991. X        XtVaSetValues (description_label,
  992. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  993. X            XmNtopWidget,        (XtArgVal) size_label,
  994. X            XmNleftAttachment,    (XtArgVal) XmATTACH_FORM,
  995. X            NULL);
  996. X        XtVaSetValues (description,
  997. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  998. X            XmNtopWidget,        (XtArgVal) size_label,
  999. X            XmNleftAttachment,    (XtArgVal) XmATTACH_WIDGET,
  1000. X            XmNleftWidget,        (XtArgVal) description_label,
  1001. X            XmNrightAttachment,    (XtArgVal) XmATTACH_FORM,
  1002. X            NULL);
  1003. X        XtVaSetValues (perms_label,
  1004. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  1005. X            XmNtopWidget,        (XtArgVal) description_label,
  1006. X            XmNleftAttachment,    (XtArgVal) XmATTACH_FORM,
  1007. X            NULL);
  1008. X        XtVaSetValues (perms_rowcol,
  1009. X            XmNtopAttachment,    (XtArgVal) XmATTACH_WIDGET,
  1010. X            XmNtopWidget,        (XtArgVal) perms_label,
  1011. X            XmNleftAttachment,    (XtArgVal) XmATTACH_FORM,
  1012. X            XmNrightAttachment,    (XtArgVal) XmATTACH_FORM,
  1013. X                        XmNbottomAttachment,    (XtArgVal) XmATTACH_FORM,
  1014. X            NULL);
  1015. X
  1016. X               /* save all these component widgets in info_dialog_widgets */
  1017. X               dpi -> idw = (info_dialog_widgets *) XtMalloc (sizeof (info_dialog_widgets));
  1018. X               dpi -> idw -> filename = filename;
  1019. X               dpi -> idw -> size = size;
  1020. X               dpi -> idw -> owner = owner;
  1021. X               dpi -> idw -> description = description;
  1022. X               dpi -> idw -> empty_label = empty_label;
  1023. X               dpi -> idw -> ur_toggle = ur_toggle;
  1024. X               dpi -> idw -> uw_toggle = uw_toggle;
  1025. X               dpi -> idw -> ux_toggle = ux_toggle;
  1026. X               dpi -> idw -> gr_toggle = gr_toggle;
  1027. X               dpi -> idw -> gw_toggle = gw_toggle;
  1028. X               dpi -> idw -> gx_toggle = gx_toggle;
  1029. X               dpi -> idw -> or_toggle = or_toggle;
  1030. X               dpi -> idw -> ow_toggle = ow_toggle;
  1031. X               dpi -> idw -> ox_toggle = ox_toggle;
  1032. X    }
  1033. X        else
  1034. X        {   /* get all these widgets back out of dpi */
  1035. X               filename = dpi -> idw -> filename;
  1036. X               size = dpi -> idw -> size;
  1037. X               owner = dpi -> idw -> owner;
  1038. X               description = dpi -> idw -> description;
  1039. X               empty_label = dpi -> idw -> empty_label;
  1040. X               ur_toggle = dpi -> idw -> ur_toggle;
  1041. X               uw_toggle = dpi -> idw -> uw_toggle;
  1042. X               ux_toggle = dpi -> idw -> ux_toggle;
  1043. X               gr_toggle = dpi -> idw -> gr_toggle;
  1044. X               gw_toggle = dpi -> idw -> gw_toggle;
  1045. X               gx_toggle = dpi -> idw -> gx_toggle;
  1046. X               or_toggle = dpi -> idw -> or_toggle;
  1047. X               ow_toggle = dpi -> idw -> ow_toggle;
  1048. X               ox_toggle = dpi -> idw -> ox_toggle;
  1049. X        }
  1050. X
  1051. X    /* whether just created or new, need to set all the following */
  1052. X    mode_changed = False;
  1053. X
  1054. X    XtVaSetValues (dialog, XmNuserData, dpi, NULL);
  1055. X
  1056. X    /* set file name */
  1057. #ifdef  FILENAME_IS_EDITABLE
  1058. X    XmTextSetString (filename, dpi -> file_selected);
  1059. #else
  1060. X    xm_file_selected = XmStringCreateSimple (dpi -> file_selected);
  1061. X    XtVaSetValues (filename, XmNlabelString, xm_file_selected, NULL);
  1062. X    XmStringFree (xm_file_selected);
  1063. #endif /* FILENAME_IS_EDITABLE */
  1064. X
  1065. X    /* find the file in the DirMgr */
  1066. X    DirectoryMgrGotoNamedItem (dpi -> directory_manager, 
  1067. X                    dpi -> file_selected);
  1068. X    de = DirectoryMgrCurrentEntry (dpi -> directory_manager);
  1069. X    
  1070. X    /* set size */
  1071. /*
  1072. X    long_size = DirEntryFileSize (de);
  1073. */
  1074. X    long_size = FIFileSize (DirEntryActualInfo (de));
  1075. X    sprintf (str_size, "%ld", long_size);
  1076. X    xm_size = XmStringCreateSimple (str_size);
  1077. X    XtVaSetValues (size, XmNlabelString, xm_size, NULL);
  1078. X    XmStringFree (xm_size);
  1079. X
  1080. X    /* set owner */
  1081. /*
  1082. X    uid = DirEntryUserID (de);
  1083. */
  1084. X    uid = FIUserID (DirEntryActualInfo (de));
  1085. X    pw_entry = getpwuid (uid);
  1086. X    xm_pw_name = XmStringCreateSimple (pw_entry -> pw_name);
  1087. X    XtVaSetValues (owner, XmNlabelString, xm_pw_name, NULL);
  1088. X    XmStringFree (xm_pw_name);
  1089. X
  1090. X    /* set description */
  1091. X    /* stub - will set description of file type from xmfmrc
  1092. X       e.g. "C source file"
  1093. X    */
  1094. X        xm_description = XmStringCreateSimple (dpi -> description);
  1095. X    XtVaSetValues (description, XmNlabelString, xm_description, NULL);
  1096. X        XmStringFree (xm_description);
  1097. X
  1098. X    /* set permissions */
  1099. /*
  1100. X    permissions = DirEntryProt (de);
  1101. */
  1102. X    permissions = FIProt (DirEntryActualInfo (de));
  1103. X        XtVaSetValues (empty_label, XmNlabelString, xm_empty, NULL);
  1104. X
  1105. X    state = (permissions & S_IRUSR) ? True : False;
  1106. X        XtVaSetValues (ur_toggle,
  1107. X                        XmNlabelString, xm_empty,
  1108. X            XmNset,     (XtArgVal) state,
  1109. X                        NULL);
  1110. X
  1111. X    state = (permissions & S_IWUSR) ? True : False;
  1112. X        XtVaSetValues (uw_toggle,
  1113. X                        XmNlabelString, xm_empty,
  1114. X            XmNset,     (XtArgVal) state,
  1115. X                        NULL);
  1116. X
  1117. X    state = (permissions & S_IXUSR) ? True : False;
  1118. X        XtVaSetValues (ux_toggle,
  1119. X                        XmNlabelString, xm_empty,
  1120. X            XmNset,     (XtArgVal) state,
  1121. X                        NULL);
  1122. X
  1123. X    state = (permissions & S_IRGRP) ? True : False;
  1124. X        XtVaSetValues (gr_toggle,
  1125. X                        XmNlabelString, xm_empty,
  1126. X            XmNset,     (XtArgVal) state,
  1127. X                        NULL);
  1128. X
  1129. X    state = (permissions & S_IWGRP) ? True : False;
  1130. X        XtVaSetValues (gw_toggle,
  1131. X                        XmNlabelString, xm_empty,
  1132. X            XmNset,     (XtArgVal) state,
  1133. X                        NULL);
  1134. X
  1135. X    state = (permissions & S_IXGRP) ? True : False;
  1136. X        XtVaSetValues (gx_toggle,
  1137. X                        XmNlabelString, xm_empty,
  1138. X            XmNset,     (XtArgVal) state,
  1139. X                        NULL);
  1140. X
  1141. X    state = (permissions & S_IROTH) ? True : False;
  1142. X        XtVaSetValues (or_toggle,
  1143. X                        XmNlabelString, xm_empty,
  1144. X            XmNset,     (XtArgVal) state,
  1145. X                        NULL);
  1146. X
  1147. X    state = (permissions & S_IWOTH) ? True : False;
  1148. X        XtVaSetValues (ow_toggle,
  1149. X                        XmNlabelString, xm_empty,
  1150. X            XmNset,     (XtArgVal) state,
  1151. X                        NULL);
  1152. X
  1153. X    state = (permissions & S_IXOTH) ? True : False;
  1154. X        XtVaSetValues (ox_toggle,
  1155. X                        XmNlabelString, xm_empty,
  1156. X            XmNset,     (XtArgVal) state,
  1157. X                        NULL);
  1158. X
  1159. X        XtManageChild (dialog);
  1160. }
  1161. X
  1162. SHAR_EOF
  1163. chmod 0644 xmfm/info.c ||
  1164. echo 'restore of xmfm/info.c failed'
  1165. Wc_c="`wc -c < 'xmfm/info.c'`"
  1166. test 26269 -eq "$Wc_c" ||
  1167.     echo 'xmfm/info.c: original size 26269, current size' "$Wc_c"
  1168. rm -f _shar_wnt_.tmp
  1169. fi
  1170. # ============= xmfm/main.c ==============
  1171. if test -f 'xmfm/main.c' -a X"$1" != X"-c"; then
  1172.     echo 'x - skipping xmfm/main.c (File already exists)'
  1173.     rm -f _shar_wnt_.tmp
  1174. else
  1175. > _shar_wnt_.tmp
  1176. echo 'x - extracting xmfm/main.c (Text)'
  1177. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/main.c' &&
  1178. /*************************************************************************
  1179. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/main.c,v $
  1180. X * Author: Jan Newmarch
  1181. X * Last modified: $Date: 1992/11/17 00:35:49 $
  1182. X * Version: $Revision: 1.7 $
  1183. X * Purpose: This file contains the main routine. It sets up the geometry
  1184. X *          and calls the Xt main loop.
  1185. X *
  1186. X * Revision history:
  1187. X *    16 Oct 92    caddr_t changed to XtPointer
  1188. X *       3 Nov 92       lint-ed
  1189. X ************************************************************************/ 
  1190. X
  1191. #include "copyright.h"
  1192. X
  1193. /*************************************************************************
  1194. X * System includes
  1195. X ************************************************************************/ 
  1196. #include <stdio.h> 
  1197. #include <string.h> 
  1198. #include <sys/types.h> 
  1199. #include <sys/stat.h> 
  1200. #include <Xm/MainW.h> 
  1201. #include <Xm/MessageB.h> 
  1202. X
  1203. /*************************************************************************
  1204. X * Local includes
  1205. X ************************************************************************/ 
  1206. #include "const.h"
  1207. #include "types.h"
  1208. X
  1209. #ifdef RDD
  1210. #include "rdd.h"
  1211. #endif /* RDD */
  1212. X
  1213. /*************************************************************************
  1214. X * Functions exported
  1215. X ************************************************************************/ 
  1216. extern int main (
  1217. #ifdef UseFunctionPrototypes
  1218. X    unsigned int argc, char **argv
  1219. #endif
  1220. );
  1221. extern void ErrorDialog (
  1222. #ifdef UseFunctionPrototypes
  1223. X    char *str
  1224. #endif
  1225. );
  1226. extern int fatal (
  1227. #ifdef UseFunctionPrototypes
  1228. X    char *s
  1229. #endif
  1230. );
  1231. X
  1232. /*************************************************************************
  1233. X * Variables exported
  1234. X ************************************************************************/ 
  1235. GC gc, gc_reversed;
  1236. file_action *actions;
  1237. XXtAppContext app_context;
  1238. #ifdef RDD
  1239. XXtTranslations trans_table;
  1240. #endif /* RDD */
  1241. X
  1242. /*************************************************************************
  1243. X * Extern variables
  1244. X ************************************************************************/ 
  1245. extern XmString empty_string;
  1246. X
  1247. /*************************************************************************
  1248. X * Extern functions
  1249. X ************************************************************************/ 
  1250. extern Widget    CreateMenu(
  1251. #ifdef UseFunctionPrototypes
  1252. X    Widget parent, XtPointer user_data
  1253. #endif
  1254. );
  1255. extern Widget    CreateApplication (
  1256. #ifdef UseFunctionPrototypes
  1257. X    Widget parent
  1258. #endif
  1259. );
  1260. extern file_action *LoadFileActions (
  1261. #ifdef UseFunctionPrototypes
  1262. X    dir_pane_info *dpi
  1263. #endif
  1264. );
  1265. extern void SetFiltersInLabels (
  1266. #ifdef UseFunctionPrototypes
  1267. X    dir_pane_info *dpi
  1268. #endif
  1269. );
  1270. extern void ResetFilesInPanes (
  1271. #ifdef UseFunctionPrototypes
  1272. X    dir_pane_info *dpi
  1273. #endif
  1274. );
  1275. extern void child_died (
  1276. #ifdef UseFunctionPrototypes
  1277. X    void
  1278. #endif
  1279. );
  1280. X
  1281. #ifdef MOTIF_DD
  1282. extern void InitMotifDD (
  1283. #ifdef UseFunctionPrototypes
  1284. X    Widget app_shell, XtAppContext app_context
  1285. #endif
  1286. );
  1287. #endif
  1288. X
  1289. /*************************************************************************
  1290. X * Forward functions
  1291. X ************************************************************************/ 
  1292. int main (
  1293. #ifdef UseFunctionPrototypes
  1294. X    unsigned int argc, char **argv
  1295. #endif
  1296. );            /*  main logic for application    */ 
  1297. X
  1298. /*************************************************************************
  1299. X * Local variables
  1300. X ************************************************************************/ 
  1301. #define Class_name "XmFm" 
  1302. static Widget    app_shell;    /*  ApplicationShell    */ 
  1303. X
  1304. /*************************************************************************
  1305. X * Function: fatal()
  1306. X * Purpose: report a fatal error and giveup
  1307. X * In parameters: s
  1308. X * Out parameters:
  1309. X * Precondition; error of some kind occurred that cant be fixed
  1310. X * Postcondition: application stopped after message printed to stderr
  1311. X ************************************************************************/ 
  1312. int fatal
  1313. #ifdef UseFunctionPrototypes
  1314. X    (char *s)
  1315. #else
  1316. X    (s)
  1317. X    char *s;
  1318. X
  1319. #endif
  1320. {
  1321. X    fprintf (stderr, s);
  1322. X    exit(1);
  1323. }
  1324. X
  1325. /*************************************************************************
  1326. X * Function: SetActionsInDirsToolbar ()
  1327. X * Purpose: Place the actions in the dirs toolbar, from .xmfmrc
  1328. X * In parameters: dpi
  1329. X * Out parameters:
  1330. X * Side effects: 
  1331. X * Precondition;
  1332. X * Postcondition: xmfm actions attached to each button in dirs toolbar
  1333. X *************************************************************************/
  1334. void
  1335. SetActionsInDirsToolbar 
  1336. #ifdef UseFunctionPrototypes
  1337. X    (dir_pane_info *dpi)
  1338. #else
  1339. X    (dpi)
  1340. X    dir_pane_info *dpi;
  1341. X
  1342. #endif
  1343. {    file_action *pfa;
  1344. X    action_pair *pap;
  1345. X    int button;
  1346. X    Widget tool_button;
  1347. X    XmString xmstr;
  1348. X    tool_button_info *tbi;
  1349. X
  1350. X    /* find file pattern matching this name */
  1351. X    pfa = actions;
  1352. X    while (pfa != NULL)
  1353. X        if (pfa -> file_type == PANE_TYPE &&
  1354. X            RegExpMatch ("*", pfa -> fsm_ptr))
  1355. X            break;
  1356. X        else    pfa = pfa -> next;
  1357. X
  1358. X    button = 0;
  1359. X    /* set actions in toolbar */
  1360. X    if (pfa != NULL)
  1361. X    {
  1362. X        pap = pfa -> actions;
  1363. X        while (button < DIRS_TOOLBAR_SIZE && pap != NULL)
  1364. X        {
  1365. X            tool_button = (dpi -> dirs_toolbar) [button];
  1366. X
  1367. X            /* set the action label in the button */
  1368. X            xmstr = XmStringCreateLtoR (pap -> action_label,
  1369. X                                          XmSTRING_DEFAULT_CHARSET);
  1370. X            XtVaSetValues (tool_button,
  1371. X                    XmNlabelString, (XtArgVal) xmstr,
  1372. X                    NULL);
  1373. X            XmStringFree (xmstr);
  1374. X
  1375. X            /* set the action in the buttons user data */
  1376. X            XtVaGetValues (tool_button,
  1377. X                    XmNuserData, (XtArgVal) &tbi,
  1378. X                    NULL);
  1379. X            tbi -> action = pap -> action;
  1380. X            tbi -> run_in_xterm = pap -> run_in_xterm;
  1381. X            tbi -> pause_after_exec = pap -> pause_after_exec;
  1382. X            tbi -> prompt = pap -> prompt;
  1383. X            tbi -> has_prompt = pap -> has_prompt;
  1384. X
  1385. X            XtSetSensitive (tool_button, True);
  1386. X            button++;
  1387. X            pap = pap -> next;
  1388. X        }
  1389. X    }
  1390. X    /* empty out the remaining buttons */
  1391. X    for ( ; button < DIRS_TOOLBAR_SIZE; button++)
  1392. X    {
  1393. X        tool_button = (dpi -> dirs_toolbar) [button];
  1394. X        /* break out as soon as we hit an already insensitive button */
  1395. /*
  1396. X        if (XtIsSensitive (tool_button) == False)
  1397. X            break;
  1398. */
  1399. X        XtVaSetValues (tool_button,
  1400. X                XmNlabelString, (XtArgVal) empty_string,
  1401. X                NULL);
  1402. X        XtSetSensitive (tool_button, False);
  1403. X    }
  1404. }
  1405. X
  1406. /*************************************************************************
  1407. X * Function: create_gcs ()
  1408. X * Purpose: set up global gcs with opposite fg/bg
  1409. X * In parameters: w
  1410. X * Out parameters:
  1411. X * Side effects: alters global gc and gc_reversed
  1412. X * Precondition;
  1413. X * Postcondition:
  1414. X ************************************************************************/ 
  1415. static void
  1416. create_gcs 
  1417. #ifdef UseFunctionPrototypes
  1418. X    (Widget w)
  1419. #else
  1420. X    (w)
  1421. X    Widget w;
  1422. X
  1423. #endif
  1424. {
  1425. X    /* uses black and white.
  1426. X       should pick up fg and bg from button resources? */
  1427. X    gc = XCreateGC (XtDisplay (w),
  1428. X            XtWindow (w),
  1429. X            (unsigned long) 0, NULL);
  1430. X    XSetBackground (XtDisplay (w),
  1431. X            gc,
  1432. X            WhitePixelOfScreen (XtScreen (w)));
  1433. X    XSetForeground (XtDisplay (w),
  1434. X            gc,
  1435. X            BlackPixelOfScreen (XtScreen (w)));
  1436. X
  1437. X    gc_reversed = XCreateGC (XtDisplay (w),
  1438. X            XtWindow (w),
  1439. X            (unsigned long) 0, NULL);
  1440. X    XSetBackground (XtDisplay (w),
  1441. X            gc_reversed,
  1442. X            BlackPixelOfScreen (XtScreen (w)));
  1443. X    XSetForeground (XtDisplay (w),
  1444. X            gc_reversed,
  1445. X            WhitePixelOfScreen (XtScreen (w)));
  1446. }
  1447. X
  1448. #ifdef RDD
  1449. /*************************************************************************
  1450. X * Function: myDropAction ()
  1451. X * Purpose: what to do when a drop takes place
  1452. X * In parameters: w, event, args, nargs
  1453. X * Out parameters:
  1454. X * Precondition: 
  1455. X * Postcondition: drop data (file name) placed in RDD cut buffer
  1456. X ************************************************************************/ 
  1457. /* ARGSUSED */
  1458. void myDropAction 
  1459. #ifdef UseFunctionPrototypes
  1460. X    (Widget w, XEvent *event, String *args, Cardinal *nargs)
  1461. #else
  1462. X    (w, event, args, nargs)
  1463. X    Widget w;
  1464. X    XEvent *event;
  1465. X    String *args;
  1466. X    Cardinal *nargs;
  1467. X
  1468. #endif
  1469. {    pane_button_info *pbi;
  1470. X    char full_file_name[MAXPATHLEN];
  1471. X
  1472. X    XtVaGetValues (w,
  1473. X            XmNuserData, &pbi, NULL);
  1474. X    strcpy (full_file_name,
  1475. X        DirectoryPath (DirectoryMgrDir (pbi -> dpi -> directory_manager)));
  1476. X    strcat (full_file_name, pbi -> name);
  1477. X
  1478. X    rddSetDropData (full_file_name,
  1479. X            strlen(full_file_name) + 1);    /* copy data to rdd,
  1480. X                              including null byte */
  1481. X    rddDropAction (w, (XButtonEvent *) event, args, nargs);        /* then use default action */
  1482. }
  1483. #endif /* RDD */
  1484. X
  1485. X
  1486. /*************************************************************************
  1487. X * Function: main.c
  1488. X * Purpose: run the application
  1489. X * In parameters: argc, argv
  1490. X * Out parameters:
  1491. X * Precondition: true
  1492. X * Postcondition: application has completed
  1493. X ************************************************************************/ 
  1494. int
  1495. main 
  1496. #ifdef UseFunctionPrototypes
  1497. X    (unsigned int argc, char **argv)
  1498. #else
  1499. X    (argc,argv)  
  1500. X    unsigned int    argc; 
  1501. X    char         **argv; 
  1502. X
  1503. #endif
  1504. {     
  1505. X    Widget        applic_widget;
  1506. X    dir_pane_info *dpi;
  1507. #ifdef RDD
  1508. /*
  1509. X * RDD
  1510. X * The normal translations for a button, plus those needed to do a 
  1511. SHAR_EOF
  1512. true || echo 'restore of xmfm/main.c failed'
  1513. fi
  1514. echo 'End of  part 6'
  1515. echo 'File xmfm/main.c is continued in part 7'
  1516. echo 7 > _shar_seq_.tmp
  1517. exit 0
  1518. --
  1519. +----------------------+---+
  1520.   Jan Newmarch, Information Science and Engineering,
  1521.   University of Canberra, PO Box 1, Belconnen, Act 2616
  1522.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  1523.