home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3214 < prev    next >
Encoding:
Internet Message Format  |  1991-04-19  |  49.3 KB

  1. From: eddyg@syma.sussex.ac.uk (Edward J. Groenendaal)
  2. Newsgroups: alt.sources
  3. Subject: X Desktop Manager(2)
  4. Message-ID: <4865@syma.sussex.ac.uk>
  5. Date: 17 Apr 91 20:48:25 GMT
  6.  
  7. ---- Cut Here and unpack ----
  8. #!/bin/sh
  9. # this is part 2 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file code/dirman.c continued
  12. #
  13. CurArch=2
  14. if test ! -r s2_seq_.tmp
  15. then echo "Please unpack part 1 first!"
  16.      exit 1; fi
  17. ( read Scheck
  18.   if test "$Scheck" != $CurArch
  19.   then echo "Please unpack part $Scheck next!"
  20.        exit 1;
  21.   else exit 0; fi
  22. ) < s2_seq_.tmp || exit 1
  23. echo "x - Continuing file code/dirman.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> code/dirman.c
  25. X{
  26. X  extern Boolean buttonSensitive;
  27. X  extern Widget trashButton, moveButton, copyButton;
  28. X  public void changestate(Boolean);
  29. X  extern void setCursor(Cursor);
  30. X  extern Mode mode;
  31. X  extern Cursor busy;
  32. X
  33. X  Arg arglist[1];
  34. X  Cardinal i;
  35. X
  36. X  if (mode == NormalMode) {
  37. X    setCursor(busy);
  38. X    XedwListHighlight(w, XedwAll);
  39. X    
  40. X    /* unhighlight . and .. */
  41. X    for (i=0; i < icon_list_size && 
  42. X     (strcmp(getfilename(icon_list[i]->string), ".") != 0); i++); 
  43. X    XedwListUnhighlight(w, i);
  44. X    for (i=i; i < icon_list_size && 
  45. X     (strcmp(getfilename(icon_list[i]->string), "..") != 0); i++); 
  46. X    XedwListUnhighlight(w, i);
  47. X    setCursor(NULL);
  48. X  } else
  49. X    XBell(XtDisplay(w), 100);
  50. X  
  51. X  /* do buttons */
  52. X  if (icon_list_size > 2) {
  53. X    changestate(True);
  54. X  }
  55. X}
  56. X
  57. Xprivate void Refresh(Widget w, XButtonEvent *event)
  58. X{
  59. X  directoryManagerNewDirectory(cwd);
  60. X}
  61. X
  62. Xpublic void changestate(Boolean new)
  63. X{
  64. X  extern Boolean buttonSensitive;
  65. X  extern Widget trashButton, copyButton, moveButton;
  66. X  extern Mode mode;
  67. X
  68. X  if (buttonSensitive == True) {
  69. X    if (mode == MoveMode) {
  70. X      /* Turn off Trash and Copy */
  71. X      XtSetSensitive(copyButton,    False);
  72. X      XtSetSensitive(trashButton,   False);
  73. X      XtSetSensitive(copymenu,      False);
  74. X      XtSetSensitive(trashmenu,     False);
  75. X      XtSetSensitive(mapmenu,       False);
  76. X      XtSetSensitive(getinfomenu,   False);
  77. X      XtSetSensitive(duplicatemenu, False);
  78. X      buttonSensitive = False;
  79. X    } else if (mode == CopyMode) {
  80. X      /* Turn off Trash and Move */
  81. X      XtSetSensitive(moveButton,    False);
  82. X      XtSetSensitive(trashButton,   False);
  83. X      XtSetSensitive(movemenu,      False);
  84. X      XtSetSensitive(trashmenu,     False);
  85. X      XtSetSensitive(mapmenu,       False);
  86. X      XtSetSensitive(getinfomenu,   False);
  87. X      XtSetSensitive(duplicatemenu, False);
  88. X      buttonSensitive = False;
  89. X    } else if (new == False) {
  90. X      /* Turn off All */
  91. X      XtSetSensitive(moveButton,    False);
  92. X      XtSetSensitive(copyButton,    False);
  93. X      XtSetSensitive(trashButton,   False);
  94. X      XtSetSensitive(copymenu,      False);
  95. X      XtSetSensitive(movemenu,      False);
  96. X      XtSetSensitive(trashmenu,     False);
  97. X      XtSetSensitive(mapmenu,       False);
  98. X      XtSetSensitive(getinfomenu,   False);
  99. X      XtSetSensitive(duplicatemenu, False);
  100. X      buttonSensitive = False;
  101. X    }
  102. X  } else {
  103. X    /* buttonSensitive == False */
  104. X
  105. X    /* If in MoveMode or CopyMode, then everything is set anyway */
  106. X    if (mode == NormalMode && new == True) {
  107. X      /* Set all to True */
  108. X      XtSetSensitive(trashButton,   True);
  109. X      XtSetSensitive(moveButton,    True);
  110. X      XtSetSensitive(copyButton,    True);
  111. X      XtSetSensitive(trashmenu,     True);
  112. X      XtSetSensitive(movemenu,      True);
  113. X      XtSetSensitive(copymenu,      True);
  114. X      XtSetSensitive(getinfomenu,   True);
  115. X      XtSetSensitive(duplicatemenu, True);
  116. X      XtSetSensitive(mapmenu,       True);
  117. X      buttonSensitive = True;
  118. X    }
  119. X  }
  120. X}
  121. X      
  122. Xpublic String getfilename(String s)
  123. X{
  124. X  extern Icon_mode current_mode;
  125. X
  126. X  if (current_mode.mode == Long && (strlen(s) > current_mode.length))
  127. X    return (s+current_mode.length);
  128. X  else
  129. X    return (s);
  130. X}
  131. SHAR_EOF
  132. echo "File code/dirman.c is complete"
  133. chmod 0644 code/dirman.c || echo "restore of code/dirman.c fails"
  134. echo "x - extracting code/display.c (Text)"
  135. sed 's/^X//' << 'SHAR_EOF' > code/display.c &&
  136. X/*****************************************************************************
  137. X ** File          : display.c                                               **
  138. X ** Purpose       : Initialise and Realise display and query dialogs        **
  139. X ** Author        : Edward Groenendaal                                      **
  140. X ** Date          : April 1991                                              **
  141. X ** Documentation : Xdtm Design Folder                                      **
  142. X ** Related Files :                                                         **
  143. X *****************************************************************************/
  144. X
  145. X#include "xdtm.h"
  146. X
  147. X#include <sys/file.h>    /* For access(2) */
  148. X#include <sys/signal.h>  /* For longjmp */
  149. X#include <setjmp.h>      /* For longjmp */
  150. X
  151. X#include <X11/Shell.h>
  152. X#include <X11/Xaw/Label.h>
  153. X#include <X11/Xaw/Command.h>
  154. X#include <X11/Xaw/AsciiText.h>
  155. X#include "Xedw/XedwForm.h"
  156. X
  157. Xextern void realize_dialog(Widget);
  158. X
  159. X
  160. Xtypedef enum {ViewReturn, CancelReturn} queryReturn;
  161. X
  162. Xpublic String viewfile;
  163. Xprivate jmp_buf env;
  164. X
  165. X/* Widgets */
  166. Xprivate Widget querypopup;      /* For asking whether to display a file */
  167. Xprivate Widget displaypopup;    /* For displaying a file */
  168. Xprivate Widget queryform;
  169. Xprivate Widget displayform;
  170. Xprivate Widget querylabel;
  171. Xprivate Widget displaylabel;
  172. Xprivate Widget queryyes;
  173. Xprivate Widget queryno;
  174. Xprivate Widget displayquit;
  175. Xprivate Widget displaytext;
  176. X
  177. Xpublic void init_query(Widget top)
  178. X{
  179. X  Arg arglist[5];
  180. X  Cardinal i;
  181. X
  182. X  querypopup = XtCreatePopupShell("querypopup",
  183. X                  transientShellWidgetClass,
  184. X                  top,
  185. X                  NULL, 0);
  186. X
  187. X  queryform  = XtCreateManagedWidget("queryform",
  188. X                     xedwFormWidgetClass,
  189. X                     querypopup,
  190. X                     NULL, 0);
  191. X
  192. X  i = 0;
  193. X  XtSetArg(arglist[i], XtNborderWidth,           0); i++;
  194. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
  195. X  XtSetArg(arglist[i], XtNfullWidth,          True); i++;
  196. X  querylabel = XtCreateManagedWidget("querylabel",
  197. X                     labelWidgetClass,
  198. X                     queryform,
  199. X                     arglist, i);
  200. X  i = 0;
  201. X  XtSetArg(arglist[i], XtNfromVert,     querylabel); i++;
  202. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
  203. X  queryno    = XtCreateManagedWidget("queryno",
  204. X                     commandWidgetClass,
  205. X                     queryform,
  206. X                     arglist, i);  
  207. X
  208. X  i = 0;
  209. X  XtSetArg(arglist[i], XtNfromVert,     querylabel); i++;
  210. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
  211. X  XtSetArg(arglist[i], XtNfromHoriz,      queryno); i++;
  212. X  XtSetArg(arglist[i], XtNwidthLinked,    queryno); i++;
  213. X  queryyes   = XtCreateManagedWidget("queryyes",
  214. X                     commandWidgetClass,
  215. X                     queryform,
  216. X                     arglist, i);
  217. X                     
  218. X}
  219. X
  220. Xpublic void init_display(Widget top)
  221. X{
  222. X  private void destroy_display_dialog(Boolean);
  223. X
  224. X  extern AppData app_data;
  225. X  XFontStruct *font;
  226. X  Arg arglist[8];
  227. X  Cardinal i, width, height;
  228. X
  229. X  private String DisplayQuit = "Quit";
  230. X
  231. X  /* Create popup */
  232. X  displaypopup  = XtCreatePopupShell("displaypopup",
  233. X                     transientShellWidgetClass,
  234. X                     top,
  235. X                     NULL, 0);
  236. X  
  237. X  displayform   = XtCreateManagedWidget("displayform",
  238. X                    xedwFormWidgetClass,
  239. X                    displaypopup,
  240. X                    NULL, 0);
  241. X  i = 0;
  242. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
  243. X  XtSetArg(arglist[i], XtNfullWidth,          True); i++;
  244. X  displaylabel  = XtCreateManagedWidget("displaylabel",
  245. X                    labelWidgetClass,
  246. X                    displayform,
  247. X                    arglist, i);
  248. X
  249. X  i = 0;
  250. X  XtSetArg(arglist[i], XtNfont,            app_data.view_font); i++;
  251. X  XtSetArg(arglist[i], XtNfullWidth,                     True); i++;
  252. X  XtSetArg(arglist[i], XtNfromVert,              displaylabel); i++;
  253. X  XtSetArg(arglist[i], XtNscrollVertical, XawtextScrollAlways); i++; 
  254. X  XtSetArg(arglist[i], XtNtype,                  XawAsciiFile); i++;
  255. X  XtSetArg(arglist[i], XtNstring,                 "/dev/null"); i++;
  256. X  XtSetArg(arglist[i], XtNdataCompression,              False); i++;
  257. X  displaytext   = XtCreateManagedWidget("displaytext",
  258. X                    asciiTextWidgetClass,
  259. X                    displayform,
  260. X                    arglist, i);
  261. X
  262. X  /* Get font from text widget, set the width of the widget to the
  263. X   * maximum width of any character in that font multiplied by 85,
  264. X   * set the height of the widget to (ascent + descent) * 24.
  265. X   * 
  266. X   * This gives a default viewing area of 85x25 characters if using a fixed 
  267. X   * width font, wider if using a variable width font.
  268. X   *
  269. X   * Note: The user may override these sizes view the application resources.
  270. X   */
  271. X
  272. X  XtSetArg(arglist[0], XtNfont, &font);
  273. X  XtGetValues(displaytext, arglist, 1);
  274. X
  275. X  width =  (font->max_bounds.width * app_data.view_width);
  276. X  height = ((font->max_bounds.ascent +
  277. X           font->max_bounds.descent) * app_data.view_height);
  278. X
  279. X  i = 0;
  280. X  XtSetArg(arglist[i], XtNwidth,   width); i++;
  281. X  XtSetArg(arglist[i], XtNheight, height); i++;
  282. X  XtSetValues(displaytext, arglist, i);
  283. X
  284. X  i = 0;
  285. X  XtSetArg(arglist[i], XtNlabel,       DisplayQuit); i++;
  286. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
  287. X  XtSetArg(arglist[i], XtNfromVert,    displaytext); i++;
  288. X  displayquit   = XtCreateManagedWidget("displayquit",
  289. X                    commandWidgetClass,
  290. X                    displayform,
  291. X                    arglist, i);
  292. X                       
  293. X  XtAddCallback(displayquit, XtNcallback, destroy_display_dialog, True);
  294. X
  295. X}
  296. X
  297. X
  298. Xpublic void query_dialog(String fullname, Boolean Query)
  299. X{    
  300. X  private void queryQueryResult(Widget, queryReturn, caddr_t);
  301. X
  302. X  Arg arglist[2];
  303. X  Cardinal i;
  304. X
  305. X  if (Query == True) {
  306. X    /* display query dialog */
  307. X
  308. X    private String QueryLabel = "View selected file?";
  309. X    private String QueryNo    = " Cancel ";
  310. X    private String QueryYes   = "View";
  311. X
  312. X    i = 0;
  313. X    XtSetArg(arglist[i], XtNlabel, QueryLabel); i++;
  314. X    XtSetValues(querylabel, arglist, i);
  315. X
  316. X    i = 0;
  317. X    XtSetArg(arglist[i], XtNsensitive, True); i++;
  318. X    XtSetArg(arglist[i], XtNlabel,  QueryNo); i++;
  319. X    XtSetValues(queryno, arglist, i);
  320. X
  321. X    i = 0;
  322. X    XtSetArg(arglist[i], XtNlabel, QueryYes); i++;
  323. X    XtSetValues(queryyes, arglist, i);
  324. X
  325. X    XtAddCallback(queryyes, XtNcallback, queryQueryResult, ViewReturn);
  326. X    XtAddCallback(queryno,  XtNcallback, queryQueryResult, CancelReturn);
  327. X
  328. X    viewfile = XtNewString(fullname);
  329. X
  330. X  } else {
  331. X    /* display view error dialog */
  332. X
  333. X    private String QueryNo    = " Cancel ";
  334. X    private String QueryYes   = "OK";
  335. X
  336. X    i = 0;
  337. X    XtSetArg(arglist[i], XtNlabel, fullname); i++;
  338. X    XtSetValues(querylabel, arglist, i);
  339. X
  340. X    i = 0;
  341. X    XtSetArg(arglist[i], XtNsensitive, False); i++;
  342. X    XtSetArg(arglist[i], XtNlabel,   QueryNo); i++;
  343. X    XtSetValues(queryno, arglist, i);
  344. X
  345. X    i = 0;
  346. X    XtSetArg(arglist[i], XtNlabel, QueryYes); i++;
  347. X    XtSetValues(queryyes, arglist, i);
  348. X
  349. X    XtAddCallback(queryyes, XtNcallback, queryQueryResult, CancelReturn);
  350. X    XtAddCallback(queryno,  XtNcallback, queryQueryResult, CancelReturn);
  351. X
  352. X    XBell(XtDisplay(displaypopup), 100);
  353. X  }
  354. X  
  355. X  realize_dialog(querypopup);
  356. X
  357. X}
  358. X
  359. Xprivate void destroy_query_dialog(void)
  360. X{
  361. X  XtPopdown(querypopup);
  362. X  
  363. X  XtRemoveAllCallbacks(queryyes, XtNcallback);
  364. X  XtRemoveAllCallbacks(queryno,  XtNcallback);
  365. X
  366. X}
  367. X
  368. X/* display */
  369. X
  370. Xpublic void displayfile(String fullname)
  371. X{
  372. X  extern void setCursor(Cursor);
  373. X  extern Cursor busy;
  374. X  private void seggie(int);
  375. X  Arg arglist[5];
  376. X  Cardinal i;
  377. X
  378. X  setCursor(busy);
  379. X  signal(SIGSEGV, seggie);
  380. X  if (setjmp(env) == 0) {
  381. X    i = 0;
  382. X    XtSetArg(arglist[i], XtNstring, fullname); i++;
  383. X    XtSetValues(displaytext, arglist, i);
  384. X    i = 0;
  385. X    XtSetArg(arglist[i], XtNlabel,  fullname); i++;
  386. X    XtSetValues(displaylabel, arglist, i);
  387. X
  388. X    setCursor(NULL);
  389. X    realize_dialog(displaypopup);
  390. X  } else {
  391. X    setCursor(NULL);
  392. X    query_dialog("Not a text file!", False);
  393. X  }
  394. X  signal(SIGSEGV, SIG_DFL);
  395. X}
  396. X
  397. Xprivate void seggie(int value)
  398. X{
  399. X  longjmp(env, value);
  400. X}
  401. X
  402. X
  403. Xprivate void destroy_display_dialog(Boolean destroy)
  404. X{
  405. X  XtPopdown(displaypopup);
  406. X}
  407. X
  408. X
  409. Xprivate void queryQueryResult(Widget w, queryReturn result, caddr_t dummy)
  410. X{
  411. X  destroy_query_dialog();
  412. X
  413. X  if (result == ViewReturn) {
  414. X    /* Call display */
  415. X    if (access(viewfile, R_OK) == 0)
  416. X      displayfile(viewfile);
  417. X    else
  418. X      query_dialog("File not readable!", False);
  419. X  } 
  420. X}
  421. X
  422. SHAR_EOF
  423. chmod 0644 code/display.c || echo "restore of code/display.c fails"
  424. echo "x - extracting code/fileman.c (Text)"
  425. sed 's/^X//' << 'SHAR_EOF' > code/fileman.c &&
  426. X/* v0.1 */
  427. X/*****************************************************************************
  428. X ** File          : fileman.c                                               **
  429. X ** Purpose       : Receive and distribute directory changes                **
  430. X ** Author        : Edward Groenendaal                                      **
  431. X ** Date          : 18th Feb 1990                                           **
  432. X ** Documentation : Xdtm Design Folder                                      **
  433. X ** Related Files : treeman.c, dirman.c, pathman.c, main.c                  **
  434. X *****************************************************************************/
  435. X
  436. X#include "xdtm.h"
  437. X
  438. X#include <X11/Xaw/AsciiText.h>
  439. X#include <X11/Xaw/Command.h>
  440. X#include <X11/Xaw/Paned.h>
  441. X#include <X11/Xaw/Viewport.h>
  442. X#include <X11/cursorfont.h>
  443. X
  444. X#include "Xedw/XedwForm.h"
  445. X
  446. Xpublic Widget vert_bar;
  447. Xpublic Widget dirSelector;
  448. Xpublic Cursor busy, left_ptr;
  449. Xpublic Widget directoryManagerView;
  450. X
  451. Xpublic void setCursor(Cursor);
  452. X
  453. Xpublic void createFileManagerWidgets(Widget w)
  454. X{
  455. X  private void GotoDir(Widget, XButtonEvent*);
  456. X  private void ClearSel(Widget, XButtonEvent*);
  457. X  private void goto_dir(Widget, caddr_t, caddr_t);
  458. X
  459. X  Widget fileManagerPane, treeManagerView;
  460. X  Widget dirSelectorForm, dirButton, dirLabel;
  461. X  extern Widget menuBar;
  462. X  Arg arglist[6], *newlist;
  463. X  Cardinal i;
  464. X  XtTranslations dirSelTranslations;
  465. X
  466. X  static XtActionsRec actions[] = {
  467. X    {"GotoDir",  GotoDir},
  468. X    {NULL, NULL}
  469. X  };
  470. X
  471. X
  472. X  static char defaultTranslations[] = 
  473. X    "Ctrl<Key>A:        beginning-of-line() \n\
  474. X     Ctrl<Key>E:        end-of-line() \n\
  475. X     <Key>Return:       GotoDir() \n\
  476. X     <Key>Escape:       beginning-of-line() kill-to-end-of-line() \n\
  477. X     <Key>Right:     forward-character() \n\
  478. X     <Key>Left:         backward-character() \n\
  479. X     <Key>Delete:       delete-previous-character() \n\
  480. X     <Key>BackSpace:    delete-previous-character() \n\
  481. X     <Key>:             insert-char() \n\
  482. X     <FocusIn>:         focus-in() \n\
  483. X     <FocusOut>:        focus-out() \n\
  484. X     <BtnDown>:         select-start()";
  485. X
  486. X  i = 0;
  487. X  XtSetArg(arglist[i], XtNfromVert,                               menuBar); i++;
  488. X  XtSetArg(arglist[i], XtNfullHeight,                                True); i++;
  489. X  XtSetArg(arglist[i], XtNfullWidth,                                 True); i++;
  490. X  XtSetArg(arglist[i], XtNfromHoriz, XtNameToWidget(w, "appManagerButton"));i++;
  491. X  newlist = XtMergeArgLists(arglist, i, chain_position, chain_size);
  492. X  fileManagerPane         =   XtCreateManagedWidget("fileManagerPane",
  493. X                            panedWidgetClass,
  494. X                            w,
  495. X                            newlist, i + chain_size);
  496. X  
  497. X  XtFree(newlist);
  498. X
  499. X/* Here is the hook onto which the tree manager will fit.
  500. X *  
  501. X *  i = 0;
  502. X *  XtSetArg(arglist[i], XtNforceBars, True); i++;
  503. X *  XtSetArg(arglist[i], XtNallowVert, True); i++;
  504. X *  XtSetArg(arglist[i], XtNallowHoriz, True); i++;
  505. X *  treeManagerView         =   XtCreateManagedWidget("treeManagerView",
  506. X *                             viewportWidgetClass,
  507. X *                             fileManagerPane,
  508. X *                             arglist, i);
  509. X */
  510. X
  511. X  i = 0;
  512. X  XtSetArg(arglist[i], XtNforceBars, True); i++;
  513. X  XtSetArg(arglist[i], XtNallowVert, True); i++;
  514. X  directoryManagerView    =   XtCreateManagedWidget("directoryManagerView",
  515. X                            viewportWidgetClass,
  516. X                            fileManagerPane,
  517. X                            arglist, i);
  518. X  
  519. X  createDirectoryManagerWidgets(directoryManagerView);
  520. X  /* createTreeManagerWidgets(treeManagerView); */
  521. X
  522. X  /* Create text widget */
  523. X
  524. X  i = 0;
  525. X  XtSetArg(arglist[i], XtNrubberHeight,   False); i++;
  526. X  XtSetArg(arglist[i], XtNrubberWidth,    False); i++;
  527. X  XtSetArg(arglist[i], XtNfromHoriz,    menuBar); i++; 
  528. X  XtSetArg(arglist[i], XtNborderWidth,        0); i++;
  529. X  XtSetArg(arglist[i], XtNlabel,        "Goto:"); i++;
  530. X  newlist = XtMergeArgLists(arglist, i, chain_position, chain_size);
  531. X  dirButton               =   XtCreateManagedWidget("dirButton",
  532. X                                                    commandWidgetClass,
  533. X                            w,
  534. X                            newlist, i + chain_size);
  535. X                                              
  536. X  XtFree(newlist);
  537. X
  538. X  i = 0;
  539. X  XtSetArg(arglist[i], XtNrubberHeight,    False); i++;
  540. X  XtSetArg(arglist[i], XtNfullWidth,        True); i++;
  541. X  XtSetArg(arglist[i], XtNfromHoriz,   dirButton); i++;
  542. X  XtSetArg(arglist[i], XtNeditType,  XawtextEdit); i++;
  543. X  XtSetArg(arglist[i], XtNborderWidth,         0); i++;
  544. X  XtSetArg(arglist[i], XtNvertDistance,        6); i++;
  545. X  newlist = XtMergeArgLists(arglist, i, chain_position, chain_size);
  546. X  dirSelector            =   XtCreateManagedWidget("dirSelector",
  547. X                            asciiTextWidgetClass,
  548. X                            w,
  549. X                            newlist, i + chain_size);
  550. X  XtFree(newlist);
  551. X  XtAddCallback(dirButton, XtNcallback, goto_dir, 0);
  552. X  XtAddActions(actions, XtNumber(actions));
  553. X  XtUninstallTranslations(dirSelector);
  554. X  dirSelTranslations = XtParseTranslationTable(defaultTranslations);
  555. X  XtOverrideTranslations(dirSelector, dirSelTranslations); 
  556. X  
  557. X }
  558. X
  559. Xpublic void initFileManager(Widget w)
  560. X{
  561. X  extern void initDirectoryManager(void);         /* dirman.c */
  562. X  /* extern void initTreeManager(void); */
  563. X  busy     = XCreateFontCursor(XtDisplay(w), XC_watch);
  564. X  left_ptr = XCreateFontCursor(XtDisplay(w), XC_left_ptr);
  565. X
  566. X  /* Check what should be mapped, unmapping those that shouldn't */
  567. X
  568. X  initDirectoryManager();
  569. X  /* initTreeManager(); */
  570. X}
  571. X
  572. Xprivate void GotoDir(Widget w, XButtonEvent *event)
  573. X{
  574. X  private goto_dir(Widget, caddr_t, caddr_t);
  575. X
  576. X  goto_dir(w, 0, 0);
  577. X}
  578. X
  579. Xprivate void goto_dir(Widget w, caddr_t client_data, caddr_t call_data)
  580. X{
  581. X  /* Called when the goto directory button is pressed, Or when return is
  582. X   * pressed in the directory selector.
  583. X   */
  584. X  extern Boolean directoryManagerNewDirectory(String);
  585. X
  586. X  extern String home;
  587. X  extern String cwd;
  588. X  Arg args[1];
  589. X  String value, tmp;
  590. X
  591. X  /* Get the contents of the dirselector */
  592. X  XtSetArg(args[0], XtNstring, &value);
  593. X  XtGetValues(dirSelector, args, 1);
  594. X
  595. X  /* expand ~ to HOME */
  596. X  if (*value == '~') {
  597. X    tmp = (String) XtMalloc ((strlen(home) + strlen(value)) * sizeof(char));
  598. X    strcpy(tmp, home);
  599. X    if (*(value+1) != '\0')
  600. X      strcat(tmp, value+1);
  601. X    value = tmp;
  602. X  }
  603. X
  604. X  /* change to the directory specified */
  605. X  if (directoryManagerNewDirectory(value) == False) {
  606. X    XBell(XtDisplay(w), 100);
  607. X  } else {
  608. X    XtFree(cwd);
  609. X    cwd = XtNewString(value);
  610. X  }
  611. X
  612. X}
  613. X
  614. Xprivate void ClearSel(Widget w, XButtonEvent *event)
  615. X{
  616. X  Arg args[1];
  617. X
  618. X  XtSetArg(args[0], XtNstring, "");
  619. X  XtSetValues(dirSelector, args, 1);
  620. X}
  621. X  
  622. Xpublic void setCursor(Cursor newcursor)
  623. X{
  624. X
  625. X  /* This should be called with a cursor to change to, or NULL to
  626. X   * go back to saved values. 
  627. X   * If the cursor is NULL then reset cursors to their defaults in
  628. X   * widgets.
  629. X   * Otherwise..
  630. X   * Set the cursor to newcursor in the following widgets:
  631. X   *   directoryManager
  632. X   *   dirSelector
  633. X   *   
  634. X   */
  635. X
  636. X  extern Widget directoryManager, appManager;
  637. X  
  638. X  static Cursor dirManCursor, appManCursor;
  639. X  Arg arglist[1];
  640. X  Cardinal i;
  641. X
  642. X  if (newcursor == NULL) {
  643. X    /* Go back to saved values */
  644. X    XtSetArg(arglist[0], XtNcursor, dirManCursor);
  645. X    XtSetValues(directoryManager, arglist, 1);
  646. X    /* XtSetArg(arglist[0], XtNcursor, treeManCursor);
  647. X     * XtSetValues(treeManager, arglist, 1); */
  648. X    XtSetArg(arglist[0], XtNcursor, appManCursor);
  649. X    XtSetValues(appManager, arglist, 1);
  650. X  } else {
  651. X    /* Get old values */
  652. X    XtSetArg(arglist[0], XtNcursor, &dirManCursor);
  653. X    XtGetValues(directoryManager, arglist, 1);
  654. X    /* XtSetArg(arglist[0], XtNcursor, &treeManCursor);
  655. X     * XtGetValues(treeManager, arglist, 1); */
  656. X    XtSetArg(arglist[0], XtNcursor, &appManCursor);
  657. X    XtGetValues(appManager, arglist, 1);
  658. X
  659. X    XtSetArg(arglist[0], XtNcursor, newcursor);
  660. X    XtSetValues(directoryManager, arglist, 1);
  661. X    /* XtSetValues(treeManager,      arglist, 1); */
  662. X    XtSetValues(appManager,       arglist, 1);
  663. X  }
  664. X
  665. X  XFlush(XtDisplay(directoryManager)); /* Change cursors immediately */
  666. X}
  667. X
  668. SHAR_EOF
  669. chmod 0644 code/fileman.c || echo "restore of code/fileman.c fails"
  670. echo "x - extracting code/info.c (Text)"
  671. sed 's/^X//' << 'SHAR_EOF' > code/info.c &&
  672. X/***********************************************************************************
  673. X ** File          : info.c                                                        **
  674. X ** Purpose       : Initialise and Realise info dialog                            **
  675. X ** Author        : Edward Groenendaal                                            **
  676. X ** Date          : April 1991                                                    **
  677. X ** Documentation : Xdtm Design Folder                                            **
  678. X ** Related Files :                                   **
  679. X ***********************************************************************************/
  680. X
  681. X#include "xdtm.h"
  682. X
  683. X
  684. Xpublic void init_info(Widget top)
  685. X{
  686. X
  687. X}
  688. SHAR_EOF
  689. chmod 0644 code/info.c || echo "restore of code/info.c fails"
  690. echo "x - extracting code/lexical.l (Text)"
  691. sed 's/^X//' << 'SHAR_EOF' > code/lexical.l &&
  692. X%{ /*-*- Mode: C -*-*/
  693. X/**************************************************************************
  694. X * Filename :       lexical.l
  695. X * Author   :       Edward Groenendaal
  696. X **************************************************************************/
  697. X
  698. X#ifdef YYLMAX                   
  699. X#  if (YYLMAX<1024)              /* Allow 1024 characters of look-ahead     */
  700. X#    undef YYLMAX                /* therefore allowing 1024 characters in a */
  701. X#    define YYLMAX      1024     /* comment. (default on my machine is 200  */
  702. X#  endif
  703. X#endif
  704. X
  705. X#include "xdtm.h"
  706. X
  707. X/* I shall use the macro RETURN whenever returning a token. If DEBUG_LEX has
  708. X * been defined then the token will be printed out, otherwise it will
  709. X * be returned.
  710. X */
  711. X
  712. X#ifdef DEBUG_LEX
  713. X
  714. X/* define the RETURN macro to print the token to be returned */
  715. X# define RETURN(token)    fprintf(stdout,"Token: " #token "\tReturned.\n")
  716. X
  717. X  /* define the tokens to be returned. ONLY in DEBUG mode, when in normal
  718. X   * operation the tokens are defined by yacc.
  719. X   */
  720. X  enum tokens { IF_T,
  721. X            SET_T,
  722. X            ICON_T,
  723. X            NAME_T,
  724. X            PATH_T,
  725. X            ASSIGN_T,
  726. X            EQUAL_T,
  727. X        NEQUAL_T,
  728. X            STRING_T,
  729. X            SEMIC_T,
  730. X            O_PAR_T,
  731. X            C_PAR_T,
  732. X            O_BRACE_T,
  733. X            C_BRACE_T,
  734. X        DEFICON_T,
  735. X        CHECKPATH_T,
  736. X        TRUE_T,
  737. X        FALSE_T,
  738. X        TYPE_T,
  739. X                DIR_T,
  740. X        FILE_T,
  741. X        READ_T,
  742. X        WRITE_T,
  743. X        EXE_T,
  744. X        PROG_T,
  745. X        OPTIONS_T,
  746. X        COMMA_T,
  747. X        MSEL_T,
  748. X        OSEL_T,
  749. X        NSEL_T,
  750. X        DEFINE_T,
  751. X        IGNORE_T,
  752. X        ERRORTOKEN
  753. X          };
  754. X
  755. X#else           /* No DEBUG */
  756. X
  757. X#include "parser.h"         /* get the tokens from yacc */
  758. X
  759. X/* define the RETURN token to set the return value to the token to be
  760. X * returned, then return that token.
  761. X */
  762. X# define RETURN(token)    yylval.number=token;return(token)
  763. X#endif
  764. X
  765. X#include <sys/types.h>
  766. X#include <stdio.h>
  767. X#include <stdarg.h>
  768. X
  769. X#define MAXERR      20      /* Maximum number of errors before the parser */
  770. X                            /* quits. */
  771. X
  772. Xvoid yyerror(char*, ...);
  773. X
  774. Xtypedef struct {                    /* structure for keyword table */
  775. X    String name;
  776. X    int token;
  777. X} keyword;
  778. X
  779. Xstatic keyword keywordtable[] = {   /* table of keywords */
  780. X  {"False",   FALSE_T},
  781. X  {"MSEL",    MSEL_T},
  782. X  {"NSEL",    NSEL_T},
  783. X  {"OSEL",    OSEL_T},
  784. X  {"True",    TRUE_T},
  785. X  {"checkpath", CHECKPATH_T},
  786. X  {"deficon", DEFICON_T},
  787. X  {"define",  DEFINE_T},
  788. X  {"dir",     DIR_T},
  789. X  {"exe",     EXE_T},
  790. X  {"false",   FALSE_T},
  791. X  {"file",    FILE_T},
  792. X  {"icon",    ICON_T},
  793. X  {"if",      IF_T},
  794. X  {"ignore",  IGNORE_T},
  795. X  {"name",    NAME_T},
  796. X  {"options", OPTIONS_T},
  797. X  {"path",    PATH_T},
  798. X  {"prog",    PROG_T},
  799. X  {"read",    READ_T},
  800. X  {"set",     SET_T},
  801. X  {"true",    TRUE_T},
  802. X  {"type",    TYPE_T},
  803. X  {"write",   WRITE_T}
  804. X};
  805. X/* number of entries in the keyword table */
  806. Xstatic int numkeywords = (sizeof(keywordtable)/sizeof(keywordtable[0]));
  807. X
  808. Xint parseerror=0;                   /* Number of parse errors */
  809. X
  810. X%}
  811. X%%
  812. X[\t ]*"#".*     { /* Remove Comments from beginning of line */ }
  813. X"="             { RETURN(ASSIGN_T);     }
  814. X"=="            { RETURN(EQUAL_T);      }
  815. X"{"             { RETURN(O_BRACE_T);    }
  816. X"}"             { RETURN(C_BRACE_T);    }
  817. X"("             { RETURN(O_PAR_T);      }
  818. X")"             { RETURN(C_PAR_T);      }
  819. X";"             { RETURN(SEMIC_T);      }
  820. X","             { RETURN(COMMA_T);      }
  821. X[A-Za-z]+       { int token = parse_keyword(yytext);
  822. X#ifndef DEBUG_LEX
  823. X          yylval.number = token;
  824. X                  return(token);
  825. X#endif
  826. X        }
  827. X[\n\t ]         { /* Ignore White space */ }
  828. X\"[^\"]*\"      {
  829. X#ifdef DEBUG_LEX
  830. X                  fprintf(stdout, "Token STRING_T %s returned", yytext);
  831. X#else
  832. X          yylval.string = yytext;
  833. X                  return(STRING_T);
  834. X#endif
  835. X                }
  836. X.               { yyerror("illegal character \'%c\'.", yytext[0]);
  837. X                }
  838. X%%
  839. X
  840. X
  841. X/*****************************************************************************
  842. X *                                yywrap                                     *
  843. X *****************************************************************************/
  844. Xint yywrap(void)
  845. X{
  846. X    /* function called when EOF encounterd.
  847. X     *
  848. X     * - Takes nothing
  849. X     * + returns EOF token, not actually used other than to indicate an error
  850. X     *   to the parser. Useful in DEBUG mode to see that EOF has been detected.
  851. X     */
  852. X
  853. X    RETURN(EOFTOKEN);
  854. X}
  855. X
  856. X
  857. X/*****************************************************************************
  858. X *                            parse_keyword                                  *
  859. X *****************************************************************************/
  860. Xint parse_keyword(String str)
  861. X{
  862. X    /* Function to determine whether a string is a reserved keyword or an
  863. X     * identifier. A table of keywords is searched via a binary search to check
  864. X     * to see if the string is a keyword,if it is found the associated
  865. X     * token is returned, otherwise the IDENT_T token is returned and
  866. X     * the value of the string is assigned to a global structure for
  867. X     * use in yacc. The effect of debugging is to prevent the assignment
  868. X     * to the yacc structure, and to print out the keyword if found.
  869. X     *
  870. X     * - Takes a string to check
  871. X     * + Returns a token (int)
  872. X     */
  873. X
  874. X    register int lower = 0, upper = numkeywords-1;
  875. X
  876. X    while (lower <= upper) {
  877. X        int middle = (lower + upper) /2;
  878. X        keyword *p = &keywordtable[middle];
  879. X        int res = strcmp(p->name, str);
  880. X
  881. X        if (res < 0) {
  882. X            lower = middle +1;
  883. X        } else if (res == 0) {
  884. X#ifdef DEBUG_LEX
  885. X            fprintf(stdout, "Token: %s\tReturned.\n", p->name);
  886. X#endif
  887. X            return(p->token);
  888. X        } else {
  889. X            upper = middle -1;
  890. X        }
  891. X    }
  892. X    yyerror("unknown keyword \'%s\'.", yytext);
  893. X    RETURN(ERRORTOKEN);
  894. X}
  895. X
  896. X/*********************************************************************************
  897. X *                                     yyerror                                   *
  898. X *********************************************************************************/
  899. Xvoid yyerror(char *fmt, ...)
  900. X{
  901. X    /* Error printing procedure. This procedure takes a variable argument list
  902. X     * in the same format as printf(3s), and outputs it on the stderr stream
  903. X     * prepended by the line-number currently being processed.
  904. X     * parserrror is incremented to indicate that an error has occurred, if
  905. X     * more than MAXERR errors occur the parser exits.
  906. X     *
  907. X     * - Takes a formatted string + parameters to print.
  908. X     * + Returns noting.
  909. X     */
  910. X
  911. X    va_list args;
  912. X    extern int yylineno;
  913. X
  914. X    if (!parseerror) {
  915. X    }
  916. X    if (parseerror < MAXERR) {
  917. X        va_start(args, fmt);
  918. X        fprintf(stderr, "(E) line :%2d: ", yylineno);
  919. X        vfprintf(stderr, fmt, args);
  920. X        fprintf(stderr, "\n");
  921. X        va_end(args);
  922. X        parseerror++;
  923. X    } else {
  924. X        fprintf(stderr, "Fatal error: over %d errors, exiting\n", MAXERR);
  925. X        exit(2);
  926. X    }
  927. X}
  928. SHAR_EOF
  929. chmod 0644 code/lexical.l || echo "restore of code/lexical.l fails"
  930. echo "x - extracting code/listoption.c (Text)"
  931. sed 's/^X//' << 'SHAR_EOF' > code/listoption.c &&
  932. X/****************************************************************************
  933. X ** File          : listoption.c                                           **
  934. X ** Purpose       : Initialise and Realise long listing dialog options     **
  935. X ** Author        : Edward Groenendaal                                     **
  936. X ** Date          : April 1991                                             **
  937. X ** Documentation : Xdtm Design Folder                                     **
  938. X ** Related Files :                                                        **
  939. X ****************************************************************************/
  940. X
  941. X#include "xdtm.h"
  942. X#include "menus.h"
  943. X#include <X11/Shell.h>
  944. X#include <X11/Xaw/Label.h>
  945. X#include <X11/Xaw/Command.h>
  946. X#include "Xedw/XedwForm.h"
  947. X
  948. X/* Note ListOption *same* order as listoptions */
  949. X
  950. Xtypedef enum {perms, nlinks, owner, group, size, modtm, acctm} ListOption;
  951. X
  952. Xstatic String listoptions[] = {
  953. X  "rwxrwxrwx ",
  954. X  "1 ",
  955. X  "owner ",
  956. X  "group ",
  957. X  "size ",
  958. X  "modtm ",
  959. X  "acctm "
  960. X};
  961. X
  962. X/* Widgets */
  963. X
  964. Xprivate Widget listoptionpopup;      
  965. Xprivate Widget listoptionform1;
  966. Xprivate Widget listoptionform2;
  967. Xprivate Widget listoptionform3;
  968. Xprivate Widget listoptionlabel;
  969. Xprivate Widget listoptionsettings;
  970. Xprivate Widget listoptionpermsButton;
  971. Xprivate Widget listoptionpermsLabel;
  972. Xprivate Widget listoptionlinksButton;
  973. Xprivate Widget listoptionlinksLabel;
  974. Xprivate Widget listoptionownerButton;
  975. Xprivate Widget listoptionownerLabel;
  976. Xprivate Widget listoptiongroupButton;
  977. Xprivate Widget listoptiongroupLabel;
  978. Xprivate Widget listoptionsizeButton;
  979. Xprivate Widget listoptionsizeLabel;
  980. Xprivate Widget listoptionacctmButton;
  981. Xprivate Widget listoptionacctmLabel;
  982. Xprivate Widget listoptionmodtmButton;
  983. Xprivate Widget listoptionmodtmLabel;
  984. Xprivate Widget listoptionquitButton;
  985. X
  986. X#define ToggleButton(b, w)  \
  987. X{ \
  988. X  Arg arglist[1]; \
  989. X  XtSetArg(arglist[0], XtNbitmap, \
  990. X       (current_mode.options & b) ? tick : emptytick); \
  991. X  XtSetValues(w, arglist, 1); \
  992. X}
  993. X         
  994. X
  995. Xpublic void init_listoption(Widget top)
  996. X{
  997. X  private void destroy_listoption_dialog(Widget, caddr_t, caddr_t);
  998. X  private void optionbutton_toggled(Widget, ListOption, caddr_t);
  999. X  Arg arglist[7];
  1000. X  Cardinal i;
  1001. X  XFontStruct *font;
  1002. X  String settings;
  1003. X  int width;
  1004. X
  1005. X  static String Label = "Long Listing Options";
  1006. X
  1007. X  /* constuct settings label */
  1008. X  settings = (String) XtMalloc (sizeof(char) * 55);
  1009. X
  1010. X  sprintf(settings, "%s%s%s%s%s%s%sfilename", 
  1011. X      listoptions[perms], 
  1012. X      listoptions[nlinks],
  1013. X      listoptions[owner],
  1014. X      listoptions[group],
  1015. X      listoptions[size],
  1016. X      listoptions[modtm],
  1017. X      listoptions[acctm]);
  1018. X
  1019. X  listoptionpopup = XtCreatePopupShell("listoptionpopup",
  1020. X                       transientShellWidgetClass,
  1021. X                       top,
  1022. X                       NULL, 0);
  1023. X  
  1024. X  listoptionform1 = XtCreateManagedWidget("listoptionform1",
  1025. X                      xedwFormWidgetClass,
  1026. X                      listoptionpopup,
  1027. X                      NULL, 0);
  1028. X
  1029. X  i = 0;
  1030. X  XtSetArg(arglist[i], XtNfullWidth,          True); i++;
  1031. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter); i++;
  1032. X  XtSetArg(arglist[i], XtNlabel,             Label); i++;
  1033. X  XtSetArg(arglist[i], XtNborderWidth,           0); i++;
  1034. X  listoptionlabel = XtCreateManagedWidget("listoptionlabel",
  1035. X                      labelWidgetClass,
  1036. X                      listoptionform1,
  1037. X                      arglist, i);
  1038. X
  1039. X  i = 1;
  1040. X  XtSetArg(arglist[i], XtNfromVert, listoptionlabel); i++;
  1041. X  XtSetArg(arglist[i], XtNjustify,    XtJustifyLeft); i++;
  1042. X  listoptionsettings = XtCreateManagedWidget("listoptionsettings",
  1043. X                         labelWidgetClass,
  1044. X                         listoptionform1,
  1045. X                         arglist, i);
  1046. X
  1047. X  /* Get font from widget, then use XTextWidth to find width of string,
  1048. X   * then set the width of the label to this width + 10.
  1049. X   */
  1050. X
  1051. X  XtSetArg(arglist[0], XtNfont, &font);
  1052. X  XtGetValues(listoptionsettings, arglist, 1);
  1053. X
  1054. X  width = XTextWidth(font, settings, strlen(settings));
  1055. X
  1056. X  XtSetArg(arglist[0], XtNwidth, width + 20);
  1057. X  XtSetValues(listoptionlabel, arglist, 1);
  1058. X
  1059. X  XtFree(settings);
  1060. X
  1061. X  i = 0;
  1062. X  XtSetArg(arglist[i], XtNborderWidth,               0); i++;
  1063. X  XtSetArg(arglist[i], XtNfromVert, listoptionsettings); i++;
  1064. X  listoptionform2 = XtCreateManagedWidget("listoptionform2",
  1065. X                      xedwFormWidgetClass,
  1066. X                      listoptionform1,
  1067. X                      arglist, i);
  1068. X
  1069. X  i = 0;
  1070. X  XtSetArg(arglist[i], XtNborderWidth,               0); i++;
  1071. X  XtSetArg(arglist[i], XtNfromVert, listoptionsettings); i++;
  1072. X  XtSetArg(arglist[i], XtNfromHoriz,   listoptionform2); i++; 
  1073. X  listoptionform3 = XtCreateManagedWidget("listoptionform3",
  1074. X                      xedwFormWidgetClass,
  1075. X                      listoptionform1,
  1076. X                      arglist, i);
  1077. X
  1078. X  /* First bank of buttons */
  1079. X
  1080. X  /* Permissions */
  1081. X  i = 0;
  1082. X  listoptionpermsButton = XtCreateManagedWidget("listoptionpermsButton",
  1083. X                        commandWidgetClass,
  1084. X                        listoptionform2,
  1085. X                        arglist, i);
  1086. X
  1087. X  i = 0;
  1088. X  XtSetArg(arglist[i], XtNborderWidth,                   0); i++;
  1089. X  XtSetArg(arglist[i], XtNfromHoriz,  listoptionpermsButton); i++;
  1090. X  XtSetArg(arglist[i], XtNlabel,              "Permissions"); i++;
  1091. X  listoptionpermsLabel  = XtCreateManagedWidget("listoptionpermsLabel",
  1092. X                        labelWidgetClass,
  1093. X                        listoptionform2,
  1094. X                        arglist, i);
  1095. X
  1096. X  XtAddCallback(listoptionpermsButton, XtNcallback, optionbutton_toggled, perms);
  1097. X
  1098. X  /* Nlinks */
  1099. X
  1100. X  i = 0;
  1101. X  XtSetArg(arglist[i], XtNfromVert,    listoptionpermsButton); i++;
  1102. X  listoptionlinksButton = XtCreateManagedWidget("listoptionlinksButton",
  1103. X                        commandWidgetClass,
  1104. X                        listoptionform2,
  1105. X                        arglist, i);
  1106. X  
  1107. X  i = 1;
  1108. X  XtSetArg(arglist[i], XtNborderWidth,                   0); i++;
  1109. X  XtSetArg(arglist[i], XtNfromHoriz, listoptionlinksButton); i++;
  1110. X  XtSetArg(arglist[i], XtNlabel,         "Number of links"); i++;
  1111. X  listoptionlinksLabel  = XtCreateManagedWidget("listoptionlinksLabel",
  1112. X                        labelWidgetClass,
  1113. X                        listoptionform2,
  1114. X                        arglist, i);
  1115. X
  1116. X  XtAddCallback(listoptionlinksButton, XtNcallback, optionbutton_toggled, nlinks);
  1117. X
  1118. X  /* Owner */
  1119. X
  1120. X  i = 0;
  1121. X  XtSetArg(arglist[i], XtNfromVert, listoptionlinksButton); i++; 
  1122. X  listoptionownerButton = XtCreateManagedWidget("listoptionownerButton",
  1123. X                        commandWidgetClass,
  1124. X                        listoptionform2,
  1125. X                        arglist, i);
  1126. X
  1127. X  i = 1;
  1128. X  XtSetArg(arglist[i], XtNborderWidth,                   0); i++;
  1129. X  XtSetArg(arglist[i], XtNfromHoriz, listoptionownerButton); i++;
  1130. X  XtSetArg(arglist[i], XtNlabel,           "Owner of file"); i++;
  1131. X  listoptionownerLabel  = XtCreateManagedWidget("listoptionownerLabel",
  1132. X                        labelWidgetClass,
  1133. X                        listoptionform2,
  1134. X                        arglist, i);
  1135. X
  1136. X  XtAddCallback(listoptionownerButton, XtNcallback, optionbutton_toggled, owner);
  1137. X
  1138. X  /* Second bank of buttons */
  1139. X
  1140. X  /* Group */
  1141. X
  1142. X  i = 0;
  1143. X  listoptiongroupButton = XtCreateManagedWidget("listoptiongroupButton",
  1144. X                        commandWidgetClass,
  1145. X                        listoptionform3,
  1146. X                        arglist, i);
  1147. X
  1148. X  i = 0;
  1149. X  XtSetArg(arglist[i], XtNborderWidth,                   0); i++;
  1150. X  XtSetArg(arglist[i], XtNfromHoriz, listoptiongroupButton); i++;
  1151. X  XtSetArg(arglist[i], XtNlabel,           "Group of file"); i++;
  1152. X  listoptiongroupLabel = XtCreateManagedWidget("listoptiongroupLabel",
  1153. X                           labelWidgetClass,
  1154. X                           listoptionform3,
  1155. X                           arglist, i);
  1156. X
  1157. X  XtAddCallback(listoptiongroupButton, XtNcallback, optionbutton_toggled, group);
  1158. X
  1159. X  /* Size */
  1160. X
  1161. X  i = 0;
  1162. X  XtSetArg(arglist[i], XtNfromVert, listoptiongroupButton); i++;
  1163. X  listoptionsizeButton = XtCreateManagedWidget("listoptionsizeButton",
  1164. X                           commandWidgetClass,
  1165. X                           listoptionform3,
  1166. X                           arglist, i);
  1167. X
  1168. X  i = 1;
  1169. X  XtSetArg(arglist[i], XtNborderWidth,                   0); i++;
  1170. X  XtSetArg(arglist[i], XtNfromHoriz, listoptionsizeButton); i++;
  1171. X  XtSetArg(arglist[i], XtNlabel,           "Size of file"); i++;
  1172. X  listoptionsizeLabel = XtCreateManagedWidget("listoptionsizeLabel",
  1173. X                         labelWidgetClass,
  1174. X                         listoptionform3,
  1175. X                         arglist, i);
  1176. X
  1177. X  XtAddCallback(listoptionsizeButton, XtNcallback, optionbutton_toggled, size);
  1178. X
  1179. X  /* Modification Time */
  1180. X
  1181. X  i = 0;
  1182. X  XtSetArg(arglist[i], XtNfromVert, listoptionsizeButton); i++;
  1183. X  listoptionmodtmButton = XtCreateManagedWidget("listoptionmodtmButton",
  1184. X                        commandWidgetClass,
  1185. X                        listoptionform3,
  1186. X                        arglist, i);
  1187. X
  1188. X  i = 1;
  1189. X  XtSetArg(arglist[i], XtNborderWidth,                   0); i++;
  1190. X  XtSetArg(arglist[i], XtNfromHoriz, listoptionmodtmButton); i++;
  1191. X  XtSetArg(arglist[i], XtNlabel,       "Modification time"); i++;
  1192. X  listoptionmodtmLabel = XtCreateManagedWidget("listoptionmodtmLabel",
  1193. X                          labelWidgetClass,
  1194. X                          listoptionform3,
  1195. X                          arglist, i);
  1196. X
  1197. X  XtAddCallback(listoptionmodtmButton, XtNcallback, optionbutton_toggled, modtm);
  1198. X
  1199. X  /* Access Time */  
  1200. X
  1201. X
  1202. X  i = 0;
  1203. X  XtSetArg(arglist[i], XtNfromVert, listoptionmodtmButton); i++;
  1204. X  listoptionacctmButton = XtCreateManagedWidget("listoptionacctmButton",
  1205. X                        commandWidgetClass,
  1206. X                        listoptionform3,
  1207. X                        arglist, i);
  1208. X
  1209. X  i = 1;
  1210. X  XtSetArg(arglist[i], XtNborderWidth,                   0); i++;
  1211. X  XtSetArg(arglist[i], XtNfromHoriz, listoptionacctmButton); i++;
  1212. X  XtSetArg(arglist[i], XtNlabel,             "Access time"); i++;
  1213. X  listoptionacctmLabel = XtCreateManagedWidget("listoptionacctmLabel",
  1214. X                           labelWidgetClass,
  1215. X                           listoptionform3,
  1216. X                           arglist, i);
  1217. X  
  1218. X  XtAddCallback(listoptionacctmButton, XtNcallback, optionbutton_toggled, acctm);
  1219. X
  1220. X  i = 0;
  1221. X  XtSetArg(arglist[i], XtNfromVert, listoptionform2); i++;
  1222. X  XtSetArg(arglist[i], XtNlabel,               "OK"); i++;
  1223. X  listoptionquitButton = XtCreateManagedWidget("listoptionquitButton",
  1224. X                           commandWidgetClass,
  1225. X                           listoptionform1,
  1226. X                           arglist, i);
  1227. X
  1228. X  XtAddCallback(listoptionquitButton, XtNcallback, destroy_listoption_dialog, 0);
  1229. X}
  1230. X
  1231. Xpublic void listoption_dialog(void)
  1232. X{
  1233. X  private String makeoptionstring(void);
  1234. X  String settings;
  1235. X  Arg arglist[1];
  1236. X
  1237. X  /* set up initial button settings */
  1238. X  ToggleButton(PERMS,  listoptionpermsButton);
  1239. X  ToggleButton(NLINKS, listoptionlinksButton);
  1240. X  ToggleButton(OWNER,  listoptionownerButton);
  1241. X  ToggleButton(GROUP,  listoptiongroupButton);
  1242. X  ToggleButton(SIZE,   listoptionsizeButton);
  1243. X  ToggleButton(MODTM,  listoptionmodtmButton);
  1244. X  ToggleButton(ACCTM,  listoptionacctmButton);
  1245. X
  1246. X  settings = makeoptionstring();
  1247. X
  1248. X  XtSetArg(arglist[0], XtNlabel, settings);
  1249. X  XtSetValues(listoptionsettings, arglist, 1);
  1250. X  
  1251. X  XtFree(settings);
  1252. X
  1253. X  realize_dialog(listoptionpopup);
  1254. X}
  1255. X
  1256. Xprivate void destroy_listoption_dialog(Widget w, caddr_t client_data,
  1257. X                       caddr_t call_data)
  1258. X{
  1259. X  extern directoryManagerNewDirectory(String);
  1260. X  extern String cwd;
  1261. X
  1262. X  XtPopdown(listoptionpopup);
  1263. X  if (current_mode.mode == Long)
  1264. X    directoryManagerNewDirectory(cwd);
  1265. X}
  1266. X
  1267. Xprivate void optionbutton_toggled(Widget w, ListOption button, caddr_t call_data)
  1268. X{
  1269. X  private String makeoptionstring(void);
  1270. X  Arg arglist[1];
  1271. X  String settings;
  1272. X
  1273. X  switch (button) {
  1274. X  case perms:
  1275. X    if (current_mode.options & PERMS) {
  1276. X      current_mode.options &= ~PERMS;
  1277. X    } else {
  1278. X      current_mode.options |= PERMS;
  1279. X    }
  1280. X    ToggleButton(PERMS, listoptionpermsButton);
  1281. X    break;
  1282. X  case nlinks:
  1283. X    if (current_mode.options & NLINKS) {
  1284. X      current_mode.options &= ~NLINKS;
  1285. X    } else {
  1286. X      current_mode.options |= NLINKS;
  1287. X    }
  1288. X    ToggleButton(NLINKS, listoptionlinksButton);
  1289. X    break;
  1290. X  case owner:
  1291. X    if (current_mode.options & OWNER) {
  1292. X      current_mode.options &= ~OWNER;
  1293. X    } else {
  1294. X      current_mode.options |= OWNER;
  1295. X    }
  1296. X    ToggleButton(OWNER, listoptionownerButton);
  1297. X    break;
  1298. X  case group:
  1299. X    if (current_mode.options & GROUP) {
  1300. X      current_mode.options &= ~GROUP;
  1301. X    } else {
  1302. X      current_mode.options |= GROUP;
  1303. X    }
  1304. X    ToggleButton(GROUP, listoptiongroupButton);
  1305. X    break;
  1306. X  case size:
  1307. X    if (current_mode.options & SIZE) {
  1308. X      current_mode.options &= ~SIZE;
  1309. X    } else {
  1310. X      current_mode.options |= SIZE;
  1311. X    }
  1312. X    ToggleButton(SIZE, listoptionsizeButton);
  1313. X    break;
  1314. X  case modtm:
  1315. X    if (current_mode.options & MODTM) {
  1316. X      current_mode.options &= ~MODTM;
  1317. X    } else {
  1318. X      current_mode.options |= MODTM;
  1319. X    }
  1320. X    ToggleButton(MODTM, listoptionmodtmButton);
  1321. X    break;
  1322. X  case acctm:
  1323. X    if (current_mode.options & ACCTM) {
  1324. X      current_mode.options &= ~ACCTM;
  1325. X    } else {
  1326. X      current_mode.options |= ACCTM;
  1327. X    }
  1328. X    ToggleButton(ACCTM, listoptionacctmButton);
  1329. X    break;
  1330. X  default:
  1331. X    fprintf(stderr, "Error: Listoptions programmer error, option out"
  1332. X        " of range\n");
  1333. X    break;
  1334. X  }
  1335. X
  1336. X  /* Put current options in settings string */
  1337. X
  1338. X  settings = makeoptionstring();
  1339. X
  1340. X  /* Put new settings string in the settings label */
  1341. X
  1342. X  XtSetArg(arglist[0], XtNlabel, settings);
  1343. X  XtSetValues(listoptionsettings, arglist, 1);
  1344. X
  1345. X  XtFree(settings);
  1346. X}
  1347. X
  1348. Xprivate String makeoptionstring(void)
  1349. X{
  1350. X  /* construct a string representing the current options,
  1351. X   * the user is responsible for free'ing it.
  1352. X   */
  1353. X  String permstring, nlinkstring, ownerstring, groupstring, sizestring;
  1354. X  String modtmstring, acctmstring, settings;
  1355. X
  1356. X  static String empty = "";
  1357. X  settings = (String) XtMalloc (sizeof(char) * 55);
  1358. X
  1359. X  if (current_mode.options & PERMS)
  1360. X    permstring = listoptions[perms];
  1361. X  else
  1362. X    permstring = empty;
  1363. X  if (current_mode.options & NLINKS)
  1364. X    nlinkstring = listoptions[nlinks];
  1365. X  else
  1366. X    nlinkstring = empty;
  1367. X  if (current_mode.options & OWNER)
  1368. X    ownerstring = listoptions[owner];
  1369. X  else
  1370. X    ownerstring = empty;
  1371. X  if (current_mode.options & GROUP)
  1372. X    groupstring = listoptions[group];
  1373. X  else
  1374. X    groupstring = empty;
  1375. X  if (current_mode.options & SIZE)
  1376. X    sizestring = listoptions[size];
  1377. X  else
  1378. X    sizestring = empty;
  1379. X  if (current_mode.options & MODTM)
  1380. X    modtmstring = listoptions[modtm];
  1381. X  else
  1382. X    modtmstring = empty;
  1383. X  if (current_mode.options & ACCTM)
  1384. X    acctmstring = listoptions[acctm];
  1385. X  else
  1386. X    acctmstring = empty;
  1387. X  
  1388. X  sprintf(settings, "%s%s%s%s%s%s%sfilename", 
  1389. X      permstring, 
  1390. X      nlinkstring,
  1391. X      ownerstring,
  1392. X      groupstring,
  1393. X      sizestring,
  1394. X      modtmstring,
  1395. X      acctmstring);
  1396. X
  1397. X  return(settings);
  1398. X}
  1399. SHAR_EOF
  1400. chmod 0644 code/listoption.c || echo "restore of code/listoption.c fails"
  1401. echo "x - extracting code/main.c (Text)"
  1402. sed 's/^X//' << 'SHAR_EOF' > code/main.c &&
  1403. X/* v0.1 */
  1404. X/***********************************************************************************
  1405. X ** File          : main.c                                                        **
  1406. X ** Purpose       : Initialise and Realise xdtm                                   **
  1407. X ** Author        : Edward Groenendaal                                            **
  1408. X ** Date          : 18th Feb 1990                                                 **
  1409. X ** Documentation : Xdtm Design Folder                                            **
  1410. X ** Related Files : All other xdtm files                                          **
  1411. X ***********************************************************************************/
  1412. X
  1413. X#include "xdtm.h"
  1414. X#include "menus.h"
  1415. X
  1416. X/* local headers */
  1417. X
  1418. X#include <X11/Shell.h>
  1419. X#include "Xedw/XedwForm.h"
  1420. X
  1421. X/* topLevel is global because it is needed by the quit popup to determine the centre
  1422. X * of the application.
  1423. X */
  1424. Xpublic Widget topLevel;
  1425. Xpublic String home;
  1426. Xpublic AppData app_data;
  1427. X
  1428. Xstatic XtResource resources[] = {
  1429. X  {   
  1430. X    XtNviewWidth, 
  1431. X    XtCViewWidth,
  1432. X    XtRInt,
  1433. X    sizeof(int),
  1434. X    XtOffset(AppDataPtr, view_width),
  1435. X    XtRImmediate,
  1436. X    (caddr_t) 85,
  1437. X  },
  1438. X  { 
  1439. X    XtNviewHeight,
  1440. X    XtCViewHeight,
  1441. X    XtRInt,
  1442. X    sizeof(int),
  1443. X    XtOffset(AppDataPtr, view_height),
  1444. X    XtRImmediate,
  1445. X    (caddr_t) 25,
  1446. X  },
  1447. X  {
  1448. X    XtNmode,
  1449. X    XtCMode,
  1450. X    XtRString,
  1451. X    sizeof(String),
  1452. X    XtOffset(AppDataPtr, mode),
  1453. X    XtRImmediate,
  1454. X    (caddr_t) "icons",
  1455. X  },
  1456. X  {
  1457. X    XtNviewFont,
  1458. X    XtCFont,
  1459. X    XtRFontStruct,
  1460. X    sizeof(XFontStruct*),
  1461. X    XtOffset(AppDataPtr, view_font),
  1462. X    XtRString,
  1463. X    (caddr_t) "6x10",
  1464. X  },
  1465. X  {
  1466. X    XtNdmFont,
  1467. X    XtCFont,
  1468. X    XtRFontStruct,
  1469. X    sizeof(XFontStruct*),
  1470. X    XtOffset(AppDataPtr, dm_font),
  1471. X    XtRString,
  1472. X    (caddr_t) "*-courier-bold-r-*-120-*",
  1473. X  },
  1474. X};
  1475. X      
  1476. X
  1477. Xpublic void main(int argc, char *argv[])
  1478. X{
  1479. X  private void initialiseXdtm(void);
  1480. X  extern void createMenuWidgets(Widget);          /* menus.c */
  1481. X  extern void createAppManagerWidgets(Widget);    /* appman.c */
  1482. X  extern void createFileManagerWidgets(Widget);   /* fileman.c */
  1483. X  extern void createDialogWidgets(Widget);        /* dialogs.c */
  1484. X
  1485. X  extern Icon_mode current_mode;
  1486. X  Widget topForm;
  1487. X  Arg arglist[6];
  1488. X  Cardinal i;
  1489. X  static String Title = "X DeskTop Manager";
  1490. X
  1491. X  /* Command Line Arguments */
  1492. X
  1493. X  static XrmOptionDescRec options[] = {
  1494. X    {"-dmfont",    "*directoryManager.font", XrmoptionSepArg, NULL}
  1495. X  };
  1496. X
  1497. X  /* Initialise Program */
  1498. X  if ((home = (String) getenv("HOME")) == NULL) {
  1499. X    fprintf(stderr, "can\'t get environment variable HOME\n");
  1500. X    home = XtNewString("/");
  1501. X  } else 
  1502. X    home = XtNewString(home);
  1503. X
  1504. X  /* Initialise the user interface */
  1505. X
  1506. X  topLevel = XtInitialize(argv[0], 
  1507. X              "Xdtm", 
  1508. X              options, 
  1509. X              XtNumber(options),
  1510. X              &argc, argv);
  1511. X
  1512. X  /* Check left over command line arguments */
  1513. X  if (argc > 1) {
  1514. X    /* incorrect command line arguments */
  1515. X    int i;
  1516. X    static int errs = False;
  1517. X    
  1518. X    for (i = 1; i < argc; i++) {
  1519. X      if (!errs++)
  1520. X    fprintf(stderr, "%s: command line option unknown:\n", argv[0]);
  1521. X      fprintf(stderr, "option: %s\n\n", argv[i]);
  1522. X    }
  1523. X    fprintf(stderr, "%s understands all standard Xt "
  1524. X        "command-line options.\n", argv[0]);
  1525. X    fprintf(stderr, "Additional options are as follows:\n");
  1526. X    fprintf(stderr, "Option              Valid Range\n");
  1527. X    fprintf(stderr, "-dmfont             Any font, should be fixed width\n");
  1528. X    exit(2);
  1529. X  }
  1530. X    
  1531. X  /* get application resources */
  1532. X  XtGetApplicationResources(topLevel,
  1533. X                &app_data,
  1534. X                resources,
  1535. X                XtNumber(resources),
  1536. X                NULL, 0);
  1537. X
  1538. X  /* check values of application resources */
  1539. X  if (app_data.view_width < 1 || app_data.view_height < 1) {
  1540. X    fprintf(stderr, "%s: error in resource settings:\n"
  1541. X        "view window must be greater than 1x1 characters\n",
  1542. X        argv[0]);
  1543. X    exit(2);
  1544. X  }
  1545. X  
  1546. X  if (strcmp(app_data.mode, "icons") == 0) 
  1547. X    current_mode.mode = Icons;
  1548. X  else if (strcmp(app_data.mode, "short") == 0)
  1549. X    current_mode.mode = Short;
  1550. X  else if (strcmp(app_data.mode,  "long") == 0)
  1551. X    current_mode.mode = Long;
  1552. X  else {
  1553. X    fprintf(stderr, "%s: error in resource settings:\n"
  1554. X        "mode must be one of either:\n"
  1555. X        "'icons'     Show icons\n"
  1556. X        "'short'     Just display file names\n"
  1557. X        "'long'      Display file names with additional data.\n",
  1558. X        argv[0]);
  1559. X    exit(2);
  1560. X  }
  1561. X
  1562. X  i = 0;
  1563. X  XtSetArg(arglist[i], XtNbottom, XtChainBottom); i++;
  1564. X  XtSetArg(arglist[i], XtNtop,       XtChainTop); i++;
  1565. X  XtSetArg(arglist[i], XtNleft,     XtChainLeft); i++;
  1566. X  XtSetArg(arglist[i], XtNright,   XtChainRight); i++;
  1567. X  XtSetArg(arglist[i], XtNhorizDistance,      5); i++;
  1568. X  XtSetArg(arglist[i], XtNvertDistance,       5); i++;
  1569. X  topForm = XtCreateManagedWidget("topForm",
  1570. X                  xedwFormWidgetClass,
  1571. X                  topLevel,
  1572. X                  arglist, i);
  1573. X
  1574. X  /* These must be called in this order, top left -> bottom right */
  1575. X  createMenuWidgets        (topForm);
  1576. X  createAppManagerWidgets  (topForm);
  1577. X  createFileManagerWidgets (topForm);
  1578. X  createDialogWidgets      (topForm);
  1579. X
  1580. X  i = 0;
  1581. X  XtSetArg(arglist[i], XtNtitle,   Title); i++;
  1582. X  XtSetArg(arglist[i], XtNminWidth,  400); i++;
  1583. X  XtSetArg(arglist[i], XtNminHeight, 200); i++;
  1584. X  XtSetValues(topLevel, arglist, i);
  1585. X
  1586. X  tzset();
  1587. X
  1588. X  /* Realize the widgets, (display program) then loop waiting for events */
  1589. X
  1590. X  XtRealizeWidget(topLevel);
  1591. X
  1592. X  initialiseXdtm();
  1593. X
  1594. X  XtMainLoop();
  1595. X
  1596. X}
  1597. X
  1598. Xpublic void quitQueryResult(Widget w, Boolean quit, caddr_t call_data)
  1599. X{
  1600. X  extern void destroy_quit_dialog(void);
  1601. X  /* Quit selected */
  1602. X  if (quit == True)
  1603. X    exit(0);
  1604. X
  1605. X  /* Cancel selected */
  1606. X  destroy_quit_dialog();
  1607. X}
  1608. X
  1609. Xprivate void initialiseXdtm(void)
  1610. X{
  1611. X
  1612. X  extern void initAppManager(Widget);               /* appman.c */
  1613. X  extern void initFileManager(Widget);              /* fileman.c */
  1614. X  extern void parsePreferences(Widget);           /* parse.c */
  1615. X
  1616. X  parsePreferences(topLevel);
  1617. X  initAppManager(topLevel);
  1618. X  initFileManager(topLevel);
  1619. X}
  1620. SHAR_EOF
  1621. chmod 0644 code/main.c || echo "restore of code/main.c fails"
  1622. echo "x - extracting code/map.c (Text)"
  1623. sed 's/^X//' << 'SHAR_EOF' > code/map.c &&
  1624. X/*****************************************************************************
  1625. X ** File          : map.c                                                   **
  1626. X ** Purpose       : Initialise and Realise map dialog                       **
  1627. X ** Author        : Edward Groenendaal                                      **
  1628. X ** Date          : April 1991                                              **
  1629. X ** Documentation : Xdtm Design Folder                                      **
  1630. X ** Related Files :                                                         **
  1631. X *****************************************************************************/
  1632. X
  1633. X#include "xdtm.h"
  1634. X#include "parse.h"        /* For SelOptions, ESIZE */
  1635. SHAR_EOF
  1636. echo "End of part 2"
  1637. echo "File code/map.c is continued in part 3"
  1638. echo "3" > s2_seq_.tmp
  1639. exit 0
  1640.