copydialog.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: copydialog.c /main/6 1996/10/29 17:08:29 mustafa $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. *
  27. * FILE: copydialog.c
  28. *
  29. *
  30. * DESCRIPTION: create dtcopy main dialog window
  31. *
  32. * FUNCTIONS: cancel_callback
  33. * create_copydir_dialog
  34. * create_error_text_window
  35. * desensitize_copy_action_area
  36. * display_cancel_warning
  37. * get_icons
  38. * ok_callback
  39. * pause_callback
  40. * sensitize_copy_action_area
  41. * warning_no_callback
  42. * warning_yes_callback
  43. *
  44. *
  45. * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
  46. * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
  47. * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
  48. * (c) Copyright 1993, 1994, 1995 Novell, Inc.
  49. *
  50. ****************************************************************************
  51. ************************************<+>*************************************/
  52. #include <stdio.h>
  53. #include <stdlib.h>
  54. #include <fcntl.h>
  55. #include <signal.h>
  56. #include <sys/wait.h>
  57. #include <time.h>
  58. #include <X11/Intrinsic.h>
  59. #include <X11/StringDefs.h>
  60. #include <Xm/Xm.h>
  61. #include <Xm/XmP.h>
  62. #include <Xm/PushB.h>
  63. #include <Xm/Label.h>
  64. #include <Xm/Form.h>
  65. #include <Xm/Frame.h>
  66. #include <Xm/BulletinB.h>
  67. #include <Xm/MessageB.h>
  68. #include <Xm/Text.h>
  69. #include <Xm/TextF.h>
  70. #include <Xm/ScrolledW.h>
  71. #include <Xm/Separator.h>
  72. #include <Xm/XmStrDefs.h>
  73. #include <Xm/ToggleB.h>
  74. #include "dtcopy.h"
  75. #include "sharedFuncs.h"
  76. #define VERTICAL_SPACING 5
  77. #define HORIZONTAL_SPACING 8
  78. #define TOP_SPACING (VERTICAL_SPACING + 5)
  79. #define INDENTED_SPACING (HORIZONTAL_SPACING + 5)
  80. /* Cannot put into sharedFuncs.h due to conflict with FileManip.c */
  81. extern int Check(
  82. char *spth,
  83. char *dpth,
  84. int mode);
  85. /*--------------------------------------------------------------------
  86. * Global variables
  87. *------------------------------------------------------------------*/
  88. static Pixmap pxWorking;
  89. static Pixmap pxStopped;
  90. static int pxWorkingMargin;
  91. static int pxStoppedMargin;
  92. static Widget icon;
  93. static void
  94. get_icons(
  95. Widget w)
  96. {
  97. Arg args[2];
  98. Pixel background, foreground, top_shadow, bottom_shadow, select;
  99. Colormap colormap;
  100. unsigned int width1, width2, height, dummy;
  101. /* get foreground and background colors */
  102. XtSetArg (args[0], XmNbackground, &background);
  103. XtSetArg (args[1], XmNcolormap, &colormap);
  104. XtGetValues (w, args, 2);
  105. XmGetColors ( XtScreen(w) , colormap, background,
  106. &foreground, &top_shadow, &bottom_shadow, &select);
  107. /* get "working" pixmap */
  108. pxWorking = XmGetPixmapByDepth(XtScreen(w), "xm_working",
  109. foreground, background, w->core.depth);
  110. if (pxWorking == XmUNSPECIFIED_PIXMAP)
  111. pxWorking = XmGetPixmapByDepth(XtScreen(w), "default_xm_working",
  112. foreground, background, w->core.depth);
  113. /* get "stopped/done" pixmap */
  114. pxStopped = XmGetPixmapByDepth(XtScreen(w), "xm_information",
  115. foreground, background, w->core.depth);
  116. if (pxStopped == XmUNSPECIFIED_PIXMAP)
  117. pxStopped = XmGetPixmapByDepth(XtScreen(w), "default_xm_information",
  118. foreground, background, w->core.depth);
  119. /* get the width of the two pixmaps */
  120. XGetGeometry(XtDisplay(w), pxWorking,
  121. (Window *) &dummy, /* returned root window */
  122. (int *) &dummy, (int *) &dummy, /* x, y of pixmap */
  123. &width1, &height, /* pixmap width, height */
  124. &dummy, &dummy); /* border width, depth */
  125. XGetGeometry(XtDisplay(w), pxStopped,
  126. (Window *) &dummy, /* returned root window */
  127. (int *) &dummy, (int *) &dummy, /* x, y of pixmap */
  128. &width2, &height, /* pixmap width, height */
  129. &dummy, &dummy); /* border width, depth */
  130. /* Compute margins necessary to make the labels the same width */
  131. if (width1 > width2)
  132. {
  133. pxWorkingMargin = 0;
  134. pxStoppedMargin = width1 - width2;
  135. }
  136. else
  137. {
  138. pxWorkingMargin = width2 - width1;
  139. pxStoppedMargin = 0;
  140. }
  141. }
  142. /*--------------------------------------------------------------------
  143. * sensitize & desensitize buttons in copy action area
  144. *------------------------------------------------------------------*/
  145. void
  146. sensitize_copy_action_area(
  147. Widget *pushbutton_array)
  148. {
  149. /* Change icon to "working" */
  150. XtVaSetValues (icon,
  151. XmNlabelPixmap, pxWorking,
  152. XmNmarginLeft, pxWorkingMargin/2,
  153. XmNmarginRight, (pxWorkingMargin + 1)/2,
  154. NULL);
  155. /* Desensitize the OK button */
  156. XtVaSetValues (pushbutton_array[0],
  157. XmNsensitive, FALSE,
  158. NULL);
  159. /* Sensitize the Pause button */
  160. XtVaSetValues (pushbutton_array[1],
  161. XmNsensitive, TRUE,
  162. NULL);
  163. /* Sensitize the Cancel button */
  164. XtVaSetValues (pushbutton_array[2],
  165. XmNsensitive, TRUE,
  166. NULL);
  167. }
  168. void
  169. desensitize_copy_action_area(
  170. Widget *pushbutton_array)
  171. {
  172. /* Change icon to "stopped" */
  173. XtVaSetValues (icon,
  174. XmNlabelPixmap, pxStopped,
  175. XmNmarginLeft, pxStoppedMargin/2,
  176. XmNmarginRight, (pxStoppedMargin + 1)/2,
  177. NULL);
  178. /* Sensitize the OK button */
  179. XtVaSetValues (pushbutton_array[0],
  180. XmNsensitive, TRUE,
  181. NULL);
  182. /* Desensitize the Pause button */
  183. XtVaSetValues (pushbutton_array[1],
  184. XmNsensitive, FALSE,
  185. NULL);
  186. /* Desensitize the Cancel button */
  187. XtVaSetValues (pushbutton_array[2],
  188. XmNsensitive, FALSE,
  189. NULL);
  190. }
  191. /*---------------------------------------------------------------------
  192. *
  193. * warning_yes_callback and warning_no_callback
  194. *
  195. * callback for the warning dialog displayed when user selects cancel
  196. *
  197. *---------------------------------------------------------------------*/
  198. static void
  199. warning_yes_callback(
  200. Widget w,
  201. XtPointer client_data,
  202. XtPointer call_data)
  203. {
  204. G_do_copy=FALSE;
  205. G_wait_on_input = FALSE;
  206. if (G_over_dialog != NULL) {
  207. G_overwrite_selection = G_SKIP;
  208. XtDestroyWidget(G_over_dialog);
  209. G_over_dialog = NULL;
  210. }
  211. if (G_error_dialog != NULL) {
  212. XtDestroyWidget(G_error_dialog);
  213. G_error_dialog = NULL;
  214. }
  215. G_dialog_closed = TRUE;
  216. G_pause_copy = FALSE;
  217. }
  218. static void
  219. warning_no_callback(
  220. Widget w,
  221. XtPointer client_data,
  222. XtPointer call_data)
  223. {
  224. G_pause_copy = G_user_pause_copy;
  225. }
  226. /*-------------------------
  227. *
  228. * display_cancel_warning
  229. *
  230. *------------------------*/
  231. void
  232. display_cancel_warning(Widget parent)
  233. {
  234. XmString msg, dialogTitle, cancelMsg, resumeMsg;
  235. int n;
  236. Arg args[20];
  237. Widget dialog;
  238. String copyWarnMessage = "This will stop the copy process. Any files that have\n\
  239. already been copied will remain in the destination folder.";
  240. String moveWarnMessage = "This will stop the move process. Any files that have\n\
  241. already been moved will remain in the destination folder.";
  242. if (G_move)
  243. {
  244. dialogTitle = XmStringCreateLocalized (GETMESSAGE(3, 12, "Folder Move - Warning"));
  245. msg = XmStringCreateLocalized (GETMESSAGE(3, 10, moveWarnMessage));
  246. cancelMsg = XmStringCreateLocalized (GETMESSAGE(3, 15, "Cancel Move"));
  247. resumeMsg = XmStringCreateLocalized (GETMESSAGE(3, 16, "Continue Move"));
  248. }
  249. else
  250. {
  251. dialogTitle = XmStringCreateLocalized (GETMESSAGE(3, 11, "Folder Copy - Warning"));
  252. msg = XmStringCreateLocalized (GETMESSAGE(3, 7, copyWarnMessage));
  253. cancelMsg = XmStringCreateLocalized (GETMESSAGE(3, 13, "Cancel Copy"));
  254. resumeMsg = XmStringCreateLocalized (GETMESSAGE(3, 14, "Continue Copy"));
  255. }
  256. n = 0;
  257. XtSetArg(args[n], XmNmessageString, msg); n++;
  258. XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
  259. XtSetArg(args[n], XmNdialogTitle, dialogTitle); n++;
  260. dialog = (Widget) XmCreateWarningDialog(parent, "warnDialog", args, n);
  261. XmStringFree(msg);
  262. XmStringFree(dialogTitle);
  263. n = 0;
  264. XtSetArg(args[n], XmNlabelString, cancelMsg); n++;
  265. XtSetValues((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON), args, n);
  266. XmStringFree(cancelMsg);
  267. n = 0;
  268. XtSetArg(args[n], XmNlabelString, resumeMsg); n++;
  269. XtSetValues((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON), args, n);
  270. XmStringFree(resumeMsg);
  271. XtAddCallback((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON),
  272. XmNactivateCallback,
  273. warning_yes_callback,
  274. dialog);
  275. XtAddCallback((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON),
  276. XmNactivateCallback,
  277. warning_no_callback,
  278. dialog);
  279. XtAddCallback((Widget) XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON),
  280. XmNactivateCallback,
  281. help_callback,
  282. (XtPointer) STOPW_HELP_DIALOG);
  283. XtManageChild(dialog);
  284. } /* end display_cancel_warning */
  285. /*--------------------------------------------------------------------
  286. * callbacks
  287. *------------------------------------------------------------------*/
  288. static void
  289. ok_callback(
  290. Widget w,
  291. XtPointer client_data,
  292. XtPointer call_data)
  293. {
  294. G_dialog_closed = TRUE;
  295. G_do_copy = FALSE;
  296. return;
  297. }
  298. void
  299. cancel_callback(
  300. Widget w,
  301. XtPointer client_data,
  302. XtPointer call_data)
  303. {
  304. display_cancel_warning(G_copy_dialog);
  305. G_pause_copy = TRUE;
  306. }
  307. static void
  308. pause_callback(Widget w, XtPointer client_data, XtPointer call_data)
  309. {
  310. XmString xm_string;
  311. Pixmap px;
  312. int margin;
  313. G_pause_copy = !G_pause_copy;
  314. G_user_pause_copy = !G_user_pause_copy;
  315. if (G_user_pause_copy)
  316. {
  317. xm_string = XmStringCreateLocalized(GETMESSAGE(3, 1, "Resume"));
  318. px = pxStopped;
  319. margin = pxStoppedMargin;
  320. }
  321. else
  322. {
  323. xm_string = XmStringCreateLocalized(GETMESSAGE(3, 2, "Pause"));
  324. px = pxWorking;
  325. margin = pxWorkingMargin;
  326. }
  327. XtVaSetValues(w,
  328. XmNlabelString, xm_string,
  329. NULL);
  330. XtVaSetValues(icon,
  331. XmNlabelPixmap, px,
  332. XmNmarginLeft, margin/2,
  333. XmNmarginRight, (margin + 1)/2,
  334. NULL);
  335. return;
  336. }
  337. /*--------------------------------------------------------------------
  338. * create dtcopy dialog
  339. * these widgets are not managed until there is an error
  340. *------------------------------------------------------------------*/
  341. static Widget
  342. create_error_text_window (
  343. Widget parent_widget,
  344. Widget top_widget,
  345. Widget bottom_widget)
  346. {
  347. Widget scrolled_text;
  348. Arg args[15];
  349. int n;
  350. n = 0;
  351. /* set text to non-editable */
  352. XtSetArg(args[n], XmNeditable, FALSE); n ++;
  353. XtSetArg(args[n], XmNcursorPositionVisible, FALSE); n ++;
  354. XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  355. XtSetArg(args[n], XmNrows, 5); n++;
  356. XtSetArg(args[n], XmNscrollVertical, True); n++;
  357. XtSetArg(args[n], XmNscrollHorizontal, True); n++;
  358. /* create the scrolled_text_window */
  359. scrolled_text = XmCreateScrolledText(parent_widget,"error_text", args, n);
  360. /* perform top attachments */
  361. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  362. XtSetArg(args[n], XmNtopWidget,top_widget); n++;
  363. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  364. XtSetArg(args[n], XmNleftOffset, INDENTED_SPACING); n++;
  365. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  366. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  367. XtSetArg(args[n], XmNbottomWidget,bottom_widget); n++;
  368. XtSetValues(XtParent(scrolled_text), args, n);
  369. XtUnmanageChild(XtParent(scrolled_text));
  370. return (scrolled_text);
  371. }
  372. Boolean
  373. create_copydir_dialog(
  374. Widget parent_widget,
  375. char *source,
  376. char *target)
  377. {
  378. Arg args[10];
  379. int n;
  380. XmString xm_string;
  381. Widget form, form1, action_area, summary_label, separator2;
  382. Widget source_label, source_text_field, target_label, target_text_field;
  383. char target_folder[MAX_PATH], target_object[MAX_PATH];
  384. Pixel background;
  385. Pixel foreground;
  386. char *ttarget,*tsource;
  387. Dimension width_target, width_source;
  388. static ActionAreaItem action_items[] = {
  389. {"Ok", 6, 1, ok_callback, NULL},
  390. {"Pause", 6, 2, pause_callback, NULL},
  391. {"Cancel Copy", 6, 7, cancel_callback, NULL}, /* possibly changed below to Cancel Move*/
  392. {"Help", 6, 4, help_callback, (XtPointer) HELP_DIR_COPY},
  393. };
  394. ActionAreaDefn copydirActions = {
  395. XtNumber(action_items),
  396. 0, /* Ok is default action */
  397. action_items
  398. };
  399. /* Save the name of the source directory in order to truncate the pathname */
  400. /* displayed as the copy proceeds ... see function UpdateStatus. */
  401. snprintf(G_source_dir, sizeof(G_source_dir), "%s", source);
  402. tsource = (char * )get_path(source);
  403. ttarget = (char * )get_path(target);
  404. if(Check(tsource,ttarget,G_move))
  405. return False;
  406. split_path(ttarget,target_folder,target_object);
  407. if (G_move)
  408. {
  409. action_items[2].label = "Cancel Move";
  410. action_items[2].msg_num = 8;
  411. }
  412. /* create a frame around the dialog for better
  413. separation from window border */
  414. G_copy_dialog =
  415. XtVaCreateWidget("outerFrame",
  416. xmFrameWidgetClass,
  417. parent_widget,
  418. XmNshadowThickness, 3,
  419. XmNshadowType, XmSHADOW_ETCHED_IN,
  420. NULL);
  421. /* Create the Manager Widget, form, for the copy dialog */
  422. form = XtVaCreateManagedWidget ("dialog_form",
  423. xmFormWidgetClass,
  424. G_copy_dialog,
  425. XmNverticalSpacing, VERTICAL_SPACING,
  426. XmNwidth, 500,
  427. XmNhorizontalSpacing, HORIZONTAL_SPACING,
  428. NULL);
  429. /* create the toggle button */
  430. xm_string = XmStringCreateLocalized(GETMESSAGE(4, 2, "Pause for errors"));
  431. G_toggle_main = XtVaCreateManagedWidget("toggle",
  432. xmToggleButtonWidgetClass,
  433. form,
  434. XmNlabelString, xm_string,
  435. XmNset, !G_ignore_errors,
  436. XmNtopAttachment, XmATTACH_FORM,
  437. XmNtopOffset, TOP_SPACING,
  438. XmNrightAttachment, XmATTACH_FORM,
  439. XmNrightOffset, INDENTED_SPACING,
  440. XmNalignment, XmALIGNMENT_BEGINNING,
  441. NULL);
  442. XtAddCallback(G_toggle_main, XmNvalueChangedCallback, toggle_callback, NULL);
  443. XmStringFree(xm_string);
  444. /* Create a form for the working/stopped icon, from/to path names, and summary lines */
  445. form1 = XtVaCreateWidget ("msg_form",
  446. xmFormWidgetClass,
  447. form,
  448. XmNtopAttachment, XmATTACH_WIDGET,
  449. XmNtopWidget, G_toggle_main,
  450. XmNtopOffset, TOP_SPACING,
  451. XmNleftAttachment, XmATTACH_FORM,
  452. XmNrightAttachment, XmATTACH_FORM,
  453. NULL);
  454. /* Create the working/stopped icon */
  455. get_icons(form1);
  456. icon = XtVaCreateManagedWidget("working_icon",
  457. xmLabelWidgetClass,
  458. form1,
  459. XmNlabelType, XmPIXMAP,
  460. XmNlabelPixmap, pxWorking,
  461. XmNmarginLeft, pxWorkingMargin/2,
  462. XmNmarginRight, (pxWorkingMargin + 1)/2,
  463. XmNtopAttachment, XmATTACH_FORM,
  464. XmNbottomAttachment, XmATTACH_FORM,
  465. XmNleftAttachment, XmATTACH_FORM,
  466. NULL);
  467. /* MJT Get color map from this particular spot in the
  468. widget hierarchy. This is being done because of a strange
  469. behavior found in the widget hierarchy. The behavior is
  470. identified by a change of the background and forground color
  471. making children widgets look somewhat odd. It is possible
  472. that this is a bug that will be modified in the future.
  473. */
  474. XtSetArg (args[0], XmNbackground, &background);
  475. XtSetArg (args[1], XmNforeground, &foreground);
  476. XtGetValues (form1, args, 2);
  477. /* Create the Source Directory Widgets */
  478. if (G_move)
  479. xm_string = XmStringCreateLocalized(GETMESSAGE(3, 3, "Moving:"));
  480. else
  481. xm_string = XmStringCreateLocalized(GETMESSAGE(3, 4, "Copying:"));
  482. source_label =
  483. XtVaCreateManagedWidget("source_label",
  484. xmLabelWidgetClass,
  485. form1,
  486. XmNlabelString, xm_string,
  487. XmNalignment, XmALIGNMENT_BEGINNING,
  488. XmNtopAttachment, XmATTACH_FORM,
  489. XmNleftAttachment, XmATTACH_WIDGET,
  490. XmNleftWidget, icon,
  491. XmNleftOffset, HORIZONTAL_SPACING,
  492. NULL);
  493. XmStringFree(xm_string);
  494. xm_string = XmStringCreateLocalized(tsource);
  495. source_text_field =
  496. XtVaCreateManagedWidget("source_text_field",
  497. xmLabelWidgetClass,
  498. form1,
  499. XmNlabelString, xm_string,
  500. XmNalignment, XmALIGNMENT_BEGINNING,
  501. XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
  502. XmNtopWidget, source_label,
  503. XmNtopOffset, 0,
  504. XmNleftAttachment, XmATTACH_WIDGET,
  505. XmNleftWidget, source_label,
  506. XmNrightAttachment, XmATTACH_FORM,
  507. NULL);
  508. XmStringFree(xm_string);
  509. /* Create the Target Directory Widgets */
  510. xm_string = XmStringCreateLocalized(GETMESSAGE(3, 5, "Into folder:"));
  511. target_label =
  512. XtVaCreateManagedWidget("target_label",
  513. xmLabelWidgetClass,
  514. form1,
  515. XmNlabelString, xm_string,
  516. XmNalignment, XmALIGNMENT_BEGINNING,
  517. XmNtopAttachment, XmATTACH_WIDGET,
  518. XmNtopWidget, source_label,
  519. XmNleftAttachment, XmATTACH_WIDGET,
  520. XmNleftWidget, icon,
  521. XmNleftOffset, HORIZONTAL_SPACING,
  522. NULL);
  523. XmStringFree(xm_string);
  524. /* modify width of shorter label so the labels are right-aligned */
  525. XtVaGetValues(target_label,
  526. XmNwidth, &width_target,
  527. NULL);
  528. XtVaGetValues(source_label,
  529. XmNwidth, &width_source,
  530. NULL);
  531. if (width_target < width_source)
  532. {
  533. XtVaSetValues(target_label,
  534. XmNwidth, width_source,
  535. XmNalignment, XmALIGNMENT_END,
  536. NULL);
  537. }
  538. else if (width_target > width_source) /* do nothing if widths are the same */
  539. {
  540. XtVaSetValues(source_label,
  541. XmNwidth, width_target,
  542. XmNalignment, XmALIGNMENT_END,
  543. NULL);
  544. }
  545. xm_string = XmStringCreateLocalized(target_folder);
  546. target_text_field =
  547. XtVaCreateManagedWidget("target_text_field",
  548. xmLabelWidgetClass,
  549. form1,
  550. XmNlabelString, xm_string,
  551. XmNalignment, XmALIGNMENT_BEGINNING,
  552. XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
  553. XmNtopWidget, target_label,
  554. XmNtopOffset, 0,
  555. XmNleftAttachment, XmATTACH_WIDGET,
  556. XmNleftWidget, target_label,
  557. XmNrightAttachment, XmATTACH_FORM,
  558. NULL);
  559. /* create copy-summary text field */
  560. if (G_move)
  561. xm_string = XmStringCreateLocalized(GETMESSAGE(3, 17, "Moved"));
  562. else
  563. xm_string = XmStringCreateLocalized(GETMESSAGE(3, 18, "Copied"));
  564. summary_label =
  565. XtVaCreateManagedWidget("target_label",
  566. xmLabelWidgetClass,
  567. form1,
  568. XmNlabelString, xm_string,
  569. XmNalignment, XmALIGNMENT_END,
  570. XmNtopAttachment, XmATTACH_WIDGET,
  571. XmNtopWidget, target_label,
  572. XmNtopOffset, TOP_SPACING,
  573. XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET,
  574. XmNrightWidget, target_label,
  575. XmNrightOffset, 0,
  576. XmNleftAttachment, XmATTACH_WIDGET,
  577. XmNleftWidget, icon,
  578. NULL);
  579. XmStringFree(xm_string);
  580. G_summary_text =
  581. XtVaCreateManagedWidget("copy_summary",
  582. xmLabelWidgetClass,
  583. form1,
  584. XmNtopAttachment, XmATTACH_WIDGET,
  585. XmNtopWidget, target_label,
  586. XmNtopOffset, TOP_SPACING,
  587. XmNleftAttachment, XmATTACH_WIDGET,
  588. XmNleftWidget, summary_label,
  589. XmNrightAttachment, XmATTACH_FORM,
  590. XmNalignment, XmALIGNMENT_BEGINNING,
  591. NULL);
  592. /* that is all that goes in form1 */
  593. XtManageChild(form1);
  594. /* create the action area of the Copy Directory Dialog */
  595. action_area =
  596. Create_Action_Area(form, copydirActions, G_copy_action_area_pbuttons);
  597. /* create the second separator widget */
  598. separator2 =
  599. XtVaCreateManagedWidget("separator",
  600. xmSeparatorWidgetClass,
  601. form,
  602. XmNbottomAttachment, XmATTACH_WIDGET,
  603. XmNbottomWidget, action_area,
  604. XmNleftAttachment, XmATTACH_FORM,
  605. XmNrightAttachment, XmATTACH_FORM,
  606. NULL);
  607. /* create copy-status text field */
  608. G_status_text =
  609. XtVaCreateManagedWidget("copy_status",
  610. xmTextFieldWidgetClass,
  611. form,
  612. XmNbackground, background,
  613. XmNforeground, foreground,
  614. /*
  615. XmNcolumns, 1,
  616. */
  617. XmNresizeWidth, True,
  618. XmNshadowThickness, 0,
  619. XmNhighlightThickness, 0,
  620. XmNtraversalOn, False,
  621. XmNeditable, False,
  622. XmNcursorPositionVisible, False,
  623. XmNtopAttachment, XmATTACH_WIDGET,
  624. XmNtopWidget, G_summary_text,
  625. XmNtopOffset, TOP_SPACING,
  626. XmNrightAttachment, XmATTACH_FORM,
  627. XmNrightOffset, INDENTED_SPACING,
  628. XmNleftAttachment, XmATTACH_FORM,
  629. XmNleftOffset, INDENTED_SPACING,
  630. XmNbottomAttachment, XmATTACH_WIDGET,
  631. XmNbottomWidget, separator2,
  632. NULL);
  633. /* create copy-status text field */
  634. /*
  635. G_status_text2 =
  636. XtVaCreateManagedWidget("copy_status",
  637. xmTextFieldWidgetClass,
  638. form,
  639. XmNbackground, background,
  640. XmNforeground, foreground,
  641. XmNshadowThickness, 0,
  642. XmNhighlightThickness, 0,
  643. XmNtraversalOn, False,
  644. XmNeditable, False,
  645. XmNcursorPositionVisible, False,
  646. XmNtopAttachment, XmATTACH_WIDGET,
  647. XmNtopWidget, G_summary_text,
  648. XmNtopOffset, TOP_SPACING,
  649. XmNleftAttachment, XmATTACH_WIDGET,
  650. XmNleftWidget, G_status_text,
  651. XmNrightAttachment, XmATTACH_FORM,
  652. XmNbottomAttachment, XmATTACH_WIDGET,
  653. XmNbottomWidget, separator2,
  654. NULL);
  655. */
  656. /* create error-count text field ... not managed until there is an error */
  657. G_error_count =
  658. XtVaCreateWidget("error_count",
  659. xmTextFieldWidgetClass,
  660. form,
  661. XmNbackground, background,
  662. XmNforeground, foreground,
  663. XmNshadowThickness, 0,
  664. XmNhighlightThickness, 0,
  665. XmNtraversalOn, False,
  666. XmNeditable, False,
  667. XmNcursorPositionVisible, False,
  668. XmNtopAttachment, XmATTACH_WIDGET,
  669. XmNtopWidget, G_status_text,
  670. XmNtopOffset, TOP_SPACING,
  671. XmNleftAttachment, XmATTACH_FORM,
  672. XmNrightAttachment, XmATTACH_FORM,
  673. NULL);
  674. /* create error-message scroll window ... not managed until there is an error */
  675. G_error_msgs = create_error_text_window (form,
  676. G_error_count,
  677. separator2);
  678. /* set initial keyboard focus to the action button area */
  679. XtSetArg (args[0], XmNinitialFocus, action_area);
  680. XtSetValues(form, args, 1);
  681. /* Manage the Copy Directory Dialog */
  682. XtManageChild(G_copy_dialog);
  683. free(ttarget);
  684. free(tsource);
  685. return True;
  686. }