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.15 1996-09-20 03:37:00 ghudson 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, True); |
---|
464 | |
---|
465 | n = 0; |
---|
466 | button = XtCreateManagedWidget( |
---|
467 | "abort", |
---|
468 | commandWidgetClass, |
---|
469 | writeBox1W, |
---|
470 | args, |
---|
471 | n); |
---|
472 | |
---|
473 | XtAddCallback (button, XtNcallback, WriteCB, 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, True); |
---|
669 | |
---|
670 | n = 0; |
---|
671 | addButton2W = XtCreateManagedWidget( |
---|
672 | "abort", |
---|
673 | commandWidgetClass, |
---|
674 | addBox3W, |
---|
675 | args, |
---|
676 | n); |
---|
677 | |
---|
678 | XtAddCallback (addButton2W, XtNcallback, AddCB, 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, True); |
---|
831 | |
---|
832 | n = 0; |
---|
833 | deleteButton2W = XtCreateManagedWidget( |
---|
834 | "abort", |
---|
835 | commandWidgetClass, |
---|
836 | deleteBox2W, |
---|
837 | args, |
---|
838 | n); |
---|
839 | XtAddCallback (deleteButton2W, XtNcallback, DeleteCB, False); |
---|
840 | |
---|
841 | XtPopup(deletePopupW, XtGrabNone); |
---|
842 | |
---|
843 | } |
---|
844 | |
---|
845 | static void |
---|
846 | DeleteCB(w, client_data, call_data) |
---|
847 | Widget w; |
---|
848 | XtPointer client_data; |
---|
849 | XtPointer call_data; |
---|
850 | { |
---|
851 | char buffer[165]; |
---|
852 | char *tempstring1, *returndata; |
---|
853 | Arg args[5]; |
---|
854 | unsigned int n; |
---|
855 | |
---|
856 | if (!deletePopupW) |
---|
857 | return; |
---|
858 | |
---|
859 | if ((Boolean) client_data) { |
---|
860 | n = 0; |
---|
861 | XtSetArg(args[n], XtNstring, &tempstring1); n++; |
---|
862 | XtGetValues (deleteMtgTextW, args, n); |
---|
863 | /* |
---|
864 | ** Protect us when we remove the current meeting. Watch out for leading |
---|
865 | ** and trailing spaces in the text widget's value. |
---|
866 | */ |
---|
867 | if ( CompareWithoutWhitespace(tempstring1, CurrentMtg(0)) || |
---|
868 | CompareWithoutWhitespace(tempstring1, CurrentMtg(1))) |
---|
869 | SaveMeetingNames("", ""); |
---|
870 | |
---|
871 | sprintf (buffer, "(dm %s)\n", tempstring1); |
---|
872 | returndata = RunCommand (buffer, NULL, NULL, True); |
---|
873 | |
---|
874 | if ( (int) returndata <= 0) |
---|
875 | return; |
---|
876 | |
---|
877 | /* |
---|
878 | TopSelect(NULL, 2, NULL); |
---|
879 | */ |
---|
880 | myfree (returndata); |
---|
881 | myfree (tempstring1); |
---|
882 | } |
---|
883 | |
---|
884 | XtDestroyWidget(deletePopupW); |
---|
885 | deletePopupW = 0; |
---|
886 | } |
---|
887 | |
---|
888 | static Boolean |
---|
889 | CompareWithoutWhitespace(s, t) |
---|
890 | char *s, *t; |
---|
891 | { |
---|
892 | while (isspace(*s)) |
---|
893 | *s++; |
---|
894 | |
---|
895 | while (isspace(*t)) |
---|
896 | *t++; |
---|
897 | |
---|
898 | while (*s && *t && (*s++ == *t++)) |
---|
899 | ; |
---|
900 | |
---|
901 | if (!*t && !*s) |
---|
902 | return (True); |
---|
903 | |
---|
904 | if (!*t) { |
---|
905 | while (isspace(*s)) |
---|
906 | s++; |
---|
907 | if (!*s) |
---|
908 | return (True); |
---|
909 | else |
---|
910 | return (False); |
---|
911 | } |
---|
912 | |
---|
913 | if (!*s) { |
---|
914 | while (isspace(*t)) |
---|
915 | t++; |
---|
916 | if (!*t) |
---|
917 | return (True); |
---|
918 | else |
---|
919 | return (False); |
---|
920 | } |
---|
921 | |
---|
922 | return (False); |
---|
923 | } |
---|
924 | |
---|
925 | PutUpWarning(prefix, message, deathoption) |
---|
926 | char *prefix; |
---|
927 | char *message; |
---|
928 | Boolean deathoption; |
---|
929 | { |
---|
930 | Arg args[5]; |
---|
931 | unsigned int n; |
---|
932 | Widget warningPaneW, warningButtonW, warningBoxW, deathButtonW; |
---|
933 | Position parentx, parenty; |
---|
934 | Dimension parentwidth, mywidth; |
---|
935 | int flag = 0; |
---|
936 | |
---|
937 | if (warningPopupW) |
---|
938 | return; |
---|
939 | |
---|
940 | n = 0; |
---|
941 | XtSetArg(args[n], XtNwidth, &parentwidth); n++; |
---|
942 | XtSetArg(args[n], XtNx, &parentx); n++; |
---|
943 | XtSetArg(args[n], XtNy, &parenty); n++; |
---|
944 | XtGetValues (topW, args, n); |
---|
945 | |
---|
946 | mywidth = (strlen(message)+2) * char_width; |
---|
947 | |
---|
948 | n = 0; |
---|
949 | XtSetArg(args[n], XtNwidth, mywidth); n++; |
---|
950 | XtSetArg(args[n], XtNtransient, True); n++; |
---|
951 | XtSetArg(args[n], XtNtransientFor, topW); n++; |
---|
952 | XtSetArg(args[n], XtNx, |
---|
953 | parentx + ((parentwidth - mywidth) / 2)); n++; |
---|
954 | XtSetArg(args[n], XtNy, parenty + 100); n++; |
---|
955 | warningPopupW = XtCreatePopupShell( |
---|
956 | "warningpopup", |
---|
957 | transientShellWidgetClass, |
---|
958 | topW, |
---|
959 | args, |
---|
960 | n); |
---|
961 | |
---|
962 | warningPaneW = XtCreateManagedWidget( |
---|
963 | "pane", |
---|
964 | panedWidgetClass, |
---|
965 | warningPopupW, |
---|
966 | NULL, |
---|
967 | 0); |
---|
968 | XtInstallAccelerators(warningPaneW, paneW); |
---|
969 | |
---|
970 | if (*prefix) { |
---|
971 | n = 0; |
---|
972 | XtSetArg(args[n], XtNlabel, prefix); n++; |
---|
973 | XtSetArg(args[n], XtNwidth, 300); n++; |
---|
974 | (void) XtCreateManagedWidget( |
---|
975 | "label1", |
---|
976 | labelWidgetClass, |
---|
977 | warningPaneW, |
---|
978 | args, |
---|
979 | n); |
---|
980 | } |
---|
981 | |
---|
982 | n = 0; |
---|
983 | XtSetArg(args[n], XtNlabel, message); n++; |
---|
984 | (void) XtCreateManagedWidget( |
---|
985 | "label2", |
---|
986 | labelWidgetClass, |
---|
987 | warningPaneW, |
---|
988 | args, |
---|
989 | n); |
---|
990 | n = 0; |
---|
991 | warningBoxW = XtCreateManagedWidget( |
---|
992 | "box", |
---|
993 | boxWidgetClass, |
---|
994 | warningPaneW, |
---|
995 | args, |
---|
996 | n); |
---|
997 | |
---|
998 | n = 0; |
---|
999 | warningButtonW = XtCreateManagedWidget( |
---|
1000 | "acknowledge", |
---|
1001 | commandWidgetClass, |
---|
1002 | warningBoxW, |
---|
1003 | args, |
---|
1004 | n); |
---|
1005 | |
---|
1006 | XtAddCallback (warningButtonW, XtNcallback, PopdownCB, False); |
---|
1007 | |
---|
1008 | if (deathoption) { |
---|
1009 | deathButtonW = XtCreateManagedWidget( |
---|
1010 | "quit immediately", |
---|
1011 | commandWidgetClass, |
---|
1012 | warningBoxW, |
---|
1013 | NULL, 0); |
---|
1014 | |
---|
1015 | XtAddCallback (deathButtonW, XtNcallback, DieCB, False); |
---|
1016 | } |
---|
1017 | |
---|
1018 | XtInstallAllAccelerators(warningPopupW, paneW); |
---|
1019 | XtSetKeyboardFocus(paneW, warningButtonW); |
---|
1020 | |
---|
1021 | XtPopup(warningPopupW, XtGrabNone); |
---|
1022 | } |
---|
1023 | |
---|
1024 | void |
---|
1025 | DieCB(w, client_data, call_data) |
---|
1026 | Widget w; |
---|
1027 | XtPointer client_data; |
---|
1028 | XtPointer call_data; |
---|
1029 | { |
---|
1030 | exit (-1); |
---|
1031 | } |
---|
1032 | |
---|
1033 | PopdownCB(w, client_data, call_data) |
---|
1034 | Widget w; |
---|
1035 | XtPointer client_data; |
---|
1036 | XtPointer call_data; |
---|
1037 | { |
---|
1038 | int didsomething = 0; |
---|
1039 | |
---|
1040 | if (warningPopupW) { |
---|
1041 | XtDestroyWidget(warningPopupW); |
---|
1042 | warningPopupW = 0; |
---|
1043 | didsomething = 1; |
---|
1044 | } |
---|
1045 | |
---|
1046 | if (helpPopupW) { |
---|
1047 | XtDestroyWidget(helpPopupW); |
---|
1048 | helpPopupW = 0; |
---|
1049 | didsomething = 1; |
---|
1050 | } |
---|
1051 | XtSetKeyboardFocus(topW, topW); |
---|
1052 | return (didsomething); |
---|
1053 | } |
---|
1054 | |
---|
1055 | |
---|
1056 | void |
---|
1057 | PutUpHelp() |
---|
1058 | { |
---|
1059 | Arg args[5]; |
---|
1060 | unsigned int n; |
---|
1061 | Widget localPaneW, textW, boxW, buttonW; |
---|
1062 | |
---|
1063 | if (helpPopupW) |
---|
1064 | return; |
---|
1065 | |
---|
1066 | n = 0; |
---|
1067 | helpPopupW = XtCreatePopupShell( |
---|
1068 | "helppopup", |
---|
1069 | topLevelShellWidgetClass, |
---|
1070 | topW, |
---|
1071 | args, |
---|
1072 | n); |
---|
1073 | |
---|
1074 | XtInstallAccelerators(helpPopupW, paneW); |
---|
1075 | n = 0; |
---|
1076 | localPaneW = XtCreateManagedWidget( |
---|
1077 | "pane", |
---|
1078 | panedWidgetClass, |
---|
1079 | helpPopupW, |
---|
1080 | args, |
---|
1081 | n); |
---|
1082 | |
---|
1083 | n = 0; |
---|
1084 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
1085 | XtSetArg(args[n], XtNwidth, 80 * char_width); n++; |
---|
1086 | |
---|
1087 | textW = XtCreateManagedWidget( |
---|
1088 | "helptext", |
---|
1089 | asciiTextWidgetClass, |
---|
1090 | localPaneW, |
---|
1091 | args, |
---|
1092 | n); |
---|
1093 | XtInstallAccelerators(textW, paneW); |
---|
1094 | |
---|
1095 | n = 0; |
---|
1096 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
1097 | boxW = XtCreateManagedWidget( |
---|
1098 | "box", |
---|
1099 | boxWidgetClass, |
---|
1100 | localPaneW, |
---|
1101 | args, |
---|
1102 | n); |
---|
1103 | |
---|
1104 | n = 0; |
---|
1105 | buttonW = XtCreateManagedWidget( |
---|
1106 | "okay", |
---|
1107 | commandWidgetClass, |
---|
1108 | boxW, |
---|
1109 | args, |
---|
1110 | n); |
---|
1111 | |
---|
1112 | XtInstallAllAccelerators(helpPopupW, paneW); |
---|
1113 | XtAddCallback (buttonW, XtNcallback, PopdownCB, True); |
---|
1114 | XtPopup(helpPopupW, XtGrabNone); |
---|
1115 | } |
---|
1116 | |
---|
1117 | |
---|
1118 | /* |
---|
1119 | ** Okay, here's some really crude stuff. We assume the text in bottextW |
---|
1120 | ** contains lines like " Host: YABBA.DABBA.DOO" where "Host:" is |
---|
1121 | ** the sort of thing that we call a "prompt." We find the line, if any, |
---|
1122 | ** including the string pointed to by prompt, and return a pointer to |
---|
1123 | ** the string from whitespace to \n following the prompt. |
---|
1124 | */ |
---|
1125 | |
---|
1126 | static char * |
---|
1127 | GetDefaultValue(prompt) |
---|
1128 | char *prompt; |
---|
1129 | { |
---|
1130 | Arg args[5]; |
---|
1131 | unsigned int n; |
---|
1132 | char *prompt1, *string, *string1, *string2; |
---|
1133 | char *retval; |
---|
1134 | |
---|
1135 | n = 0; |
---|
1136 | XtSetArg(args[n], XtNstring, &string); n++; |
---|
1137 | XtGetValues (bottextW, args, n); |
---|
1138 | |
---|
1139 | /* |
---|
1140 | ** Now we look for the prompt. |
---|
1141 | */ |
---|
1142 | |
---|
1143 | for (string1 = string; *string1; string1++) { |
---|
1144 | for ( prompt1 = prompt, string2 = string1; |
---|
1145 | *prompt1 == *string2; |
---|
1146 | prompt1++, string2++) |
---|
1147 | ; |
---|
1148 | |
---|
1149 | if (!*prompt1) break; |
---|
1150 | } |
---|
1151 | |
---|
1152 | if (!*string1) { |
---|
1153 | return (NULL); |
---|
1154 | } |
---|
1155 | |
---|
1156 | for (string2 = string1; *string2 != ' '; string2++); |
---|
1157 | |
---|
1158 | for ( ; *string2 == ' '; string2++); |
---|
1159 | |
---|
1160 | *strchr (string2, '\n') = '\0'; |
---|
1161 | |
---|
1162 | retval = (char *) malloc (strlen(string2) + 1); |
---|
1163 | strcpy (retval, string2); |
---|
1164 | *(strchr(string2, '\0')) = '\n'; |
---|
1165 | return (retval); |
---|
1166 | } |
---|
1167 | |
---|
1168 | void |
---|
1169 | GetTransactionNum() |
---|
1170 | { |
---|
1171 | Arg args[5]; |
---|
1172 | unsigned int n; |
---|
1173 | Widget button, numPaneW, numBox1W; |
---|
1174 | Position parentx, parenty; |
---|
1175 | Dimension parentwidth, mywidth; |
---|
1176 | |
---|
1177 | if (numPopupW) |
---|
1178 | return; |
---|
1179 | |
---|
1180 | n = 0; |
---|
1181 | XtSetArg(args[n], XtNwidth, &parentwidth); n++; |
---|
1182 | XtSetArg(args[n], XtNx, &parentx); n++; |
---|
1183 | XtSetArg(args[n], XtNy, &parenty); n++; |
---|
1184 | XtGetValues (topW, args, n); |
---|
1185 | |
---|
1186 | mywidth = 35 * char_width; |
---|
1187 | |
---|
1188 | n = 0; |
---|
1189 | XtSetArg(args[n], XtNwidth, mywidth); n++; |
---|
1190 | XtSetArg(args[n], XtNtransient, True); n++; |
---|
1191 | XtSetArg(args[n], XtNtransientFor, topW); n++; |
---|
1192 | XtSetArg(args[n], XtNx, |
---|
1193 | parentx + ((parentwidth - mywidth) / 2)); n++; |
---|
1194 | XtSetArg(args[n], XtNy, parenty + 100); n++; |
---|
1195 | |
---|
1196 | numPopupW = XtCreatePopupShell( |
---|
1197 | "numpopup", |
---|
1198 | transientShellWidgetClass, |
---|
1199 | topW, |
---|
1200 | args, |
---|
1201 | n); |
---|
1202 | |
---|
1203 | numPaneW = XtCreateManagedWidget( |
---|
1204 | "pane", |
---|
1205 | panedWidgetClass, |
---|
1206 | numPopupW, |
---|
1207 | NULL, |
---|
1208 | 0); |
---|
1209 | |
---|
1210 | n = 0; |
---|
1211 | |
---|
1212 | (void) XtCreateManagedWidget( |
---|
1213 | "label", |
---|
1214 | labelWidgetClass, |
---|
1215 | numPaneW, |
---|
1216 | args, |
---|
1217 | n); |
---|
1218 | |
---|
1219 | n = 0; |
---|
1220 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
1221 | XtSetArg(args[n], XtNeditType, XawtextEdit); n++; |
---|
1222 | XtSetArg(args[n], XtNwidth, 15 * char_width); n++; |
---|
1223 | |
---|
1224 | numTextW = XtCreateManagedWidget( |
---|
1225 | "text", |
---|
1226 | asciiTextWidgetClass, |
---|
1227 | numPaneW, |
---|
1228 | args, |
---|
1229 | n); |
---|
1230 | |
---|
1231 | n = 0; |
---|
1232 | XtSetArg(args[n], XtNborderWidth, 0); n++; |
---|
1233 | numBox1W = XtCreateManagedWidget( |
---|
1234 | "box1", |
---|
1235 | boxWidgetClass, |
---|
1236 | numPaneW, |
---|
1237 | args, |
---|
1238 | n); |
---|
1239 | |
---|
1240 | n = 0; |
---|
1241 | button = XtCreateManagedWidget( |
---|
1242 | "goto", |
---|
1243 | commandWidgetClass, |
---|
1244 | numBox1W, |
---|
1245 | args, |
---|
1246 | n); |
---|
1247 | |
---|
1248 | XtAddCallback (button, XtNcallback, NumCB, True); |
---|
1249 | |
---|
1250 | n = 0; |
---|
1251 | button = XtCreateManagedWidget( |
---|
1252 | "abort", |
---|
1253 | commandWidgetClass, |
---|
1254 | numBox1W, |
---|
1255 | args, |
---|
1256 | n); |
---|
1257 | |
---|
1258 | XtAddCallback (button, XtNcallback, NumCB, False); |
---|
1259 | XtPopup(numPopupW, XtGrabNone); |
---|
1260 | } |
---|
1261 | |
---|
1262 | static void |
---|
1263 | NumCB(w, client_data, call_data) |
---|
1264 | Widget w; |
---|
1265 | XtPointer client_data; |
---|
1266 | XtPointer call_data; |
---|
1267 | { |
---|
1268 | char *tempstring; |
---|
1269 | Arg args[5]; |
---|
1270 | unsigned int n; |
---|
1271 | |
---|
1272 | if (!numPopupW) |
---|
1273 | return; |
---|
1274 | |
---|
1275 | if ((Boolean) client_data) { |
---|
1276 | n = 0; |
---|
1277 | XtSetArg(args[n], XtNstring, &tempstring); n++; |
---|
1278 | XtGetValues (numTextW, args, n); |
---|
1279 | GoToTransaction(atoi(tempstring), True); |
---|
1280 | myfree (tempstring); |
---|
1281 | } |
---|
1282 | |
---|
1283 | XtDestroyWidget(numPopupW); |
---|
1284 | XtSetKeyboardFocus(topW, topW); |
---|
1285 | numPopupW = 0; |
---|
1286 | } |
---|
1287 | |
---|
1288 | void |
---|
1289 | TriggerAdd(w, event, params, num_params) |
---|
1290 | Widget w; |
---|
1291 | XEvent *event; |
---|
1292 | String *params; |
---|
1293 | int *num_params; |
---|
1294 | { |
---|
1295 | if (*num_params < 1) |
---|
1296 | return; |
---|
1297 | |
---|
1298 | AddCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1299 | } |
---|
1300 | |
---|
1301 | void |
---|
1302 | TriggerNum(w, event, params, num_params) |
---|
1303 | Widget w; |
---|
1304 | XEvent *event; |
---|
1305 | String *params; |
---|
1306 | int *num_params; |
---|
1307 | { |
---|
1308 | if (*num_params < 1) |
---|
1309 | return; |
---|
1310 | |
---|
1311 | NumCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1312 | } |
---|
1313 | |
---|
1314 | void |
---|
1315 | TriggerWrite(w, event, params, num_params) |
---|
1316 | Widget w; |
---|
1317 | XEvent *event; |
---|
1318 | String *params; |
---|
1319 | int *num_params; |
---|
1320 | { |
---|
1321 | if (*num_params < 1) |
---|
1322 | return; |
---|
1323 | |
---|
1324 | WriteCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1325 | } |
---|
1326 | |
---|
1327 | void |
---|
1328 | TriggerDelete(w, event, params, num_params) |
---|
1329 | Widget w; |
---|
1330 | XEvent *event; |
---|
1331 | String *params; |
---|
1332 | int *num_params; |
---|
1333 | { |
---|
1334 | if (*num_params < 1) |
---|
1335 | return; |
---|
1336 | |
---|
1337 | DeleteCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1338 | } |
---|
1339 | |
---|
1340 | void |
---|
1341 | TriggerPopdown(w, event, params, num_params) |
---|
1342 | Widget w; |
---|
1343 | XEvent *event; |
---|
1344 | String *params; |
---|
1345 | int *num_params; |
---|
1346 | { |
---|
1347 | if (*num_params < 1) |
---|
1348 | return; |
---|
1349 | |
---|
1350 | PopdownCB(w, (XtPointer) !strcmp(params[0], "Go"), NULL); |
---|
1351 | } |
---|
1352 | |
---|
1353 | void |
---|
1354 | TriggerSend(w, event, params, num_params) |
---|
1355 | Widget w; |
---|
1356 | XEvent *event; |
---|
1357 | String *params; |
---|
1358 | int *num_params; |
---|
1359 | { |
---|
1360 | TransactionRecPtr i; |
---|
1361 | |
---|
1362 | if (*num_params < 1) |
---|
1363 | return; |
---|
1364 | |
---|
1365 | if (listhead == 0) { |
---|
1366 | return; |
---|
1367 | } |
---|
1368 | |
---|
1369 | for (i = listhead; i; i = i->nextrec) { |
---|
1370 | if (w == i->data->subjectTextW) |
---|
1371 | break; |
---|
1372 | if (w == i->data->bodyTextW) |
---|
1373 | break; |
---|
1374 | if (w == i->data->sendButtonW) |
---|
1375 | break; |
---|
1376 | if (w == i->data->sendPopupW) |
---|
1377 | break; |
---|
1378 | } |
---|
1379 | |
---|
1380 | if (i == 0) |
---|
1381 | return; |
---|
1382 | |
---|
1383 | /* |
---|
1384 | ** Okay, here's a kludge. SendCB() checks the incoming widget ID, |
---|
1385 | ** and if it's equal to the sendButtonW stored in the data structure, |
---|
1386 | ** it actually does the send. So we fool it here. |
---|
1387 | */ |
---|
1388 | if (strcmp(params[0], "Go") == 0) |
---|
1389 | SendCB(i->data->sendButtonW, i->data, NULL); |
---|
1390 | else |
---|
1391 | SendCB(NULL, i->data, NULL); |
---|
1392 | } |
---|
1393 | |
---|
1394 | /* |
---|
1395 | ** Pass TriggerFocusMove "Prev" to move focus up, "Next" to move it down. |
---|
1396 | ** It figures out which widget got the event and moves focus to |
---|
1397 | ** the appropriate neighbor. |
---|
1398 | */ |
---|
1399 | |
---|
1400 | void |
---|
1401 | TriggerFocusMove(w, event, params, num_params) |
---|
1402 | Widget w; |
---|
1403 | XEvent *event; |
---|
1404 | String *params; |
---|
1405 | int *num_params; |
---|
1406 | { |
---|
1407 | TransactionRecPtr i; |
---|
1408 | int direction = -1; |
---|
1409 | Widget targetW = 0; |
---|
1410 | Widget shellparent; |
---|
1411 | |
---|
1412 | if (*num_params < 1) |
---|
1413 | return; |
---|
1414 | |
---|
1415 | for ( shellparent = XtParent(w); |
---|
1416 | shellparent && !XtIsShell(shellparent); |
---|
1417 | shellparent = XtParent(shellparent)) |
---|
1418 | ; |
---|
1419 | |
---|
1420 | if (!strcmp (params[0], "Next")) |
---|
1421 | direction = 2; |
---|
1422 | if (!strcmp (params[0], "Prev")) |
---|
1423 | direction = 1; |
---|
1424 | if (!strcmp (params[0], "Toggle")) |
---|
1425 | direction = 0; |
---|
1426 | |
---|
1427 | if (!strcmp (params[0], "Here")) { |
---|
1428 | XtSetKeyboardFocus(topW, shellparent); |
---|
1429 | XtSetKeyboardFocus(shellparent, w); |
---|
1430 | return; |
---|
1431 | } |
---|
1432 | |
---|
1433 | /* |
---|
1434 | ** Was the hit widget in the add-mtg popup? All keys become toggle. |
---|
1435 | */ |
---|
1436 | if (addPopupW) { |
---|
1437 | if (w == addHostTextW) |
---|
1438 | targetW = addPathTextW; |
---|
1439 | if (w == addPathTextW) |
---|
1440 | targetW = addHostTextW; |
---|
1441 | } |
---|
1442 | |
---|
1443 | /* |
---|
1444 | ** Check the subject and body widgets in the list of entryrecs. |
---|
1445 | */ |
---|
1446 | if (listhead != 0) { |
---|
1447 | for (i = listhead; i; i = i->nextrec) { |
---|
1448 | if (w == i->data->subjectTextW && |
---|
1449 | (direction == 2 || direction == 0)) |
---|
1450 | targetW = i->data->bodyTextW; |
---|
1451 | if (w == i->data->bodyTextW && |
---|
1452 | (direction == 1 || direction == 0)) |
---|
1453 | targetW = i->data->subjectTextW; |
---|
1454 | } |
---|
1455 | } |
---|
1456 | |
---|
1457 | if (targetW) { |
---|
1458 | XtSetKeyboardFocus(topW, shellparent); |
---|
1459 | XtSetKeyboardFocus(shellparent, targetW); |
---|
1460 | } |
---|
1461 | } |
---|