1 /* $TOG: dtchooser.c /main/8 1998/04/20 12:56:18 mgreess $ */
3 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
4 * (c) Copyright 1993, 1994 International Business Machines Corp. *
5 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
6 * (c) Copyright 1993, 1994 Novell, Inc. *
11 /****************************************************************************
15 ** Project: HP Visual User Environment (DT)
17 ** Description: Main line code for Dtgreet application
19 ** These routines initialize the toolkit, create the widgets,
20 ** set up callbacks, and wait for events.
23 ** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
27 ****************************************************************************
28 ************************************<+>*************************************/
32 /***************************************************************************
36 ***************************************************************************/
42 #include <sys/signal.h>
47 #include <X11/Shell.h>
48 #include <X11/cursorfont.h>
50 #include <Xm/DrawingA.h>
54 #include <Xm/LabelG.h>
59 #include <Xm/PushBG.h>
60 #include <Xm/MessageB.h>
61 #include <Xm/RowColumn.h>
62 #include <Xm/SeparatoG.h>
63 #include <Xm/ToggleBG.h>
64 #include <Xm/CascadeBG.h>
65 #include <Dt/EnvControlP.h>
68 #include <Dt/MenuButton.h>
74 /***************************************************************************
76 * External declarations
78 ***************************************************************************/
79 extern char password[]; /* pswd string value */
80 extern int password_length; /* pswd string length */
82 extern void DoAccept (Widget w, XtPointer client_data, XtPointer call_data);
83 extern void DoPing (Widget w, XtPointer client_data, XtPointer call_data);
85 /***************************************************************************
87 * Procedure declarations
89 ***************************************************************************/
91 static SIGVAL syncTimeout( int arg ) ;
92 static Widget InitToolKit( int argc, char **argv) ;
93 void MakeRootCursor( void ) ;
94 void MakeBackground( void ) ;
95 void MakeButtons( void ) ;
96 void MakeLogin( void ) ;
97 void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
98 static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
99 static SIGVAL Terminate( int arg ) ;
100 extern void DoCancel (Widget w, XtPointer client_data, XtPointer call_data);
106 /***************************************************************************
110 ***************************************************************************/
113 AppInfo appInfo; /* application resources */
114 Arg argt[100]; /* used for resources */
115 DisplayInfo dpyinfo; /* information about the display */
116 XmString xmstr; /* used for compound strings */
117 char *langenv; /* current value of LANG environment var. */
118 char *errorLogFile; /* current value of environment var. */
119 int showVerifyError;/* display a Verify() error dialog */
120 int fullScreen = 0; /* Obscure the entire screen. */
123 /******************************************************************************
127 ** toplevel "main" (toplevel)
128 ** login_shell "login_shell" (overrideShell)
129 ** table "table" (DrawingAreaWidget)
130 ** copyright_msg "copyright_msg" (MessageBox)
131 ** error_message "error_message" (MessageBox)
132 ** help_message "help_message" (MessageBox)
133 ** passwd_message "passwd_message" (MessageBox)
134 ** hostname_message "hostname_msg" (MessageBox)
135 ** matte "matte" (FormWidget)
136 ** logo "logo" (FrameWidget)
137 ** logo_pixmap "logo_pixmap" (LabelGadget)
138 ** matteFrame "matteFrame" (FrameWidget)
139 ** matte1 "matte1" (FormWidget)
140 ** dt_label "dt_label" (LabelGadget)
141 ** help_button "help_button" (PushButtonGadget)
142 ** greeting "greeting" (LabelGadget)
143 ** login_form "login_form" (FormWidget)
144 ** login_label "login_label" (LabelGadget)
145 ** login_text "login_text" (TextField)
146 ** ok_button "ok_button" (PushButtonGadget)
147 ** clear_button "clear_button" (PushButtonGadget)
148 ** options_button "options_button" (PushButton)
149 ** options_menu "options_menu" (PopupMenu)
150 ** options_item[0] "options_languages" (CascadeButtonGadget)
151 ** options_item[1] "options_sep2" (SeparatorGadget)
152 ** options_item[2] "session_menus" (CascadeButtonGadget)
153 ** options_item[3] "options_sep1" (SeparatorGadget)
154 ** options_item[4] "options_noWindows" (PushButtonGadget)
155 ** options_item[5] "options_restartServer"(PushButtonGadget)
156 ** options_item[6] "options_sep1" (SeparatorGadget)
157 ** options_item[7] "options_Copyright" (PushButtonGadget)
158 ** session_menu "session_menu" (PulldownMenu)
159 ** options_dt "options_dt" (ToggleButtonGadget)
160 ** options_failsafe "options_failsafe" (ToggleButtonGadget)
161 ** lang_menu "lang_menu" (PulldownMenu)
162 ** (lang items) (lang items) (ToggleButtonGadget)
168 extern Widget toplevel; /* top level shell widget */
169 Widget login_shell; /* shell for the main login widgets. */
170 Widget table; /* black background for everything */
171 Widget matte; /* main level form widget */
172 Widget matteFrame; /* main level form widget */
173 Widget matte1; /* second level form widget */
175 Widget greeting; /* Welcome message */
177 Widget logo1; /* frame around the Corporate logo */
178 Widget logo_pixmap; /* Corporate logo */
179 Widget logo_shadow; /* drop shadow under the Corporate logo */
181 Widget login_matte; /* bulletin board for login/password */
182 Widget dt_label; /* desktop label showing the current session */
183 Widget login_form = NULL; /* form containing the login widgets */
184 Widget login_label; /* label to left of login text widget */
185 Widget login_text; /* login text widget */
187 Widget ok_button; /* accept name/password text button */
188 Widget clear_button; /* clear name/password text button */
189 Widget options_button; /* login options button */
190 Widget help_button; /* help button */
192 Widget copyright_msg = NULL; /* copyright notice widget */
193 Widget help_message = NULL; /* the help message box */
194 Widget error_message = NULL; /* the error message box */
195 Widget hostname_message = NULL; /* the invalid hostname message box */
196 Widget passwd_message = NULL; /* the expired password message box */
198 Widget options_menu = NULL; /* pop-up menu on options button */
199 Widget options_item[10]; /* items on options pop_up menu */
200 Widget options_nowindows; /* nowindows pane on options pop_up menu */
201 Widget options_failsafe; /* failsafe pane on options pop_up menu */
202 Widget options_dtlite; /* dtlite pane on options pop_up menu */
203 Widget options_dt; /* dt regular pane on options pop_up menu */
206 Widget options_sp_dt; /* dt button for special desktop */
207 Widget options_last_dt; /* user's last dt */
211 Widget lang_menu = NULL; /* cascading menu on "Language" option */
212 Widget session_menu = NULL; /* cascading menu on "Session" option */
214 Widget chooser_list; /* list of hosts displayed by chooser */
215 Widget list_head; /* the heading for the chooser list */
220 XtResource AppResources[] = {
221 { "workspaceCursor", "WorkspaceCursor",
222 XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
223 XtRImmediate, (caddr_t)False },
225 { "labelFont", "LabelFont",
226 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
227 XmRString, "Fixed" },
229 { "textFont", "TextFont",
230 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
231 XmRString, "Fixed" },
233 { "chlistFont", "ChlistFont",
234 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, chlistFont),
235 XmRString, "Fixed" },
237 { "optionsDelay", "OptionsDelay",
238 XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
239 XtRImmediate, (XtPointer) 0 },
241 {"languageList", "LanguageList",
242 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
245 #if defined (ENABLE_DYNAMIC_LANGLIST)
246 {"languageListCmd", "LanguageListCmd",
247 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
249 #endif /* ENABLE_DYNAMIC_LANGLIST */
260 /***************************************************************************
265 ***************************************************************************/
268 MakeRootCursor( void )
272 vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
274 XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
279 /***************************************************************************
283 * Widgets: login_shell, table, matte
284 ***************************************************************************/
287 MakeBackground( void )
292 * Get resources first
294 SetResourceDatabase();
295 XtGetApplicationResources(toplevel, &appInfo, AppResources,
296 XtNumber(AppResources), NULL, 0);
300 * create the login shell widget...
305 /* CORE resource set */
306 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
307 XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
308 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
309 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
310 XtSetArg(argt[i], XmNsensitive, True ); i++;
311 XtSetArg(argt[i], XmNtranslations, NULL ); i++;
313 /* COMPOSITE resource set */
314 XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
316 /* SHELL resource set (set to avoid interference by user) */
317 XtSetArg(argt[i], XmNallowShellResize, False ); i++;
318 XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
319 XtSetArg(argt[i], XmNgeometry, NULL ); i++;
320 XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
321 XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
322 XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
323 XtSetArg(argt[i], XmNsaveUnder, False ); i++;
325 login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
327 XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
329 /* Fix to display Input Method's status area. */
330 XtSetArg(argt[0], XmNheight, dpyinfo.height);
331 XtSetValues(login_shell, argt, 1);
335 * create the full-screen drawing area...
338 i = InitArg(DrawingA);
339 XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
340 XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
341 XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
343 table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
344 login_shell, argt, i);
346 XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
351 * create the main matte...
355 /* XmNwidth, (set by user) */
356 /* XmNheight, (set by user) */
357 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
359 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
360 XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
363 matte = XmCreateForm(table, "matte", argt, i);
364 XtManageChild(matte);
367 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
368 XtSetArg(argt[i], XmNshadowThickness, 2); i++;
369 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
370 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
371 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
373 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
375 XtSetArg(argt[i], XmNtopOffset, 15); i++;
376 XtSetArg(argt[i], XmNbottomOffset, 15); i++;
377 XtSetArg(argt[i], XmNleftOffset, 15); i++;
379 XtSetArg(argt[i], XmNrightOffset, 15); i++;
381 matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
382 XtManageChild(matteFrame);
385 matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
386 XtManageChild(matte1);
393 /***************************************************************************
397 * Widgets: ok_button, clear_button, options_button, help_button
398 ***************************************************************************/
407 Dimension max_width; /* maximum width of a set of widgets */
408 Dimension max_height; /* maximum height of a set of widgets */
410 int origin; /* horizontal origin for button placement */
411 int spacing; /* spacing between buttons (width/32) */
415 * create the buttons...
421 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
422 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
423 XtSetArg(argt[i], XmNtraversalOn, True); i++;
424 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
426 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
427 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
429 ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
432 XtManageChild(ok_button);
434 XtAddCallback(ok_button, XmNactivateCallback, DoAccept, NULL);
440 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
441 XtSetArg(argt[i], XmNleftWidget, ok_button); i++;
442 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_UPDATE_LABEL, MC_DEF_UPDATE_LABEL);
443 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
445 clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
448 XtManageChild(clear_button);
449 XtAddCallback(clear_button, XmNactivateCallback, DoPing,
457 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
458 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
460 help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
461 XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
462 (XtPointer) help_chooser);
464 XtManageChild(help_button);
468 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
469 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
470 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
471 XtSetArg(argt[i], XmNleftWidget, clear_button); i++;
472 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OPTIONS_LABEL, MC_DEF_OPTIONS_LABEL );
473 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
475 options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
478 XtManageChild(options_button);
480 /** set attachment for help button **/
482 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
483 XtSetArg(argt[i], XmNleftWidget, options_button); i++;
484 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
485 XtSetValues(help_button, argt, i);
489 * tell form that ok_button is the default button...
493 XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
494 XtSetValues(matte1, argt, i);
499 * make all buttons the same size...
503 max_width = max_height = 0;
504 GetBiggest(ok_button, &max_width, &max_height);
505 GetBiggest(clear_button, &max_width, &max_height);
506 GetBiggest(options_button, &max_width, &max_height);
507 GetBiggest(help_button, &max_width, &max_height);
509 if ( max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
512 XtSetArg(argt[i], XmNwidth, max_width ); i++;
513 XtSetArg(argt[i], XmNheight, max_height ); i++;
514 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
516 XtSetValues(ok_button, argt, i);
517 XtSetValues(clear_button, argt, i);
518 XtSetValues(options_button, argt, i);
519 XtSetValues(help_button, argt, i);
523 /***************************************************************************
527 * Widgets: greeting, list_head, chooser_list
528 ***************************************************************************/
531 } GreetInfo, *GreetInfoPtr;
533 static GreetInfo greetInfo;
535 static XtResource greetResources[] = {
536 {XmNfontList, XmCFontList,
537 XmRFontList, sizeof(XmFontList),
538 XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
547 XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
548 greetResources, XtNumber(greetResources), NULL, 0);
550 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_TITLE, MC_DEF_CHOOSER_TITLE);
551 XtSetArg(argt[i], XmNtraversalOn, False); i++;
552 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
553 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
554 XtSetArg(argt[i], XmNtopOffset, 10); i++;
555 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
556 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
557 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER); i++;
558 if ( greetInfo.fontList != NULL ) {
559 XtSetArg(argt[i], XmNfontList, greetInfo.fontList); i++;
561 greeting = XmCreateLabel(matte1, "greeting", argt, i);
562 XtManageChild(greeting);
567 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_HEADING,
568 MC_DEF_CHOOSER_HEADING);
569 XtSetArg(argt[i], XmNtraversalOn, False); i++;
570 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
571 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
572 XtSetArg(argt[i], XmNtopWidget, greeting); i++;
573 XtSetArg(argt[i], XmNtopOffset, 10); i++;
574 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
575 XtSetArg(argt[i], XmNleftOffset, 13); i++;
576 if (appInfo.chlistFont != NULL) {
577 XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
579 list_head = XmCreateLabelGadget(matte1, "list_head", argt, i);
580 XtManageChild(list_head);
584 XtSetArg(argt[i], XmNresizable, True);
585 XtSetValues(matte, argt, i);
586 XtSetValues(matte1, argt, i);
590 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
591 XtSetArg(argt[i], XmNleftOffset, 10); i++;
592 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
593 XtSetArg(argt[i], XmNrightOffset, 10); i++;
594 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
595 XtSetArg(argt[i], XmNtopWidget, list_head); i++;
596 XtSetArg(argt[i], XmNtopOffset, 1); i++;
597 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
598 XtSetArg(argt[i], XmNbottomWidget, ok_button); i++;
599 XtSetArg(argt[i], XmNbottomOffset, 10); i++;
600 XtSetArg(argt[i], XmNallowShellResize, True); i++;
601 XtSetArg(argt[i], XmNlistSizePolicy, XmCONSTANT); i++;
602 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++;
603 if (appInfo.chlistFont != NULL) {
604 XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
606 chooser_list = XmCreateScrolledList(matte1, "chooser_list", argt, i);
607 XtAddCallback(chooser_list, XmNdefaultActionCallback, DoAccept, NULL);
608 XtManageChild(chooser_list);
610 if (appInfo.workspaceCursor)
616 XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
621 /***************************************************************************
625 * Widgets: error_message, help_message, copyright_msg, hostname_message,
627 ***************************************************************************/
630 MakeDialog( DialogType dtype )
641 Dimension txt_width, txt_height;
642 XmString ok, cancel, nw, sv;
646 * do things common to all dialogs...
649 ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
650 cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
652 i = InitArg(MessageBox);
653 XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
654 XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
655 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
656 XtSetArg(argt[i], XmNokLabelString, ok ); i++;
657 XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
658 XtSetArg(argt[i], XmNnoResize, False ); i++;
659 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
662 * create the various dialogs...
668 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
669 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
671 w = XmCreateErrorDialog(table, "error_message", argt, i);
672 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
673 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
680 xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
681 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
682 w = XmCreateInformationDialog(table, "help_message", argt, i);
683 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
684 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
686 txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
687 txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
688 txt_width = (txt_width > 850) ? 800 : txt_width - 50;
689 txt_height = (txt_height > 900) ? 750 : txt_height - 150;
691 XtSetArg(argt[i], XmNheight, txt_height); i++;
692 XtSetArg(argt[i], XmNwidth, txt_width); i++;
693 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
694 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
695 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
696 XtSetArg(argt[i], XmNeditable, False); i++;
697 str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
698 XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
699 text = XmCreateScrolledText(w, "help_message_text", argt, i);
708 if ((fp = fopen(COPYRIGHT,"r")) == NULL)
709 #if defined( __hp_osf )
710 xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
711 XmFONTLIST_DEFAULT_TAG);
713 xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
714 XmFONTLIST_DEFAULT_TAG);
717 xmstr = (XmString) NULL;
719 while (fgets(buffer, 128, fp) != NULL) {
721 if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
724 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
726 xmstr = XmStringConcat(xmstr,
727 XmStringCreate(buffer,
728 XmFONTLIST_DEFAULT_TAG));
733 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
735 w = XmCreateInformationDialog(table, "copyright_msg", argt, i);
736 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
737 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
739 XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
747 nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
748 sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
750 xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
751 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
752 XtSetArg(argt[i], XmNokLabelString, nw ); i++;
753 XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
755 w = XmCreateWarningDialog(table, "hostname_msg", argt, i);
757 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
762 hostname_message = w;
768 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
769 MC_DEF_PASSWD_EXPIRED);
770 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
772 w = XmCreateQuestionDialog(table, "password_msg", argt, i);
774 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
781 xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
783 w = XmCreateInformationDialog(table, "help_message", argt, i);
784 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
785 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
787 txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
788 txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
789 txt_width = (txt_width > 850) ? 800 : txt_width - 50;
790 txt_height = (txt_height > 900) ? 750 : txt_height - 150;
792 XtSetArg(argt[i], XmNheight, txt_height); i++;
793 XtSetArg(argt[i], XmNwidth, txt_width); i++;
794 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
795 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
796 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
797 XtSetArg(argt[i], XmNeditable, False); i++;
799 ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
800 XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
801 text = XmCreateScrolledText(w, "help_message_text", argt, i);
817 XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
818 XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
823 XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
824 XtSetValues(w, argt, 1);
828 XmStringFree(cancel);
832 * adjust the width of the "ok" button on the dialogs...
835 width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
838 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
839 XtSetArg(argt[i], XmNwidth, width ); i++;
841 XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
847 /***************************************************************************
851 * Widgets: options_menu, options_item[]
852 ***************************************************************************/
855 MakeOptionsMenu( void )
863 * get the built-in pop_up menu from the DtMenuButton...
866 XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
869 * create language cascade menus...
872 if ( lang_menu == NULL )
877 * create first level menu items...
882 * build [ Language ] menu pane if there are languages to choose from...
884 if ( lang_menu != NULL ) {
886 * [ Language ] menu pane...
887 * attach language cascade menu to this pane
889 i = InitArg(CascadeBG);
890 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
891 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
892 XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
893 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
894 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
895 "options_languages", argt, i);
902 i = InitArg(SeparatorG);
903 options_item[j] = XmCreateSeparatorGadget(options_menu,
911 * [ Restart Server ] menu pane...
913 i = k = InitArg(PushBG);
914 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
915 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
916 options_item[j] = XmCreatePushButtonGadget(options_menu,
917 "options_restartServer",
920 XtAddCallback(options_item[j], XmNactivateCallback,
921 DoCancel, (XtPointer) OB_RESTART_SERVER);
924 #ifdef copyright_option
928 i = InitArg(SeparatorG);
929 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
935 * [ Copyright ] menu pane...
937 i = k = InitArg(PushBG);
938 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
939 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
940 options_item[j] = XmCreatePushButtonGadget(options_menu,
944 XtAddCallback(options_item[j], XmNactivateCallback,
945 MenuItemCB, (XtPointer) OB_COPYRIGHT);
950 * manage the [Options] menu...
952 XtManageChildren(options_item, j);
957 * If the DT Lite Session Manager is not available, remove the DT Lite
958 * and DT menu panes. The actual widgets must still be created since
959 * other code (ex. MenuItemCB()) tries to obtain some of their resources.
962 if ( stat(DTLITESESSION, &statb) != 0 ||
963 ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
966 XtUnmanageChild(options_dt);
970 if ( getenv(PINGINTERVAL) != NULL )
971 XtUnmanageChild(options_nowindows);
980 /***************************************************************************
984 * X protocol error handler to override the default
985 ***************************************************************************/
988 ErrorHandler( Display *dpy, XErrorEvent *event )
996 /***************************************************************************
1000 * Timeout routine to build options menu
1001 ***************************************************************************/
1004 MakeOptionsProc( XtPointer data, XtIntervalId *id )
1007 if (options_menu == NULL)
1016 /***************************************************************************
1020 * Catch a SIGTERM and unmanage display
1021 ***************************************************************************/
1024 Terminate( int arg )
1027 write(1, "terminate", 9);
1028 CleanupAndExit(NULL, NOTIFY_ABORT);
1033 * Chooser doesn't use SIA but it does link with vgcallback.o. We just need
1034 * this symbol to keep the linker happy.