1 /*
2 xrus - keyboard switcher/indicator
3 Copyright (c) 1995-1998 Alexander V. Lukyanov
4 This is free software with no warranty.
5 See COPYING for details.
6
7 Athena version of properties dialog
8 by Vladimir Grachev, e-mail vgrachev@ssau.ru (1998)
9 */
10 /*__________________________________________________________________________
11 **
12 ** File: props.c
13 **__________________________________________________________________________
14 */
15 #include <config.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #include <X11/Xlib.h>
20 #include <X11/Intrinsic.h>
21 #include <X11/StringDefs.h>
22
23 #if TK==TK_MOTIF
24 #include <Xm/Xm.h>
25 #include <Xm/Form.h>
26 #include <Xm/PushB.h>
27 #include <Xm/DialogS.h>
28 #include <Xm/ToggleB.h>
29 #include <Xm/RowColumn.h>
30 #include <Xm/Separator.h>
31 #include <Xm/Scale.h>
32 #include <Xm/Frame.h>
33 #include <Xm/TextF.h>
34 #include <Xm/LabelG.h>
35 #include <Xm/MessageB.h>
36
37 #elif TK==TK_XAW
38
39 #include <X11/Shell.h>
40 #include <X11/Xaw/Form.h>
41 #include <X11/Xaw/Toggle.h>
42 #include <X11/Xaw/Scrollbar.h>
43 #include <X11/Xaw/Label.h>
44 #include <X11/Xaw/AsciiText.h>
45 #include <X11/Xaw/Command.h>
46 #include <X11/Xaw/Dialog.h>
47 #endif
48
49 #include "keycomb.h"
50 #include "xrus.h"
51
52 #include "xalloca.h"
53
54 #if TK!=TK_NONE
55
56 #if TK==TK_MOTIF
57 struct
58 {
59 Widget shell,form,ok_button,apply_button,cancel_button;
60 Widget allow_locker,autolock_delay,use_bell;
61 Widget frame1,frame2,form1;
62 Widget form2,form4;
63 Widget locker,switch_keys,locker_def,switch_keys_def;
64 Widget to_lat_keys,to_rus_keys;
65 Widget switch_for_one_keys;
66 Widget locker_test,save_button;
67 }
68 props;
69 #elif TK==TK_XAW
70
71 #define MAX_LOCKER_TIMEOUT 120
72
73 int locker_timeout;
74
75 struct {
76 Widget shell, form;
77 Widget locker_toggle, minutes_sb, minutes_label, minutes_value_label;
78 Widget command_label, locker;
79 Widget test_button, default1_button;
80 Widget bell_toggle;
81 Widget switch_label, switch_keys;
82 Widget lat_label, to_lat_keys;
83 Widget rus_label, to_rus_keys;
84 Widget switch_for_one_keys;
85 Widget default2_button;
86 Widget ok_button, apply_button, save_button, cancel_button;
87 } props;
88
set_minutes(void)89 void set_minutes(void) {
90 Dimension length;
91 char buffer[20];
92 float top;
93 Arg args[1];
94 XtArgVal *l_top;
95
96 XtVaGetValues(props.minutes_sb,
97 XtNlength, &length,
98 NULL);
99
100 /* This doesn't work! Why??? */
101 /* XawScrollbarSetThumb(props.minutes_sb,
102 (float) ((float) locker_timeout / (float) MAX_LOCKER_TIMEOUT), 0.0);*/
103
104 top = (float) ((float) locker_timeout / (float) MAX_LOCKER_TIMEOUT);
105 l_top = (XtArgVal *) ⊤
106 XtSetArg(args[0], XtNtopOfThumb, *l_top);
107 XtSetValues(props.minutes_sb, args, 1);
108
109 sprintf(buffer, "%d ", locker_timeout);
110 XtVaSetValues(props.minutes_value_label,
111 XtNlabel, buffer,
112 NULL);
113
114 };
115 #endif /* TK==TK_XAW */
116
117 static
get_string(Widget w)118 char *get_string(Widget w)
119 {
120 char *value;
121 #if TK==TK_MOTIF
122 XtVaGetValues(w,XmNvalue,&value,NULL);
123 #elif TK==TK_XAW
124 XtVaGetValues(w,XtNstring,&value,NULL);
125 #endif
126 return value;
127 }
128
129 static
set_string(Widget w,const char * value)130 void set_string(Widget w,const char *value)
131 {
132 #if TK==TK_MOTIF
133 XtVaSetValues(w,XmNvalue,value,NULL);
134 #elif TK==TK_XAW
135 XtVaSetValues(w,XtNstring,value,NULL);
136 #endif
137 }
138
139 static
PropsSet()140 void PropsSet()
141 {
142 #if TK==TK_MOTIF
143 XtVaSetValues(props.allow_locker,XmNset,!!AppData.autolock,NULL);
144 XtVaSetValues(props.autolock_delay,XmNvalue,AppData.timeout,NULL);
145 XtVaSetValues(props.use_bell,XmNset,!!AppData.useBell,NULL);
146 #elif TK==TK_XAW
147 XtVaSetValues(props.locker_toggle,
148 XtNstate, !!AppData.autolock,
149 NULL);
150
151 locker_timeout = AppData.timeout;
152 set_minutes();
153
154 XtVaSetValues(props.minutes_sb,
155 XtNvalue, AppData.timeout,
156 NULL);
157 XtVaSetValues(props.bell_toggle,
158 XtNstate, !!AppData.useBell,
159 NULL);
160 #endif
161
162 set_string(props.locker,AppData.locker);
163 set_string(props.switch_keys,AppData.switchKeys);
164 set_string(props.to_lat_keys,AppData.toLatKeys);
165 set_string(props.to_rus_keys,AppData.toRusKeys);
166 set_string(props.switch_for_one_keys,AppData.switchForOneKeys);
167 }
168
169 static
ErrorDismiss_CB(Widget w,XtPointer closure,XtPointer call_data)170 void ErrorDismiss_CB(Widget w,XtPointer closure,XtPointer call_data)
171 {
172 XtDestroyWidget((Widget)closure);
173 }
174
175 static
PropsApply()176 int PropsApply()
177 {
178 char old_switchKeys[256];
179 char message[1024];
180 char large_message[3*1024];
181
182 large_message[0]=0;
183
184 strcpy(old_switchKeys,AppData.switchKeys);
185 strcpy(AppData.switchKeys,get_string(props.switch_keys));
186 ParseKeyCombination(AppData.switchKeys,&SwitchKeys,message);
187 if(*message)
188 {
189 strcat(large_message,message);
190
191 strcpy(AppData.switchKeys,old_switchKeys);
192 ParseKeyCombination(AppData.switchKeys,&SwitchKeys,message);
193 }
194
195 strcpy(old_switchKeys,AppData.toLatKeys);
196 strcpy(AppData.toLatKeys,get_string(props.to_lat_keys));
197 ParseKeyCombination(AppData.toLatKeys,&ToLatKeys,message);
198 if(*message)
199 {
200 strcat(large_message,message);
201
202 strcpy(AppData.toLatKeys,old_switchKeys);
203 ParseKeyCombination(AppData.toLatKeys,&ToLatKeys,message);
204 }
205
206 strcpy(old_switchKeys,AppData.toRusKeys);
207 strcpy(AppData.toRusKeys,get_string(props.to_rus_keys));
208 ParseKeyCombination(AppData.toRusKeys,&ToRusKeys,message);
209 if(*message)
210 {
211 strcat(large_message,message);
212
213 strcpy(AppData.toRusKeys,old_switchKeys);
214 ParseKeyCombination(AppData.toRusKeys,&ToRusKeys,message);
215 }
216
217 strcpy(old_switchKeys,AppData.switchForOneKeys);
218 strcpy(AppData.switchForOneKeys,get_string(props.switch_for_one_keys));
219 ParseKeyCombination(AppData.switchForOneKeys,&SwitchForOneKeys,message);
220 if(*message)
221 {
222 strcat(large_message,message);
223
224 strcpy(AppData.switchForOneKeys,old_switchKeys);
225 ParseKeyCombination(AppData.switchForOneKeys,&SwitchForOneKeys,message);
226 }
227
228 if(large_message[0])
229 {
230 #if TK==TK_MOTIF
231 Widget error;
232 Arg arg[3];
233 XmString msg=XmStringCreateLocalized(large_message);
234 XmString title=XmStringCreateLocalized("Parse error");
235
236 if(message[strlen(message)-1]=='\n')
237 message[strlen(message)-1]=0;
238
239 XtSetArg(arg[0],XmNmessageString,msg);
240 XtSetArg(arg[1],XmNdialogStyle,XmDIALOG_APPLICATION_MODAL);
241 XtSetArg(arg[2],XmNdialogTitle,title);
242 error=XmCreateErrorDialog(props.shell,"error",arg,3);
243 XtUnmanageChild(XtNameToWidget(error,"Cancel"));
244 XtUnmanageChild(XtNameToWidget(error,"Help"));
245 XtAddCallback(error,XmNunmapCallback,ErrorDismiss_CB,(XtPointer)error);
246
247 XmStringFree(msg);
248 XmStringFree(title);
249 XtManageChild(error);
250 #elif TK==TK_XAW
251 Widget error_shell, error_dialog;
252
253 error_shell = XtVaCreatePopupShell("error_shell",
254 topLevelShellWidgetClass, props.shell,
255 NULL);
256
257 error_dialog = XtVaCreateManagedWidget("error_dialog",
258 dialogWidgetClass, error_shell,
259 XtNlabel, large_message,
260 NULL);
261
262 XawDialogAddButton(error_dialog,
263 "Ok", ErrorDismiss_CB, (XtPointer) error_shell);
264
265 XtPopup(error_shell, XtGrabExclusive);
266 XSetWMProtocols(disp,XtWindow(error_shell),&wm_delete_window,1);
267
268 #endif /* TK==TK_XAW */
269 return 0;
270 }
271
272 strcpy(AppData.locker,get_string(props.locker));
273
274 #if TK==TK_MOTIF
275 XtVaGetValues(props.allow_locker,XmNset,&AppData.autolock,NULL);
276 XtVaGetValues(props.autolock_delay,XmNvalue,&AppData.timeout,NULL);
277 XtVaGetValues(props.use_bell,XmNset,&AppData.useBell,NULL);
278 #elif TK==TK_XAW
279 XtVaGetValues(props.locker_toggle,
280 XtNstate, &AppData.autolock,
281 NULL);
282 AppData.timeout = locker_timeout;
283 XtVaGetValues(props.bell_toggle,
284 XtNstate, &AppData.useBell,
285 NULL);
286 #endif
287 SetAlarm();
288 return 1;
289 }
290
291 static
PropsPopdown()292 void PropsPopdown()
293 {
294 XtPopdown(props.shell);
295 XtUnmanageChild(props.form);
296 }
297
PropsSave()298 void PropsSave()
299 {
300 FILE *f;
301 char *HOME=getenv("HOME");
302 char *filename;
303
304 if(!HOME)
305 return;
306
307 filename=alloca(strlen(HOME)+10);
308 sprintf(filename,"%s/.xrus",HOME);
309
310 f=fopen(filename,"w");
311 if(!f)
312 {
313 perror(filename);
314 return;
315 }
316
317 fprintf(f,"! This file was created automatically by Xrus\n"
318 "Xrus*locker:\t\t%s\n"
319 "Xrus*timeout:\t\t%d\n"
320 "Xrus*autolock:\t\t%s\n"
321 "Xrus*useBell:\t\t%s\n"
322 "Xrus*switchKeys:\t%s\n"
323 "Xrus*toLatKeys:\t\t%s\n"
324 "Xrus*toRusKeys:\t\t%s\n"
325 "Xrus*switchForOneKeys:\t%s\n",
326
327 AppData.locker,
328 AppData.timeout,
329 AppData.autolock?"true":"false",
330 AppData.useBell ?"true":"false",
331 AppData.switchKeys,
332 AppData.toLatKeys,
333 AppData.toRusKeys,
334 AppData.switchForOneKeys
335 );
336
337 fclose(f);
338 }
339
340 static
Button_CB(Widget w,XtPointer user_data,XtPointer cb_data)341 void Button_CB(Widget w,XtPointer user_data,XtPointer cb_data)
342 {
343 switch((int)user_data)
344 {
345 case(0): /* Ok */
346 if(!PropsApply())
347 return;
348 PropsPopdown();
349 break;
350 case(1): /* Apply */
351 if(!PropsApply())
352 return;
353 break;
354 case(2): /* Cancel */
355 PropsPopdown();
356 break;
357 case(3): /* Save */
358 if(!PropsApply())
359 return;
360 PropsSave();
361 PropsPopdown();
362 break;
363 }
364 }
365
366 static
LockerTest_CB(Widget w,XtPointer user_data,XtPointer cb_data)367 void LockerTest_CB(Widget w,XtPointer user_data,XtPointer cb_data)
368 {
369 char old_locker[256];
370
371 strcpy(old_locker,AppData.locker);
372 strcpy(AppData.locker,get_string(props.locker));
373
374 LockScreen();
375
376 strcpy(AppData.locker,old_locker);
377 }
378
379 static
Default_CB(Widget w,XtPointer closure,XtPointer cd_data)380 void Default_CB(Widget w,XtPointer closure,XtPointer cd_data)
381 {
382 switch((int)closure)
383 {
384 case(0):
385 /* set locker defaults */
386 #if TK==TK_MOTIF
387 XtVaSetValues(props.locker,XmNvalue,DefaultLocker,NULL);
388 XtVaSetValues(props.allow_locker,XmNset,0,NULL);
389 XtVaSetValues(props.autolock_delay,XmNvalue,30,NULL);
390 #elif TK==TK_XAW
391 XtVaSetValues(props.locker,
392 XtNstring, DefaultLocker,
393 NULL);
394 locker_timeout = 30;
395 set_minutes();
396 XtVaSetValues(props.locker_toggle,
397 XtNstate, 0,
398 NULL);
399 /* XtVaSetValues(props.autolock_delay,XmNvalue,30,NULL);*/
400 #endif
401 break;
402 case(1):
403 /* set switch keys default */
404 #if TK==TK_MOTIF
405 XtVaSetValues(props.use_bell,XmNset,0,NULL);
406 #elif TK==TK_XAW
407 XtVaSetValues(props.bell_toggle,
408 XtNstate, 0,
409 NULL);
410 #endif
411 set_string(props.switch_keys,DefaultSwitchKeys);
412 set_string(props.to_lat_keys,DefaultToLatKeys);
413 set_string(props.to_rus_keys,DefaultToRusKeys);
414 set_string(props.switch_for_one_keys,DefaultSwitchForOneKeys);
415 break;
416 }
417 }
418
419 #if TK==TK_XAW
cb_scroll(Widget w,XtPointer client_data,XtPointer position)420 static void cb_scroll(Widget w, XtPointer client_data, XtPointer position) {
421
422 if ((int) position > 0 && locker_timeout < MAX_LOCKER_TIMEOUT)
423 locker_timeout++;
424 if ((int) position < 0 && locker_timeout > 1)
425 locker_timeout--;
426
427 set_minutes();
428
429 };
430
cb_jump(Widget w,XtPointer client_data,XtPointer percent_ptr)431 static void cb_jump(Widget w, XtPointer client_data, XtPointer percent_ptr) {
432
433 locker_timeout = (int) (*(float *) percent_ptr * MAX_LOCKER_TIMEOUT);
434
435 set_minutes();
436
437 };
438 #endif /* TK_XAW */
439
440 static
PropsInit()441 void PropsInit()
442 {
443 static int inited=0;
444
445 #if TK==TK_MOTIF
446 int count;
447 Arg args[10];
448 #endif
449
450 if(inited)
451 return;
452
453 /* Create Properties sheet */
454
455 #if TK==TK_MOTIF
456
457 StartArgs();
458 AddArg(XmNmappedWhenManaged,False);
459 props.shell=XmCreateDialogShell(top_level,"props",args,count);
460
461 props.form=XtVaCreateWidget("form",xmFormWidgetClass,props.shell,
462 XmNautoUnmanage,False,
463 NULL);
464
465 props.frame1=XtVaCreateManagedWidget("frame1",xmFrameWidgetClass,props.form,NULL);
466 props.form1=XtVaCreateManagedWidget("form1",xmFormWidgetClass,props.frame1,NULL);
467
468 props.locker_def=XtVaCreateManagedWidget("locker_def",xmPushButtonWidgetClass,props.form1,NULL);
469 XtAddCallback(props.locker_def,XmNactivateCallback,Default_CB,(XtPointer)0);
470
471 props.locker_test=XtVaCreateManagedWidget("locker_test",xmPushButtonWidgetClass,props.form1,NULL);
472 XtAddCallback(props.locker_test,XmNactivateCallback,LockerTest_CB,(XtPointer)0);
473
474 props.locker=XtVaCreateManagedWidget("locker",xmTextFieldWidgetClass,props.form1,NULL);
475 XtVaCreateManagedWidget("locker_label",xmLabelGadgetClass,props.form1,NULL);
476
477 props.allow_locker=XtVaCreateManagedWidget("allow_locker",xmToggleButtonWidgetClass,props.form1,NULL);
478 props.autolock_delay=XtVaCreateManagedWidget("autolock_delay",xmScaleWidgetClass,props.form1,NULL);
479
480 props.frame2=XtVaCreateManagedWidget("frame2",xmFrameWidgetClass,props.form,NULL);
481 props.form2=XtVaCreateManagedWidget("form2",xmFormWidgetClass,props.frame2,NULL);
482
483 props.use_bell=XtVaCreateManagedWidget("use_bell",xmToggleButtonWidgetClass,props.form2,NULL);
484 XtVaCreateManagedWidget("switch_keys_label",xmLabelGadgetClass,props.form2,NULL);
485 props.switch_keys=XtVaCreateManagedWidget("switch_keys",xmTextFieldWidgetClass,props.form2,NULL);
486 XtVaCreateManagedWidget("to_lat_keys_label",xmLabelGadgetClass,props.form2,NULL);
487 props.to_lat_keys=XtVaCreateManagedWidget("to_lat_keys",xmTextFieldWidgetClass,props.form2,NULL);
488 XtVaCreateManagedWidget("to_rus_keys_label",xmLabelGadgetClass,props.form2,NULL);
489 props.to_rus_keys=XtVaCreateManagedWidget("to_rus_keys",xmTextFieldWidgetClass,props.form2,NULL);
490 XtVaCreateManagedWidget("switch_for_one_keys_label",xmLabelGadgetClass,props.form2,NULL);
491 props.switch_for_one_keys=XtVaCreateManagedWidget("switch_for_one_keys",xmTextFieldWidgetClass,props.form2,NULL);
492
493 props.switch_keys_def=XtVaCreateManagedWidget("switch_keys_def",xmPushButtonWidgetClass,props.form2,NULL);
494 XtAddCallback(props.switch_keys_def,XmNactivateCallback,Default_CB,(XtPointer)1);
495
496 props.form4=XtVaCreateManagedWidget("form4",xmFormWidgetClass,props.form,NULL);
497
498 props.ok_button=XtVaCreateManagedWidget("ok",xmPushButtonWidgetClass,props.form4,NULL);
499 XtVaSetValues(props.form,
500 XmNdefaultButton,props.ok_button,
501 NULL);
502 XtVaSetValues(props.form4,
503 XmNdefaultButton,props.ok_button,
504 NULL);
505
506 props.cancel_button=XtVaCreateManagedWidget("cancel",xmPushButtonWidgetClass,props.form4,NULL);
507 props.apply_button=XtVaCreateManagedWidget("apply",xmPushButtonWidgetClass,props.form4,NULL);
508 props.save_button=XtVaCreateManagedWidget("save",xmPushButtonWidgetClass,props.form4,NULL);
509
510 XtVaSetValues(props.form,
511 XmNcancelButton,props.cancel_button,
512 NULL);
513
514 XtAddCallback(props.ok_button,XmNactivateCallback,Button_CB,(XtPointer)0);
515 XtAddCallback(props.apply_button,XmNactivateCallback,Button_CB,(XtPointer)1);
516 XtAddCallback(props.cancel_button,XmNactivateCallback,Button_CB,(XtPointer)2);
517 XtAddCallback(props.save_button,XmNactivateCallback,Button_CB,(XtPointer)3);
518
519 #elif TK==TK_XAW
520
521 props.shell = XtVaCreatePopupShell("props_xaw",
522 topLevelShellWidgetClass, top_level,
523 NULL);
524
525 props.form = XtVaCreateWidget("form",
526 formWidgetClass, props.shell,
527 NULL);
528
529 props.locker_toggle = XtVaCreateManagedWidget("locker_toggle",
530 toggleWidgetClass, props.form,
531 NULL);
532
533 props.minutes_sb = XtVaCreateManagedWidget("minutes_sb",
534 scrollbarWidgetClass, props.form,
535 XtNorientation, XtorientHorizontal,
536 NULL);
537 XtAddCallback(props.minutes_sb,
538 XtNscrollProc, cb_scroll, (XtPointer) NULL);
539 XtAddCallback(props.minutes_sb,
540 XtNjumpProc, cb_jump, (XtPointer) NULL);
541
542 props.minutes_label = XtVaCreateManagedWidget("minutes_label",
543 labelWidgetClass, props.form,
544 NULL);
545
546 props.minutes_value_label = XtVaCreateManagedWidget("minutes_value_label",
547 labelWidgetClass, props.form,
548 NULL);
549
550 props.command_label = XtVaCreateManagedWidget("command_label",
551 labelWidgetClass, props.form,
552 NULL);
553
554 props.locker = XtVaCreateManagedWidget("command_text",
555 asciiTextWidgetClass, props.form,
556 XtNtype, XawAsciiString,
557 XtNeditType, XawtextEdit,
558 NULL);
559
560 props.test_button = XtVaCreateManagedWidget("test_button",
561 commandWidgetClass, props.form,
562 NULL);
563 XtAddCallback(props.test_button,
564 XtNcallback, LockerTest_CB, (XtPointer) 0);
565
566 props.default1_button = XtVaCreateManagedWidget("default1_button",
567 commandWidgetClass, props.form,
568 NULL);
569 XtAddCallback(props.default1_button,
570 XtNcallback, Default_CB, (XtPointer) 0);
571
572 props.bell_toggle = XtVaCreateManagedWidget("bell_toggle",
573 toggleWidgetClass, props.form,
574 NULL);
575
576 props.switch_label = XtVaCreateManagedWidget("switch_label",
577 labelWidgetClass, props.form,
578 NULL);
579
580 props.switch_keys = XtVaCreateManagedWidget("switch_text",
581 asciiTextWidgetClass, props.form,
582 XtNtype, XawAsciiString,
583 XtNeditType, XawtextEdit,
584 NULL);
585
586 props.lat_label = XtVaCreateManagedWidget("lat_label",
587 labelWidgetClass, props.form,
588 NULL);
589
590 props.to_lat_keys = XtVaCreateManagedWidget("lat_text",
591 asciiTextWidgetClass, props.form,
592 XtNtype, XawAsciiString,
593 XtNeditType, XawtextEdit,
594 NULL);
595
596 props.rus_label = XtVaCreateManagedWidget("rus_label",
597 labelWidgetClass, props.form,
598 NULL);
599
600 props.to_rus_keys = XtVaCreateManagedWidget("rus_text",
601 asciiTextWidgetClass, props.form,
602 XtNtype, XawAsciiString,
603 XtNeditType, XawtextEdit,
604 NULL);
605
606 XtVaCreateManagedWidget("switch_for_one_keys_label",
607 labelWidgetClass, props.form,
608 NULL);
609
610 props.switch_for_one_keys = XtVaCreateManagedWidget("switch_for_one_keys",
611 asciiTextWidgetClass, props.form,
612 XtNtype, XawAsciiString,
613 XtNeditType, XawtextEdit,
614 NULL);
615
616 props.default2_button = XtVaCreateManagedWidget("default2_button",
617 commandWidgetClass, props.form,
618 NULL);
619 XtAddCallback(props.default2_button,
620 XtNcallback, Default_CB, (XtPointer) 1);
621
622 props.ok_button = XtVaCreateManagedWidget("ok_button",
623 commandWidgetClass, props.form,
624 NULL);
625 XtAddCallback(props.ok_button,
626 XtNcallback, Button_CB, (XtPointer) 0);
627
628 props.apply_button = XtVaCreateManagedWidget("apply_button",
629 commandWidgetClass, props.form,
630 NULL);
631 XtAddCallback(props.apply_button,
632 XtNcallback, Button_CB, (XtPointer) 1);
633
634 props.save_button = XtVaCreateManagedWidget("save_button",
635 commandWidgetClass, props.form,
636 NULL);
637 XtAddCallback(props.save_button,
638 XtNcallback, Button_CB, (XtPointer) 3);
639
640 props.cancel_button = XtVaCreateManagedWidget("cancel_button",
641 commandWidgetClass, props.form,
642 NULL);
643 XtAddCallback(props.cancel_button,
644 XtNcallback, Button_CB, (XtPointer) 2);
645
646 #endif /* TK_XAW */
647
648 inited=1;
649 }
650
PropsPopup()651 void PropsPopup()
652 {
653 PropsInit();
654
655 if(!XtIsManaged(props.form))
656 PropsSet();
657
658 XtManageChild(props.form);
659
660 #if TK==TK_MOTIF
661 {
662 int count;
663 Arg args[10];
664 Dimension width,height;
665 static int limit_set=0;
666
667 if(!limit_set)
668 {
669 StartArgs();
670 AddArg(XmNwidth,&width);
671 AddArg(XmNheight,&height);
672 XtGetValues(props.shell,args,count);
673 StartArgs();
674 AddArg(XmNminWidth,width);
675 AddArg(XmNminHeight,height);
676 AddArg(XmNmaxHeight,height);
677 XtSetValues(props.shell,args,count);
678
679 limit_set=1;
680 }
681 }
682 #endif /* TK_MOTIF */
683
684 XtPopup(props.shell, XtGrabNone);
685
686 #if TK==TK_XAW
687 XSetWMProtocols(disp,XtWindow(props.shell),&wm_delete_window,1);
688 #endif
689 } /* End of PropsPopup */
690 #else /* TK_NONE */
PropsPopup()691 void PropsPopup() {}
692 #endif
693