home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume13 / xdtm / part05 < prev    next >
Text File  |  1991-05-18  |  40KB  |  1,132 lines

  1. Path: uunet!olivea!apple!sun-barr!newstop!exodus!cogs.sussex.ac.uk
  2. From: eddyg@cogs.sussex.ac.uk (EdwardJ. Groenendaal)
  3. Newsgroups: comp.sources.x
  4. Subject: v13i010: xdtm - X Desktop Manager for the X Window System, Part05/11
  5. Message-ID: <13574@exodus.Eng.Sun.COM>
  6. Date: 19 May 91 00:03:04 GMT
  7. References: <csx-13i006:xdtm@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 1120
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: Edward "J." Groenendaal <eddyg@cogs.sussex.ac.uk>
  13. Posting-number: Volume 13, Issue 10
  14. Archive-name: xdtm/part05
  15.  
  16. Submitted-by: eddyg@cste
  17. Archive-name: xdtm/part05
  18.  
  19. ---- Cut Here and feed the following to sh ----
  20. #!/bin/sh
  21. # This is part 05 of xdtm
  22. # ============= xdtm/bitmaps/file.icon ==============
  23. if test ! -d 'xdtm'; then
  24.     echo 'x - creating directory xdtm'
  25.     mkdir 'xdtm'
  26. fi
  27. if test ! -d 'xdtm/bitmaps'; then
  28.     echo 'x - creating directory xdtm/bitmaps'
  29.     mkdir 'xdtm/bitmaps'
  30. fi
  31. if test -f 'xdtm/bitmaps/file.icon' -a X"$1" != X"-c"; then
  32.     echo 'x - skipping xdtm/bitmaps/file.icon (File already exists)'
  33. else
  34. echo 'x - extracting xdtm/bitmaps/file.icon (Text)'
  35. sed 's/^X//' << 'SHAR_EOF' > 'xdtm/bitmaps/file.icon' &&
  36. X#define file_width 32
  37. X#define file_height 32
  38. Xstatic char file_bits[] = {
  39. X   0xf0, 0xff, 0x7f, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x10, 0x00, 0x40, 0x01,
  40. X   0x10, 0x00, 0x40, 0x02, 0x10, 0x00, 0x40, 0x04, 0x10, 0x00, 0xc0, 0x0f,
  41. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  42. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  43. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  44. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  45. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  46. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  47. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  48. X   0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08,
  49. X   0x10, 0x00, 0x00, 0x08, 0xf0, 0xff, 0xff, 0x0f};
  50. SHAR_EOF
  51. chmod 0644 xdtm/bitmaps/file.icon ||
  52. echo 'restore of xdtm/bitmaps/file.icon failed'
  53. Wc_c="`wc -c < 'xdtm/bitmaps/file.icon'`"
  54. test 875 -eq "$Wc_c" ||
  55.     echo 'xdtm/bitmaps/file.icon: original size 875, current size' "$Wc_c"
  56. fi
  57. # ============= xdtm/bitmaps/folder.icon ==============
  58. if test -f 'xdtm/bitmaps/folder.icon' -a X"$1" != X"-c"; then
  59.     echo 'x - skipping xdtm/bitmaps/folder.icon (File already exists)'
  60. else
  61. echo 'x - extracting xdtm/bitmaps/folder.icon (Text)'
  62. sed 's/^X//' << 'SHAR_EOF' > 'xdtm/bitmaps/folder.icon' &&
  63. X#define folder_width 32
  64. X#define folder_height 32
  65. Xstatic char folder_bits[] = {
  66. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  67. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  68. X   0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x02, 0x08,
  69. X   0xfe, 0xff, 0xff, 0x7f, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  70. X   0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  71. X   0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  72. X   0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  73. X   0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  74. X   0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  75. X   0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  76. X   0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
  77. SHAR_EOF
  78. chmod 0644 xdtm/bitmaps/folder.icon ||
  79. echo 'restore of xdtm/bitmaps/folder.icon failed'
  80. Wc_c="`wc -c < 'xdtm/bitmaps/folder.icon'`"
  81. test 881 -eq "$Wc_c" ||
  82.     echo 'xdtm/bitmaps/folder.icon: original size 881, current size' "$Wc_c"
  83. fi
  84. # ============= xdtm/bitmaps/xdtm.xbm ==============
  85. if test -f 'xdtm/bitmaps/xdtm.xbm' -a X"$1" != X"-c"; then
  86.     echo 'x - skipping xdtm/bitmaps/xdtm.xbm (File already exists)'
  87. else
  88. echo 'x - extracting xdtm/bitmaps/xdtm.xbm (Text)'
  89. sed 's/^X//' << 'SHAR_EOF' > 'xdtm/bitmaps/xdtm.xbm' &&
  90. X/* This X bitmap is designed for use with the X Desktop Manager.
  91. X * it was designed by Edward Groenendaal, April 1991.
  92. X */
  93. X#define xdtm_width 32
  94. X#define xdtm_height 32
  95. Xstatic char xdtm_bits[] = {
  96. X   0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0x4a, 0x06, 0x00, 0x58,
  97. X   0xfe, 0xff, 0xff, 0x7f, 0x02, 0x08, 0x10, 0x40, 0x02, 0x88, 0xff, 0x43,
  98. X   0x02, 0x88, 0x10, 0x42, 0xfe, 0xcf, 0x39, 0x47, 0x02, 0x48, 0x29, 0x45,
  99. X   0xe2, 0xc8, 0x39, 0x47, 0xa2, 0x88, 0x00, 0x42, 0xa2, 0xf8, 0x07, 0x42,
  100. X   0xe2, 0x88, 0x04, 0x42, 0x02, 0xf8, 0xff, 0x7f, 0xfa, 0x0b, 0x00, 0x40,
  101. X   0x02, 0xe8, 0x9c, 0x43, 0xe2, 0xa8, 0x94, 0x42, 0xa2, 0xa8, 0x94, 0x42,
  102. X   0xa2, 0xe8, 0x9c, 0x43, 0xe2, 0x08, 0x00, 0x40, 0x02, 0xe8, 0xb6, 0x43,
  103. X   0x7a, 0x0b, 0x00, 0x40, 0x02, 0xe8, 0x9c, 0x43, 0x02, 0xa8, 0x94, 0x42,
  104. X   0x02, 0xa8, 0x94, 0x42, 0x02, 0xe8, 0x9c, 0x43, 0xfe, 0x0f, 0x00, 0x40,
  105. X   0x92, 0xec, 0x9c, 0x43, 0x92, 0x0c, 0x00, 0x40, 0x92, 0x0c, 0x00, 0x40,
  106. X   0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
  107. SHAR_EOF
  108. chmod 0644 xdtm/bitmaps/xdtm.xbm ||
  109. echo 'restore of xdtm/bitmaps/xdtm.xbm failed'
  110. Wc_c="`wc -c < 'xdtm/bitmaps/xdtm.xbm'`"
  111. test 998 -eq "$Wc_c" ||
  112.     echo 'xdtm/bitmaps/xdtm.xbm: original size 998, current size' "$Wc_c"
  113. fi
  114. # ============= xdtm/buttons.c ==============
  115. if test -f 'xdtm/buttons.c' -a X"$1" != X"-c"; then
  116.     echo 'x - skipping xdtm/buttons.c (File already exists)'
  117. else
  118. echo 'x - extracting xdtm/buttons.c (Text)'
  119. sed 's/^X//' << 'SHAR_EOF' > 'xdtm/buttons.c' &&
  120. X/*****************************************************************************
  121. X ** File          : buttons.c                                               **
  122. X ** Purpose       : Initialise and Realise button dialogs                   **
  123. X ** Author        : Edward Groenendaal                                      **
  124. X ** Date          : April 1991                                              **
  125. X ** Documentation : Xdtm Design Folder                                      **
  126. X ** Related Files :                                                         **
  127. X *****************************************************************************/
  128. X
  129. X#include "xdtm.h"
  130. X#include "menus.h"
  131. X
  132. X#include <X11/Shell.h>
  133. X#include <X11/Xaw/Label.h>
  134. X#include <X11/Xaw/Command.h>
  135. X#include <X11/Xaw/Viewport.h>
  136. X#include "Xedw/XedwForm.h"
  137. X#include "Xedw/XedwList.h"
  138. X
  139. Xextern void realize_dialog(Widget);
  140. X
  141. X/* Widgets */
  142. X
  143. Xprivate Widget buttonpopup;     /* For confermation of move/copy/trash buttons */
  144. Xprivate Widget buttonform;
  145. Xprivate Widget buttonlabel1;
  146. Xprivate Widget buttonlabel2;
  147. Xprivate Widget buttonyes;
  148. Xprivate Widget buttonno;
  149. Xprivate Widget fileview;
  150. Xprivate Widget filelist;
  151. X
  152. X/*****************************************************************************
  153. X *                             init_button                                   *
  154. X *****************************************************************************/
  155. Xpublic void init_button(Widget top)
  156. X{
  157. X  /* initialise the widget which display's a list of filenames with a message
  158. X   * and a couple of buttons.
  159. X   */
  160. X
  161. X  Arg arglist[5];
  162. X  Cardinal i;
  163. X  XtTranslations translations;
  164. X  Dimension height, space;
  165. X  XFontStruct *font;
  166. X
  167. X  buttonpopup  =   XtCreatePopupShell("buttonpopup",
  168. X                      transientShellWidgetClass,
  169. X                      top,
  170. X                      NULL, 0);
  171. X
  172. X
  173. X  buttonform    =   XtCreateManagedWidget("buttonform",
  174. X                      xedwFormWidgetClass,
  175. X                      buttonpopup,
  176. X                      NULL, 0);
  177. X
  178. X  i = 0;
  179. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter);  i++;
  180. X  XtSetArg(arglist[i], XtNfullWidth,          True);  i++;
  181. X  XtSetArg(arglist[i], XtNborderWidth,           0); i++;
  182. X  buttonlabel1  =   XtCreateManagedWidget("buttonlabel1",
  183. X                      labelWidgetClass,
  184. X                      buttonform,
  185. X                      arglist, i);
  186. X
  187. X  i = 3;
  188. X  XtSetArg(arglist[i], XtNfromVert,   buttonlabel1);  i++; 
  189. X  buttonlabel2  =   XtCreateManagedWidget("buttonlabel2",
  190. X                      labelWidgetClass,
  191. X                      buttonform,
  192. X                      arglist, i);
  193. X
  194. X  i = 0;
  195. X  XtSetArg(arglist[i], XtNfromVert, buttonlabel2);  i++; 
  196. X  XtSetArg(arglist[i], XtNfullWidth,        True);  i++;
  197. X  XtSetArg(arglist[i], XtNforceBars,        True);  i++;
  198. X  XtSetArg(arglist[i], XtNallowVert,        True);  i++;
  199. X  fileview = XtCreateManagedWidget("fileview",
  200. X                   viewportWidgetClass,
  201. X                   buttonform,
  202. X                   arglist, i);
  203. X
  204. X  translations = XtParseTranslationTable("");
  205. X  i = 0;
  206. X  XtSetArg(arglist[i], XtNdefaultColumns,  1); i++;
  207. X  XtSetArg(arglist[i], XtNforceColumns, True); i++;
  208. X  XtSetArg(arglist[i], XtNrowSpacing,      4); i++;
  209. X  XtSetArg(arglist[i], XtNtranslations, translations); i++;
  210. X  filelist = XtCreateManagedWidget("filelist",
  211. X                   xedwListWidgetClass,
  212. X                   fileview,
  213. X                   arglist, i);
  214. X
  215. X
  216. X  /* Get font height from filelist, then set fileview to be 5 times that
  217. X   * size.
  218. X   */
  219. X
  220. X  i = 0;
  221. X  XtSetArg(arglist[i], XtNfont, &font); i++;
  222. X  XtSetArg(arglist[i], XtNrowSpacing, &space); i++;
  223. X  XtGetValues(filelist, arglist, i);
  224. X
  225. X  height = (font->max_bounds.ascent +
  226. X           font->max_bounds.descent +
  227. X       space) * 5;
  228. X
  229. X  i = 0;
  230. X  XtSetArg(arglist[i], XtNheight, height); i++;
  231. X  XtSetValues(fileview, arglist, i);
  232. X
  233. X
  234. X  i = 0;
  235. X  XtSetArg(arglist[i], XtNfromVert,       fileview);  i++; 
  236. X  XtSetArg(arglist[i], XtNjustify, XtJustifyCenter);  i++;
  237. X  buttonno   =   XtCreateManagedWidget("buttonyes",
  238. X                       commandWidgetClass,
  239. X                       buttonform,
  240. X                       arglist, i);
  241. X  i = 2;
  242. X  XtSetArg(arglist[i], XtNfromHoriz,   buttonno);  i++;
  243. X  XtSetArg(arglist[i], XtNwidthLinked, buttonno);  i++;
  244. X  buttonyes  =   XtCreateManagedWidget("buttonyes",
  245. X                       commandWidgetClass,
  246. X                       buttonform,
  247. X                       arglist, i);
  248. X
  249. X}
  250. X
  251. X/*****************************************************************************
  252. X *                                button_dialog                              *
  253. X *****************************************************************************/
  254. Xpublic void button_dialog(Cardinal type, XedwListReturnStruct *list)
  255. X{
  256. X  /* Set the resources of the dialog to the type of dialog required, 
  257. X   * the type is either Trash, Copy or Move then popup the dialog.
  258. X   *
  259. X   * - Takes the type of dialog, and the list of files to display.
  260. X   */
  261. X
  262. X  private int buttoniconcmp(XedwList **, XedwList **);
  263. X  extern String getfilename(String);
  264. X  extern void setscroll(Widget, float);
  265. X
  266. X  XedwListReturnStruct *tmp;
  267. X  XedwList **buttonlist;
  268. X  Arg arglist[5];
  269. X  Cardinal i, n;
  270. X  private String CancelButtonLabel = "Cancel";
  271. X
  272. X  /* Count items in linked list */
  273. X  n = 0;
  274. X  tmp = list;
  275. X  while (tmp != NULL) {
  276. X    tmp = tmp->next;
  277. X    n++;
  278. X  }
  279. X
  280. X  /* Allocate an array of XedwList* of that size */
  281. X  buttonlist = (XedwList**) XtMalloc (sizeof(XedwList*) * (n+1));
  282. X
  283. X  /* Put Strings from linked list into array, using NULL icons */
  284. X  for (i = 0; i < n; i++) {
  285. X    buttonlist[i] = XtNew(XedwList);
  286. X    buttonlist[i]->string = list->string;
  287. X    list = list->next;
  288. X  }
  289. X  buttonlist[i] = NULL;
  290. X
  291. X  /* Sort the list */
  292. X  qsort((char*)buttonlist, n, sizeof(buttonlist[0]), buttoniconcmp);
  293. X
  294. X  /* Reset view to top */
  295. X
  296. X  setscroll(fileview, 0.0);
  297. X
  298. X  switch (type) {
  299. X  case Trash:
  300. X    {
  301. X      extern void trashQueryResult(Widget, Boolean, caddr_t);
  302. X      private String TrashLabel1       = "Delete these files";
  303. X      private String TrashLabel2       = "from current directory?";
  304. X      private String TrashButtonLabel  = "Delete";
  305. X
  306. X      /* label */
  307. X      i = 0;
  308. X      XtSetArg(arglist[i], XtNlabel, TrashLabel1);  i++;
  309. X      XtSetValues(buttonlabel1, arglist, i);
  310. X    
  311. X      /* label2 */
  312. X      i = 0;
  313. X      XtSetArg(arglist[i], XtNlabel,       TrashLabel2);  i++; 
  314. X      XtSetValues(buttonlabel2, arglist, i);
  315. X      
  316. X      /* file list */
  317. X      i = 0;
  318. X      XtSetArg(arglist[i], XtNlongest,           0); i++;
  319. X      XtSetArg(arglist[i], XtNnumberStrings,     0); i++;
  320. X      XtSetArg(arglist[i], XtNxedwList, buttonlist); i++;
  321. X      XtSetValues(filelist, arglist, i);
  322. X
  323. X      /* button1 */
  324. X      i = 0;
  325. X      XtSetArg(arglist[i], XtNlabel, CancelButtonLabel);  i++;
  326. X      XtSetValues(buttonno, arglist, i);
  327. X      
  328. X      /* button2 */
  329. X      i = 0;
  330. X      XtSetArg(arglist[i], XtNlabel,   TrashButtonLabel);  i++;
  331. X      XtSetValues(buttonyes, arglist, i);
  332. X      
  333. X      XtAddCallback(buttonno, XtNcallback, trashQueryResult, False);
  334. X      XtAddCallback(buttonyes, XtNcallback, trashQueryResult, True);
  335. X      realize_dialog(buttonpopup);
  336. X      break;
  337. X    }
  338. X  case Copy:
  339. X    {
  340. X      extern void copyQueryResult(Widget, Boolean, caddr_t);
  341. X      private String CopyLabel1       = "Copy these files";
  342. X      private String CopyLabel2       = "to current directory?";
  343. X      private String CopyButtonLabel  = "Copy";
  344. X
  345. X      /* label */
  346. X      i = 0;
  347. X      XtSetArg(arglist[i], XtNlabel, CopyLabel1);  i++;
  348. X      XtSetValues(buttonlabel1, arglist, i);
  349. X    
  350. X      /* label2 */
  351. X      i = 0;
  352. X      XtSetArg(arglist[i], XtNlabel, CopyLabel2);  i++; 
  353. X      XtSetValues(buttonlabel2, arglist, i);
  354. X      
  355. X      /* file list */
  356. X      i = 0;
  357. X      XtSetArg(arglist[i], XtNlongest,           0); i++;
  358. X      XtSetArg(arglist[i], XtNnumberStrings,     0); i++;
  359. X      XtSetArg(arglist[i], XtNxedwList, buttonlist); i++;
  360. X      XtSetValues(filelist, arglist, i);
  361. X
  362. X      /* button1 */
  363. X      i = 0;
  364. X      XtSetArg(arglist[i], XtNlabel, CancelButtonLabel);  i++;
  365. X      XtSetValues(buttonno, arglist, i);
  366. X      
  367. X      /* button2 */
  368. X      i = 0;
  369. X      XtSetArg(arglist[i], XtNlabel, CopyButtonLabel);  i++;
  370. X      XtSetValues(buttonyes, arglist, i);
  371. X      
  372. X      XtAddCallback(buttonno, XtNcallback,  copyQueryResult, False);
  373. X      XtAddCallback(buttonyes, XtNcallback, copyQueryResult, True);
  374. X      realize_dialog(buttonpopup);
  375. X      break;
  376. X    }
  377. X  case Move:
  378. X    {
  379. X      extern void moveQueryResult(Widget, Boolean, caddr_t);
  380. X      private String MoveLabel1       = "Move these files";
  381. X      private String MoveLabel2       = "to current directory?";
  382. X      private String MoveButtonLabel  = "Move";
  383. X
  384. X      /* label */
  385. X      i = 0;
  386. X      XtSetArg(arglist[i], XtNlabel, MoveLabel1);  i++;
  387. X      XtSetValues(buttonlabel1, arglist, i);
  388. X    
  389. X      /* label2 */
  390. X      i = 0;
  391. X      XtSetArg(arglist[i], XtNlabel, MoveLabel2);  i++; 
  392. X      XtSetValues(buttonlabel2, arglist, i);
  393. X      
  394. X      /* file list */
  395. X      i = 0;
  396. X      XtSetArg(arglist[i], XtNlongest,           0); i++;
  397. X      XtSetArg(arglist[i], XtNnumberStrings,     0); i++;
  398. X      XtSetArg(arglist[i], XtNxedwList, buttonlist); i++;
  399. X      XtSetValues(filelist, arglist, i);
  400. X
  401. X      /* button1 */
  402. X      i = 0;
  403. X      XtSetArg(arglist[i], XtNlabel, CancelButtonLabel);  i++;
  404. X      XtSetValues(buttonno, arglist, i);
  405. X      
  406. X      /* button2 */
  407. X      i = 0;
  408. X      XtSetArg(arglist[i], XtNlabel, MoveButtonLabel);  i++;
  409. X      XtSetValues(buttonyes, arglist, i);
  410. X      
  411. X      XtAddCallback(buttonno, XtNcallback,  moveQueryResult, False);
  412. X      XtAddCallback(buttonyes, XtNcallback, moveQueryResult, True);
  413. X      realize_dialog(buttonpopup);
  414. X      break;
  415. X    }
  416. X
  417. X  default:
  418. X    fprintf(stderr, "Unrecognised button dialog request\n");
  419. X    break;
  420. X  }
  421. X
  422. X}
  423. X
  424. X/*****************************************************************************
  425. X *                             destroy_button_dialog                         *
  426. X *****************************************************************************/
  427. Xpublic void destroy_button_dialog(void)
  428. X{
  429. X  /* Popdown and destroy the callback lists of the dialog */
  430. X
  431. X  XtPopdown(buttonpopup);
  432. X  
  433. X  XtRemoveAllCallbacks(buttonyes, XtNcallback);
  434. X  XtRemoveAllCallbacks(buttonno, XtNcallback);
  435. X
  436. X}
  437. X
  438. X/*****************************************************************************
  439. X *                               buttoniconcmp                               *
  440. X *****************************************************************************/
  441. Xprivate int buttoniconcmp(XedwList **ip1, XedwList **ip2)
  442. X{
  443. X  /* compare the strings of 2 XedwList's */
  444. X
  445. X  return (strcmp((*ip1)->string, 
  446. X         (*ip2)->string));
  447. X}
  448. SHAR_EOF
  449. chmod 0644 xdtm/buttons.c ||
  450. echo 'restore of xdtm/buttons.c failed'
  451. Wc_c="`wc -c < 'xdtm/buttons.c'`"
  452. test 10282 -eq "$Wc_c" ||
  453.     echo 'xdtm/buttons.c: original size 10282, current size' "$Wc_c"
  454. fi
  455. # ============= xdtm/dialogs.c ==============
  456. if test -f 'xdtm/dialogs.c' -a X"$1" != X"-c"; then
  457.     echo 'x - skipping xdtm/dialogs.c (File already exists)'
  458. else
  459. echo 'x - extracting xdtm/dialogs.c (Text)'
  460. sed 's/^X//' << 'SHAR_EOF' > 'xdtm/dialogs.c' &&
  461. X/*****************************************************************************
  462. X ** File          : dialogs.c                                               **
  463. X ** Purpose       : Initialise and Realise dialogs                          **
  464. X ** Author        : Edward Groenendaal                                      **
  465. X ** Date          : 18th Feb 1991                                           **
  466. X ** Documentation : Xdtm Design Folder                                      **
  467. X ** Related Files : quit.c buttons.c listoption.c map.c select.c display.c  **
  468. X **                 newfile.c                            **
  469. X *****************************************************************************/
  470. X
  471. X/* dialog box's provided: Quit    - Quit (yes/no)
  472. X *              Button  - Do action to these files (yes/no)
  473. X *                        Longl   - Select options on Long Listing
  474. X *                        Map     - Map program x over selected files OR
  475. X *                        Select  - Select files using RE x.
  476. X *              Query   - Display file?
  477. X *               Display - Display a file.
  478. X *                     Newfile - Ask for filename, create empty file. 
  479. X *
  480. X */
  481. X
  482. X#include "xdtm.h"
  483. X
  484. X/*****************************************************************************
  485. X *                         createDialogWidgets                               *
  486. X *****************************************************************************/
  487. Xpublic void createDialogWidgets(Widget top)
  488. X{
  489. X  /* Call the initialise procedures of all the xdtm dialogs */
  490. X
  491. X  extern void init_quit(Widget);
  492. X  extern void init_button(Widget);
  493. X  extern void init_listoption(Widget);
  494. X  extern void init_map(Widget);
  495. X  extern void init_query(Widget);
  496. X  extern void init_display(Widget);
  497. X  extern void init_newfile(Widget);
  498. X
  499. X  init_quit(top);
  500. X  init_button(top);
  501. X  init_listoption(top);
  502. X  init_map(top);
  503. X  init_query(top);
  504. X  init_display(top);
  505. X  init_newfile(top);
  506. X                  
  507. X}
  508. X
  509. X/*****************************************************************************
  510. X *                               realize_dialog                              *
  511. X *****************************************************************************/
  512. Xpublic void realize_dialog(Widget popup)
  513. X{
  514. X  /* Given a popup widget this procedure, modified from one in the X Toolkit
  515. X   * Intrinsics Programmers Manual, O'Reilly & Associates, pops it up with
  516. X   * the center of the popup over the center of the application.
  517. X   */
  518. X
  519. X  extern Widget topLevel;
  520. X  Position x,y;
  521. X  Dimension appWidth, appHeight, qWidth, qHeight;
  522. X  XtGeometryResult result;
  523. X  XtWidgetGeometry answer, question;
  524. X  Arg arglist[2];
  525. X  Cardinal i;
  526. X  
  527. X  /* You dont know the dimensions of a widget for certain until it is
  528. X   * realized, therefore realize the dialog.
  529. X   * NOTE: XtRealizeWidget returns without an error if widget is already
  530. X   *       realized, hence no check via XtIsRealized.
  531. X   */
  532. X
  533. X  XtRealizeWidget(popup);
  534. X
  535. X  /* Get dimensions of application */
  536. X  i = 0;
  537. X  XtSetArg(arglist[i], XtNwidth,  &appWidth);    i++;
  538. X  XtSetArg(arglist[i], XtNheight, &appHeight);   i++;
  539. X  XtGetValues(topLevel, arglist, i);
  540. X
  541. X  /* Get dimensions of quit popup */
  542. X  i = 0;
  543. X  XtSetArg(arglist[i], XtNwidth,  &qWidth);    i++;
  544. X  XtSetArg(arglist[i], XtNheight, &qHeight);   i++;
  545. X  XtGetValues(popup, arglist, i);
  546. X
  547. X  /* Translate application coordinates to screen coordinates */
  548. X  XtTranslateCoords(topLevel,
  549. X            (Position) ((appWidth/2)-(qWidth/2)),
  550. X            (Position) ((appHeight/2)-(qHeight/2)),
  551. X            &x, &y);
  552. X
  553. X  /* move popup shell to that position */
  554. X  i = 0;
  555. X  XtSetArg(arglist[i], XtNx, x);  i++;
  556. X  XtSetArg(arglist[i], XtNy, y);  i++;
  557. X  XtSetValues(popup, arglist, i);
  558. X
  559. X  XtPopup(popup, XtGrabNonexclusive);
  560. X  
  561. X}
  562. SHAR_EOF
  563. chmod 0644 xdtm/dialogs.c ||
  564. echo 'restore of xdtm/dialogs.c failed'
  565. Wc_c="`wc -c < 'xdtm/dialogs.c'`"
  566. test 3636 -eq "$Wc_c" ||
  567.     echo 'xdtm/dialogs.c: original size 3636, current size' "$Wc_c"
  568. fi
  569. # ============= xdtm/dirman.c ==============
  570. if test -f 'xdtm/dirman.c' -a X"$1" != X"-c"; then
  571.     echo 'x - skipping xdtm/dirman.c (File already exists)'
  572. else
  573. echo 'x - extracting xdtm/dirman.c (Text)'
  574. sed 's/^X//' << 'SHAR_EOF' > 'xdtm/dirman.c' &&
  575. X/*****************************************************************************
  576. X ** File          : dirman.c                                                **
  577. X ** Purpose       : Directory Manager                                       **
  578. X ** Author        : Edward Groenendaal                                      **
  579. X ** Date          : 18th Feb 1991                                           **
  580. X ** Documentation : Xdtm Design Folder                                      **
  581. X *****************************************************************************/
  582. X
  583. X/* Include the application header file */
  584. X#include "xdtm.h"
  585. X
  586. X/* Include the local header files */
  587. X#include <sys/types.h>
  588. X#include <dirent.h>
  589. X#include <sys/stat.h>
  590. X#include <sys/param.h>
  591. X#include <limits.h>
  592. X#include <X11/Xaw/AsciiText.h>
  593. X
  594. X#include "menus.h"
  595. X#include "Xedw/XedwList.h"
  596. X#include "Xedw/XedwForm.h"
  597. X
  598. X#define LISTSIZE    128        /* The initial size of the icon_list   */
  599. X#define LISTINCR    64        /* The steps by which it will increase */
  600. X
  601. X#ifdef TRUE_SYSV
  602. X#ifndef MAXPATHLEN
  603. X#define MAXPATHLEN 512  /* jcc */
  604. X#endif
  605. X#endif
  606. X
  607. Xpublic void   changestate(Boolean);        /* Change sensitivity */
  608. Xpublic String getfilename(String);       /* extract filename */
  609. X
  610. Xpublic Widget directoryManager;
  611. Xpublic String cwd;            /* current working directory */
  612. Xpublic Cardinal icon_list_size = 0;
  613. Xpublic Cardinal icon_list_max_size = LISTSIZE;
  614. Xpublic XedwList **icon_list;        /* List with icons and/or filenames */
  615. X
  616. X/* local copies of the menu panes which are to be made insensitive when
  617. X * no there is no current selection.
  618. X */
  619. Xprivate Widget duplicatemenu, trashmenu, 
  620. X               copymenu, movemenu, mapmenu;
  621. X
  622. X
  623. X/*****************************************************************************
  624. X *                       createDirectoryManagerWidgets                       *
  625. X *****************************************************************************/
  626. Xpublic void createDirectoryManagerWidgets(Widget view)
  627. X{
  628. X  /* Create the directory manager widget 
  629. X   *
  630. X   * - Takes the directoryManager's parent widget
  631. X   */
  632. X
  633. X  public  void selection_made(Widget, caddr_t, caddr_t);
  634. X  private void DoubleClick(Widget, XButtonEvent*);
  635. X  private void GoUp(Widget, XButtonEvent*);
  636. X  private void SelectAll(Widget, XButtonEvent*);
  637. X  private void Refresh(Widget, XButtonEvent*);
  638. X
  639. X  extern Icon_mode current_mode;
  640. X  Cardinal i;
  641. X  Arg arglist[6];
  642. X  XtTranslations dirManTranslations;
  643. X
  644. X  /* New actions for directoryManager */
  645. X  static XtActionsRec actions[] = {
  646. X    {"DoubleClick", DoubleClick},
  647. X    {"GoUp",        GoUp},
  648. X    {"SelectAll",   SelectAll},
  649. X    {"Refresh",     Refresh},
  650. X    {NULL, NULL}
  651. X  };
  652. X
  653. X  /* New translations for directoryManager */
  654. X  static char defaultTranslations[] =
  655. X             "<Btn1Up>(2):     DoubleClick()\n\
  656. X              <Key>u:          GoUp()\n\
  657. X              <Key>a:          SelectAll()\n\
  658. X          Ctrl<Key>L:      Refresh()";
  659. X  
  660. X  /* Set the initial mode depending on the value set in the application
  661. X   * defaults. (current_mode.mode set previously to this value when 
  662. X   * creating widgets.
  663. X   */
  664. X  i = 0;
  665. X  switch (current_mode.mode) {
  666. X  case Icons:
  667. X    XtSetArg(arglist[i], XtNshowIcons, True); i++;
  668. X    break;
  669. X  case Short:
  670. X    XtSetArg(arglist[i], XtNshowIcons,   False); i++;
  671. X    XtSetArg(arglist[i], XtNrowSpacing, 5); i++;
  672. X    break;
  673. X  case Long:
  674. X    XtSetArg(arglist[i], XtNshowIcons,   False); i++;
  675. X    XtSetArg(arglist[i], XtNrowSpacing,      5); i++;
  676. X    XtSetArg(arglist[i], XtNforceColumns, True); i++;
  677. X    XtSetArg(arglist[i], XtNdefaultColumns,  1); i++;    
  678. X  }
  679. X  XtSetArg(arglist[i], XtNfont, app_data.dm_font); i++;    
  680. X  XtSetArg(arglist[i], XtNmSelections,      True); i++;
  681. X  directoryManager    =   XtCreateManagedWidget("directoryManager",
  682. X                        xedwListWidgetClass,
  683. X                        view,
  684. X                        arglist, i);
  685. X
  686. X  /* Add callbacks and translations */
  687. X  XtAddCallback(directoryManager, XtNcallback, selection_made, 0);
  688. X  XtAddActions(actions, XtNumber(actions));
  689. X  dirManTranslations = XtParseTranslationTable(defaultTranslations);
  690. X  XtAugmentTranslations(directoryManager, dirManTranslations);
  691. X}
  692. X
  693. X/*****************************************************************************
  694. X *                     directoryManagerNewDirectory                          *
  695. X *****************************************************************************/
  696. Xpublic Boolean directoryManagerNewDirectory(String newpath)
  697. X{
  698. X  /* Change the contents of the directoryManager to that of the directory
  699. X   * contained in the string newpath.
  700. X   */
  701. X
  702. X  extern Boolean getIconType(String, String, XedwList*);
  703. X  extern void setCursor(Cursor);
  704. X  extern void setscroll(Widget, float);
  705. X  private int iconcmp(XedwList*, XedwList*);
  706. X
  707. X  extern Icon_mode current_mode;
  708. X  extern Cursor busy;
  709. X  extern Widget dirSelector;
  710. X  extern Widget directoryManagerView;
  711. X  Arg args[1];
  712. X  XedwList temp;
  713. X  DIR *dirp;
  714. X  struct dirent *dp;
  715. X  Cardinal i = 0, n;
  716. X  Boolean result = False; /* Whether the change of directories succeeded */
  717. X
  718. X  /* create a new one */
  719. X  if ((dirp = opendir(newpath)) != NULL && chdir(newpath) == 0) {
  720. X
  721. X    /* set cursor to busy */
  722. X    setCursor(busy);
  723. X
  724. X    /* Trash old list */
  725. X    for(i=0; i < icon_list_size; i++) {
  726. X      XtFree(icon_list[i]->string);
  727. X      XtFree(icon_list[i]);
  728. X    }
  729. X
  730. X    /* Get icon type for each file */
  731. X    i = 0;
  732. X    while ((dp = readdir(dirp)) != NULL) {
  733. X      if (i == icon_list_max_size) {
  734. X    icon_list_max_size += LISTINCR;
  735. X    icon_list = (XedwList**) XtRealloc(icon_list,
  736. X                       sizeof(XedwList*) * 
  737. X                       icon_list_max_size);
  738. X      } else 
  739. X    if (getIconType(dp->d_name, newpath, &temp)) {
  740. X      icon_list[i] = XtNew(XedwList);
  741. X      icon_list[i]->string = temp.string;
  742. X      icon_list[i]->icon   = temp.icon;
  743. X      i++;
  744. X    }
  745. X    }
  746. X    icon_list[i] = NULL;    /* NULL terminated */
  747. X    icon_list_size = i;
  748. X
  749. X    /* Sort the list */
  750. X    qsort((char*)icon_list, icon_list_size, sizeof(icon_list[0]), iconcmp);
  751. X
  752. X    /* Change the contents of the directory Manager */
  753. X    XedwListChange(directoryManager, icon_list, icon_list_size, 0, True);
  754. X
  755. X    /* Set the scrollbar of the viewport to the top */
  756. X    setscroll(directoryManagerView, 0.0);
  757. X    
  758. X    closedir(dirp);
  759. X    result = True;
  760. X
  761. X    /* Change entry in the directory selector */
  762. X    XtSetArg(args[0], XtNstring, newpath); 
  763. X    XtSetValues(dirSelector, args, 1);
  764. X    /* reset cursor */
  765. X    setCursor(NULL);
  766. X  } else 
  767. X    XBell(XtDisplay(directoryManager), 100);
  768. X  return(result);
  769. X}
  770. X
  771. X/*****************************************************************************
  772. X *                                iconcmp                                    *
  773. X *****************************************************************************/
  774. Xprivate int iconcmp(XedwList **ip1, XedwList **ip2)
  775. X{
  776. X  /* compare the strings of 2 XedwList's */
  777. X
  778. X  return (strcmp(getfilename((*ip1)->string), 
  779. X         getfilename((*ip2)->string)));
  780. X}
  781. X
  782. X/*****************************************************************************
  783. X *                              initDirectoryManager                         *
  784. X *****************************************************************************/
  785. Xpublic void initDirectoryManager(void)
  786. X{
  787. X  /* Get the menubar pane widgets, create the initial icon_list, find 
  788. X   * out what the current directory is.
  789. X   */
  790. X
  791. X  extern Boolean buttonSensitive;
  792. X  extern Widget menuBar;
  793. X  char tmpcwd[MAXPATHLEN];
  794. X
  795. X  /* Initialise the icon list */
  796. X  icon_list = (XedwList**) XtMalloc(sizeof(XedwList*) * LISTSIZE);
  797. X
  798. X  /* Set the starting directory */
  799. X#ifdef USE_CWD
  800. X  if (getcwd(tmpcwd, MAXPATHLEN) != NULL)
  801. X#else
  802. X  if (getwd(tmpcwd) != NULL) 
  803. X#endif
  804. X    cwd = XtNewString(tmpcwd);
  805. X  else
  806. X    if ((cwd = (char*) getenv("HOME")) == NULL) 
  807. X      cwd = XtNewString("/");
  808. X    else
  809. X      cwd = XtNewString(cwd);
  810. X
  811. X  /* Get the id's of the menu widgets which are to be toggled with the
  812. X   * buttons. Note: This relies on the menus being created first, which
  813. X   * they are.
  814. X   */
  815. X  if ((duplicatemenu = 
  816. X       XtNameToWidget(menuBar, "fileMenuButton.fileMenu.duplicate")) == NULL) {
  817. X    fprintf(stderr, "Directorymanager: Can't find duplicate menu widget\n");
  818. X    exit(2);
  819. X  }
  820. X  if ((trashmenu   = 
  821. X       XtNameToWidget(menuBar, "fileMenuButton.fileMenu.trash")) == NULL) {
  822. X    fprintf(stderr, "Directorymanager: Can't find trash menu widget\n");
  823. X    exit(2);
  824. X  }
  825. X  if ((copymenu    = 
  826. X       XtNameToWidget(menuBar, "fileMenuButton.fileMenu.copy")) == NULL) {
  827. X    fprintf(stderr, "Directorymanager: Can't find copy menu widget\n");
  828. X    exit(2);
  829. X  }
  830. X  if ((movemenu    = 
  831. X       XtNameToWidget(menuBar, "fileMenuButton.fileMenu.move")) == NULL) {
  832. X    fprintf(stderr, "Directorymanager: Can't find move menu widget\n");
  833. X    exit(2);
  834. X  }
  835. X  if ((mapmenu     = 
  836. X       XtNameToWidget(menuBar, "optionMenuButton.optionMenu.map")) == NULL) {
  837. X    fprintf(stderr, "Directorymanager: Can't find map menu widget\n");
  838. X    exit(2);
  839. X  }
  840. X  (void) directoryManagerNewDirectory(cwd);
  841. X  buttonSensitive = True;
  842. X  changestate(False);        /* Insure that menus are insensitive */
  843. X}
  844. X
  845. X/*****************************************************************************
  846. X *                              selection_made                               *
  847. X *****************************************************************************/
  848. Xpublic void selection_made(Widget w, caddr_t client_data, caddr_t call_data)
  849. X{
  850. X  /* Someone has either selected or deselected an item.
  851. X   * If there's nothing selected then buttons are changed to 
  852. X   * not sensitive.
  853. X   */
  854. X
  855. X  extern Boolean buttonSensitive;
  856. X  extern Widget trashButton, copyButton, moveButton;
  857. X  Arg arglist[1];
  858. X  Cardinal i;
  859. X
  860. X
  861. X  if (XedwListSelection(w) != buttonSensitive)
  862. X    if (buttonSensitive == False) {
  863. X      changestate(True);
  864. X    } else {
  865. X      changestate(False);
  866. X    }
  867. X}
  868. X
  869. X/*****************************************************************************
  870. X *                              DoubleClick                                  *
  871. X *****************************************************************************/
  872. Xprivate void DoubleClick(Widget w, XButtonEvent *event)
  873. X{
  874. X  /* Either Start a program, View a file or change directory.
  875. X   * executable = try to exec it.
  876. X   * directory  = try to enter it.
  877. X   * otherwise offer to view it.
  878. X   *
  879. X   * Maybe add stuff here to start a predefined application with this
  880. X   * file as an argument if the filename matches a particular pattern,
  881. X   * (James Beal, Henry Thomas)
  882. X   *
  883. X   * e.g. "\.ps$"  -> "xps !@"
  884. X   *      "\.man$" -> "xterm -T 'Manual Page' -e sh -c 'nroff -man !@ | less'"
  885. X   *      "\.gif$" -> "xview !@"
  886. X   */
  887. X
  888. X  extern void query_dialog(String, Boolean);
  889. X  extern int execute(String, String, String, Boolean);
  890. X
  891. X  extern Boolean buttonSensitive;
  892. X  extern Widget trashButton, moveButton, copyButton;
  893. X
  894. X  struct stat filestatus;
  895. X  String fullname, filename, temp;
  896. X  XedwListReturnStruct *highlighted;
  897. X  Arg arglist[1];
  898. X  Cardinal i;
  899. X
  900. X  selection_made(w, (caddr_t)0, (caddr_t)0);
  901. X  highlighted = XedwListShowCurrent(w);
  902. X
  903. X  if (highlighted->xedwList_index != XDTM_LIST_NONE) {
  904. X    filename = getfilename(highlighted->string);
  905. X    fullname=(String) XtMalloc((strlen(filename)+strlen(cwd)+2) * sizeof(char));
  906. X    strcpy(fullname, cwd);
  907. X    if (strcmp(cwd, "/") != 0)
  908. X      strcat(fullname, "/");
  909. X    strcat(fullname, filename);
  910. X
  911. X    /* Use normal stat.. follows symbolic links */
  912. X    if (stat(fullname, &filestatus) == -1) {
  913. X      fprintf(stderr,"xdtm: ARRRGGHHH stat error\n");
  914. X    } else {
  915. X      if ((filestatus.st_mode & S_IFMT) == S_IFDIR) {
  916. X    if (strcmp(filename, "..") == 0) {
  917. X      strcpy(fullname, cwd);
  918. X      if ((temp = (char*) strrchr(fullname, '/')) == NULL) 
  919. X        fprintf(stderr, "xdtm: impossible error\n");
  920. X      if (temp == fullname)
  921. X        *(temp+1) = '\0';
  922. X      else
  923. X        *temp = '\0';
  924. X    }  
  925. X    if (strcmp(filename, ".") == 0) {
  926. X      XtFree(fullname);
  927. X      fullname=XtNewString(cwd);
  928. X    }
  929. X    if (directoryManagerNewDirectory(fullname) == True) {
  930. X      XtFree(cwd);
  931. X      cwd=fullname;
  932. X      changestate(False);
  933. X    } else XBell(XtDisplay(w), 100);
  934. X      } else {
  935. X    /* Not a directory, is it executable? */
  936. X    if ((filestatus.st_mode & S_IXUSR) != 0 ||
  937. X        (filestatus.st_mode & S_IXGRP) != 0 ||
  938. X        (filestatus.st_mode & S_IXOTH) != 0) {
  939. X      extern void setCursor(Cursor);
  940. X      extern Cursor busy;
  941. X
  942. X      setCursor(busy);
  943. X      execute(fullname, filename, filename, False);
  944. X      setCursor(NULL);
  945. X    } else
  946. X      if ((filestatus.st_mode & S_IFMT) == S_IFREG) {
  947. X        /* Display dialog box to ask whether to display file */
  948. X        query_dialog(fullname, True);
  949. X      } else XBell(XtDisplay(w), 100);
  950. X    XtFree(fullname);
  951. X      }
  952. X    }
  953. X    XtFree(highlighted);
  954. X  }
  955. X}
  956. X
  957. X/*****************************************************************************
  958. X *                                     GoUp                                  *
  959. X *****************************************************************************/
  960. Xprivate void GoUp(Widget w, XButtonEvent *event)
  961. X{
  962. X  /* Change to the directory immeditaly above the current one,
  963. X   * does this by highlighting the .. directory, then calling 
  964. X   * DoubleClick to change to the highlighted directory. 
  965. X   * I used this longwinded approach because it showed on screen
  966. X   * what was actually happening.
  967. X   */
  968. X
  969. X  Cardinal i;
  970. X  /* Find entry with .. */
  971. X  for (i=0; i < icon_list_size && 
  972. X       (strcmp(getfilename(icon_list[i]->string), "..") != 0); i++); 
  973. X
  974. X  XedwListUnhighlight(w, XedwAll);
  975. X  /* Call XedwListHighlight with item number */
  976. X  XedwListHighlight(w, i);
  977. X
  978. X  /* Call double click */
  979. X
  980. X  DoubleClick(w, (XButtonEvent*) NULL);
  981. X
  982. X}
  983. X
  984. X/*****************************************************************************
  985. X *                                 SelectAll                                 *
  986. X *****************************************************************************/
  987. Xprivate void SelectAll(Widget w, XButtonEvent *event)
  988. X{
  989. X  /* Select All the files in the current directory except for . and .. */
  990. X
  991. X  extern Boolean buttonSensitive;
  992. X  extern Widget trashButton, moveButton, copyButton;
  993. X  public void changestate(Boolean);
  994. X  extern void setCursor(Cursor);
  995. X  extern Mode mode;
  996. X  extern Cursor busy;
  997. X
  998. X  Arg arglist[1];
  999. X  Cardinal i;
  1000. X
  1001. X  /* Don't do it if in copy or move mode */
  1002. X  if (mode == NormalMode) {
  1003. X    setCursor(busy);
  1004. X    XedwListHighlight(w, XedwAll);
  1005. X    
  1006. X    /* unhighlight . and .. */
  1007. X    for (i=0; i < icon_list_size && 
  1008. X     (strcmp(getfilename(icon_list[i]->string), ".") != 0); i++); 
  1009. X    XedwListUnhighlight(w, i);
  1010. X    for (i=i; i < icon_list_size && 
  1011. X     (strcmp(getfilename(icon_list[i]->string), "..") != 0); i++); 
  1012. X    XedwListUnhighlight(w, i);
  1013. X    setCursor(NULL);
  1014. X  } else
  1015. X    XBell(XtDisplay(w), 100);
  1016. X  
  1017. X  /* do buttons */
  1018. X  if (icon_list_size > 2) {
  1019. X    changestate(True);
  1020. X  }
  1021. X}
  1022. X
  1023. X/*****************************************************************************
  1024. X *                                Refresh                                    *
  1025. X *****************************************************************************/
  1026. Xprivate void Refresh(Widget w, XButtonEvent *event)
  1027. X{
  1028. X  /* Refresh the current directory contents to the actual contents.
  1029. X   */
  1030. X
  1031. X  directoryManagerNewDirectory(cwd);
  1032. X}
  1033. X
  1034. X/*****************************************************************************
  1035. X *                               changestate                                 *
  1036. X *****************************************************************************/
  1037. Xpublic void changestate(Boolean new)
  1038. X{
  1039. X  /* Toggle the sensitivity of all the widgets which may not be used
  1040. X   * when no files are highlighted.
  1041. X   *
  1042. X   * - Takes the new state for widgets.
  1043. X   */
  1044. X
  1045. X  extern Boolean buttonSensitive;
  1046. X  extern Widget trashButton, copyButton, moveButton;
  1047. X  extern Mode mode;
  1048. X
  1049. X  if (buttonSensitive == True) {
  1050. X    if (mode == MoveMode) {
  1051. X      /* Turn off Trash and Copy */
  1052. X      XtSetSensitive(copyButton,    False);
  1053. X      XtSetSensitive(trashButton,   False);
  1054. X      XtSetSensitive(copymenu,      False);
  1055. X      XtSetSensitive(trashmenu,     False);
  1056. X      XtSetSensitive(mapmenu,       False);
  1057. X      XtSetSensitive(duplicatemenu, False);
  1058. X      buttonSensitive = False;
  1059. X    } else if (mode == CopyMode) {
  1060. X      /* Turn off Trash and Move */
  1061. X      XtSetSensitive(moveButton,    False);
  1062. X      XtSetSensitive(trashButton,   False);
  1063. X      XtSetSensitive(movemenu,      False);
  1064. X      XtSetSensitive(trashmenu,     False);
  1065. X      XtSetSensitive(mapmenu,       False);
  1066. X      XtSetSensitive(duplicatemenu, False);
  1067. X      buttonSensitive = False;
  1068. X    } else if (new == False) {
  1069. X      /* Turn off All */
  1070. X      XtSetSensitive(moveButton,    False);
  1071. X      XtSetSensitive(copyButton,    False);
  1072. X      XtSetSensitive(trashButton,   False);
  1073. X      XtSetSensitive(copymenu,      False);
  1074. X      XtSetSensitive(movemenu,      False);
  1075. X      XtSetSensitive(trashmenu,     False);
  1076. X      XtSetSensitive(mapmenu,       False);
  1077. X      XtSetSensitive(duplicatemenu, False);
  1078. X      buttonSensitive = False;
  1079. X    }
  1080. X  } else {
  1081. X    /* buttonSensitive == False */
  1082. X
  1083. X    /* If in MoveMode or CopyMode, then everything is set anyway */
  1084. X    if (mode == NormalMode && new == True) {
  1085. X      /* Set all to True */
  1086. X      XtSetSensitive(trashButton,   True);
  1087. X      XtSetSensitive(moveButton,    True);
  1088. X      XtSetSensitive(copyButton,    True);
  1089. X      XtSetSensitive(trashmenu,     True);
  1090. X      XtSetSensitive(movemenu,      True);
  1091. X      XtSetSensitive(copymenu,      True);
  1092. X      XtSetSensitive(duplicatemenu, True);
  1093. X      XtSetSensitive(mapmenu,       True);
  1094. X      buttonSensitive = True;
  1095. X    }
  1096. X  }
  1097. X}
  1098. X
  1099. X/*****************************************************************************
  1100. X *                              getfilename                                  *
  1101. X *****************************************************************************/
  1102. Xpublic String getfilename(String s)
  1103. X{
  1104. X  /* If in Long Listing mode this function returns the filename part
  1105. X   * of the string used in the directory list. If not in Long Listing
  1106. X   * then return the string unmolested.
  1107. X   */
  1108. X  extern Icon_mode current_mode;
  1109. X
  1110. X  if (current_mode.mode == Long && (strlen(s) > current_mode.length))
  1111. X    return (s+current_mode.length);
  1112. X  else
  1113. X    return (s);
  1114. X}
  1115. SHAR_EOF
  1116. chmod 0644 xdtm/dirman.c ||
  1117. echo 'restore of xdtm/dirman.c failed'
  1118. Wc_c="`wc -c < 'xdtm/dirman.c'`"
  1119. test 17893 -eq "$Wc_c" ||
  1120.     echo 'xdtm/dirman.c: original size 17893, current size' "$Wc_c"
  1121. fi
  1122. true || echo 'restore of xdtm/display.c failed'
  1123. echo End of part 5, continue with part 6
  1124. exit 0
  1125.  
  1126. --
  1127. Dan Heller
  1128. O'Reilly && Associates       Z-Code Software    Comp-sources-x:
  1129. Senior Writer                President          comp-sources-x@uunet.uu.net
  1130. argv@ora.com                 argv@zipcode.com
  1131.