2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: dtchooser.c /main/8 1998/04/20 12:56:18 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
33 /****************************************************************************
37 ** Project: HP Visual User Environment (DT)
39 ** Description: Main line code for Dtgreet application
41 ** These routines initialize the toolkit, create the widgets,
42 ** set up callbacks, and wait for events.
45 ** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
49 ****************************************************************************
50 ************************************<+>*************************************/
54 /***************************************************************************
58 ***************************************************************************/
64 #include <sys/signal.h>
69 #include <X11/Shell.h>
70 #include <X11/cursorfont.h>
72 #include <Xm/DrawingA.h>
76 #include <Xm/LabelG.h>
81 #include <Xm/PushBG.h>
82 #include <Xm/MessageB.h>
83 #include <Xm/RowColumn.h>
84 #include <Xm/SeparatoG.h>
85 #include <Xm/ToggleBG.h>
86 #include <Xm/CascadeBG.h>
87 #include <Dt/EnvControlP.h>
90 #include <Dt/MenuButton.h>
96 /***************************************************************************
98 * External declarations
100 ***************************************************************************/
101 extern char password[]; /* pswd string value */
102 extern int password_length; /* pswd string length */
104 extern void DoAccept (Widget w, XtPointer client_data, XtPointer call_data);
105 extern void DoPing (Widget w, XtPointer client_data, XtPointer call_data);
107 /***************************************************************************
109 * Procedure declarations
111 ***************************************************************************/
113 static SIGVAL syncTimeout( int arg ) ;
114 static Widget InitToolKit( int argc, char **argv) ;
115 void MakeRootCursor( void ) ;
116 void MakeBackground( void ) ;
117 void MakeButtons( void ) ;
118 void MakeLogin( void ) ;
119 void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
120 static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
121 static SIGVAL Terminate( int arg ) ;
122 extern void DoCancel (Widget w, XtPointer client_data, XtPointer call_data);
128 /***************************************************************************
132 ***************************************************************************/
135 AppInfo appInfo; /* application resources */
136 Arg argt[100]; /* used for resources */
137 DisplayInfo dpyinfo; /* information about the display */
138 XmString xmstr; /* used for compound strings */
139 char *langenv; /* current value of LANG environment var. */
140 char *errorLogFile; /* current value of environment var. */
141 int showVerifyError;/* display a Verify() error dialog */
142 int fullScreen = 0; /* Obscure the entire screen. */
145 /******************************************************************************
149 ** toplevel "main" (toplevel)
150 ** login_shell "login_shell" (overrideShell)
151 ** table "table" (DrawingAreaWidget)
152 ** copyright_msg "copyright_msg" (MessageBox)
153 ** error_message "error_message" (MessageBox)
154 ** help_message "help_message" (MessageBox)
155 ** passwd_message "passwd_message" (MessageBox)
156 ** hostname_message "hostname_msg" (MessageBox)
157 ** matte "matte" (FormWidget)
158 ** logo "logo" (FrameWidget)
159 ** logo_pixmap "logo_pixmap" (LabelGadget)
160 ** matteFrame "matteFrame" (FrameWidget)
161 ** matte1 "matte1" (FormWidget)
162 ** dt_label "dt_label" (LabelGadget)
163 ** help_button "help_button" (PushButtonGadget)
164 ** greeting "greeting" (LabelGadget)
165 ** login_form "login_form" (FormWidget)
166 ** login_label "login_label" (LabelGadget)
167 ** login_text "login_text" (TextField)
168 ** ok_button "ok_button" (PushButtonGadget)
169 ** clear_button "clear_button" (PushButtonGadget)
170 ** options_button "options_button" (PushButton)
171 ** options_menu "options_menu" (PopupMenu)
172 ** options_item[0] "options_languages" (CascadeButtonGadget)
173 ** options_item[1] "options_sep2" (SeparatorGadget)
174 ** options_item[2] "session_menus" (CascadeButtonGadget)
175 ** options_item[3] "options_sep1" (SeparatorGadget)
176 ** options_item[4] "options_noWindows" (PushButtonGadget)
177 ** options_item[5] "options_restartServer"(PushButtonGadget)
178 ** options_item[6] "options_sep1" (SeparatorGadget)
179 ** options_item[7] "options_Copyright" (PushButtonGadget)
180 ** session_menu "session_menu" (PulldownMenu)
181 ** options_dt "options_dt" (ToggleButtonGadget)
182 ** options_failsafe "options_failsafe" (ToggleButtonGadget)
183 ** lang_menu "lang_menu" (PulldownMenu)
184 ** (lang items) (lang items) (ToggleButtonGadget)
190 extern Widget toplevel; /* top level shell widget */
191 Widget login_shell; /* shell for the main login widgets. */
192 Widget table; /* black background for everything */
193 Widget matte; /* main level form widget */
194 Widget matteFrame; /* main level form widget */
195 Widget matte1; /* second level form widget */
197 Widget greeting; /* Welcome message */
199 Widget logo1; /* frame around the Corporate logo */
200 Widget logo_pixmap; /* Corporate logo */
201 Widget logo_shadow; /* drop shadow under the Corporate logo */
203 Widget login_matte; /* bulletin board for login/password */
204 Widget dt_label; /* desktop label showing the current session */
205 Widget login_form = NULL; /* form containing the login widgets */
206 Widget login_label; /* label to left of login text widget */
207 Widget login_text; /* login text widget */
209 Widget ok_button; /* accept name/password text button */
210 Widget clear_button; /* clear name/password text button */
211 Widget options_button; /* login options button */
212 Widget help_button; /* help button */
214 Widget copyright_msg = NULL; /* copyright notice widget */
215 Widget help_message = NULL; /* the help message box */
216 Widget error_message = NULL; /* the error message box */
217 Widget hostname_message = NULL; /* the invalid hostname message box */
218 Widget passwd_message = NULL; /* the expired password message box */
220 Widget options_menu = NULL; /* pop-up menu on options button */
221 Widget options_item[10]; /* items on options pop_up menu */
222 Widget options_nowindows; /* nowindows pane on options pop_up menu */
223 Widget options_failsafe; /* failsafe pane on options pop_up menu */
224 Widget options_dtlite; /* dtlite pane on options pop_up menu */
225 Widget options_dt; /* dt regular pane on options pop_up menu */
228 Widget options_sp_dt; /* dt button for special desktop */
229 Widget options_last_dt; /* user's last dt */
233 Widget lang_menu = NULL; /* cascading menu on "Language" option */
234 Widget session_menu = NULL; /* cascading menu on "Session" option */
236 Widget chooser_list; /* list of hosts displayed by chooser */
237 Widget list_head; /* the heading for the chooser list */
242 XtResource AppResources[] = {
243 { "workspaceCursor", "WorkspaceCursor",
244 XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
245 XtRImmediate, (caddr_t)False },
247 { "labelFont", "LabelFont",
248 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
249 XmRString, "Fixed" },
251 { "textFont", "TextFont",
252 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
253 XmRString, "Fixed" },
255 { "chlistFont", "ChlistFont",
256 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, chlistFont),
257 XmRString, "Fixed" },
259 { "optionsDelay", "OptionsDelay",
260 XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
261 XtRImmediate, (XtPointer) 0 },
263 {"languageList", "LanguageList",
264 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
267 #if defined (ENABLE_DYNAMIC_LANGLIST)
268 {"languageListCmd", "LanguageListCmd",
269 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
271 #endif /* ENABLE_DYNAMIC_LANGLIST */
282 /***************************************************************************
287 ***************************************************************************/
290 MakeRootCursor( void )
294 vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
296 XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
301 /***************************************************************************
305 * Widgets: login_shell, table, matte
306 ***************************************************************************/
309 MakeBackground( void )
314 * Get resources first
316 SetResourceDatabase();
317 XtGetApplicationResources(toplevel, &appInfo, AppResources,
318 XtNumber(AppResources), NULL, 0);
322 * create the login shell widget...
327 /* CORE resource set */
328 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
329 XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
330 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
331 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
332 XtSetArg(argt[i], XmNsensitive, True ); i++;
333 XtSetArg(argt[i], XmNtranslations, NULL ); i++;
335 /* COMPOSITE resource set */
336 XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
338 /* SHELL resource set (set to avoid interference by user) */
339 XtSetArg(argt[i], XmNallowShellResize, False ); i++;
340 XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
341 XtSetArg(argt[i], XmNgeometry, NULL ); i++;
342 XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
343 XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
344 XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
345 XtSetArg(argt[i], XmNsaveUnder, False ); i++;
347 login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
349 XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
351 /* Fix to display Input Method's status area. */
352 XtSetArg(argt[0], XmNheight, dpyinfo.height);
353 XtSetValues(login_shell, argt, 1);
357 * create the full-screen drawing area...
360 i = InitArg(DrawingA);
361 XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
362 XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
363 XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
365 table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
366 login_shell, argt, i);
368 XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
373 * create the main matte...
377 /* XmNwidth, (set by user) */
378 /* XmNheight, (set by user) */
379 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
381 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
382 XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
385 matte = XmCreateForm(table, "matte", argt, i);
386 XtManageChild(matte);
389 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
390 XtSetArg(argt[i], XmNshadowThickness, 2); i++;
391 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
392 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
393 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
395 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
397 XtSetArg(argt[i], XmNtopOffset, 15); i++;
398 XtSetArg(argt[i], XmNbottomOffset, 15); i++;
399 XtSetArg(argt[i], XmNleftOffset, 15); i++;
401 XtSetArg(argt[i], XmNrightOffset, 15); i++;
403 matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
404 XtManageChild(matteFrame);
407 matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
408 XtManageChild(matte1);
415 /***************************************************************************
419 * Widgets: ok_button, clear_button, options_button, help_button
420 ***************************************************************************/
429 Dimension max_width; /* maximum width of a set of widgets */
430 Dimension max_height; /* maximum height of a set of widgets */
432 int origin; /* horizontal origin for button placement */
433 int spacing; /* spacing between buttons (width/32) */
437 * create the buttons...
443 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
444 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
445 XtSetArg(argt[i], XmNtraversalOn, True); i++;
446 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
448 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
449 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
451 ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
454 XtManageChild(ok_button);
456 XtAddCallback(ok_button, XmNactivateCallback, DoAccept, NULL);
462 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
463 XtSetArg(argt[i], XmNleftWidget, ok_button); i++;
464 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_UPDATE_LABEL, MC_DEF_UPDATE_LABEL);
465 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
467 clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
470 XtManageChild(clear_button);
471 XtAddCallback(clear_button, XmNactivateCallback, DoPing,
479 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
480 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
482 help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
483 XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
484 (XtPointer) help_chooser);
486 XtManageChild(help_button);
490 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
491 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
492 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
493 XtSetArg(argt[i], XmNleftWidget, clear_button); i++;
494 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OPTIONS_LABEL, MC_DEF_OPTIONS_LABEL );
495 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
497 options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
500 XtManageChild(options_button);
502 /** set attachment for help button **/
504 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
505 XtSetArg(argt[i], XmNleftWidget, options_button); i++;
506 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
507 XtSetValues(help_button, argt, i);
511 * tell form that ok_button is the default button...
515 XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
516 XtSetValues(matte1, argt, i);
521 * make all buttons the same size...
525 max_width = max_height = 0;
526 GetBiggest(ok_button, &max_width, &max_height);
527 GetBiggest(clear_button, &max_width, &max_height);
528 GetBiggest(options_button, &max_width, &max_height);
529 GetBiggest(help_button, &max_width, &max_height);
531 if ( max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
534 XtSetArg(argt[i], XmNwidth, max_width ); i++;
535 XtSetArg(argt[i], XmNheight, max_height ); i++;
536 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
538 XtSetValues(ok_button, argt, i);
539 XtSetValues(clear_button, argt, i);
540 XtSetValues(options_button, argt, i);
541 XtSetValues(help_button, argt, i);
545 /***************************************************************************
549 * Widgets: greeting, list_head, chooser_list
550 ***************************************************************************/
553 } GreetInfo, *GreetInfoPtr;
555 static GreetInfo greetInfo;
557 static XtResource greetResources[] = {
558 {XmNfontList, XmCFontList,
559 XmRFontList, sizeof(XmFontList),
560 XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
569 XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
570 greetResources, XtNumber(greetResources), NULL, 0);
572 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_TITLE, MC_DEF_CHOOSER_TITLE);
573 XtSetArg(argt[i], XmNtraversalOn, False); i++;
574 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
575 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
576 XtSetArg(argt[i], XmNtopOffset, 10); i++;
577 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
578 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
579 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER); i++;
580 if ( greetInfo.fontList != NULL ) {
581 XtSetArg(argt[i], XmNfontList, greetInfo.fontList); i++;
583 greeting = XmCreateLabel(matte1, "greeting", argt, i);
584 XtManageChild(greeting);
589 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_HEADING,
590 MC_DEF_CHOOSER_HEADING);
591 XtSetArg(argt[i], XmNtraversalOn, False); i++;
592 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
593 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
594 XtSetArg(argt[i], XmNtopWidget, greeting); i++;
595 XtSetArg(argt[i], XmNtopOffset, 10); i++;
596 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
597 XtSetArg(argt[i], XmNleftOffset, 13); i++;
598 if (appInfo.chlistFont != NULL) {
599 XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
601 list_head = XmCreateLabelGadget(matte1, "list_head", argt, i);
602 XtManageChild(list_head);
606 XtSetArg(argt[i], XmNresizable, True);
607 XtSetValues(matte, argt, i);
608 XtSetValues(matte1, argt, i);
612 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
613 XtSetArg(argt[i], XmNleftOffset, 10); i++;
614 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
615 XtSetArg(argt[i], XmNrightOffset, 10); i++;
616 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
617 XtSetArg(argt[i], XmNtopWidget, list_head); i++;
618 XtSetArg(argt[i], XmNtopOffset, 1); i++;
619 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
620 XtSetArg(argt[i], XmNbottomWidget, ok_button); i++;
621 XtSetArg(argt[i], XmNbottomOffset, 10); i++;
622 XtSetArg(argt[i], XmNallowShellResize, True); i++;
623 XtSetArg(argt[i], XmNlistSizePolicy, XmCONSTANT); i++;
624 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++;
625 if (appInfo.chlistFont != NULL) {
626 XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
628 chooser_list = XmCreateScrolledList(matte1, "chooser_list", argt, i);
629 XtAddCallback(chooser_list, XmNdefaultActionCallback, DoAccept, NULL);
630 XtManageChild(chooser_list);
632 if (appInfo.workspaceCursor)
638 XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
643 /***************************************************************************
647 * Widgets: error_message, help_message, copyright_msg, hostname_message,
649 ***************************************************************************/
652 MakeDialog( DialogType dtype )
663 Dimension txt_width, txt_height;
664 XmString ok, cancel, nw, sv;
668 * do things common to all dialogs...
671 ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
672 cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
674 i = InitArg(MessageBox);
675 XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
676 XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
677 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
678 XtSetArg(argt[i], XmNokLabelString, ok ); i++;
679 XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
680 XtSetArg(argt[i], XmNnoResize, False ); i++;
681 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
684 * create the various dialogs...
690 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
691 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
693 w = XmCreateErrorDialog(table, "error_message", argt, i);
694 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
695 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
702 xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
703 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
704 w = XmCreateInformationDialog(table, "help_message", argt, i);
705 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
706 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
708 txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
709 txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
710 txt_width = (txt_width > 850) ? 800 : txt_width - 50;
711 txt_height = (txt_height > 900) ? 750 : txt_height - 150;
713 XtSetArg(argt[i], XmNheight, txt_height); i++;
714 XtSetArg(argt[i], XmNwidth, txt_width); i++;
715 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
716 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
717 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
718 XtSetArg(argt[i], XmNeditable, False); i++;
719 str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
720 XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
721 text = XmCreateScrolledText(w, "help_message_text", argt, i);
730 if ((fp = fopen(COPYRIGHT,"r")) == NULL)
731 #if defined( __hp_osf )
732 xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
733 XmFONTLIST_DEFAULT_TAG);
735 xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
736 XmFONTLIST_DEFAULT_TAG);
739 xmstr = (XmString) NULL;
741 while (fgets(buffer, 128, fp) != NULL) {
743 if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
746 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
748 xmstr = XmStringConcat(xmstr,
749 XmStringCreate(buffer,
750 XmFONTLIST_DEFAULT_TAG));
755 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
757 w = XmCreateInformationDialog(table, "copyright_msg", argt, i);
758 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
759 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
761 XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
769 nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
770 sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
772 xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
773 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
774 XtSetArg(argt[i], XmNokLabelString, nw ); i++;
775 XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
777 w = XmCreateWarningDialog(table, "hostname_msg", argt, i);
779 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
784 hostname_message = w;
790 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
791 MC_DEF_PASSWD_EXPIRED);
792 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
794 w = XmCreateQuestionDialog(table, "password_msg", argt, i);
796 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
803 xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
805 w = XmCreateInformationDialog(table, "help_message", argt, i);
806 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
807 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
809 txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
810 txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
811 txt_width = (txt_width > 850) ? 800 : txt_width - 50;
812 txt_height = (txt_height > 900) ? 750 : txt_height - 150;
814 XtSetArg(argt[i], XmNheight, txt_height); i++;
815 XtSetArg(argt[i], XmNwidth, txt_width); i++;
816 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
817 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
818 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
819 XtSetArg(argt[i], XmNeditable, False); i++;
821 ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
822 XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
823 text = XmCreateScrolledText(w, "help_message_text", argt, i);
839 XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
840 XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
845 XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
846 XtSetValues(w, argt, 1);
850 XmStringFree(cancel);
854 * adjust the width of the "ok" button on the dialogs...
857 width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
860 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
861 XtSetArg(argt[i], XmNwidth, width ); i++;
863 XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
869 /***************************************************************************
873 * Widgets: options_menu, options_item[]
874 ***************************************************************************/
877 MakeOptionsMenu( void )
885 * get the built-in pop_up menu from the DtMenuButton...
888 XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
891 * create language cascade menus...
894 if ( lang_menu == NULL )
899 * create first level menu items...
904 * build [ Language ] menu pane if there are languages to choose from...
906 if ( lang_menu != NULL ) {
908 * [ Language ] menu pane...
909 * attach language cascade menu to this pane
911 i = InitArg(CascadeBG);
912 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
913 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
914 XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
915 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
916 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
917 "options_languages", argt, i);
924 i = InitArg(SeparatorG);
925 options_item[j] = XmCreateSeparatorGadget(options_menu,
933 * [ Restart Server ] menu pane...
935 i = k = InitArg(PushBG);
936 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
937 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
938 options_item[j] = XmCreatePushButtonGadget(options_menu,
939 "options_restartServer",
942 XtAddCallback(options_item[j], XmNactivateCallback,
943 DoCancel, (XtPointer) OB_RESTART_SERVER);
946 #ifdef copyright_option
950 i = InitArg(SeparatorG);
951 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
957 * [ Copyright ] menu pane...
959 i = k = InitArg(PushBG);
960 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
961 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
962 options_item[j] = XmCreatePushButtonGadget(options_menu,
966 XtAddCallback(options_item[j], XmNactivateCallback,
967 MenuItemCB, (XtPointer) OB_COPYRIGHT);
972 * manage the [Options] menu...
974 XtManageChildren(options_item, j);
979 * If the DT Lite Session Manager is not available, remove the DT Lite
980 * and DT menu panes. The actual widgets must still be created since
981 * other code (ex. MenuItemCB()) tries to obtain some of their resources.
984 if ( stat(DTLITESESSION, &statb) != 0 ||
985 ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
988 XtUnmanageChild(options_dt);
992 if ( getenv(PINGINTERVAL) != NULL )
993 XtUnmanageChild(options_nowindows);
1002 /***************************************************************************
1006 * X protocol error handler to override the default
1007 ***************************************************************************/
1010 ErrorHandler( Display *dpy, XErrorEvent *event )
1018 /***************************************************************************
1022 * Timeout routine to build options menu
1023 ***************************************************************************/
1026 MakeOptionsProc( XtPointer data, XtIntervalId *id )
1029 if (options_menu == NULL)
1038 /***************************************************************************
1042 * Catch a SIGTERM and unmanage display
1043 ***************************************************************************/
1046 Terminate( int arg )
1049 write(1, "terminate", 9);
1050 CleanupAndExit(NULL, NOTIFY_ABORT);
1055 * Chooser doesn't use SIA but it does link with vgcallback.o. We just need
1056 * this symbol to keep the linker happy.