dtchooser.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  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)
  10. * any later version.
  11. *
  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
  16. * details.
  17. *
  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
  22. */
  23. /* $TOG: dtchooser.c /main/8 1998/04/20 12:56:18 mgreess $ */
  24. /* *
  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. *
  29. */
  30. /*
  31. */
  32. /****************************************************************************
  33. **
  34. ** File: dtchooser.c
  35. **
  36. ** Project: HP Visual User Environment (DT)
  37. **
  38. ** Description: Main line code for Dtgreet application
  39. **
  40. ** These routines initialize the toolkit, create the widgets,
  41. ** set up callbacks, and wait for events.
  42. **
  43. **
  44. ** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
  45. **
  46. **
  47. **
  48. ****************************************************************************
  49. ************************************<+>*************************************/
  50. /***************************************************************************
  51. *
  52. * Includes
  53. *
  54. ***************************************************************************/
  55. #include <stdio.h>
  56. #include <stdlib.h>
  57. #include <unistd.h>
  58. #include <sys/signal.h>
  59. #include <sys/stat.h>
  60. #include <locale.h>
  61. #include <Xm/Xm.h>
  62. #include <X11/Shell.h>
  63. #include <X11/cursorfont.h>
  64. #include <Xm/DragC.h>
  65. #include <Xm/DrawingA.h>
  66. #include <Xm/Frame.h>
  67. #include <Xm/Form.h>
  68. #include <Xm/Label.h>
  69. #include <Xm/LabelG.h>
  70. #include <Xm/List.h>
  71. #include <Xm/Text.h>
  72. #include <Xm/TextF.h>
  73. #include <Xm/PushB.h>
  74. #include <Xm/PushBG.h>
  75. #include <Xm/MessageB.h>
  76. #include <Xm/RowColumn.h>
  77. #include <Xm/SeparatoG.h>
  78. #include <Xm/ToggleBG.h>
  79. #include <Xm/CascadeBG.h>
  80. #include <Dt/EnvControlP.h>
  81. #include "vg.h"
  82. #include "vgmsg.h"
  83. #include <Dt/MenuButton.h>
  84. #ifdef USE_XINERAMA
  85. #include <Dt/DtXinerama.h>
  86. #endif
  87. /***************************************************************************
  88. *
  89. * External declarations
  90. *
  91. ***************************************************************************/
  92. extern char password[]; /* pswd string value */
  93. extern int password_length; /* pswd string length */
  94. extern void DoAccept (Widget w, XtPointer client_data, XtPointer call_data);
  95. extern void DoPing (Widget w, XtPointer client_data, XtPointer call_data);
  96. /***************************************************************************
  97. *
  98. * Procedure declarations
  99. *
  100. ***************************************************************************/
  101. static SIGVAL syncTimeout( int arg ) ;
  102. static Widget InitToolKit( int argc, char **argv) ;
  103. void MakeRootCursor( void ) ;
  104. void MakeBackground( void ) ;
  105. void MakeButtons( void ) ;
  106. void MakeLogin( void ) ;
  107. void MakeOptionsProc( XtPointer data, XtIntervalId *id) ;
  108. static int ErrorHandler( Display *dpy, XErrorEvent *event) ;
  109. static SIGVAL Terminate( int arg ) ;
  110. extern void DoCancel (Widget w, XtPointer client_data, XtPointer call_data);
  111. /***************************************************************************
  112. *
  113. * Global variables
  114. *
  115. ***************************************************************************/
  116. AppInfo appInfo; /* application resources */
  117. Arg argt[100]; /* used for resources */
  118. DisplayInfo dpyinfo; /* information about the display */
  119. XmString xmstr; /* used for compound strings */
  120. char *langenv; /* current value of LANG environment var. */
  121. char *errorLogFile; /* current value of environment var. */
  122. int showVerifyError;/* display a Verify() error dialog */
  123. int fullScreen = 0; /* Obscure the entire screen. */
  124. /******************************************************************************
  125. **
  126. ** WIDGET LAYOUT
  127. **
  128. ** toplevel "main" (toplevel)
  129. ** login_shell "login_shell" (overrideShell)
  130. ** table "table" (DrawingAreaWidget)
  131. ** copyright_msg "copyright_msg" (MessageBox)
  132. ** error_message "error_message" (MessageBox)
  133. ** help_message "help_message" (MessageBox)
  134. ** passwd_message "passwd_message" (MessageBox)
  135. ** hostname_message "hostname_msg" (MessageBox)
  136. ** matte "matte" (FormWidget)
  137. ** logo "logo" (FrameWidget)
  138. ** logo_pixmap "logo_pixmap" (LabelGadget)
  139. ** matteFrame "matteFrame" (FrameWidget)
  140. ** matte1 "matte1" (FormWidget)
  141. ** dt_label "dt_label" (LabelGadget)
  142. ** help_button "help_button" (PushButtonGadget)
  143. ** greeting "greeting" (LabelGadget)
  144. ** login_form "login_form" (FormWidget)
  145. ** login_label "login_label" (LabelGadget)
  146. ** login_text "login_text" (TextField)
  147. ** ok_button "ok_button" (PushButtonGadget)
  148. ** clear_button "clear_button" (PushButtonGadget)
  149. ** options_button "options_button" (PushButton)
  150. ** options_menu "options_menu" (PopupMenu)
  151. ** options_item[0] "options_languages" (CascadeButtonGadget)
  152. ** options_item[1] "options_sep2" (SeparatorGadget)
  153. ** options_item[2] "session_menus" (CascadeButtonGadget)
  154. ** options_item[3] "options_sep1" (SeparatorGadget)
  155. ** options_item[4] "options_noWindows" (PushButtonGadget)
  156. ** options_item[5] "options_restartServer"(PushButtonGadget)
  157. ** options_item[6] "options_sep1" (SeparatorGadget)
  158. ** options_item[7] "options_Copyright" (PushButtonGadget)
  159. ** session_menu "session_menu" (PulldownMenu)
  160. ** options_dt "options_dt" (ToggleButtonGadget)
  161. ** options_failsafe "options_failsafe" (ToggleButtonGadget)
  162. ** lang_menu "lang_menu" (PulldownMenu)
  163. ** (lang items) (lang items) (ToggleButtonGadget)
  164. ** ...
  165. **
  166. */
  167. extern Widget toplevel; /* top level shell widget */
  168. Widget login_shell; /* shell for the main login widgets. */
  169. Widget table; /* black background for everything */
  170. Widget matte; /* main level form widget */
  171. Widget matteFrame; /* main level form widget */
  172. Widget matte1; /* second level form widget */
  173. Widget greeting; /* Welcome message */
  174. Widget logo1; /* frame around the Corporate logo */
  175. Widget logo_pixmap; /* Corporate logo */
  176. Widget logo_shadow; /* drop shadow under the Corporate logo */
  177. Widget login_matte; /* bulletin board for login/password */
  178. Widget dt_label; /* desktop label showing the current session */
  179. Widget login_form = NULL; /* form containing the login widgets */
  180. Widget login_label; /* label to left of login text widget */
  181. Widget login_text; /* login text widget */
  182. Widget ok_button; /* accept name/password text button */
  183. Widget clear_button; /* clear name/password text button */
  184. Widget options_button; /* login options button */
  185. Widget help_button; /* help button */
  186. Widget copyright_msg = NULL; /* copyright notice widget */
  187. Widget help_message = NULL; /* the help message box */
  188. Widget error_message = NULL; /* the error message box */
  189. Widget hostname_message = NULL; /* the invalid hostname message box */
  190. Widget passwd_message = NULL; /* the expired password message box */
  191. Widget options_menu = NULL; /* pop-up menu on options button */
  192. Widget options_item[10]; /* items on options pop_up menu */
  193. Widget options_nowindows; /* nowindows pane on options pop_up menu */
  194. Widget options_failsafe; /* failsafe pane on options pop_up menu */
  195. Widget options_dtlite; /* dtlite pane on options pop_up menu */
  196. Widget options_dt; /* dt regular pane on options pop_up menu */
  197. Widget *alt_dts;
  198. Widget options_sp_dt; /* dt button for special desktop */
  199. Widget options_last_dt; /* user's last dt */
  200. Widget lang_menu = NULL; /* cascading menu on "Language" option */
  201. Widget session_menu = NULL; /* cascading menu on "Session" option */
  202. Widget chooser_list; /* list of hosts displayed by chooser */
  203. Widget list_head; /* the heading for the chooser list */
  204. static
  205. XtResource AppResources[] = {
  206. { "workspaceCursor", "WorkspaceCursor",
  207. XtRBoolean, sizeof(Boolean), XtOffset(AppInfoPtr, workspaceCursor),
  208. XtRImmediate, (caddr_t)False },
  209. { "labelFont", "LabelFont",
  210. XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, labelFont),
  211. XmRString, "Fixed" },
  212. { "textFont", "TextFont",
  213. XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, textFont),
  214. XmRString, "Fixed" },
  215. { "chlistFont", "ChlistFont",
  216. XmRFontList, sizeof(XmFontList), XtOffset(AppInfoPtr, chlistFont),
  217. XmRString, "Fixed" },
  218. { "optionsDelay", "OptionsDelay",
  219. XtRInt, sizeof(int), XtOffset(AppInfoPtr, optionsDelay),
  220. XtRImmediate, (XtPointer) 0 },
  221. {"languageList", "LanguageList",
  222. XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
  223. XtRString, NULL },
  224. #if defined(USE_XINERAMA)
  225. { "xineramaPreferredScreen", "XineramaPreferredScreen",
  226. XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
  227. XtRImmediate, (XtPointer) 0
  228. },
  229. #endif
  230. #if defined (ENABLE_DYNAMIC_LANGLIST)
  231. {"languageListCmd", "LanguageListCmd",
  232. XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
  233. XtRString, NULL },
  234. #endif /* ENABLE_DYNAMIC_LANGLIST */
  235. };
  236. /***************************************************************************
  237. *
  238. * MakeRootCursor
  239. *
  240. * Widgets: none
  241. ***************************************************************************/
  242. void
  243. MakeRootCursor( void )
  244. {
  245. Cursor vg_cursor;
  246. vg_cursor = XCreateFontCursor (dpyinfo.dpy, XC_left_ptr);
  247. XDefineCursor (dpyinfo.dpy, dpyinfo.root, vg_cursor);
  248. return;
  249. }
  250. /***************************************************************************
  251. *
  252. * MakeBackground
  253. *
  254. * Widgets: login_shell, table, matte
  255. ***************************************************************************/
  256. void
  257. MakeBackground( void )
  258. {
  259. int i;
  260. /*
  261. * Get resources first
  262. */
  263. SetResourceDatabase();
  264. XtGetApplicationResources(toplevel, &appInfo, AppResources,
  265. XtNumber(AppResources), NULL, 0);
  266. /*
  267. * create the login shell widget...
  268. */
  269. i = 0;
  270. /* CORE resource set */
  271. XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
  272. XtSetArg(argt[i], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP ); i++;
  273. XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
  274. XtSetArg(argt[i], XmNmappedWhenManaged, False ); i++;
  275. XtSetArg(argt[i], XmNsensitive, True ); i++;
  276. XtSetArg(argt[i], XmNtranslations, NULL ); i++;
  277. /* COMPOSITE resource set */
  278. XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
  279. /* SHELL resource set (set to avoid interference by user) */
  280. XtSetArg(argt[i], XmNallowShellResize, False ); i++;
  281. XtSetArg(argt[i], XmNcreatePopupChildProc, NULL ); i++;
  282. XtSetArg(argt[i], XmNgeometry, NULL ); i++;
  283. XtSetArg(argt[i], XmNpopupCallback, NULL ); i++;
  284. XtSetArg(argt[i], XmNpopdownCallback, NULL ); i++;
  285. XtSetArg(argt[i], XmNoverrideRedirect, False ); i++;
  286. XtSetArg(argt[i], XmNsaveUnder, False ); i++;
  287. login_shell = XtCreatePopupShell("login_shell", transientShellWidgetClass,
  288. toplevel, argt, i);
  289. XtAddCallback(login_shell, XmNpopupCallback, LayoutCB, NULL);
  290. /* Fix to display Input Method's status area. */
  291. XtSetArg(argt[0], XmNheight, dpyinfo.height);
  292. XtSetValues(login_shell, argt, 1);
  293. /*
  294. * create the full-screen drawing area...
  295. */
  296. i = InitArg(DrawingA);
  297. XtSetArg(argt[i], XmNwidth, dpyinfo.width ); i++;
  298. XtSetArg(argt[i], XmNheight, dpyinfo.height ); i++;
  299. XtSetArg(argt[i], XmNunitType, XmPIXELS ); i++;
  300. table = XtCreateManagedWidget("table", xmDrawingAreaWidgetClass,
  301. login_shell, argt, i);
  302. XtAddEventHandler(table, ButtonPressMask, False, RefreshEH, NULL);
  303. /*
  304. * create the main matte...
  305. */
  306. i = InitArg(Form);
  307. /* XmNwidth, (set by user) */
  308. /* XmNheight, (set by user) */
  309. XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
  310. /*
  311. XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
  312. XtSetArg(argt[i], XmNshadowThickness, 5 ); i++;
  313. */
  314. matte = XmCreateForm(table, "matte", argt, i);
  315. XtManageChild(matte);
  316. i = 0;
  317. XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT); i++;
  318. XtSetArg(argt[i], XmNshadowThickness, 2); i++;
  319. XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
  320. XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  321. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
  322. /*
  323. XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
  324. */
  325. XtSetArg(argt[i], XmNtopOffset, 15); i++;
  326. XtSetArg(argt[i], XmNbottomOffset, 15); i++;
  327. XtSetArg(argt[i], XmNleftOffset, 15); i++;
  328. /*
  329. XtSetArg(argt[i], XmNrightOffset, 15); i++;
  330. */
  331. matteFrame = XmCreateFrame(matte, "matteFrame", argt, i);
  332. XtManageChild(matteFrame);
  333. i = 0;
  334. matte1 = XmCreateForm(matteFrame, "matte1", argt, i);
  335. XtManageChild(matte1);
  336. }
  337. /***************************************************************************
  338. *
  339. * MakeButtons
  340. *
  341. * Widgets: ok_button, clear_button, options_button, help_button
  342. ***************************************************************************/
  343. void
  344. MakeButtons( void )
  345. {
  346. int i;
  347. Dimension width;
  348. Dimension max_width; /* maximum width of a set of widgets */
  349. Dimension max_height; /* maximum height of a set of widgets */
  350. int origin; /* horizontal origin for button placement */
  351. int spacing; /* spacing between buttons (width/32) */
  352. /*
  353. * create the buttons...
  354. */
  355. /* ok button */
  356. i = InitArg(PushBG);
  357. XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  358. XtSetArg(argt[i], XmNbottomPosition, 95); i++;
  359. XtSetArg(argt[i], XmNtraversalOn, True); i++;
  360. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
  361. xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL );
  362. XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
  363. ok_button = XmCreatePushButtonGadget(matte1, "ok_button", argt, i);
  364. XmStringFree(xmstr);
  365. XtManageChild(ok_button);
  366. XtAddCallback(ok_button, XmNactivateCallback, DoAccept, NULL);
  367. /* clear button */
  368. i -= 2;
  369. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
  370. XtSetArg(argt[i], XmNleftWidget, ok_button); i++;
  371. xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_UPDATE_LABEL, MC_DEF_UPDATE_LABEL);
  372. XtSetArg(argt[i], XmNlabelString, xmstr); i++;
  373. clear_button = XmCreatePushButtonGadget(matte1, "clear_button", argt, i);
  374. XmStringFree(xmstr);
  375. XtManageChild(clear_button);
  376. XtAddCallback(clear_button, XmNactivateCallback, DoPing,
  377. (XtPointer) 0);
  378. /* help button */
  379. i -= 3;
  380. xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
  381. XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
  382. help_button = XmCreatePushButtonGadget(matte1, "help_button", argt, i);
  383. XtAddCallback(help_button, XmNactivateCallback, ShowDialogCB,
  384. (XtPointer) help_chooser);
  385. XmStringFree(xmstr);
  386. XtManageChild(help_button);
  387. i = InitArg(Label);
  388. XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_POSITION); i++;
  389. XtSetArg(argt[i], XmNbottomPosition, 95); i++;
  390. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
  391. XtSetArg(argt[i], XmNleftWidget, clear_button); i++;
  392. xmstr = ReadCatalogXms(MC_LABEL_SET, MC_OPTIONS_LABEL, MC_DEF_OPTIONS_LABEL );
  393. XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
  394. options_button = DtCreateMenuButton(matte1, "options_button", argt, i);
  395. XmStringFree(xmstr);
  396. XtManageChild(options_button);
  397. /** set attachment for help button **/
  398. i = 0;
  399. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_WIDGET); i++;
  400. XtSetArg(argt[i], XmNleftWidget, options_button); i++;
  401. XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
  402. XtSetValues(help_button, argt, i);
  403. /*
  404. * tell form that ok_button is the default button...
  405. */
  406. i = 0;
  407. XtSetArg(argt[i], XmNdefaultButton, ok_button ); i++;
  408. XtSetValues(matte1, argt, i);
  409. /*
  410. * make all buttons the same size...
  411. */
  412. max_width = max_height = 0;
  413. GetBiggest(ok_button, &max_width, &max_height);
  414. GetBiggest(clear_button, &max_width, &max_height);
  415. GetBiggest(options_button, &max_width, &max_height);
  416. GetBiggest(help_button, &max_width, &max_height);
  417. if ( max_width < MIN_BUTTON_SIZE) max_width = MIN_BUTTON_SIZE;
  418. i = 0;
  419. XtSetArg(argt[i], XmNwidth, max_width ); i++;
  420. XtSetArg(argt[i], XmNheight, max_height ); i++;
  421. XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
  422. XtSetValues(ok_button, argt, i);
  423. XtSetValues(clear_button, argt, i);
  424. XtSetValues(options_button, argt, i);
  425. XtSetValues(help_button, argt, i);
  426. }
  427. /***************************************************************************
  428. *
  429. * MakeChooser
  430. *
  431. * Widgets: greeting, list_head, chooser_list
  432. ***************************************************************************/
  433. typedef struct {
  434. XmFontList fontList;
  435. } GreetInfo, *GreetInfoPtr;
  436. static GreetInfo greetInfo;
  437. static XtResource greetResources[] = {
  438. {XmNfontList, XmCFontList,
  439. XmRFontList, sizeof(XmFontList),
  440. XtOffset(GreetInfoPtr, fontList), XtRString, NULL }
  441. };
  442. void
  443. MakeChooser( void )
  444. {
  445. int i;
  446. /** greeting **/
  447. XtGetSubresources(table, &greetInfo, "greeting", "Greeting",
  448. greetResources, XtNumber(greetResources), NULL, 0);
  449. i = InitArg(LabelG);
  450. xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_TITLE, MC_DEF_CHOOSER_TITLE);
  451. XtSetArg(argt[i], XmNtraversalOn, False); i++;
  452. XtSetArg(argt[i], XmNlabelString, xmstr); i++;
  453. XtSetArg(argt[i], XmNtopAttachment, XmATTACH_FORM); i++;
  454. XtSetArg(argt[i], XmNtopOffset, 10); i++;
  455. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
  456. XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
  457. XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER); i++;
  458. if ( greetInfo.fontList != NULL ) {
  459. XtSetArg(argt[i], XmNfontList, greetInfo.fontList); i++;
  460. }
  461. greeting = XmCreateLabel(matte1, "greeting", argt, i);
  462. XtManageChild(greeting);
  463. XmStringFree(xmstr);
  464. /** list head **/
  465. i = InitArg(LabelG);
  466. xmstr = ReadCatalogXms(MC_CHOOSER_SET, MC_CHOOSER_HEADING,
  467. MC_DEF_CHOOSER_HEADING);
  468. XtSetArg(argt[i], XmNtraversalOn, False); i++;
  469. XtSetArg(argt[i], XmNlabelString, xmstr); i++;
  470. XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
  471. XtSetArg(argt[i], XmNtopWidget, greeting); i++;
  472. XtSetArg(argt[i], XmNtopOffset, 10); i++;
  473. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
  474. XtSetArg(argt[i], XmNleftOffset, 13); i++;
  475. if (appInfo.chlistFont != NULL) {
  476. XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
  477. }
  478. list_head = XmCreateLabelGadget(matte1, "list_head", argt, i);
  479. XtManageChild(list_head);
  480. XmStringFree(xmstr);
  481. i = 0;
  482. XtSetArg(argt[i], XmNresizable, True);
  483. XtSetValues(matte, argt, i);
  484. XtSetValues(matte1, argt, i);
  485. /** chooser_list **/
  486. i = 0;
  487. XtSetArg(argt[i], XmNleftAttachment, XmATTACH_FORM); i++;
  488. XtSetArg(argt[i], XmNleftOffset, 10); i++;
  489. XtSetArg(argt[i], XmNrightAttachment, XmATTACH_FORM); i++;
  490. XtSetArg(argt[i], XmNrightOffset, 10); i++;
  491. XtSetArg(argt[i], XmNtopAttachment, XmATTACH_WIDGET); i++;
  492. XtSetArg(argt[i], XmNtopWidget, list_head); i++;
  493. XtSetArg(argt[i], XmNtopOffset, 1); i++;
  494. XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
  495. XtSetArg(argt[i], XmNbottomWidget, ok_button); i++;
  496. XtSetArg(argt[i], XmNbottomOffset, 10); i++;
  497. XtSetArg(argt[i], XmNallowShellResize, True); i++;
  498. XtSetArg(argt[i], XmNlistSizePolicy, XmCONSTANT); i++;
  499. XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmSTATIC); i++;
  500. if (appInfo.chlistFont != NULL) {
  501. XtSetArg(argt[i], XmNfontList, appInfo.chlistFont); i++;
  502. }
  503. chooser_list = XmCreateScrolledList(matte1, "chooser_list", argt, i);
  504. XtAddCallback(chooser_list, XmNdefaultActionCallback, DoAccept, NULL);
  505. XtManageChild(chooser_list);
  506. if (appInfo.workspaceCursor)
  507. {
  508. MakeRootCursor();
  509. }
  510. else
  511. {
  512. XUndefineCursor(dpyinfo.dpy, dpyinfo.root);
  513. }
  514. }
  515. /***************************************************************************
  516. *
  517. * MakeDialog
  518. *
  519. * Widgets: error_message, help_message, copyright_msg, hostname_message,
  520. * passwd_message
  521. ***************************************************************************/
  522. void
  523. MakeDialog( DialogType dtype )
  524. {
  525. int i, j;
  526. int width;
  527. FILE *fp = NULL, *fopen();
  528. char buffer[128];
  529. char *str;
  530. Widget w = NULL, text;
  531. Dimension txt_width, txt_height;
  532. XmString ok, cancel, nw, sv;
  533. Widget tlev;
  534. /*
  535. * do things common to all dialogs...
  536. */
  537. ok = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
  538. cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
  539. i = InitArg(MessageBox);
  540. XtSetArg(argt[i], XmNmarginHeight, MBOX_MARGIN_HEIGHT ); i++;
  541. XtSetArg(argt[i], XmNmarginWidth, MBOX_MARGIN_WIDTH ); i++;
  542. XtSetArg(argt[i], XmNshadowThickness, SHADOW_THICKNESS ); i++;
  543. XtSetArg(argt[i], XmNokLabelString, ok ); i++;
  544. XtSetArg(argt[i], XmNcancelLabelString, cancel ); i++;
  545. XtSetArg(argt[i], XmNnoResize, False ); i++;
  546. XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
  547. /*
  548. * create the various dialogs...
  549. */
  550. /* JET - check the matte widget, and if non-null, well use that as
  551. * the parent for dialogs. Otherwise use table (the original
  552. * toplevel widget for this func). This is useful for Xinerama so
  553. * that child dialogs are centered on the matte, and not the whole
  554. * SLS screen.
  555. */
  556. if (matte != (Widget)NULL)
  557. tlev = matte;
  558. else
  559. tlev = table;
  560. switch (dtype) {
  561. case error:
  562. xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
  563. XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
  564. w = XmCreateErrorDialog(tlev, "error_message", argt, i);
  565. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
  566. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
  567. error_message = w;
  568. break;
  569. case help:
  570. xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
  571. XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
  572. w = XmCreateInformationDialog(tlev, "help_message", argt, i);
  573. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
  574. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
  575. txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
  576. txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
  577. txt_width = (txt_width > 850) ? 800 : txt_width - 50;
  578. txt_height = (txt_height > 900) ? 750 : txt_height - 150;
  579. i = InitArg(Text);
  580. XtSetArg(argt[i], XmNheight, txt_height); i++;
  581. XtSetArg(argt[i], XmNwidth, txt_width); i++;
  582. XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
  583. XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
  584. XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
  585. XtSetArg(argt[i], XmNeditable, False); i++;
  586. str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
  587. XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
  588. text = XmCreateScrolledText(w, "help_message_text", argt, i);
  589. XtManageChild(text);
  590. XtManageChild(w);
  591. help_message = w;
  592. break;
  593. case copyright:
  594. if ((fp = fopen(COPYRIGHT,"r")) == NULL)
  595. xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
  596. XmFONTLIST_DEFAULT_TAG);
  597. else {
  598. xmstr = (XmString) NULL;
  599. while (fgets(buffer, 128, fp) != NULL) {
  600. j = strlen(buffer);
  601. if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
  602. if ( xmstr != NULL )
  603. xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());
  604. xmstr = XmStringConcat(xmstr,
  605. XmStringCreate(buffer,
  606. XmFONTLIST_DEFAULT_TAG));
  607. }
  608. }
  609. if(fp) {
  610. fclose(fp);
  611. }
  612. XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
  613. w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
  614. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
  615. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
  616. XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);
  617. copyright_msg = w;
  618. break;
  619. case hostname:
  620. nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL, MC_DEF_NW_LABEL);
  621. sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);
  622. xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
  623. XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
  624. XtSetArg(argt[i], XmNokLabelString, nw ); i++;
  625. XtSetArg(argt[i], XmNcancelLabelString, sv ); i++;
  626. w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
  627. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
  628. XmStringFree(nw);
  629. XmStringFree(sv);
  630. hostname_message = w;
  631. break;
  632. case expassword:
  633. xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED,
  634. MC_DEF_PASSWD_EXPIRED);
  635. XtSetArg(argt[i], XmNmessageString, xmstr ); i++;
  636. w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
  637. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
  638. passwd_message = w;
  639. break;
  640. case help_chooser:
  641. xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
  642. w = XmCreateInformationDialog(tlev, "help_message", argt, i);
  643. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
  644. XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
  645. txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
  646. txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
  647. txt_width = (txt_width > 850) ? 800 : txt_width - 50;
  648. txt_height = (txt_height > 900) ? 750 : txt_height - 150;
  649. i = InitArg(Text);
  650. XtSetArg(argt[i], XmNheight, txt_height); i++;
  651. XtSetArg(argt[i], XmNwidth, txt_width); i++;
  652. XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
  653. XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
  654. XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
  655. XtSetArg(argt[i], XmNeditable, False); i++;
  656. str = (char*)
  657. ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
  658. XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
  659. text = XmCreateScrolledText(w, "help_message_text", argt, i);
  660. XtManageChild(text);
  661. XtManageChild(w);
  662. help_message = w;
  663. break;
  664. }
  665. /*
  666. * finish up...
  667. */
  668. switch (dtype) {
  669. case error:
  670. case hostname:
  671. case expassword:
  672. XtAddCallback(w, XmNokCallback, RespondDialogCB, NULL);
  673. XtAddCallback(w, XmNcancelCallback, RespondDialogCB, NULL);
  674. break;
  675. }
  676. XtSetArg(argt[0], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); i++;
  677. XtSetValues(w, argt, 1);
  678. XmStringFree(xmstr);
  679. XmStringFree(ok);
  680. XmStringFree(cancel);
  681. /*
  682. * adjust the width of the "ok" button on the dialogs...
  683. */
  684. width = (dtype == hostname ? FromMM(4000) : MIN_BUTTON_SIZE);
  685. i = 0;
  686. XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
  687. XtSetArg(argt[i], XmNwidth, width ); i++;
  688. XtSetValues(XmMessageBoxGetChild(w, XmDIALOG_OK_BUTTON), argt, i);
  689. }
  690. /***************************************************************************
  691. *
  692. * MakeOptionsMenu
  693. *
  694. * Widgets: options_menu, options_item[]
  695. ***************************************************************************/
  696. void
  697. MakeOptionsMenu( void )
  698. {
  699. int i, j, k;
  700. struct stat statb;
  701. /*
  702. * get the built-in pop_up menu from the DtMenuButton...
  703. */
  704. XtVaGetValues(options_button, DtNsubMenuId, &options_menu, NULL);
  705. /*
  706. * create language cascade menus...
  707. */
  708. if ( lang_menu == NULL )
  709. MakeLangMenu();
  710. /*
  711. * create first level menu items...
  712. */
  713. j = 0;
  714. /*
  715. * build [ Language ] menu pane if there are languages to choose from...
  716. */
  717. if ( lang_menu != NULL ) {
  718. /*
  719. * [ Language ] menu pane...
  720. * attach language cascade menu to this pane
  721. */
  722. i = InitArg(CascadeBG);
  723. xmstr = ReadCatalogXms(MC_LABEL_SET, MC_LANG_LABEL, MC_DEF_LANG_LABEL);
  724. XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
  725. XtSetArg(argt[i], XmNsubMenuId, lang_menu ); i++;
  726. XtSetArg(argt[i], XmNrecomputeSize, True ); i++;
  727. options_item[j] = XmCreateCascadeButtonGadget(options_menu,
  728. "options_languages", argt, i);
  729. XmStringFree(xmstr);
  730. j++;
  731. /*
  732. * separator...
  733. */
  734. i = InitArg(SeparatorG);
  735. options_item[j] = XmCreateSeparatorGadget(options_menu,
  736. "options_sep2",
  737. argt, i);
  738. j++;
  739. }
  740. /*
  741. * [ Restart Server ] menu pane...
  742. */
  743. i = k = InitArg(PushBG);
  744. xmstr = ReadCatalogXms(MC_LABEL_SET, MC_RS_LABEL, MC_DEF_RS_LABEL);
  745. XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
  746. options_item[j] = XmCreatePushButtonGadget(options_menu,
  747. "options_restartServer",
  748. argt, i);
  749. XmStringFree(xmstr);
  750. XtAddCallback(options_item[j], XmNactivateCallback,
  751. DoCancel, (XtPointer) OB_RESTART_SERVER);
  752. j++;
  753. #ifdef copyright_option
  754. /*
  755. * separator...
  756. */
  757. i = InitArg(SeparatorG);
  758. options_item[j] = XmCreateSeparatorGadget(options_menu, "options_sep1",
  759. argt, i);
  760. j++;
  761. /*
  762. * [ Copyright ] menu pane...
  763. */
  764. i = k = InitArg(PushBG);
  765. xmstr = ReadCatalogXms(MC_LABEL_SET, MC_COPY_LABEL, MC_DEF_COPY_LABEL);
  766. XtSetArg(argt[i], XmNlabelString, xmstr ); i++;
  767. options_item[j] = XmCreatePushButtonGadget(options_menu,
  768. "options_copyright",
  769. argt, i);
  770. XmStringFree(xmstr);
  771. XtAddCallback(options_item[j], XmNactivateCallback,
  772. MenuItemCB, (XtPointer) OB_COPYRIGHT);
  773. j++;
  774. #endif
  775. /*
  776. * manage the [Options] menu...
  777. */
  778. XtManageChildren(options_item, j);
  779. /*
  780. * If the DT Lite Session Manager is not available, remove the DT Lite
  781. * and DT menu panes. The actual widgets must still be created since
  782. * other code (ex. MenuItemCB()) tries to obtain some of their resources.
  783. */
  784. if ( stat(DTLITESESSION, &statb) != 0 ||
  785. ((statb.st_mode & S_IXOTH) != S_IXOTH) ) {
  786. /*
  787. XtUnmanageChild(options_dt);
  788. */
  789. }
  790. if ( getenv(PINGINTERVAL) != NULL )
  791. XtUnmanageChild(options_nowindows);
  792. }
  793. /***************************************************************************
  794. *
  795. * ErrorHandler
  796. *
  797. * X protocol error handler to override the default
  798. ***************************************************************************/
  799. static int
  800. ErrorHandler( Display *dpy, XErrorEvent *event )
  801. {
  802. return 0;
  803. }
  804. /***************************************************************************
  805. *
  806. * MakeOptionsProc
  807. *
  808. * Timeout routine to build options menu
  809. ***************************************************************************/
  810. void
  811. MakeOptionsProc( XtPointer data, XtIntervalId *id )
  812. {
  813. if (options_menu == NULL)
  814. MakeOptionsMenu();
  815. return;
  816. }
  817. /***************************************************************************
  818. *
  819. * Terminate
  820. *
  821. * Catch a SIGTERM and unmanage display
  822. ***************************************************************************/
  823. static SIGVAL
  824. Terminate( int arg )
  825. {
  826. write(1, "terminate", 9);
  827. CleanupAndExit(NULL, NOTIFY_ABORT);
  828. }
  829. #ifdef SIA
  830. /*
  831. * Chooser doesn't use SIA but it does link with vgcallback.o. We just need
  832. * this symbol to keep the linker happy.
  833. */
  834. void SiaForm()
  835. {
  836. return;
  837. }
  838. #endif