1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $TOG: dtchooser.c /main/8 1998/04/20 12:56:18 mgreess $ */
- /* *
- * (c) Copyright 1993, 1994 Hewlett-Packard Company *
- * (c) Copyright 1993, 1994 International Business Machines Corp. *
- * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
- * (c) Copyright 1993, 1994 Novell, Inc. *
- */
- /*
- */
- /****************************************************************************
- **
- ** File: dtchooser.c
- **
- ** Project: HP Visual User Environment (DT)
- **
- ** Description: Main line code for Dtgreet application
- **
- ** These routines initialize the toolkit, create the widgets,
- ** set up callbacks, and wait for events.
- **
- **
- ** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
- **
- **
- **
- ****************************************************************************
- ************************************<+>*************************************/
- /***************************************************************************
- *
- * Includes
- *
- ***************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/signal.h>
- #include <sys/stat.h>
- #include <locale.h>
- #include <Xm/Xm.h>
- #include <X11/Shell.h>
- #include <X11/cursorfont.h>
- #include <Xm/DragC.h>
- #include <Xm/DrawingA.h>
- #include <Xm/Frame.h>
- #include <Xm/Form.h>
- #include <Xm/Label.h>
- #include <Xm/LabelG.h>
- #include <Xm/List.h>
- #include <Xm/Text.h>
- #include <Xm/TextF.h>
- #include <Xm/PushB.h>
- #include <Xm/PushBG.h>
- #include <Xm/MessageB.h>
- #include <Xm/RowColumn.h>
- #include <Xm/SeparatoG.h>
- #include <Xm/ToggleBG.h>
- #include <Xm/CascadeBG.h>
- #include <Dt/EnvControlP.h>
- #include "vg.h"
- #include "vgmsg.h"
- #include <Dt/MenuButton.h>
- #ifdef USE_XINERAMA
- #include <Dt/DtXinerama.h>
- #endif
- /***************************************************************************
- *
- * External declarations
- *
- ***************************************************************************/
- extern char password[]; /* pswd string value */
- extern int password_length; /* pswd string length */
- extern void DoAccept (Widget w, XtPointer client_data, XtPointer call_data);
- extern void DoPing (Widget w, XtPointer client_data, XtPointer call_data);
- /***************************************************************************
- *
- * Procedure declarations
- *
- ***************************************************************************/
- static SIGVAL syncTimeout( int arg ) ;
- static Widget InitToolKit( int argc, char **argv) ;
- void MakeRootCursor( void ) ;
- void MakeBackground( void ) ;
- void MakeButtons( void ) ;
- void MakeLogin( void ) ;
- void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
- static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
- static SIGVAL Terminate( int arg ) ;
- extern void DoCancel (Widget w, XtPointer client_data, XtPointer call_data);
- /***************************************************************************
- *
- * Global variables
- *
- ***************************************************************************/
- AppInfo appInfo; /* application resources */
- Arg argt[100]; /* used for resources */
- DisplayInfo dpyinfo; /* information about the display */
- XmString xmstr; /* used for compound strings */
- char *langenv; /* current value of LANG environment var. */
- char *errorLogFile; /* current value of environment var. */
- int showVerifyError;/* display a Verify() error dialog */
- int fullScreen = 0; /* Obscure the entire screen. */
- /******************************************************************************
- **
- ** WIDGET LAYOUT
- **
- ** toplevel "main" (toplevel)
- ** login_shell "login_shell" (overrideShell)
- ** table "table" (DrawingAreaWidget)
- ** copyright_msg "copyright_msg" (MessageBox)
- ** error_message "error_message" (MessageBox)
- ** help_message "help_message" (MessageBox)
- ** passwd_message "passwd_message" (MessageBox)
- ** hostname_message "hostname_msg" (MessageBox)
- ** matte "matte" (FormWidget)
- ** logo "logo" (FrameWidget)
- ** logo_pixmap "logo_pixmap" (LabelGadget)
- ** matteFrame "matteFrame" (FrameWidget)
- ** matte1 "matte1" (FormWidget)
- ** dt_label "dt_label" (LabelGadget)
- ** help_button "help_button" (PushButtonGadget)
- ** greeting "greeting" (LabelGadget)
- ** login_form "login_form" (FormWidget)
- ** login_label "login_label" (LabelGadget)
- ** login_text "login_text" (TextField)
- ** ok_button "ok_button" (PushButtonGadget)
- ** clear_button "clear_button" (PushButtonGadget)
- ** options_button "options_button" (PushButton)
- ** options_menu "options_menu" (PopupMenu)
- ** options_item[0] "options_languages" (CascadeButtonGadget)
- ** options_item[1] "options_sep2" (SeparatorGadget)
- ** options_item[2] "session_menus" (CascadeButtonGadget)
- ** options_item[3] "options_sep1" (SeparatorGadget)
- ** options_item[4] "options_noWindows" (PushButtonGadget)
- ** options_item[5] "options_restartServer"(PushButtonGadget)
- ** options_item[6] "options_sep1" (SeparatorGadget)
- ** options_item[7] "options_Copyright" (PushButtonGadget)
- ** session_menu "session_menu" (PulldownMenu)
- ** options_dt "options_dt" (ToggleButtonGadget)
- ** options_failsafe "options_failsafe" (ToggleButtonGadget)
- ** lang_menu "lang_menu" (PulldownMenu)
- ** (lang items) (lang items) (ToggleButtonGadget)
- ** ...
- **
- */
- extern Widget toplevel; /* top level shell widget */
- Widget login_shell; /* shell for the main login widgets. */
- Widget table; /* black background for everything */
- Widget matte; /* main level form widget */
- Widget matteFrame; /* main level form widget */
- Widget matte1; /* second level form widget */
- Widget greeting; /* Welcome message */
- Widget logo1; /* frame around the Corporate logo */
- Widget logo_pixmap; /* Corporate logo */
- Widget logo_shadow; /* drop shadow under the Corporate logo */
- Widget login_matte; /* bulletin board for login/password */
- Widget dt_label; /* desktop label showing the current session */
- Widget login_form = NULL; /* form containing the login widgets */
- Widget login_label; /* label to left of login text widget */
- Widget login_text; /* login text widget */
- Widget ok_button; /* accept name/password text button */
- Widget clear_button; /* clear name/password text button */
- Widget options_button; /* login options button */
- Widget help_button; /* help button */
- Widget copyright_msg = NULL; /* copyright notice widget */
- Widget help_message = NULL; /* the help message box */
- Widget error_message = NULL; /* the error message box */
- Widget hostname_message = NULL; /* the invalid hostname message box */
- Widget passwd_message = NULL; /* the expired password message box */
- Widget options_menu = NULL; /* pop-up menu on options button */
- Widget options_item[10]; /* items on options pop_up menu */
- Widget options_nowindows; /* nowindows pane on options pop_up menu */
- Widget options_failsafe; /* failsafe pane on options pop_up menu */
- Widget options_dtlite; /* dtlite pane on options pop_up menu */
- Widget options_dt; /* dt regular pane on options pop_up menu */
- Widget *alt_dts;
- Widget options_sp_dt; /* dt button for special desktop */
- Widget options_last_dt; /* user's last dt */
- Widget lang_menu = NULL; /* cascading menu on "Language" option */
- Widget session_menu = NULL; /* cascading menu on "Session" option */
- Widget chooser_list; /* list of hosts displayed by chooser */
- Widget list_head; /* the heading for the chooser list */
- static
- XtResource AppResources[] = {
- { "workspaceCursor", "WorkspaceCursor",
- XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
- XtRImmediate, (caddr_t)False },
- { "labelFont", "LabelFont",
- XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
- XmRString, "Fixed" },
- { "textFont", "TextFont",
- XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
- XmRString, "Fixed" },
- { "chlistFont", "ChlistFont",
- XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, chlistFont),
- XmRString, "Fixed" },
- { "optionsDelay", "OptionsDelay",
- XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
- XtRImmediate, (XtPointer) 0 },
- {"languageList", "LanguageList",
- XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
- XtRString, NULL },
- #if defined(USE_XINERAMA)
- { "xineramaPreferredScreen", "XineramaPreferredScreen",
- XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
- XtRImmediate, (XtPointer) 0
- },
- #endif
- #if defined (ENABLE_DYNAMIC_LANGLIST)
- {"languageListCmd", "LanguageListCmd",
- XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
- XtRString, NULL },
- #endif /* ENABLE_DYNAMIC_LANGLIST */
- };
- /***************************************************************************
- *
- * MakeRootCursor
- *
- * Widgets: none
- ***************************************************************************/
- void
- MakeRootCursor( void )
- {
- Cursor vg_cursor;
- vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
- XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
- return;
- }
- /***************************************************************************
- *
- * MakeBackground
- *
- * Widgets: login_shell, table, matte
- ***************************************************************************/
- void
- MakeBackground( void )
- {
- int i;
- /*
- * Get resources first
- */
- SetResourceDatabase();
- XtGetApplicationResources(toplevel, &appInfo, AppResources,
- XtNumber(AppResources), NULL, 0);
-
-
- /*
- * create the login shell widget...
- */
- i = 0;
- /* CORE resource set */
- XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
- XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
- XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
- XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
- XtSetArg(argt[i], XmNsensitive, True ); i++;
- XtSetArg(argt[i], XmNtranslations, NULL ); i++;
- /* COMPOSITE resource set */
- XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
- /* SHELL resource set (set to avoid interference by user) */
- XtSetArg(argt[i], XmNallowShellResize, False ); i++;
- XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
- XtSetArg(argt[i], XmNgeometry, NULL ); i++;
- XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
- XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
- XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
- XtSetArg(argt[i], XmNsaveUnder, False ); i++;
- login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
- toplevel, argt, i);
- XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
- /* Fix to display Input Method's status area. */
- XtSetArg(argt[0], XmNheight, dpyinfo.height);
- XtSetValues(login_shell, argt, 1);
- /*
- * create the full-screen drawing area...
- */
- i = InitArg(DrawingA);
- XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
- XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
- XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
- table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
- login_shell, argt, i);
- XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
- /*
- * create the main matte...
- */
- i = InitArg(Form);
- /* XmNwidth, (set by user) */
- /* XmNheight, (set by user) */
- XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
- /*
- XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
- XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
- */
- matte = XmCreateForm(table, "matte", argt, i);
- XtManageChild(matte);
- i = 0;
- XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
- XtSetArg(argt[i], XmNshadowThickness, 2); i++;
- XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- /*
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
- */
- XtSetArg(argt[i], XmNtopOffset, 15); i++;
- XtSetArg(argt[i], XmNbottomOffset, 15); i++;
- XtSetArg(argt[i], XmNleftOffset, 15); i++;
- /*
- XtSetArg(argt[i], XmNrightOffset, 15); i++;
- */
- matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
- XtManageChild(matteFrame);
- i = 0;
- matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
- XtManageChild(matte1);
-
- }
- /***************************************************************************
- *
- * MakeButtons
- *
- * Widgets: ok_button, clear_button, options_button, help_button
- ***************************************************************************/
- void
- MakeButtons( void )
- {
- int i;
- Dimension width;
- Dimension max_width; /* maximum width of a set of widgets */
- Dimension max_height; /* maximum height of a set of widgets */
- int origin; /* horizontal origin for button placement */
- int spacing; /* spacing between buttons (width/32) */
-
- /*
- * create the buttons...
- */
- /* ok button */
-
- i = InitArg(PushBG);
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(argt[i], XmNbottomPosition, 95); i++;
- XtSetArg(argt[i], XmNtraversalOn, True); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
- XmStringFree(xmstr);
- XtManageChild(ok_button);
- XtAddCallback(ok_button, XmNactivateCallback, DoAccept, NULL);
- /* clear button */
- i -= 2;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(argt[i], XmNleftWidget, ok_button); i++;
- xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_UPDATE_LABEL, MC_DEF_UPDATE_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr); i++;
- clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
- XmStringFree(xmstr);
- XtManageChild(clear_button);
- XtAddCallback(clear_button, XmNactivateCallback, DoPing,
- (XtPointer) 0);
- /* help button */
-
- i -= 3;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
- XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
- (XtPointer) help_chooser);
- XmStringFree(xmstr);
- XtManageChild(help_button);
- i = InitArg(Label);
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
- XtSetArg(argt[i], XmNbottomPosition, 95); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(argt[i], XmNleftWidget, clear_button); i++;
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OPTIONS_LABEL, MC_DEF_OPTIONS_LABEL );
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
- XmStringFree(xmstr);
- XtManageChild(options_button);
- /** set attachment for help button **/
- i = 0;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(argt[i], XmNleftWidget, options_button); i++;
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetValues(help_button, argt, i);
- /*
- * tell form that ok_button is the default button...
- */
- i = 0;
- XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
- XtSetValues(matte1, argt, i);
-
- /*
- * make all buttons the same size...
- */
-
- max_width = max_height = 0;
- GetBiggest(ok_button, &max_width, &max_height);
- GetBiggest(clear_button, &max_width, &max_height);
- GetBiggest(options_button, &max_width, &max_height);
- GetBiggest(help_button, &max_width, &max_height);
- if ( max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
-
- i = 0;
- XtSetArg(argt[i], XmNwidth, max_width ); i++;
- XtSetArg(argt[i], XmNheight, max_height ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
- XtSetValues(ok_button, argt, i);
- XtSetValues(clear_button, argt, i);
- XtSetValues(options_button, argt, i);
- XtSetValues(help_button, argt, i);
- }
- /***************************************************************************
- *
- * MakeChooser
- *
- * Widgets: greeting, list_head, chooser_list
- ***************************************************************************/
- typedef struct {
- XmFontList fontList;
- } GreetInfo, *GreetInfoPtr;
- static GreetInfo greetInfo;
- static XtResource greetResources[] = {
- {XmNfontList, XmCFontList,
- XmRFontList, sizeof(XmFontList),
- XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
- };
- void
- MakeChooser( void )
- {
- int i;
- /** greeting **/
- XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
- greetResources, XtNumber(greetResources), NULL, 0);
- i = InitArg(LabelG);
- xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_TITLE, MC_DEF_CHOOSER_TITLE);
- XtSetArg(argt[i], XmNtraversalOn, False); i++;
- XtSetArg(argt[i], XmNlabelString, xmstr); i++;
- XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNtopOffset, 10); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER); i++;
- if ( greetInfo.fontList != NULL ) {
- XtSetArg(argt[i], XmNfontList, greetInfo.fontList); i++;
- }
- greeting = XmCreateLabel(matte1, "greeting", argt, i);
- XtManageChild(greeting);
- XmStringFree(xmstr);
- /** list head **/
- i = InitArg(LabelG);
- xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_HEADING,
- MC_DEF_CHOOSER_HEADING);
- XtSetArg(argt[i], XmNtraversalOn, False); i++;
- XtSetArg(argt[i], XmNlabelString, xmstr); i++;
- XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(argt[i], XmNtopWidget, greeting); i++;
- XtSetArg(argt[i], XmNtopOffset, 10); i++;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNleftOffset, 13); i++;
- if (appInfo.chlistFont != NULL) {
- XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
- }
- list_head = XmCreateLabelGadget(matte1, "list_head", argt, i);
- XtManageChild(list_head);
- XmStringFree(xmstr);
- i = 0;
- XtSetArg(argt[i], XmNresizable, True);
- XtSetValues(matte, argt, i);
- XtSetValues(matte1, argt, i);
- /** chooser_list **/
- i = 0;
- XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNleftOffset, 10); i++;
- XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
- XtSetArg(argt[i], XmNrightOffset, 10); i++;
- XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(argt[i], XmNtopWidget, list_head); i++;
- XtSetArg(argt[i], XmNtopOffset, 1); i++;
- XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
- XtSetArg(argt[i], XmNbottomWidget, ok_button); i++;
- XtSetArg(argt[i], XmNbottomOffset, 10); i++;
- XtSetArg(argt[i], XmNallowShellResize, True); i++;
- XtSetArg(argt[i], XmNlistSizePolicy, XmCONSTANT); i++;
- XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++;
- if (appInfo.chlistFont != NULL) {
- XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
- }
- chooser_list = XmCreateScrolledList(matte1, "chooser_list", argt, i);
- XtAddCallback(chooser_list, XmNdefaultActionCallback, DoAccept, NULL);
- XtManageChild(chooser_list);
- if (appInfo.workspaceCursor)
- {
- MakeRootCursor();
- }
- else
- {
- XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
- }
- }
- /***************************************************************************
- *
- * MakeDialog
- *
- * Widgets: error_message, help_message, copyright_msg, hostname_message,
- * passwd_message
- ***************************************************************************/
- void
- MakeDialog( DialogType dtype )
- {
- int i, j;
- int width;
-
- FILE *fp = NULL, *fopen();
- char buffer[128];
- char *str;
- Widget w = NULL, text;
- Dimension txt_width, txt_height;
- XmString ok, cancel, nw, sv;
- Widget tlev;
- /*
- * do things common to all dialogs...
- */
- ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
- cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
- i = InitArg(MessageBox);
- XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
- XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
- XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
- XtSetArg(argt[i], XmNokLabelString, ok ); i++;
- XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
- XtSetArg(argt[i], XmNnoResize, False ); i++;
- XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
- /*
- * create the various dialogs...
- */
- /* JET - check the matte widget, and if non-null, well use that as
- * the parent for dialogs. Otherwise use table (the original
- * toplevel widget for this func). This is useful for Xinerama so
- * that child dialogs are centered on the matte, and not the whole
- * SLS screen.
- */
- if (matte != (Widget)NULL)
- tlev = matte;
- else
- tlev = table;
- switch (dtype) {
- case error:
- xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- w = XmCreateErrorDialog(tlev, "error_message", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- error_message = w;
- break;
- case help:
- xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- w = XmCreateInformationDialog(tlev, "help_message", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
- txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
- txt_width = (txt_width > 850) ? 800 : txt_width - 50;
- txt_height = (txt_height > 900) ? 750 : txt_height - 150;
- i = InitArg(Text);
- XtSetArg(argt[i], XmNheight, txt_height); i++;
- XtSetArg(argt[i], XmNwidth, txt_width); i++;
- XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
- XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
- XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
- XtSetArg(argt[i], XmNeditable, False); i++;
- str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
- XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
- text = XmCreateScrolledText(w, "help_message_text", argt, i);
- XtManageChild(text);
- XtManageChild(w);
- help_message = w;
- break;
- case copyright:
- if ((fp = fopen(COPYRIGHT,"r")) == NULL)
- xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
- XmFONTLIST_DEFAULT_TAG);
- else {
- xmstr = (XmString) NULL;
-
- while (fgets(buffer, 128, fp) != NULL) {
- j = strlen(buffer);
- if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
-
- if ( xmstr != NULL )
- xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
- xmstr = XmStringConcat(xmstr,
- XmStringCreate(buffer,
- XmFONTLIST_DEFAULT_TAG));
- }
- }
- if(fp) {
- fclose(fp);
- }
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
-
- XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
- copyright_msg = w;
- break;
-
- case hostname:
-
- nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
- sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
- xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- XtSetArg(argt[i], XmNokLabelString, nw ); i++;
- XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
- w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- XmStringFree(nw);
- XmStringFree(sv);
- hostname_message = w;
- break;
- case expassword:
- xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
- MC_DEF_PASSWD_EXPIRED);
- XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
- w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- passwd_message = w;
- break;
- case help_chooser:
- xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
- w = XmCreateInformationDialog(tlev, "help_message", argt, i);
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
- XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
- txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
- txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
- txt_width = (txt_width > 850) ? 800 : txt_width - 50;
- txt_height = (txt_height > 900) ? 750 : txt_height - 150;
- i = InitArg(Text);
- XtSetArg(argt[i], XmNheight, txt_height); i++;
- XtSetArg(argt[i], XmNwidth, txt_width); i++;
- XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
- XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
- XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
- XtSetArg(argt[i], XmNeditable, False); i++;
- str = (char*)
- ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
- XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
- text = XmCreateScrolledText(w, "help_message_text", argt, i);
- XtManageChild(text);
- XtManageChild(w);
- help_message = w;
- break;
- }
- /*
- * finish up...
- */
- switch (dtype) {
- case error:
- case hostname:
- case expassword:
- XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
- XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
- break;
- }
- XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
- XtSetValues(w, argt, 1);
- XmStringFree(xmstr);
- XmStringFree(ok);
- XmStringFree(cancel);
- /*
- * adjust the width of the "ok" button on the dialogs...
- */
- width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
-
- i = 0;
- XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
- XtSetArg(argt[i], XmNwidth, width ); i++;
- XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
- }
- /***************************************************************************
- *
- * MakeOptionsMenu
- *
- * Widgets: options_menu, options_item[]
- ***************************************************************************/
- void
- MakeOptionsMenu( void )
- {
- int i, j, k;
- struct stat statb;
- /*
- * get the built-in pop_up menu from the DtMenuButton...
- */
-
- XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
- /*
- * create language cascade menus...
- */
- if ( lang_menu == NULL )
- MakeLangMenu();
- /*
- * create first level menu items...
- */
- j = 0;
- /*
- * build [ Language ] menu pane if there are languages to choose from...
- */
- if ( lang_menu != NULL ) {
- /*
- * [ Language ] menu pane...
- * attach language cascade menu to this pane
- */
- i = InitArg(CascadeBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
- XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
- options_item[j] = XmCreateCascadeButtonGadget(options_menu,
- "options_languages", argt, i);
- XmStringFree(xmstr);
- j++;
- /*
- * separator...
- */
- i = InitArg(SeparatorG);
- options_item[j] = XmCreateSeparatorGadget(options_menu,
- "options_sep2",
- argt, i);
- j++;
- }
- /*
- * [ Restart Server ] menu pane...
- */
- i = k = InitArg(PushBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- options_item[j] = XmCreatePushButtonGadget(options_menu,
- "options_restartServer",
- argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_item[j], XmNactivateCallback,
- DoCancel, (XtPointer) OB_RESTART_SERVER);
- j++;
- #ifdef copyright_option
- /*
- * separator...
- */
- i = InitArg(SeparatorG);
- options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
- argt, i);
- j++;
- /*
- * [ Copyright ] menu pane...
- */
- i = k = InitArg(PushBG);
- xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
- XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
- options_item[j] = XmCreatePushButtonGadget(options_menu,
- "options_copyright",
- argt, i);
- XmStringFree(xmstr);
- XtAddCallback(options_item[j], XmNactivateCallback,
- MenuItemCB, (XtPointer) OB_COPYRIGHT);
- j++;
- #endif
- /*
- * manage the [Options] menu...
- */
- XtManageChildren(options_item, j);
- /*
- * If the DT Lite Session Manager is not available, remove the DT Lite
- * and DT menu panes. The actual widgets must still be created since
- * other code (ex. MenuItemCB()) tries to obtain some of their resources.
- */
-
- if ( stat(DTLITESESSION, &statb) != 0 ||
- ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
- /*
- XtUnmanageChild(options_dt);
- */
- }
- if ( getenv(PINGINTERVAL) != NULL )
- XtUnmanageChild(options_nowindows);
-
- }
- /***************************************************************************
- *
- * ErrorHandler
- *
- * X protocol error handler to override the default
- ***************************************************************************/
- static int
- ErrorHandler( Display *dpy, XErrorEvent *event )
- {
- return 0;
- }
- /***************************************************************************
- *
- * MakeOptionsProc
- *
- * Timeout routine to build options menu
- ***************************************************************************/
- void
- MakeOptionsProc( XtPointer data, XtIntervalId *id )
- {
- if (options_menu == NULL)
- MakeOptionsMenu();
-
- return;
- }
- /***************************************************************************
- *
- * Terminate
- *
- * Catch a SIGTERM and unmanage display
- ***************************************************************************/
- static SIGVAL
- Terminate( int arg )
- {
- write(1, "terminate", 9);
- CleanupAndExit(NULL, NOTIFY_ABORT);
- }
- #ifdef SIA
- /*
- * Chooser doesn't use SIA but it does link with vgcallback.o. We just need
- * this symbol to keep the linker happy.
- */
- void SiaForm()
- {
- return;
- }
- #endif
|