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 libraries 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>
93 #include <DtXinerama.h>
97 /***************************************************************************
99 * External declarations
101 ***************************************************************************/
102 extern char password[]; /* pswd string value */
103 extern int password_length; /* pswd string length */
105 extern void DoAccept (Widget w, XtPointer client_data, XtPointer call_data);
106 extern void DoPing (Widget w, XtPointer client_data, XtPointer call_data);
108 /***************************************************************************
110 * Procedure declarations
112 ***************************************************************************/
114 static SIGVAL syncTimeout( int arg ) ;
115 static Widget InitToolKit( int argc, char **argv) ;
116 void MakeRootCursor( void ) ;
117 void MakeBackground( void ) ;
118 void MakeButtons( void ) ;
119 void MakeLogin( void ) ;
120 void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
121 static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
122 static SIGVAL Terminate( int arg ) ;
123 extern void DoCancel (Widget w, XtPointer client_data, XtPointer call_data);
129 /***************************************************************************
133 ***************************************************************************/
136 AppInfo appInfo; /* application resources */
137 Arg argt[100]; /* used for resources */
138 DisplayInfo dpyinfo; /* information about the display */
139 XmString xmstr; /* used for compound strings */
140 char *langenv; /* current value of LANG environment var. */
141 char *errorLogFile; /* current value of environment var. */
142 int showVerifyError;/* display a Verify() error dialog */
143 int fullScreen = 0; /* Obscure the entire screen. */
146 /******************************************************************************
150 ** toplevel "main" (toplevel)
151 ** login_shell "login_shell" (overrideShell)
152 ** table "table" (DrawingAreaWidget)
153 ** copyright_msg "copyright_msg" (MessageBox)
154 ** error_message "error_message" (MessageBox)
155 ** help_message "help_message" (MessageBox)
156 ** passwd_message "passwd_message" (MessageBox)
157 ** hostname_message "hostname_msg" (MessageBox)
158 ** matte "matte" (FormWidget)
159 ** logo "logo" (FrameWidget)
160 ** logo_pixmap "logo_pixmap" (LabelGadget)
161 ** matteFrame "matteFrame" (FrameWidget)
162 ** matte1 "matte1" (FormWidget)
163 ** dt_label "dt_label" (LabelGadget)
164 ** help_button "help_button" (PushButtonGadget)
165 ** greeting "greeting" (LabelGadget)
166 ** login_form "login_form" (FormWidget)
167 ** login_label "login_label" (LabelGadget)
168 ** login_text "login_text" (TextField)
169 ** ok_button "ok_button" (PushButtonGadget)
170 ** clear_button "clear_button" (PushButtonGadget)
171 ** options_button "options_button" (PushButton)
172 ** options_menu "options_menu" (PopupMenu)
173 ** options_item[0] "options_languages" (CascadeButtonGadget)
174 ** options_item[1] "options_sep2" (SeparatorGadget)
175 ** options_item[2] "session_menus" (CascadeButtonGadget)
176 ** options_item[3] "options_sep1" (SeparatorGadget)
177 ** options_item[4] "options_noWindows" (PushButtonGadget)
178 ** options_item[5] "options_restartServer"(PushButtonGadget)
179 ** options_item[6] "options_sep1" (SeparatorGadget)
180 ** options_item[7] "options_Copyright" (PushButtonGadget)
181 ** session_menu "session_menu" (PulldownMenu)
182 ** options_dt "options_dt" (ToggleButtonGadget)
183 ** options_failsafe "options_failsafe" (ToggleButtonGadget)
184 ** lang_menu "lang_menu" (PulldownMenu)
185 ** (lang items) (lang items) (ToggleButtonGadget)
191 extern Widget toplevel; /* top level shell widget */
192 Widget login_shell; /* shell for the main login widgets. */
193 Widget table; /* black background for everything */
194 Widget matte; /* main level form widget */
195 Widget matteFrame; /* main level form widget */
196 Widget matte1; /* second level form widget */
198 Widget greeting; /* Welcome message */
200 Widget logo1; /* frame around the Corporate logo */
201 Widget logo_pixmap; /* Corporate logo */
202 Widget logo_shadow; /* drop shadow under the Corporate logo */
204 Widget login_matte; /* bulletin board for login/password */
205 Widget dt_label; /* desktop label showing the current session */
206 Widget login_form = NULL; /* form containing the login widgets */
207 Widget login_label; /* label to left of login text widget */
208 Widget login_text; /* login text widget */
210 Widget ok_button; /* accept name/password text button */
211 Widget clear_button; /* clear name/password text button */
212 Widget options_button; /* login options button */
213 Widget help_button; /* help button */
215 Widget copyright_msg = NULL; /* copyright notice widget */
216 Widget help_message = NULL; /* the help message box */
217 Widget error_message = NULL; /* the error message box */
218 Widget hostname_message = NULL; /* the invalid hostname message box */
219 Widget passwd_message = NULL; /* the expired password message box */
221 Widget options_menu = NULL; /* pop-up menu on options button */
222 Widget options_item[10]; /* items on options pop_up menu */
223 Widget options_nowindows; /* nowindows pane on options pop_up menu */
224 Widget options_failsafe; /* failsafe pane on options pop_up menu */
225 Widget options_dtlite; /* dtlite pane on options pop_up menu */
226 Widget options_dt; /* dt regular pane on options pop_up menu */
229 Widget options_sp_dt; /* dt button for special desktop */
230 Widget options_last_dt; /* user's last dt */
234 Widget lang_menu = NULL; /* cascading menu on "Language" option */
235 Widget session_menu = NULL; /* cascading menu on "Session" option */
237 Widget chooser_list; /* list of hosts displayed by chooser */
238 Widget list_head; /* the heading for the chooser list */
243 XtResource AppResources[] = {
244 { "workspaceCursor", "WorkspaceCursor",
245 XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
246 XtRImmediate, (caddr_t)False },
248 { "labelFont", "LabelFont",
249 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
250 XmRString, "Fixed" },
252 { "textFont", "TextFont",
253 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
254 XmRString, "Fixed" },
256 { "chlistFont", "ChlistFont",
257 XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, chlistFont),
258 XmRString, "Fixed" },
260 { "optionsDelay", "OptionsDelay",
261 XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
262 XtRImmediate, (XtPointer) 0 },
264 {"languageList", "LanguageList",
265 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
268 #if defined(USE_XINERAMA)
269 { "xineramaPreferredScreen", "XineramaPreferredScreen",
270 XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
271 XtRImmediate, (XtPointer) 0
275 #if defined (ENABLE_DYNAMIC_LANGLIST)
276 {"languageListCmd", "LanguageListCmd",
277 XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
279 #endif /* ENABLE_DYNAMIC_LANGLIST */
290 /***************************************************************************
295 ***************************************************************************/
298 MakeRootCursor( void )
302 vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
304 XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
309 /***************************************************************************
313 * Widgets: login_shell, table, matte
314 ***************************************************************************/
317 MakeBackground( void )
322 * Get resources first
324 SetResourceDatabase();
325 XtGetApplicationResources(toplevel, &appInfo, AppResources,
326 XtNumber(AppResources), NULL, 0);
330 * create the login shell widget...
335 /* CORE resource set */
336 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
337 XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
338 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
339 XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
340 XtSetArg(argt[i], XmNsensitive, True ); i++;
341 XtSetArg(argt[i], XmNtranslations, NULL ); i++;
343 /* COMPOSITE resource set */
344 XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
346 /* SHELL resource set (set to avoid interference by user) */
347 XtSetArg(argt[i], XmNallowShellResize, False ); i++;
348 XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
349 XtSetArg(argt[i], XmNgeometry, NULL ); i++;
350 XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
351 XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
352 XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
353 XtSetArg(argt[i], XmNsaveUnder, False ); i++;
355 login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
357 XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
359 /* Fix to display Input Method's status area. */
360 XtSetArg(argt[0], XmNheight, dpyinfo.height);
361 XtSetValues(login_shell, argt, 1);
365 * create the full-screen drawing area...
368 i = InitArg(DrawingA);
369 XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
370 XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
371 XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
373 table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
374 login_shell, argt, i);
376 XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
381 * create the main matte...
385 /* XmNwidth, (set by user) */
386 /* XmNheight, (set by user) */
387 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
389 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
390 XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
393 matte = XmCreateForm(table, "matte", argt, i);
394 XtManageChild(matte);
397 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
398 XtSetArg(argt[i], XmNshadowThickness, 2); i++;
399 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
400 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
401 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
403 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
405 XtSetArg(argt[i], XmNtopOffset, 15); i++;
406 XtSetArg(argt[i], XmNbottomOffset, 15); i++;
407 XtSetArg(argt[i], XmNleftOffset, 15); i++;
409 XtSetArg(argt[i], XmNrightOffset, 15); i++;
411 matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
412 XtManageChild(matteFrame);
415 matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
416 XtManageChild(matte1);
423 /***************************************************************************
427 * Widgets: ok_button, clear_button, options_button, help_button
428 ***************************************************************************/
437 Dimension max_width; /* maximum width of a set of widgets */
438 Dimension max_height; /* maximum height of a set of widgets */
440 int origin; /* horizontal origin for button placement */
441 int spacing; /* spacing between buttons (width/32) */
445 * create the buttons...
451 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
452 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
453 XtSetArg(argt[i], XmNtraversalOn, True); i++;
454 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
456 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
457 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
459 ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
462 XtManageChild(ok_button);
464 XtAddCallback(ok_button, XmNactivateCallback, DoAccept, NULL);
470 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
471 XtSetArg(argt[i], XmNleftWidget, ok_button); i++;
472 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_UPDATE_LABEL, MC_DEF_UPDATE_LABEL);
473 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
475 clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
478 XtManageChild(clear_button);
479 XtAddCallback(clear_button, XmNactivateCallback, DoPing,
487 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
488 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
490 help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
491 XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
492 (XtPointer) help_chooser);
494 XtManageChild(help_button);
498 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
499 XtSetArg(argt[i], XmNbottomPosition, 95); i++;
500 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
501 XtSetArg(argt[i], XmNleftWidget, clear_button); i++;
502 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OPTIONS_LABEL, MC_DEF_OPTIONS_LABEL );
503 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
505 options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
508 XtManageChild(options_button);
510 /** set attachment for help button **/
512 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
513 XtSetArg(argt[i], XmNleftWidget, options_button); i++;
514 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
515 XtSetValues(help_button, argt, i);
519 * tell form that ok_button is the default button...
523 XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
524 XtSetValues(matte1, argt, i);
529 * make all buttons the same size...
533 max_width = max_height = 0;
534 GetBiggest(ok_button, &max_width, &max_height);
535 GetBiggest(clear_button, &max_width, &max_height);
536 GetBiggest(options_button, &max_width, &max_height);
537 GetBiggest(help_button, &max_width, &max_height);
539 if ( max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
542 XtSetArg(argt[i], XmNwidth, max_width ); i++;
543 XtSetArg(argt[i], XmNheight, max_height ); i++;
544 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
546 XtSetValues(ok_button, argt, i);
547 XtSetValues(clear_button, argt, i);
548 XtSetValues(options_button, argt, i);
549 XtSetValues(help_button, argt, i);
553 /***************************************************************************
557 * Widgets: greeting, list_head, chooser_list
558 ***************************************************************************/
561 } GreetInfo, *GreetInfoPtr;
563 static GreetInfo greetInfo;
565 static XtResource greetResources[] = {
566 {XmNfontList, XmCFontList,
567 XmRFontList, sizeof(XmFontList),
568 XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
577 XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
578 greetResources, XtNumber(greetResources), NULL, 0);
580 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_TITLE, MC_DEF_CHOOSER_TITLE);
581 XtSetArg(argt[i], XmNtraversalOn, False); i++;
582 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
583 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
584 XtSetArg(argt[i], XmNtopOffset, 10); i++;
585 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
586 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
587 XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER); i++;
588 if ( greetInfo.fontList != NULL ) {
589 XtSetArg(argt[i], XmNfontList, greetInfo.fontList); i++;
591 greeting = XmCreateLabel(matte1, "greeting", argt, i);
592 XtManageChild(greeting);
597 xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_HEADING,
598 MC_DEF_CHOOSER_HEADING);
599 XtSetArg(argt[i], XmNtraversalOn, False); i++;
600 XtSetArg(argt[i], XmNlabelString, xmstr); i++;
601 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
602 XtSetArg(argt[i], XmNtopWidget, greeting); i++;
603 XtSetArg(argt[i], XmNtopOffset, 10); i++;
604 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
605 XtSetArg(argt[i], XmNleftOffset, 13); i++;
606 if (appInfo.chlistFont != NULL) {
607 XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
609 list_head = XmCreateLabelGadget(matte1, "list_head", argt, i);
610 XtManageChild(list_head);
614 XtSetArg(argt[i], XmNresizable, True);
615 XtSetValues(matte, argt, i);
616 XtSetValues(matte1, argt, i);
620 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
621 XtSetArg(argt[i], XmNleftOffset, 10); i++;
622 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
623 XtSetArg(argt[i], XmNrightOffset, 10); i++;
624 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
625 XtSetArg(argt[i], XmNtopWidget, list_head); i++;
626 XtSetArg(argt[i], XmNtopOffset, 1); i++;
627 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
628 XtSetArg(argt[i], XmNbottomWidget, ok_button); i++;
629 XtSetArg(argt[i], XmNbottomOffset, 10); i++;
630 XtSetArg(argt[i], XmNallowShellResize, True); i++;
631 XtSetArg(argt[i], XmNlistSizePolicy, XmCONSTANT); i++;
632 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++;
633 if (appInfo.chlistFont != NULL) {
634 XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
636 chooser_list = XmCreateScrolledList(matte1, "chooser_list", argt, i);
637 XtAddCallback(chooser_list, XmNdefaultActionCallback, DoAccept, NULL);
638 XtManageChild(chooser_list);
640 if (appInfo.workspaceCursor)
646 XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
651 /***************************************************************************
655 * Widgets: error_message, help_message, copyright_msg, hostname_message,
657 ***************************************************************************/
660 MakeDialog( DialogType dtype )
666 FILE *fp = NULL, *fopen();
671 Dimension txt_width, txt_height;
672 XmString ok, cancel, nw, sv;
677 * do things common to all dialogs...
680 ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
681 cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
683 i = InitArg(MessageBox);
684 XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
685 XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
686 XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
687 XtSetArg(argt[i], XmNokLabelString, ok ); i++;
688 XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
689 XtSetArg(argt[i], XmNnoResize, False ); i++;
690 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
693 * create the various dialogs...
696 /* JET - check the matte widget, and if non-null, well use that as
697 * the parent for dialogs. Otherwise use table (the original
698 * toplevel widget for this func). This is useful for Xinerama so
699 * that child dialogs are centered on the matte, and not the whole
702 if (matte != (Widget)NULL)
711 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
712 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
714 w = XmCreateErrorDialog(tlev, "error_message", argt, i);
715 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
716 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
723 xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
724 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
725 w = XmCreateInformationDialog(tlev, "help_message", argt, i);
726 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
727 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
729 txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
730 txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
731 txt_width = (txt_width > 850) ? 800 : txt_width - 50;
732 txt_height = (txt_height > 900) ? 750 : txt_height - 150;
734 XtSetArg(argt[i], XmNheight, txt_height); i++;
735 XtSetArg(argt[i], XmNwidth, txt_width); i++;
736 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
737 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
738 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
739 XtSetArg(argt[i], XmNeditable, False); i++;
740 str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
741 XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
742 text = XmCreateScrolledText(w, "help_message_text", argt, i);
751 if ((fp = fopen(COPYRIGHT,"r")) == NULL)
752 xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
753 XmFONTLIST_DEFAULT_TAG);
755 xmstr = (XmString) NULL;
757 while (fgets(buffer, 128, fp) != NULL) {
759 if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
762 xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
764 xmstr = XmStringConcat(xmstr,
765 XmStringCreate(buffer,
766 XmFONTLIST_DEFAULT_TAG));
773 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
775 w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
776 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
777 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
779 XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
787 nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
788 sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
790 xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
791 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
792 XtSetArg(argt[i], XmNokLabelString, nw ); i++;
793 XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
795 w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
797 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
802 hostname_message = w;
808 xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
809 MC_DEF_PASSWD_EXPIRED);
810 XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
812 w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
814 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
821 xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
823 w = XmCreateInformationDialog(tlev, "help_message", argt, i);
824 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
825 XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
827 txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
828 txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
829 txt_width = (txt_width > 850) ? 800 : txt_width - 50;
830 txt_height = (txt_height > 900) ? 750 : txt_height - 150;
832 XtSetArg(argt[i], XmNheight, txt_height); i++;
833 XtSetArg(argt[i], XmNwidth, txt_width); i++;
834 XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
835 XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
836 XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
837 XtSetArg(argt[i], XmNeditable, False); i++;
839 ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
840 XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
841 text = XmCreateScrolledText(w, "help_message_text", argt, i);
857 XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
858 XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
863 XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
864 XtSetValues(w, argt, 1);
868 XmStringFree(cancel);
872 * adjust the width of the "ok" button on the dialogs...
875 width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
878 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
879 XtSetArg(argt[i], XmNwidth, width ); i++;
881 XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
887 /***************************************************************************
891 * Widgets: options_menu, options_item[]
892 ***************************************************************************/
895 MakeOptionsMenu( void )
903 * get the built-in pop_up menu from the DtMenuButton...
906 XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
909 * create language cascade menus...
912 if ( lang_menu == NULL )
917 * create first level menu items...
922 * build [ Language ] menu pane if there are languages to choose from...
924 if ( lang_menu != NULL ) {
926 * [ Language ] menu pane...
927 * attach language cascade menu to this pane
929 i = InitArg(CascadeBG);
930 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
931 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
932 XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
933 XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
934 options_item[j] = XmCreateCascadeButtonGadget(options_menu,
935 "options_languages", argt, i);
942 i = InitArg(SeparatorG);
943 options_item[j] = XmCreateSeparatorGadget(options_menu,
951 * [ Restart Server ] menu pane...
953 i = k = InitArg(PushBG);
954 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
955 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
956 options_item[j] = XmCreatePushButtonGadget(options_menu,
957 "options_restartServer",
960 XtAddCallback(options_item[j], XmNactivateCallback,
961 DoCancel, (XtPointer) OB_RESTART_SERVER);
964 #ifdef copyright_option
968 i = InitArg(SeparatorG);
969 options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
975 * [ Copyright ] menu pane...
977 i = k = InitArg(PushBG);
978 xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
979 XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
980 options_item[j] = XmCreatePushButtonGadget(options_menu,
984 XtAddCallback(options_item[j], XmNactivateCallback,
985 MenuItemCB, (XtPointer) OB_COPYRIGHT);
990 * manage the [Options] menu...
992 XtManageChildren(options_item, j);
997 * If the DT Lite Session Manager is not available, remove the DT Lite
998 * and DT menu panes. The actual widgets must still be created since
999 * other code (ex. MenuItemCB()) tries to obtain some of their resources.
1002 if ( stat(DTLITESESSION, &statb) != 0 ||
1003 ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
1006 XtUnmanageChild(options_dt);
1010 if ( getenv(PINGINTERVAL) != NULL )
1011 XtUnmanageChild(options_nowindows);
1020 /***************************************************************************
1024 * X protocol error handler to override the default
1025 ***************************************************************************/
1028 ErrorHandler( Display *dpy, XErrorEvent *event )
1036 /***************************************************************************
1040 * Timeout routine to build options menu
1041 ***************************************************************************/
1044 MakeOptionsProc( XtPointer data, XtIntervalId *id )
1047 if (options_menu == NULL)
1056 /***************************************************************************
1060 * Catch a SIGTERM and unmanage display
1061 ***************************************************************************/
1064 Terminate( int arg )
1067 write(1, "terminate", 9);
1068 CleanupAndExit(NULL, NOTIFY_ABORT);
1073 * Chooser doesn't use SIA but it does link with vgcallback.o. We just need
1074 * this symbol to keep the linker happy.