1 | /* |
---|
2 | Copyright 1991 by the Massachusetts Institute of Technology |
---|
3 | |
---|
4 | Permission to use, copy, modify, and distribute this |
---|
5 | software and its documentation for any purpose and without |
---|
6 | fee is hereby granted, provided that the above copyright |
---|
7 | notice appear in all copies and that both that copyright |
---|
8 | notice and this permission notice appear in supporting |
---|
9 | documentation, and that the name of M.I.T. not be used in |
---|
10 | advertising or publicity pertaining to distribution of the |
---|
11 | software without specific, written prior permission. |
---|
12 | M.I.T. makes no representations about the suitability of |
---|
13 | this software for any purpose. It is provided "as is" |
---|
14 | without express or implied warranty. |
---|
15 | */ |
---|
16 | |
---|
17 | #include <stdio.h> |
---|
18 | #include <string.h> |
---|
19 | #include <ctype.h> |
---|
20 | #include <X11/Intrinsic.h> |
---|
21 | #include <X11/StringDefs.h> |
---|
22 | #include <X11/Xaw/List.h> |
---|
23 | #include <X11/Xaw/Command.h> |
---|
24 | #include <X11/Xaw/Box.h> |
---|
25 | #include <X11/Xaw/Paned.h> |
---|
26 | #include <X11/Xaw/AsciiText.h> |
---|
27 | #include <X11/Xaw/Dialog.h> |
---|
28 | #include <X11/Shell.h> |
---|
29 | #include "xdsc.h" |
---|
30 | |
---|
31 | static char rcsid[] = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/xdsc/reply.c,v 1.16 1998-12-20 23:05:12 rbasch Exp $"; |
---|
32 | |
---|
33 | extern char *getenv(); |
---|
34 | extern char *RunCommand(); |
---|
35 | extern char *CurrentMtg(); |
---|
36 | extern char filebase[]; |
---|
37 | extern int topscreen; |
---|
38 | extern Widget topW, paneW; |
---|
39 | extern TextWidget bottextW; |
---|
40 | extern int char_width; |
---|
41 | extern char *GetTransactionFile(); |
---|
42 | extern Boolean nocache; |
---|
43 | |
---|
44 | static char sourcefile[80]; |
---|
45 | |
---|
46 | static void SendCB(); |
---|
47 | void TriggerSend(); |
---|
48 | |
---|
49 | static Widget writePopupW = 0, writeTextW; |
---|
50 | static void WriteCB(); |
---|
51 | void TriggerWrite(); |
---|
52 | |
---|
53 | static Widget numPopupW = 0, numTextW; |
---|
54 | static void NumCB(); |
---|
55 | void GetTransactionNum(); |
---|
56 | void TriggerNum(); |
---|
57 | |
---|
58 | static Widget addPopupW = 0, addHostTextW, addPathTextW; |
---|
59 | static void AddCB(); |
---|
60 | void TriggerAdd(); |
---|
61 | |
---|
62 | static Widget deletePopupW = 0, deleteMtgTextW; |
---|
63 | static void DeleteCB(); |
---|
64 | void TriggerDelete(); |
---|
65 | |
---|
66 | static Widget warningPopupW = 0; |
---|
67 | void DieCB(); |
---|
68 | void TriggerPopdown(); |
---|
69 | void TriggerFocusMove(); |
---|
70 | int PopdownCB(); |
---|
71 | |
---|
72 | static Widget helpPopupW = 0; |
---|
73 | |
---|
74 | static char *GetDefaultValue(); |
---|
75 | |
---|
76 | static Boolean CompareWithoutWhitespace(); |
---|
77 | |
---|
78 | typedef struct { |
---|
79 | Widget sendPopupW; |
---|
80 | Widget sendButtonW; |
---|
81 | Widget subjectTextW; |
---|
82 | Widget bodyTextW; |
---|
83 | char mtg[80]; |
---|
84 | int replynum; |
---|
85 | } SendData, *SendDataPtr; |
---|
86 | |
---|
87 | typedef struct trnrec { |
---|
88 | SendDataPtr data; |
---|
89 | struct trnrec *nextrec; |
---|
90 | } TransactionRec, *TransactionRecPtr; |
---|
91 | |
---|
92 | static TransactionRecPtr listhead = 0; |
---|
93 | |
---|
94 | /* |
---|
95 | ** The structures TransactionRec and SendData are to keep track of the |
---|
96 | ** contexts for multiple enter-transaction windows. listhead is the |
---|
97 | ** first of a chain of TransactionRec's, one per window. This is |
---|
98 | ** so we can search through the list when a keyhit comes in trying to |
---|
99 | ** trigger a button, and figure out which button matches a particular |
---|
100 | ** text widget. |
---|
101 | */ |
---|
102 | |
---|
103 | void |
---|
104 | SubmitTransaction(myreplynum) |
---|
105 | int myreplynum; |
---|
106 | { |
---|
107 | Arg args[5]; |
---|
108 | unsigned int n; |
---|
109 | char *subjectline; |
---|
110 | char buffer[80]; |
---|
111 | char *ptr1, *ptr2; |
---|
112 | char *returndata; |
---|
113 | Widget localPaneW, box1W, box2W, buttonW; |
---|
114 | SendDataPtr data; |
---|
115 | TransactionRecPtr i; |
---|
116 | |
---|
117 | if (listhead == 0) { |
---|
118 | listhead = (TransactionRecPtr) malloc (sizeof (TransactionRec)); |
---|
119 | listhead->data = 0; |
---|
120 | listhead->nextrec = 0; |
---|
121 | } |
---|
122 | |
---|
123 | for (i = listhead; i->data != 0 && i->nextrec != 0; i = i->nextrec) |
---|
124 | ; |
---|
125 | |
---|
126 | if (i->data != 0) { |
---|
127 | i->nextrec = |
---|
128 | (TransactionRecPtr) malloc (sizeof (TransactionRec)); |
---|
129 | i = i->nextrec; |
---|
130 | i->data = 0; |
---|
131 | i->nextrec = 0; |
---|
132 | } |
---|
133 | |
---|
134 | data = (SendDataPtr) malloc (sizeof (SendData)); |
---|
135 | |
---|
136 | i->data = data; |
---|
137 | |
---|
138 | /* |
---|
139 | ** Save current meeting name and reply number |
---|
140 | */ |
---|
141 | strcpy (data->mtg, CurrentMtg(0)); |
---|
142 | data->replynum = myreplynum; |
---|
143 | |
---|
144 | /* |
---|
145 | ** Find and use the subject of the previous transaction if we are replying. |
---|
146 | */ |
---|
147 | if (myreplynum != 0) { |
---|
148 | sprintf (buffer, "(gti %d %s)\n", myreplynum, CurrentMtg(0)); |
---|
149 | returndata = RunCommand (buffer, NULL, NULL, True); |
---|
150 | |
---|
151 | if ((int) returndata <= 0) { |
---|
152 | return; |
---|
153 | } |
---|
154 | |
---|
155 | /* |
---|
156 | ** Find the third quote |
---|
157 | */ |
---|
158 | for (n = 0, ptr1 = returndata; n < 3; n++) |
---|
159 | while (*ptr1++ != '\"') |
---|
160 | ; |
---|
161 | /* |
---|
162 | ** Copy from just after the third quote to the next non-escaped quote |
---|
163 | */ |
---|
164 | ptr2 = buffer; |
---|
165 | while (*ptr1 != '\"') { |
---|
166 | if (*ptr1 == '\\') |
---|
167 | ptr1++; |
---|
168 | *ptr2++ = *ptr1++; |
---|
169 | } |
---|
170 | *ptr2 = '\0'; |
---|
171 | |
---|
172 | if (!strncmp (buffer, "Re: ", 4)) { |
---|
173 | subjectline = (char *) malloc (strlen(buffer) + 1); |
---|
174 | sprintf (subjectline, "%s", buffer); |
---|
175 | } |
---|
176 | else { |
---|
177 | subjectline = (char *) malloc (strlen(buffer) + 5); |
---|
178 | sprintf (subjectline, "Re: %s", buffer); |
---|
179 | } |
---|
180 | myfree(returndata); |
---|
181 | } |
---|
182 | else { |
---|
183 | subjectline = (char *) malloc (80); |
---|
184 | sprintf (subjectline, ""); |
---|
185 | } |
---|
186 | |
---|
187 | n = 0; |
---|
188 | XtSetArg(args[n], XtNwidth, 80 * char_width); n++; |
---|
189 | data->sendPopupW = XtCreatePopupShell( |
---|
190 | "enterpopup", |
---|
191 | topLevelShellWidgetClass, |
---|
192 | topW, |
---|
193 | args, |
---|
194 | n); |
---|
195 | |
---|
196 | n = 0; |
---|
197 | localPaneW = XtCreateManagedWidget( |
---|
198 | "pane", |
---|
199 | panedWidgetClass, |
---|
200 | data->sendPopupW, |
---|
201 | args, |
---|
202 | n); |
---|
203 | |
---|
204 | if (myreplynum == 0) { |
---|
205 | sprintf ( buffer, |
---|
206 | " (Entering new transaction in %s)", |
---|
207 | CurrentMtg(0)); |
---|
208 | } |
---|
209 | |
---|
210 | else { |
---|
211 | sprintf ( buffer, |
---|
212 | " (Replying to transaction %d in %s)", |
---|
213 | myreplynum, CurrentMtg(0)); |
---|
214 | } |
---|
215 | |
---|
216 | n = 0; |
---|
217 | XtSetArg(args[n], XtNstring, buffer); n++; |
---|
218 | XtSetArg(args[n], XtNeditType, XawtextRead); n++; |
---|
219 | (void) XtCreateManagedWidget( |
---|
220 | "desctext", |
---|
221 | asciiTextWidgetClass, |
---|
222 | localPaneW, |
---|
223 | args, |
---|
224 | n); |
---|
225 | |
---|
226 | n = 0; |
---|
227 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
228 | box1W = XtCreateManagedWidget( |
---|
229 | "topbox", |
---|
230 | boxWidgetClass, |
---|
231 | localPaneW, |
---|
232 | args, |
---|
233 | n); |
---|
234 | |
---|
235 | n = 0; |
---|
236 | (void) XtCreateManagedWidget( |
---|
237 | "label", |
---|
238 | labelWidgetClass, |
---|
239 | box1W, |
---|
240 | args, |
---|
241 | n); |
---|
242 | |
---|
243 | n = 0; |
---|
244 | XtSetArg(args[n], XtNstring, subjectline); n++; |
---|
245 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
246 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
247 | XtSetArg(args[n], XtNwidth, 60 * char_width); n++; |
---|
248 | data->subjectTextW = XtCreateManagedWidget( |
---|
249 | "subjecttext", |
---|
250 | asciiTextWidgetClass, |
---|
251 | box1W, |
---|
252 | args, |
---|
253 | n); |
---|
254 | myfree(subjectline); |
---|
255 | |
---|
256 | n = 0; |
---|
257 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
258 | XtSetArg(args[n], XtNwidth, 80 * char_width); n++; |
---|
259 | data->bodyTextW = XtCreateManagedWidget( |
---|
260 | "bodytext", |
---|
261 | asciiTextWidgetClass, |
---|
262 | localPaneW, |
---|
263 | args, |
---|
264 | n); |
---|
265 | |
---|
266 | n = 0; |
---|
267 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
268 | box2W = XtCreateManagedWidget( |
---|
269 | "botbox", |
---|
270 | boxWidgetClass, |
---|
271 | localPaneW, |
---|
272 | args, |
---|
273 | n); |
---|
274 | |
---|
275 | n = 0; |
---|
276 | data->sendButtonW = XtCreateManagedWidget( |
---|
277 | "send", |
---|
278 | commandWidgetClass, |
---|
279 | box2W, |
---|
280 | args, |
---|
281 | n); |
---|
282 | |
---|
283 | XtAddCallback (data->sendButtonW, XtNcallback, SendCB, data); |
---|
284 | |
---|
285 | n = 0; |
---|
286 | buttonW = XtCreateManagedWidget( |
---|
287 | "abort", |
---|
288 | commandWidgetClass, |
---|
289 | box2W, |
---|
290 | args, |
---|
291 | n); |
---|
292 | XtAddCallback (buttonW, XtNcallback, SendCB, data); |
---|
293 | XtPopup(data->sendPopupW, XtGrabNone); |
---|
294 | } |
---|
295 | |
---|
296 | static void |
---|
297 | SendCB(w, client_data, call_data) |
---|
298 | Widget w; |
---|
299 | XtPointer client_data; |
---|
300 | XtPointer call_data; |
---|
301 | { |
---|
302 | Arg args[5]; |
---|
303 | unsigned int n; |
---|
304 | char *tempstring; |
---|
305 | char command [LONGNAMELEN + 25]; |
---|
306 | char filename[50]; |
---|
307 | FILE *fp; |
---|
308 | char *returndata; |
---|
309 | SendDataPtr data = (SendDataPtr) client_data; |
---|
310 | TransactionRecPtr i, parent; |
---|
311 | |
---|
312 | if (data->sendButtonW == w) { |
---|
313 | n = 0; |
---|
314 | XtSetArg(args[n], XtNstring, &tempstring); n++; |
---|
315 | XtGetValues (data->bodyTextW, args, n); |
---|
316 | |
---|
317 | sprintf ( filename, "%s-%dr", |
---|
318 | filebase, data->replynum); |
---|
319 | if ((fp = fopen(filename, "w")) == (FILE *) NULL) { |
---|
320 | sprintf (command, "could not open file'%s'\n", filename); |
---|
321 | PutUpWarning("WARNING", command, False); |
---|
322 | } |
---|
323 | else { |
---|
324 | fprintf (fp, "%s\n", tempstring); |
---|
325 | fclose (fp); |
---|
326 | /* |
---|
327 | ** Breakdown in the edsc protocol: We have to first send it the (at...) |
---|
328 | ** to enter the transaction, then the newline-terminated subject line |
---|
329 | ** on the next line. (No parens around subject line) |
---|
330 | */ |
---|
331 | sprintf(command, "(at %d %s %s)\n", |
---|
332 | data->replynum, filename, data->mtg); |
---|
333 | (void) RunCommand (command, NULL, NULL, False); |
---|
334 | |
---|
335 | n = 0; |
---|
336 | XtSetArg(args[n], XtNstring, &tempstring); n++; |
---|
337 | XtGetValues (data->subjectTextW, args, n); |
---|
338 | |
---|
339 | for (n = 0; tempstring[n]; n++) |
---|
340 | if (tempstring[n] == '\n') |
---|
341 | tempstring[n] = ' '; |
---|
342 | |
---|
343 | sprintf(command, "%s\n",tempstring); |
---|
344 | |
---|
345 | returndata = RunCommand (command, NULL, NULL, True); |
---|
346 | if ((int) returndata > 0) |
---|
347 | myfree(returndata); |
---|
348 | unlink (filename); |
---|
349 | } |
---|
350 | } |
---|
351 | |
---|
352 | XtDestroyWidget(data->sendPopupW); |
---|
353 | myfree (data); |
---|
354 | |
---|
355 | for (i = listhead, parent = 0; i; parent = i, i = i->nextrec) { |
---|
356 | if (data->subjectTextW == i->data->subjectTextW) { |
---|
357 | if (parent) |
---|
358 | parent->nextrec = i->nextrec; |
---|
359 | else |
---|
360 | listhead = i->nextrec; |
---|
361 | myfree (i->data); |
---|
362 | myfree (i); |
---|
363 | break; |
---|
364 | } |
---|
365 | } |
---|
366 | |
---|
367 | GoToTransaction (TransactionNum(CURRENT), False); |
---|
368 | |
---|
369 | XFlush(XtDisplay(topW)); |
---|
370 | } |
---|
371 | |
---|
372 | void |
---|
373 | WriteTransaction(current) |
---|
374 | int current; |
---|
375 | { |
---|
376 | Arg args[5]; |
---|
377 | unsigned int n; |
---|
378 | char destfile[80]; |
---|
379 | Widget button, writePaneW, writeBox1W; |
---|
380 | Position parentx, parenty; |
---|
381 | Dimension parentwidth, mywidth; |
---|
382 | |
---|
383 | if (writePopupW) |
---|
384 | return; |
---|
385 | |
---|
386 | n = 0; |
---|
387 | XtSetArg(args[n], XtNwidth, &parentwidth); n++; |
---|
388 | XtSetArg(args[n], XtNx, &parentx); n++; |
---|
389 | XtSetArg(args[n], XtNy, &parenty); n++; |
---|
390 | XtGetValues (topW, args, n); |
---|
391 | |
---|
392 | sprintf ( destfile, |
---|
393 | "%s/xdsc/%s-%d", getenv("HOME"), |
---|
394 | CurrentMtg(1), current); |
---|
395 | |
---|
396 | if (nocache) |
---|
397 | strcpy (sourcefile, GetTransactionFile(current)); |
---|
398 | else |
---|
399 | sprintf ( sourcefile, |
---|
400 | "%s-%d", filebase, current); |
---|
401 | |
---|
402 | mywidth = 80 * char_width; |
---|
403 | |
---|
404 | n = 0; |
---|
405 | XtSetArg(args[n], XtNwidth, mywidth); n++; |
---|
406 | XtSetArg(args[n], XtNtransient, True); n++; |
---|
407 | XtSetArg(args[n], XtNtransientFor, topW); n++; |
---|
408 | XtSetArg(args[n], XtNx, |
---|
409 | parentx + ((parentwidth - mywidth) / 2)); n++; |
---|
410 | XtSetArg(args[n], XtNy, parenty + 100); n++; |
---|
411 | writePopupW = XtCreatePopupShell( |
---|
412 | "writepopup", |
---|
413 | transientShellWidgetClass, |
---|
414 | topW, |
---|
415 | args, |
---|
416 | n); |
---|
417 | |
---|
418 | writePaneW = XtCreateManagedWidget( |
---|
419 | "pane", |
---|
420 | panedWidgetClass, |
---|
421 | writePopupW, |
---|
422 | NULL, |
---|
423 | 0); |
---|
424 | |
---|
425 | n = 0; |
---|
426 | (void) XtCreateManagedWidget( |
---|
427 | "label", |
---|
428 | labelWidgetClass, |
---|
429 | writePaneW, |
---|
430 | args, |
---|
431 | n); |
---|
432 | |
---|
433 | n = 0; |
---|
434 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
435 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
436 | XtSetArg(args[n], XtNwidth, 15 * char_width); n++; |
---|
437 | XtSetArg(args[n], XtNstring, destfile); n++; |
---|
438 | |
---|
439 | writeTextW = XtCreateManagedWidget( |
---|
440 | "text", |
---|
441 | asciiTextWidgetClass, |
---|
442 | writePaneW, |
---|
443 | args, |
---|
444 | n); |
---|
445 | |
---|
446 | n = 0; |
---|
447 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
448 | writeBox1W = XtCreateManagedWidget( |
---|
449 | "box1", |
---|
450 | boxWidgetClass, |
---|
451 | writePaneW, |
---|
452 | args, |
---|
453 | n); |
---|
454 | |
---|
455 | n = 0; |
---|
456 | button = XtCreateManagedWidget( |
---|
457 | "write", |
---|
458 | commandWidgetClass, |
---|
459 | writeBox1W, |
---|
460 | args, |
---|
461 | n); |
---|
462 | |
---|
463 | XtAddCallback (button, XtNcallback, WriteCB, (XtPointer) True); |
---|
464 | |
---|
465 | n = 0; |
---|
466 | button = XtCreateManagedWidget( |
---|
467 | "abort", |
---|
468 | commandWidgetClass, |
---|
469 | writeBox1W, |
---|
470 | args, |
---|
471 | n); |
---|
472 | |
---|
473 | XtAddCallback (button, XtNcallback, WriteCB, (XtPointer) False); |
---|
474 | XtPopup(writePopupW, XtGrabNone); |
---|
475 | } |
---|
476 | |
---|
477 | static void |
---|
478 | WriteCB(w, client_data, call_data) |
---|
479 | Widget w; |
---|
480 | XtPointer client_data; |
---|
481 | XtPointer call_data; |
---|
482 | { |
---|
483 | char command[165]; |
---|
484 | char *tempptr1, *destfile; |
---|
485 | Arg args[5]; |
---|
486 | unsigned int n; |
---|
487 | |
---|
488 | if (!writePopupW) |
---|
489 | return; |
---|
490 | |
---|
491 | if ((Boolean) client_data) { |
---|
492 | n = 0; |
---|
493 | XtSetArg(args[n], XtNstring, &destfile); n++; |
---|
494 | XtGetValues (writeTextW, args, n); |
---|
495 | |
---|
496 | /* |
---|
497 | ** Make directory path. We ignore errors until we actually try to copy. |
---|
498 | */ |
---|
499 | tempptr1 = strchr(destfile + 1,'/'); |
---|
500 | |
---|
501 | while (tempptr1) { |
---|
502 | *tempptr1 = '\0'; |
---|
503 | sprintf (command, "test -d %s", destfile); |
---|
504 | if (system (command) != 0) { |
---|
505 | sprintf (command, "mkdir %s", destfile); |
---|
506 | system (command); |
---|
507 | } |
---|
508 | *tempptr1 = '/'; |
---|
509 | tempptr1 = strchr(tempptr1+1,'/'); |
---|
510 | } |
---|
511 | |
---|
512 | sprintf (command, "cp %s %s", sourcefile, destfile); |
---|
513 | if (system (command) != 0) { |
---|
514 | sprintf (command, "Cannot write to '%s'\n",destfile); |
---|
515 | PutUpWarning("WARNING", command, False); |
---|
516 | } |
---|
517 | } |
---|
518 | |
---|
519 | XtDestroyWidget(writePopupW); |
---|
520 | writePopupW = 0; |
---|
521 | } |
---|
522 | |
---|
523 | void |
---|
524 | AddMeeting() |
---|
525 | { |
---|
526 | Arg args[5]; |
---|
527 | unsigned int n; |
---|
528 | char *defaultvalue1, *defaultvalue2; |
---|
529 | Position parentx, parenty; |
---|
530 | Dimension parentwidth, mywidth; |
---|
531 | |
---|
532 | Widget addPaneW, addBox1W, addLabel1W; |
---|
533 | Widget addBox2W, addLabel2W, addBox3W, addButton1W; |
---|
534 | Widget addButton2W; |
---|
535 | |
---|
536 | if (addPopupW) |
---|
537 | return; |
---|
538 | |
---|
539 | n = 0; |
---|
540 | XtSetArg(args[n], XtNwidth, &parentwidth); n++; |
---|
541 | XtSetArg(args[n], XtNx, &parentx); n++; |
---|
542 | XtSetArg(args[n], XtNy, &parenty); n++; |
---|
543 | XtGetValues (topW, args, n); |
---|
544 | |
---|
545 | mywidth = 80 * char_width; |
---|
546 | |
---|
547 | n = 0; |
---|
548 | XtSetArg(args[n], XtNwidth, mywidth); n++; |
---|
549 | XtSetArg(args[n], XtNtransient, True); n++; |
---|
550 | XtSetArg(args[n], XtNtransientFor, topW); n++; |
---|
551 | XtSetArg(args[n], XtNx, |
---|
552 | parentx + ((parentwidth - mywidth) / 2)); n++; |
---|
553 | XtSetArg(args[n], XtNy, parenty + 100); n++; |
---|
554 | |
---|
555 | addPopupW = XtCreatePopupShell( |
---|
556 | "addpopup", |
---|
557 | transientShellWidgetClass, |
---|
558 | topW, |
---|
559 | args, |
---|
560 | n); |
---|
561 | |
---|
562 | addPaneW = XtCreateManagedWidget( |
---|
563 | "pane", |
---|
564 | panedWidgetClass, |
---|
565 | addPopupW, |
---|
566 | NULL, |
---|
567 | 0); |
---|
568 | |
---|
569 | n = 0; |
---|
570 | (void) XtCreateManagedWidget( |
---|
571 | "label", |
---|
572 | labelWidgetClass, |
---|
573 | addPaneW, |
---|
574 | args, |
---|
575 | n); |
---|
576 | n = 0; |
---|
577 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
578 | addBox1W = XtCreateManagedWidget( |
---|
579 | "box1", |
---|
580 | boxWidgetClass, |
---|
581 | addPaneW, |
---|
582 | args, |
---|
583 | n); |
---|
584 | |
---|
585 | n = 0; |
---|
586 | addLabel1W = XtCreateManagedWidget( |
---|
587 | "label", |
---|
588 | labelWidgetClass, |
---|
589 | addBox1W, |
---|
590 | args, |
---|
591 | n); |
---|
592 | |
---|
593 | n = 0; |
---|
594 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
595 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
596 | XtSetArg(args[n], XtNwidth, 60 * char_width); n++; |
---|
597 | /* |
---|
598 | ** Is there a default hostname we can use? |
---|
599 | */ |
---|
600 | if (defaultvalue1 = GetDefaultValue("Host:")) { |
---|
601 | XtSetArg(args[n], XtNstring, defaultvalue1); n++; |
---|
602 | } |
---|
603 | |
---|
604 | addHostTextW = XtCreateManagedWidget( |
---|
605 | "hosttext", |
---|
606 | asciiTextWidgetClass, |
---|
607 | addBox1W, |
---|
608 | args, |
---|
609 | n); |
---|
610 | |
---|
611 | if (defaultvalue1) |
---|
612 | myfree (defaultvalue1); |
---|
613 | |
---|
614 | n = 0; |
---|
615 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
616 | addBox2W = XtCreateManagedWidget( |
---|
617 | "box2", |
---|
618 | boxWidgetClass, |
---|
619 | addPaneW, |
---|
620 | args, |
---|
621 | n); |
---|
622 | |
---|
623 | n = 0; |
---|
624 | addLabel2W = XtCreateManagedWidget( |
---|
625 | "label", |
---|
626 | labelWidgetClass, |
---|
627 | addBox2W, |
---|
628 | args, |
---|
629 | n); |
---|
630 | |
---|
631 | n = 0; |
---|
632 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
633 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
634 | XtSetArg(args[n], XtNwidth, 60 * char_width); n++; |
---|
635 | /* |
---|
636 | ** Is there a default pathname we can use? |
---|
637 | */ |
---|
638 | if (defaultvalue2 = GetDefaultValue("Pathname:")) { |
---|
639 | XtSetArg(args[n], XtNstring, defaultvalue2); n++; |
---|
640 | } |
---|
641 | |
---|
642 | addPathTextW = XtCreateManagedWidget( |
---|
643 | "pathtext", |
---|
644 | asciiTextWidgetClass, |
---|
645 | addBox2W, |
---|
646 | args, |
---|
647 | n); |
---|
648 | |
---|
649 | if (defaultvalue2) |
---|
650 | myfree (defaultvalue2); |
---|
651 | |
---|
652 | n = 0; |
---|
653 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
654 | addBox3W = XtCreateManagedWidget( |
---|
655 | "box3", |
---|
656 | boxWidgetClass, |
---|
657 | addPaneW, |
---|
658 | args, |
---|
659 | n); |
---|
660 | |
---|
661 | n = 0; |
---|
662 | addButton1W = XtCreateManagedWidget( |
---|
663 | "add", |
---|
664 | commandWidgetClass, |
---|
665 | addBox3W, |
---|
666 | args, |
---|
667 | n); |
---|
668 | XtAddCallback (addButton1W, XtNcallback, AddCB, (XtPointer) True); |
---|
669 | |
---|
670 | n = 0; |
---|
671 | addButton2W = XtCreateManagedWidget( |
---|
672 | "abort", |
---|
673 | commandWidgetClass, |
---|
674 | addBox3W, |
---|
675 | args, |
---|
676 | n); |
---|
677 | |
---|
678 | XtAddCallback (addButton2W, XtNcallback, AddCB, (XtPointer) False); |
---|
679 | XtPopup(addPopupW, XtGrabNone); |
---|
680 | |
---|
681 | } |
---|
682 | |
---|
683 | static void |
---|
684 | AddCB(w, client_data, call_data) |
---|
685 | Widget w; |
---|
686 | XtPointer client_data; |
---|
687 | XtPointer call_data; |
---|
688 | { |
---|
689 | char buffer[165]; |
---|
690 | char *tempstring1, *tempstring2, *returndata; |
---|
691 | Arg args[5]; |
---|
692 | unsigned int n; |
---|
693 | |
---|
694 | if ((Boolean) client_data && addPopupW) { |
---|
695 | n = 0; |
---|
696 | XtSetArg(args[n], XtNstring, &tempstring1); n++; |
---|
697 | XtGetValues (addHostTextW, args, n); |
---|
698 | |
---|
699 | n = 0; |
---|
700 | XtSetArg(args[n], XtNstring, &tempstring2); n++; |
---|
701 | XtGetValues (addPathTextW, args, n); |
---|
702 | |
---|
703 | sprintf (buffer, "(am %s %s)\n", tempstring1, tempstring2); |
---|
704 | returndata = RunCommand (buffer, NULL, NULL, True); |
---|
705 | |
---|
706 | if ( (int) returndata <= 0) |
---|
707 | return; |
---|
708 | |
---|
709 | /* This forced an automatic update. Unfortunately, it erased any list |
---|
710 | of transaction headers. |
---|
711 | |
---|
712 | TopSelect(NULL, 2, NULL); |
---|
713 | */ |
---|
714 | myfree (returndata); |
---|
715 | myfree (tempstring1); |
---|
716 | myfree (tempstring2); |
---|
717 | } |
---|
718 | |
---|
719 | if (addPopupW) { |
---|
720 | XtDestroyWidget(addPopupW); |
---|
721 | XtSetKeyboardFocus(topW, topW); |
---|
722 | } |
---|
723 | |
---|
724 | addPopupW = 0; |
---|
725 | } |
---|
726 | |
---|
727 | void |
---|
728 | DeleteMeeting() |
---|
729 | { |
---|
730 | Arg args[5]; |
---|
731 | unsigned int n; |
---|
732 | |
---|
733 | Widget deletePaneW, deleteBox1W; |
---|
734 | Widget deleteBox2W, deleteButton1W, deleteButton2W; |
---|
735 | char *defaultvalue; |
---|
736 | Position parentx, parenty; |
---|
737 | Dimension parentwidth, mywidth; |
---|
738 | |
---|
739 | if (deletePopupW) |
---|
740 | return; |
---|
741 | |
---|
742 | n = 0; |
---|
743 | XtSetArg(args[n], XtNwidth, &parentwidth); n++; |
---|
744 | XtSetArg(args[n], XtNx, &parentx); n++; |
---|
745 | XtSetArg(args[n], XtNy, &parenty); n++; |
---|
746 | XtGetValues (topW, args, n); |
---|
747 | |
---|
748 | mywidth = 80 * char_width; |
---|
749 | |
---|
750 | n = 0; |
---|
751 | XtSetArg(args[n], XtNwidth, mywidth); n++; |
---|
752 | XtSetArg(args[n], XtNtransient, True); n++; |
---|
753 | XtSetArg(args[n], XtNtransientFor, topW); n++; |
---|
754 | XtSetArg(args[n], XtNx, |
---|
755 | parentx + ((parentwidth - mywidth) / 2)); n++; |
---|
756 | XtSetArg(args[n], XtNy, parenty + 100); n++; |
---|
757 | |
---|
758 | deletePopupW = XtCreatePopupShell( |
---|
759 | "deletepopup", |
---|
760 | transientShellWidgetClass, |
---|
761 | topW, |
---|
762 | args, |
---|
763 | n); |
---|
764 | |
---|
765 | deletePaneW = XtCreateManagedWidget( |
---|
766 | "pane", |
---|
767 | panedWidgetClass, |
---|
768 | deletePopupW, |
---|
769 | NULL, |
---|
770 | 0); |
---|
771 | |
---|
772 | n = 0; |
---|
773 | (void) XtCreateManagedWidget( |
---|
774 | "label", |
---|
775 | labelWidgetClass, |
---|
776 | deletePaneW, |
---|
777 | args, |
---|
778 | n); |
---|
779 | |
---|
780 | n = 0; |
---|
781 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
782 | deleteBox1W = XtCreateManagedWidget( |
---|
783 | "box1", |
---|
784 | boxWidgetClass, |
---|
785 | deletePaneW, |
---|
786 | args, |
---|
787 | n); |
---|
788 | |
---|
789 | n = 0; |
---|
790 | (void) XtCreateManagedWidget( |
---|
791 | "label", |
---|
792 | labelWidgetClass, |
---|
793 | deleteBox1W, |
---|
794 | args, |
---|
795 | n); |
---|
796 | |
---|
797 | n = 0; |
---|
798 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
799 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
800 | XtSetArg(args[n], XtNwidth, 60 * char_width); n++; |
---|
801 | if (defaultvalue = GetDefaultValue("Name:")) { |
---|
802 | XtSetArg(args[n], XtNstring, defaultvalue); n++; |
---|
803 | } |
---|
804 | deleteMtgTextW = XtCreateManagedWidget( |
---|
805 | "text", |
---|
806 | asciiTextWidgetClass, |
---|
807 | deleteBox1W, |
---|
808 | args, |
---|
809 | n); |
---|
810 | |
---|
811 | if (defaultvalue) |
---|
812 | myfree (defaultvalue); |
---|
813 | |
---|
814 | n = 0; |
---|
815 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
816 | deleteBox2W = XtCreateManagedWidget( |
---|
817 | "box2", |
---|
818 | boxWidgetClass, |
---|
819 | deletePaneW, |
---|
820 | args, |
---|
821 | n); |
---|
822 | |
---|
823 | n = 0; |
---|
824 | deleteButton1W = XtCreateManagedWidget( |
---|
825 | "delete", |
---|
826 | commandWidgetClass, |
---|
827 | deleteBox2W, |
---|
828 | args, |
---|
829 | n); |
---|
830 | XtAddCallback (deleteButton1W, XtNcallback, DeleteCB, |
---|
831 | (XtPointer) True); |
---|
832 | |
---|
833 | n = 0; |
---|
834 | deleteButton2W = XtCreateManagedWidget( |
---|
835 | "abort", |
---|
836 | commandWidgetClass, |
---|
837 | deleteBox2W, |
---|
838 | args, |
---|
839 | n); |
---|
840 | XtAddCallback (deleteButton2W, XtNcallback, DeleteCB, |
---|
841 | (XtPointer) False); |
---|
842 | |
---|
843 | XtPopup(deletePopupW, XtGrabNone); |
---|
844 | |
---|
845 | } |
---|
846 | |
---|
847 | static void |
---|
848 | DeleteCB(w, client_data, call_data) |
---|
849 | Widget w; |
---|
850 | XtPointer client_data; |
---|
851 | XtPointer call_data; |
---|
852 | { |
---|
853 | char buffer[165]; |
---|
854 | char *tempstring1, *returndata; |
---|
855 | Arg args[5]; |
---|
856 | unsigned int n; |
---|
857 | |
---|
858 | if (!deletePopupW) |
---|
859 | return; |
---|
860 | |
---|
861 | if ((Boolean) client_data) { |
---|
862 | n = 0; |
---|
863 | XtSetArg(args[n], XtNstring, &tempstring1); n++; |
---|
864 | XtGetValues (deleteMtgTextW, args, n); |
---|
865 | /* |
---|
866 | ** Protect us when we remove the current meeting. Watch out for leading |
---|
867 | ** and trailing spaces in the text widget's value. |
---|
868 | */ |
---|
869 | if ( CompareWithoutWhitespace(tempstring1, CurrentMtg(0)) || |
---|
870 | CompareWithoutWhitespace(tempstring1, CurrentMtg(1))) |
---|
871 | SaveMeetingNames("", ""); |
---|
872 | |
---|
873 | sprintf (buffer, "(dm %s)\n", tempstring1); |
---|
874 | returndata = RunCommand (buffer, NULL, NULL, True); |
---|
875 | |
---|
876 | if ( (int) returndata <= 0) |
---|
877 | return; |
---|
878 | |
---|
879 | /* |
---|
880 | TopSelect(NULL, 2, NULL); |
---|
881 | */ |
---|
882 | myfree (returndata); |
---|
883 | myfree (tempstring1); |
---|
884 | } |
---|
885 | |
---|
886 | XtDestroyWidget(deletePopupW); |
---|
887 | deletePopupW = 0; |
---|
888 | } |
---|
889 | |
---|
890 | static Boolean |
---|
891 | CompareWithoutWhitespace(s, t) |
---|
892 | char *s, *t; |
---|
893 | { |
---|
894 | while (isspace(*s)) |
---|
895 | *s++; |
---|
896 | |
---|
897 | while (isspace(*t)) |
---|
898 | *t++; |
---|
899 | |
---|
900 | while (*s && *t && (*s++ == *t++)) |
---|
901 | ; |
---|
902 | |
---|
903 | if (!*t && !*s) |
---|
904 | return (True); |
---|
905 | |
---|
906 | if (!*t) { |
---|
907 | while (isspace(*s)) |
---|
908 | s++; |
---|
909 | if (!*s) |
---|
910 | return (True); |
---|
911 | else |
---|
912 | return (False); |
---|
913 | } |
---|
914 | |
---|
915 | if (!*s) { |
---|
916 | while (isspace(*t)) |
---|
917 | t++; |
---|
918 | if (!*t) |
---|
919 | return (True); |
---|
920 | else |
---|
921 | return (False); |
---|
922 | } |
---|
923 | |
---|
924 | return (False); |
---|
925 | } |
---|
926 | |
---|
927 | PutUpWarning(prefix, message, deathoption) |
---|
928 | char *prefix; |
---|
929 | char *message; |
---|
930 | Boolean deathoption; |
---|
931 | { |
---|
932 | Arg args[5]; |
---|
933 | unsigned int n; |
---|
934 | Widget warningPaneW, warningButtonW, warningBoxW, deathButtonW; |
---|
935 | Position parentx, parenty; |
---|
936 | Dimension parentwidth, mywidth; |
---|
937 | int flag = 0; |
---|
938 | |
---|
939 | if (warningPopupW) |
---|
940 | return; |
---|
941 | |
---|
942 | n = 0; |
---|
943 | XtSetArg(args[n], XtNwidth, &parentwidth); n++; |
---|
944 | XtSetArg(args[n], XtNx, &parentx); n++; |
---|
945 | XtSetArg(args[n], XtNy, &parenty); n++; |
---|
946 | XtGetValues (topW, args, n); |
---|
947 | |
---|
948 | mywidth = (strlen(message)+2) * char_width; |
---|
949 | |
---|
950 | n = 0; |
---|
951 | XtSetArg(args[n], XtNwidth, mywidth); n++; |
---|
952 | XtSetArg(args[n], XtNtransient, True); n++; |
---|
953 | XtSetArg(args[n], XtNtransientFor, topW); n++; |
---|
954 | XtSetArg(args[n], XtNx, |
---|
955 | parentx + ((parentwidth - mywidth) / 2)); n++; |
---|
956 | XtSetArg(args[n], XtNy, parenty + 100); n++; |
---|
957 | warningPopupW = XtCreatePopupShell( |
---|
958 | "warningpopup", |
---|
959 | transientShellWidgetClass, |
---|
960 | topW, |
---|
961 | args, |
---|
962 | n); |
---|
963 | |
---|
964 | warningPaneW = XtCreateManagedWidget( |
---|
965 | "pane", |
---|
966 | panedWidgetClass, |
---|
967 | warningPopupW, |
---|
968 | NULL, |
---|
969 | 0); |
---|
970 | XtInstallAccelerators(warningPaneW, paneW); |
---|
971 | |
---|
972 | if (*prefix) { |
---|
973 | n = 0; |
---|
974 | XtSetArg(args[n], XtNlabel, prefix); n++; |
---|
975 | XtSetArg(args[n], XtNwidth, 300); n++; |
---|
976 | (void) XtCreateManagedWidget( |
---|
977 | "label1", |
---|
978 | labelWidgetClass, |
---|
979 | warningPaneW, |
---|
980 | args, |
---|
981 | n); |
---|
982 | } |
---|
983 | |
---|
984 | n = 0; |
---|
985 | XtSetArg(args[n], XtNlabel, message); n++; |
---|
986 | (void) XtCreateManagedWidget( |
---|
987 | "label2", |
---|
988 | labelWidgetClass, |
---|
989 | warningPaneW, |
---|
990 | args, |
---|
991 | n); |
---|
992 | n = 0; |
---|
993 | warningBoxW = XtCreateManagedWidget( |
---|
994 | "box", |
---|
995 | boxWidgetClass, |
---|
996 | warningPaneW, |
---|
997 | args, |
---|
998 | n); |
---|
999 | |
---|
1000 | n = 0; |
---|
1001 | warningButtonW = XtCreateManagedWidget( |
---|
1002 | "acknowledge", |
---|
1003 | commandWidgetClass, |
---|
1004 | warningBoxW, |
---|
1005 | args, |
---|
1006 | n); |
---|
1007 | |
---|
1008 | XtAddCallback (warningButtonW, XtNcallback, PopdownCB, |
---|
1009 | (XtPointer) False); |
---|
1010 | |
---|
1011 | if (deathoption) { |
---|
1012 | deathButtonW = XtCreateManagedWidget( |
---|
1013 | "quit immediately", |
---|
1014 | commandWidgetClass, |
---|
1015 | warningBoxW, |
---|
1016 | NULL, 0); |
---|
1017 | |
---|
1018 | XtAddCallback (deathButtonW, XtNcallback, DieCB, |
---|
1019 | (XtPointer) False); |
---|
1020 | } |
---|
1021 | |
---|
1022 | XtInstallAllAccelerators(warningPopupW, paneW); |
---|
1023 | XtSetKeyboardFocus(paneW, warningButtonW); |
---|
1024 | |
---|
1025 | XtPopup(warningPopupW, XtGrabNone); |
---|
1026 | } |
---|
1027 | |
---|
1028 | void |
---|
1029 | DieCB(w, client_data, call_data) |
---|
1030 | Widget w; |
---|
1031 | XtPointer client_data; |
---|
1032 | XtPointer call_data; |
---|
1033 | { |
---|
1034 | exit (-1); |
---|
1035 | } |
---|
1036 | |
---|
1037 | PopdownCB(w, client_data, call_data) |
---|
1038 | Widget w; |
---|
1039 | XtPointer client_data; |
---|
1040 | XtPointer call_data; |
---|
1041 | { |
---|
1042 | int didsomething = 0; |
---|
1043 | |
---|
1044 | if (warningPopupW) { |
---|
1045 | XtDestroyWidget(warningPopupW); |
---|
1046 | warningPopupW = 0; |
---|
1047 | didsomething = 1; |
---|
1048 | } |
---|
1049 | |
---|
1050 | if (helpPopupW) { |
---|
1051 | XtDestroyWidget(helpPopupW); |
---|
1052 | helpPopupW = 0; |
---|
1053 | didsomething = 1; |
---|
1054 | } |
---|
1055 | XtSetKeyboardFocus(topW, topW); |
---|
1056 | return (didsomething); |
---|
1057 | } |
---|
1058 | |
---|
1059 | |
---|
1060 | void |
---|
1061 | PutUpHelp() |
---|
1062 | { |
---|
1063 | Arg args[5]; |
---|
1064 | unsigned int n; |
---|
1065 | Widget localPaneW, textW, boxW, buttonW; |
---|
1066 | |
---|
1067 | if (helpPopupW) |
---|
1068 | return; |
---|
1069 | |
---|
1070 | n = 0; |
---|
1071 | helpPopupW = XtCreatePopupShell( |
---|
1072 | "helppopup", |
---|
1073 | topLevelShellWidgetClass, |
---|
1074 | topW, |
---|
1075 | args, |
---|
1076 | n); |
---|
1077 | |
---|
1078 | XtInstallAccelerators(helpPopupW, paneW); |
---|
1079 | n = 0; |
---|
1080 | localPaneW = XtCreateManagedWidget( |
---|
1081 | "pane", |
---|
1082 | panedWidgetClass, |
---|
1083 | helpPopupW, |
---|
1084 | args, |
---|
1085 | n); |
---|
1086 | |
---|
1087 | n = 0; |
---|
1088 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
1089 | XtSetArg(args[n], XtNwidth, 80 * char_width); n++; |
---|
1090 | |
---|
1091 | textW = XtCreateManagedWidget( |
---|
1092 | "helptext", |
---|
1093 | asciiTextWidgetClass, |
---|
1094 | localPaneW, |
---|
1095 | args, |
---|
1096 | n); |
---|
1097 | XtInstallAccelerators(textW, paneW); |
---|
1098 | |
---|
1099 | n = 0; |
---|
1100 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
1101 | boxW = XtCreateManagedWidget( |
---|
1102 | "box", |
---|
1103 | boxWidgetClass, |
---|
1104 | localPaneW, |
---|
1105 | args, |
---|
1106 | n); |
---|
1107 | |
---|
1108 | n = 0; |
---|
1109 | buttonW = XtCreateManagedWidget( |
---|
1110 | "okay", |
---|
1111 | commandWidgetClass, |
---|
1112 | boxW, |
---|
1113 | args, |
---|
1114 | n); |
---|
1115 | |
---|
1116 | XtInstallAllAccelerators(helpPopupW, paneW); |
---|
1117 | XtAddCallback (buttonW, XtNcallback, PopdownCB, (XtPointer) True); |
---|
1118 | XtPopup(helpPopupW, XtGrabNone); |
---|
1119 | } |
---|
1120 | |
---|
1121 | |
---|
1122 | /* |
---|
1123 | ** Okay, here's some really crude stuff. We assume the text in bottextW |
---|
1124 | ** contains lines like " Host: YABBA.DABBA.DOO" where "Host:" is |
---|
1125 | ** the sort of thing that we call a "prompt." We find the line, if any, |
---|
1126 | ** including the string pointed to by prompt, and return a pointer to |
---|
1127 | ** the string from whitespace to \n following the prompt. |
---|
1128 | */ |
---|
1129 | |
---|
1130 | static char * |
---|
1131 | GetDefaultValue(prompt) |
---|
1132 | char *prompt; |
---|
1133 | { |
---|
1134 | Arg args[5]; |
---|
1135 | unsigned int n; |
---|
1136 | char *prompt1, *string, *string1, *string2; |
---|
1137 | char *retval; |
---|
1138 | |
---|
1139 | n = 0; |
---|
1140 | XtSetArg(args[n], XtNstring, &string); n++; |
---|
1141 | XtGetValues (bottextW, args, n); |
---|
1142 | |
---|
1143 | /* |
---|
1144 | ** Now we look for the prompt. |
---|
1145 | */ |
---|
1146 | |
---|
1147 | for (string1 = string; *string1; string1++) { |
---|
1148 | for ( prompt1 = prompt, string2 = string1; |
---|
1149 | *prompt1 == *string2; |
---|
1150 | prompt1++, string2++) |
---|
1151 | ; |
---|
1152 | |
---|
1153 | if (!*prompt1) break; |
---|
1154 | } |
---|
1155 | |
---|
1156 | if (!*string1) { |
---|
1157 | return (NULL); |
---|
1158 | } |
---|
1159 | |
---|
1160 | for (string2 = string1; *string2 != ' '; string2++); |
---|
1161 | |
---|
1162 | for ( ; *string2 == ' '; string2++); |
---|
1163 | |
---|
1164 | *strchr (string2, '\n') = '\0'; |
---|
1165 | |
---|
1166 | retval = (char *) malloc (strlen(string2) + 1); |
---|
1167 | strcpy (retval, string2); |
---|
1168 | *(strchr(string2, '\0')) = '\n'; |
---|
1169 | return (retval); |
---|
1170 | } |
---|
1171 | |
---|
1172 | void |
---|
1173 | GetTransactionNum() |
---|
1174 | { |
---|
1175 | Arg args[5]; |
---|
1176 | unsigned int n; |
---|
1177 | Widget button, numPaneW, numBox1W; |
---|
1178 | Position parentx, parenty; |
---|
1179 | Dimension parentwidth, mywidth; |
---|
1180 | |
---|
1181 | if (numPopupW) |
---|
1182 | return; |
---|
1183 | |
---|
1184 | n = 0; |
---|
1185 | XtSetArg(args[n], XtNwidth, &parentwidth); n++; |
---|
1186 | XtSetArg(args[n], XtNx, &parentx); n++; |
---|
1187 | XtSetArg(args[n], XtNy, &parenty); n++; |
---|
1188 | XtGetValues (topW, args, n); |
---|
1189 | |
---|
1190 | mywidth = 35 * char_width; |
---|
1191 | |
---|
1192 | n = 0; |
---|
1193 | XtSetArg(args[n], XtNwidth, mywidth); n++; |
---|
1194 | XtSetArg(args[n], XtNtransient, True); n++; |
---|
1195 | XtSetArg(args[n], XtNtransientFor, topW); n++; |
---|
1196 | XtSetArg(args[n], XtNx, |
---|
1197 | parentx + ((parentwidth - mywidth) / 2)); n++; |
---|
1198 | XtSetArg(args[n], XtNy, parenty + 100); n++; |
---|
1199 | |
---|
1200 | numPopupW = XtCreatePopupShell( |
---|
1201 | "numpopup", |
---|
1202 | transientShellWidgetClass, |
---|
1203 | topW, |
---|
1204 | args, |
---|
1205 | n); |
---|
1206 | |
---|
1207 | numPaneW = XtCreateManagedWidget( |
---|
1208 | "pane", |
---|
1209 | panedWidgetClass, |
---|
1210 | numPopupW, |
---|
1211 | NULL, |
---|
1212 | 0); |
---|
1213 | |
---|
1214 | n = 0; |
---|
1215 | |
---|
1216 | (void) XtCreateManagedWidget( |
---|
1217 | "label", |
---|
1218 | labelWidgetClass, |
---|
1219 | numPaneW, |
---|
1220 | args, |
---|
1221 | n); |
---|
1222 | |
---|
1223 | n = 0; |
---|
1224 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
1225 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
1226 | XtSetArg(args[n], XtNwidth, 15 * char_width); n++; |
---|
1227 | |
---|
1228 | numTextW = XtCreateManagedWidget( |
---|
1229 | "text", |
---|
1230 | asciiTextWidgetClass, |
---|
1231 | numPaneW, |
---|
1232 | args, |
---|
1233 | n); |
---|
1234 | |
---|
1235 | n = 0; |
---|
1236 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
1237 | numBox1W = XtCreateManagedWidget( |
---|
1238 | "box1", |
---|
1239 | boxWidgetClass, |
---|
1240 | numPaneW, |
---|
1241 | args, |
---|
1242 | n); |
---|
1243 | |
---|
1244 | n = 0; |
---|
1245 | button = XtCreateManagedWidget( |
---|
1246 | "goto", |
---|
1247 | commandWidgetClass, |
---|
1248 | numBox1W, |
---|
1249 | args, |
---|
1250 | n); |
---|
1251 | |
---|
1252 | XtAddCallback (button, XtNcallback, NumCB, (XtPointer) True); |
---|
1253 | |
---|
1254 | n = 0; |
---|
1255 | button = XtCreateManagedWidget( |
---|
1256 | "abort", |
---|
1257 | commandWidgetClass, |
---|
1258 | numBox1W, |
---|
1259 | args, |
---|
1260 | n); |
---|
1261 | |
---|
1262 | XtAddCallback (button, XtNcallback, NumCB, (XtPointer) False); |
---|
1263 | XtPopup(numPopupW, XtGrabNone); |
---|
1264 | } |
---|
1265 | |
---|
1266 | static void |
---|
1267 | NumCB(w, client_data, call_data) |
---|
1268 | Widget w; |
---|
1269 | XtPointer client_data; |
---|
1270 | XtPointer call_data; |
---|
1271 | { |
---|
1272 | char *tempstring; |
---|
1273 | Arg args[5]; |
---|
1274 | unsigned int n; |
---|
1275 | |
---|
1276 | if (!numPopupW) |
---|
1277 | return; |
---|
1278 | |
---|
1279 | if ((Boolean) client_data) { |
---|
1280 | n = 0; |
---|
1281 | XtSetArg(args[n], XtNstring, &tempstring); n++; |
---|
1282 | XtGetValues (numTextW, args, n); |
---|
1283 | GoToTransaction(atoi(tempstring), True); |
---|
1284 | myfree (tempstring); |
---|
1285 | } |
---|
1286 | |
---|
1287 | XtDestroyWidget(numPopupW); |
---|
1288 | XtSetKeyboardFocus(topW, topW); |
---|
1289 | numPopupW = 0; |
---|
1290 | } |
---|
1291 | |
---|
1292 | void |
---|
1293 | TriggerAdd(w, event, params, num_params) |
---|
1294 | Widget w; |
---|
1295 | XEvent *event; |
---|
1296 | String *params; |
---|
1297 | int *num_params; |
---|
1298 | { |
---|
1299 | if (*num_params < 1) |
---|
1300 | return; |
---|
1301 | |
---|
1302 | AddCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1303 | } |
---|
1304 | |
---|
1305 | void |
---|
1306 | TriggerNum(w, event, params, num_params) |
---|
1307 | Widget w; |
---|
1308 | XEvent *event; |
---|
1309 | String *params; |
---|
1310 | int *num_params; |
---|
1311 | { |
---|
1312 | if (*num_params < 1) |
---|
1313 | return; |
---|
1314 | |
---|
1315 | NumCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1316 | } |
---|
1317 | |
---|
1318 | void |
---|
1319 | TriggerWrite(w, event, params, num_params) |
---|
1320 | Widget w; |
---|
1321 | XEvent *event; |
---|
1322 | String *params; |
---|
1323 | int *num_params; |
---|
1324 | { |
---|
1325 | if (*num_params < 1) |
---|
1326 | return; |
---|
1327 | |
---|
1328 | WriteCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1329 | } |
---|
1330 | |
---|
1331 | void |
---|
1332 | TriggerDelete(w, event, params, num_params) |
---|
1333 | Widget w; |
---|
1334 | XEvent *event; |
---|
1335 | String *params; |
---|
1336 | int *num_params; |
---|
1337 | { |
---|
1338 | if (*num_params < 1) |
---|
1339 | return; |
---|
1340 | |
---|
1341 | DeleteCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1342 | } |
---|
1343 | |
---|
1344 | void |
---|
1345 | TriggerPopdown(w, event, params, num_params) |
---|
1346 | Widget w; |
---|
1347 | XEvent *event; |
---|
1348 | String *params; |
---|
1349 | int *num_params; |
---|
1350 | { |
---|
1351 | if (*num_params < 1) |
---|
1352 | return; |
---|
1353 | |
---|
1354 | PopdownCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1355 | } |
---|
1356 | |
---|
1357 | void |
---|
1358 | TriggerSend(w, event, params, num_params) |
---|
1359 | Widget w; |
---|
1360 | XEvent *event; |
---|
1361 | String *params; |
---|
1362 | int *num_params; |
---|
1363 | { |
---|
1364 | TransactionRecPtr i; |
---|
1365 | |
---|
1366 | if (*num_params < 1) |
---|
1367 | return; |
---|
1368 | |
---|
1369 | if (listhead == 0) { |
---|
1370 | return; |
---|
1371 | } |
---|
1372 | |
---|
1373 | for (i = listhead; i; i = i->nextrec) { |
---|
1374 | if (w == i->data->subjectTextW) |
---|
1375 | break; |
---|
1376 | if (w == i->data->bodyTextW) |
---|
1377 | break; |
---|
1378 | if (w == i->data->sendButtonW) |
---|
1379 | break; |
---|
1380 | if (w == i->data->sendPopupW) |
---|
1381 | break; |
---|
1382 | } |
---|
1383 | |
---|
1384 | if (i == 0) |
---|
1385 | return; |
---|
1386 | |
---|
1387 | /* |
---|
1388 | ** Okay, here's a kludge. SendCB() checks the incoming widget ID, |
---|
1389 | ** and if it's equal to the sendButtonW stored in the data structure, |
---|
1390 | ** it actually does the send. So we fool it here. |
---|
1391 | */ |
---|
1392 | if (strcmp(params[0], "Go") == 0) |
---|
1393 | SendCB(i->data->sendButtonW, i->data, NULL); |
---|
1394 | else |
---|
1395 | SendCB(NULL, i->data, NULL); |
---|
1396 | } |
---|
1397 | |
---|
1398 | /* |
---|
1399 | ** Pass TriggerFocusMove "Prev" to move focus up, "Next" to move it down. |
---|
1400 | ** It figures out which widget got the event and moves focus to |
---|
1401 | ** the appropriate neighbor. |
---|
1402 | */ |
---|
1403 | |
---|
1404 | void |
---|
1405 | TriggerFocusMove(w, event, params, num_params) |
---|
1406 | Widget w; |
---|
1407 | XEvent *event; |
---|
1408 | String *params; |
---|
1409 | int *num_params; |
---|
1410 | { |
---|
1411 | TransactionRecPtr i; |
---|
1412 | int direction = -1; |
---|
1413 | Widget targetW = 0; |
---|
1414 | Widget shellparent; |
---|
1415 | |
---|
1416 | if (*num_params < 1) |
---|
1417 | return; |
---|
1418 | |
---|
1419 | for ( shellparent = XtParent(w); |
---|
1420 | shellparent && !XtIsShell(shellparent); |
---|
1421 | shellparent = XtParent(shellparent)) |
---|
1422 | ; |
---|
1423 | |
---|
1424 | if (!strcmp (params[0], "Next")) |
---|
1425 | direction = 2; |
---|
1426 | if (!strcmp (params[0], "Prev")) |
---|
1427 | direction = 1; |
---|
1428 | if (!strcmp (params[0], "Toggle")) |
---|
1429 | direction = 0; |
---|
1430 | |
---|
1431 | if (!strcmp (params[0], "Here")) { |
---|
1432 | XtSetKeyboardFocus(topW, shellparent); |
---|
1433 | XtSetKeyboardFocus(shellparent, w); |
---|
1434 | return; |
---|
1435 | } |
---|
1436 | |
---|
1437 | /* |
---|
1438 | ** Was the hit widget in the add-mtg popup? All keys become toggle. |
---|
1439 | */ |
---|
1440 | if (addPopupW) { |
---|
1441 | if (w == addHostTextW) |
---|
1442 | targetW = addPathTextW; |
---|
1443 | if (w == addPathTextW) |
---|
1444 | targetW = addHostTextW; |
---|
1445 | } |
---|
1446 | |
---|
1447 | /* |
---|
1448 | ** Check the subject and body widgets in the list of entryrecs. |
---|
1449 | */ |
---|
1450 | if (listhead != 0) { |
---|
1451 | for (i = listhead; i; i = i->nextrec) { |
---|
1452 | if (w == i->data->subjectTextW && |
---|
1453 | (direction == 2 || direction == 0)) |
---|
1454 | targetW = i->data->bodyTextW; |
---|
1455 | if (w == i->data->bodyTextW && |
---|
1456 | (direction == 1 || direction == 0)) |
---|
1457 | targetW = i->data->subjectTextW; |
---|
1458 | } |
---|
1459 | } |
---|
1460 | |
---|
1461 | if (targetW) { |
---|
1462 | XtSetKeyboardFocus(topW, shellparent); |
---|
1463 | XtSetKeyboardFocus(shellparent, targetW); |
---|
1464 | } |
---|
1465 | } |
---|