Screen.c 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174
  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. /************************************<+>*************************************/
  24. /****************************************************************************/
  25. /** **/
  26. /** File: Screen.c **/
  27. /** **/
  28. /** Project: DT 1.0 **/
  29. /** **/
  30. /** Description: Controls the Dtstyle Screen dialog **/
  31. /** **/
  32. /** **/
  33. /** **/
  34. /** **/
  35. /****************************************************************************/
  36. /************************************<+>*************************************/
  37. /*$TOG: Screen.c /main/9 1997/07/14 17:44:42 samborn $*/
  38. #include <X11/Xlib.h>
  39. #include <Xm/MwmUtil.h>
  40. #include <Xm/Xm.h>
  41. #include <Xm/XmP.h>
  42. #include <Xm/DrawingA.h>
  43. #include <Xm/Form.h>
  44. #include <Xm/List.h>
  45. #include <Xm/Frame.h>
  46. #include <Xm/LabelG.h>
  47. #include <Xm/PushBG.h>
  48. #include <Xm/PushB.h>
  49. #include <Xm/RowColumn.h>
  50. #include <Xm/Scale.h>
  51. #include <Xm/ToggleBG.h>
  52. #include <Xm/VendorSEP.h>
  53. #include <Xm/Protocols.h>
  54. #include <stdio.h>
  55. #include <signal.h>
  56. #include <errno.h>
  57. #include <X11/Intrinsic.h>
  58. #include <X11/Xutil.h>
  59. #include <X11/Xatom.h>
  60. #include <Dt/Action.h>
  61. #include <Dt/UserMsg.h>
  62. #include <Dt/SaverP.h>
  63. #include <Dt/DialogBox.h>
  64. #include <Dt/Icon.h>
  65. #include <Dt/TitleBox.h>
  66. #include <Dt/Message.h>
  67. #include <Dt/HourGlass.h>
  68. #include "Help.h"
  69. #include "Main.h"
  70. #include "SaveRestore.h"
  71. #include "Protocol.h"
  72. /*+++++++++++++++++++++++++++++++++++++++*/
  73. /* include extern functions */
  74. /*+++++++++++++++++++++++++++++++++++++++*/
  75. #include "Screen.h"
  76. /*+++++++++++++++++++++++++++++++++++++++*/
  77. /* Local #defines */
  78. /*+++++++++++++++++++++++++++++++++++++++*/
  79. #ifndef MIN
  80. #define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
  81. #endif
  82. #define TIMEOUT_MIN 1
  83. #define TIMEOUT_MAX 120
  84. #define CYCLETIME_MIN 0
  85. #define CYCLE_DEFAULT 3 /* 1-120 */
  86. #define LOCK_DEFAULT 30 /* 1-120 */
  87. #define SAVER_DEFAULT 10 /* 0-120 */
  88. #define SAVER_HEIGHT 238
  89. #define SAVER_WIDTH 298
  90. /*+++++++++++++++++++++++++++++++++++++++*/
  91. /* Internal Functions */
  92. /*+++++++++++++++++++++++++++++++++++++++*/
  93. static Widget build_screenDialog( Widget shell) ;
  94. static void formLayoutCB(Widget w,
  95. XtPointer client_data,
  96. XtPointer call_data) ;
  97. static void no_svr_ext_formLayoutCB(Widget w,
  98. XtPointer client_data,
  99. XtPointer call_data) ;
  100. static void _DtmapCB_screenDialog(Widget w,
  101. XtPointer client_data,
  102. XtPointer call_data) ;
  103. static void no_svr_ext_DtmapCB_screenDialog(Widget w,
  104. XtPointer client_data,
  105. XtPointer call_data) ;
  106. static void timeOutvalueChangedCB(Widget w,
  107. XtPointer client_data,
  108. XtPointer call_data) ;
  109. static void no_svr_ext_timeOutvalueChangedCB(Widget w,
  110. XtPointer client_data,
  111. XtPointer call_data) ;
  112. static void saverToggleCB(Widget w,
  113. XtPointer client_data,
  114. XtPointer call_data) ;
  115. static void no_svr_ext_saverToggleCB(Widget w,
  116. XtPointer client_data,
  117. XtPointer call_data) ;
  118. static void saversToggleCB(Widget w,
  119. XtPointer client_data,
  120. XtPointer call_data) ;
  121. static void lockToggleCB(Widget w,
  122. XtPointer client_data,
  123. XtPointer call_data) ;
  124. static void systemDefaultCB(Widget w,
  125. XtPointer client_data,
  126. XtPointer call_data) ;
  127. static void no_svr_ext_systemDefaultCB(Widget w,
  128. XtPointer client_data,
  129. XtPointer call_data) ;
  130. static void ButtonCB(Widget w,
  131. XtPointer client_data,
  132. XtPointer call_data) ;
  133. static void no_svr_ext_ButtonCB(Widget w,
  134. XtPointer client_data,
  135. XtPointer call_data) ;
  136. static XmString * MakeListStrings(char **list ) ;
  137. static void FreeListStrings(XmString *xmlist,
  138. int count) ;
  139. static void ListCB(Widget w,
  140. XtPointer client_data,
  141. XtPointer call_data) ;
  142. static void IconHandler(Widget shell,
  143. XtPointer client_data,
  144. XEvent *event,
  145. Boolean *dispatch) ;
  146. static void UnmapCB(Widget w,
  147. XtPointer client_data,
  148. XtPointer call_data) ;
  149. /*+++++++++++++++++++++++++++++++++++++++*/
  150. /* Internal Variables */
  151. /*+++++++++++++++++++++++++++++++++++++++*/
  152. typedef struct {
  153. Widget pictLabel;
  154. Widget systemDefault;
  155. Widget saverFrame;
  156. Widget saverForm;
  157. Widget saverArea;
  158. Widget saverAreaFrame;
  159. Widget saverLabel;
  160. Widget prevLabel;
  161. Widget saverOn;
  162. Widget saverOff;
  163. Widget saverRadioBox;
  164. Widget saverList;
  165. Widget timeOutLabel;
  166. Widget timeOutScale;
  167. Widget saverMinutesLabel;
  168. Widget cycleTimeLabel;
  169. Widget cycleTimeScale;
  170. Widget cycleMinutesLabel;
  171. Widget lockFrame;
  172. Widget lockForm;
  173. Widget lockLabel;
  174. Widget lockOn;
  175. Widget lockOff;
  176. Widget lockRadioBox;
  177. Widget lockingRadioBox;
  178. Widget lockOutLabel;
  179. Widget lockOutScale;
  180. Widget lockMinutesLabel;
  181. Widget useSaversOn; /* used for graying saverList and saverArea in no saver extn mode */
  182. Widget useSaversOff; /* used for graying saverList and saverArea in no saver extn mode */
  183. int interval;
  184. int blanking;
  185. int exposures;
  186. int newTimeout; /* the min value of savertimeout and locktimeout */
  187. int origTimeout; /* the original value of the min of savertimeout and locktimeout */
  188. int xTimeout; /* the value of the timeout extracted from the X server */
  189. Boolean timeMismatch; /* use to keep track of mismatch between xTimeout and newTimeout */
  190. int saverTimeout; /* the value of savertimeout */
  191. int lockTimeout; /* the value of locktimeout */
  192. int cycleTimeout; /* the value of cycletimeout */
  193. int saverTimeout_xrdb; /* the value of savertimeout from xrdb, in case saver is off */
  194. int lockTimeout_xrdb; /* the value of locktimeout from xrdb, in case lock is off */
  195. int new_blanking;
  196. Boolean systemDefaultFlag;
  197. } ScreenData; /* using the savers toggle when the saver extn is not present */
  198. static ScreenData screen;
  199. static saveRestore save = {FALSE, 0,};
  200. typedef struct {
  201. char *saversList; /* list of available savers */
  202. char *selsaversList; /* list of selected savers */
  203. char **saverActionNames; /* array of saver names */
  204. char **saverActionDesc; /* array of saver action descriptions */
  205. char **selsaverActionNames; /* array of originally selected saver names */
  206. int *selPositions; /* array of currently selected saver positions */
  207. int *origSelPositions; /* array of originally selected saver positions */
  208. int saverCount; /* number of available savers */
  209. int selsaverCount; /* number of currently selected screen savers */
  210. int orig_selsaverCount; /* number of originally selected screen savers */
  211. int previous_selsaverCount; /* number of previously selected screen savers */
  212. char *current_saver; /* name of current screen saver actions */
  213. char *current_saverDesc; /* description of current screen saver actions */
  214. int current_position; /* the clicked on position in the scrolled list */
  215. int shadow; /* shadow width of saver area */
  216. Pixel bg; /* bg color of the style manager dialogs */
  217. Pixel black; /* value of the black pixel */
  218. void *saverstate; /* current running screen saver state */
  219. } Savers, *SaversPtr;
  220. static Savers savers;
  221. /*++++++++++++++++++++++++++++++++++++++++*/
  222. /* build_saverList */
  223. /* parses a space separated list of */
  224. /* savers to build a an array of saver */
  225. /* names. Returns the array and the saver */
  226. /* count. */
  227. /*++++++++++++++++++++++++++++++++++++++++*/
  228. char **
  229. build_saverList(char * str,
  230. int * count)
  231. {
  232. char tokenSep[] = " ";
  233. char * token;
  234. char ** saverList = NULL;
  235. int i = 0;
  236. char * tmpStr, *tmpStr2;
  237. int len = strlen(str);
  238. *count = 0;
  239. tmpStr = (char *)XtCalloc(1, len + 1);
  240. tmpStr2 = tmpStr;
  241. strcpy(tmpStr, str);
  242. token = strtok(tmpStr, tokenSep);
  243. while(token != NULL)
  244. {
  245. ++(i);
  246. token = strtok(NULL, tokenSep);
  247. }
  248. if (i == 0)
  249. return (NULL);
  250. saverList = (char **) XtCalloc(1, i * sizeof(char *));
  251. if( saverList )
  252. {
  253. strcpy(tmpStr, str);
  254. while (isspace(*tmpStr))
  255. tmpStr++;
  256. token = strtok(tmpStr, tokenSep);
  257. *count=0;
  258. while(token != NULL)
  259. {
  260. if (DtActionExists(token))
  261. {
  262. saverList[*count] = (char *) XtCalloc(1, strlen( token ) + 1);
  263. strcpy(saverList[*count], token);
  264. ++(*count);
  265. }
  266. tmpStr += strlen(token);
  267. if (tmpStr >= tmpStr2 + len )
  268. token = NULL;
  269. else
  270. {
  271. do tmpStr++;
  272. while (isspace(*tmpStr));
  273. token = strtok(tmpStr, tokenSep);
  274. }
  275. }
  276. }
  277. if (tmpStr2)
  278. XtFree ((char *) tmpStr2);
  279. return(saverList);
  280. }
  281. /*+++++++++++++++++++++++++++++++++++++++*/
  282. /* build_selsaverList */
  283. /*+++++++++++++++++++++++++++++++++++++++*/
  284. char **
  285. build_selsaverList(char * envStr,
  286. int * count)
  287. {
  288. char tokenSep[] = " ";
  289. char * token;
  290. char ** saverList = NULL;
  291. int i = 0;
  292. char * tmpStr;
  293. int len = strlen(envStr);
  294. *count = 0;
  295. tmpStr = (char *)XtCalloc(1, len + 1);
  296. strcpy(tmpStr, envStr);
  297. token = strtok(tmpStr, tokenSep);
  298. while(token != NULL)
  299. {
  300. ++(i);
  301. token = strtok(NULL, tokenSep);
  302. }
  303. if (i == 0)
  304. return (NULL);
  305. saverList = (char **) XtCalloc(1, i * sizeof(char *));
  306. if( saverList )
  307. {
  308. strcpy(tmpStr, envStr);
  309. token = strtok(tmpStr, tokenSep);
  310. *count=0;
  311. while(token != NULL)
  312. {
  313. saverList[*count] = (char *) XtCalloc(1, strlen( token ) + 1);
  314. strcpy(saverList[*count], token);
  315. token = strtok(NULL, tokenSep);
  316. ++(*count);
  317. }
  318. }
  319. XtFree ((char *) tmpStr);
  320. return(saverList);
  321. }
  322. /*+++++++++++++++++++++++++++++++++++++++*/
  323. /* build_saverDesc */
  324. /*+++++++++++++++++++++++++++++++++++++++*/
  325. char **
  326. build_saverDesc(char ** names,
  327. int count)
  328. {
  329. char **saverDesc = NULL;
  330. char *tmpstr;
  331. int i;
  332. saverDesc = (char **) XtCalloc(1, count * sizeof(char *));
  333. for (i=0; i<count; i++)
  334. {
  335. tmpstr = DtActionDescription(savers.saverActionNames[i]);
  336. if (tmpstr == NULL)
  337. {
  338. saverDesc[i] = (char *) XtMalloc(strlen(savers.saverActionNames[i]) + 1);
  339. strcpy(saverDesc[i], savers.saverActionNames[i]);
  340. }
  341. else
  342. {
  343. saverDesc[i] = (char *) XtMalloc(strlen(tmpstr) + 1);
  344. strcpy(saverDesc[i], tmpstr);
  345. }
  346. XtFree((char *) tmpstr);
  347. }
  348. return(saverDesc);
  349. }
  350. /*+++++++++++++++++++++++++++++++++++++++*/
  351. /* build_selectedList */
  352. /* takes an array of names and a count */
  353. /* and returns a space separated list */
  354. /*+++++++++++++++++++++++++++++++++++++++*/
  355. char *
  356. build_selectedList(char ** saverList,
  357. int count)
  358. {
  359. char * selectedList = NULL;
  360. int i = 0;
  361. char * tmpStr;
  362. int len = 0;
  363. int tmplen = 0;
  364. if (saverList == NULL)
  365. return(NULL);
  366. for (i=0; i<count; i++)
  367. {
  368. len += strlen(saverList[i]) + 1;
  369. }
  370. selectedList = (char *)XtMalloc(len + 1);
  371. selectedList[0] = '\0';
  372. for (i=0; i<count; i++)
  373. {
  374. strcat(selectedList, saverList[i]);
  375. strcat(selectedList, " ");
  376. }
  377. return(selectedList);
  378. }
  379. /*+++++++++++++++++++++++++++++++++++++++*/
  380. /* free_saverList */
  381. /*+++++++++++++++++++++++++++++++++++++++*/
  382. void
  383. free_saverList(char ** saverList,
  384. int count)
  385. {
  386. int i;
  387. if (saverList == NULL)
  388. return;
  389. for (i=0; i<count; i++)
  390. XtFree((char *) saverList[i]);
  391. XtFree ((char *) saverList);
  392. }
  393. /*+++++++++++++++++++++++++++++++++++++++*/
  394. /* popup_screenBB */
  395. /*+++++++++++++++++++++++++++++++++++++++*/
  396. void
  397. popup_screenBB(
  398. Widget shell )
  399. {
  400. if (style.screenDialog == NULL) {
  401. _DtTurnOnHourGlass(shell);
  402. build_screenDialog(shell);
  403. XtManageChild(style.screenDialog);
  404. _DtTurnOffHourGlass(shell);
  405. }
  406. else
  407. {
  408. XtManageChild(style.screenDialog);
  409. raiseWindow(XtWindow(XtParent(style.screenDialog)));
  410. }
  411. }
  412. /*+++++++++++++++++++++++++++++++++++++++*/
  413. /* build_screenDialog */
  414. /*+++++++++++++++++++++++++++++++++++++++*/
  415. static Widget
  416. build_screenDialog(
  417. Widget shell )
  418. {
  419. int i, m, n;
  420. Arg args[MAX_ARGS];
  421. Widget form;
  422. Boolean sel_matched = False;
  423. int sel_found = 1;
  424. int old_selsaverCount = 0;
  425. Widget widget_list1[12];
  426. Widget widget_list2[12];
  427. int list1_count = 0;
  428. int list2_count = 0;
  429. XmString button_string[NUM_LABELS];
  430. XmString string;
  431. XmString *listStrings;
  432. XColor color;
  433. Colormap cmap;
  434. Dimension MaxLabelWidth = 0;
  435. Dimension LabelWidth = 0;
  436. Atom delete_window_atom;
  437. Boolean low_res = False;
  438. XtArgVal scratch;
  439. /* initialize saver data */
  440. savers.shadow = 2;
  441. savers.saverstate = NULL;
  442. savers.saverCount = 0;
  443. savers.selsaverCount = 0;
  444. savers.previous_selsaverCount = 0;
  445. savers.saversList = NULL;
  446. savers.selsaverActionNames = NULL;
  447. savers.selPositions = NULL;
  448. savers.selsaversList = NULL;
  449. savers.saverActionNames = NULL;
  450. savers.saverActionDesc = NULL;
  451. savers.current_saver = NULL;
  452. savers.current_saverDesc = NULL;
  453. savers.current_position = 0;
  454. savers.black = BlackPixel(style.display, DefaultScreen(XtDisplay(shell)));
  455. /* load the actions data base */
  456. DtDbLoad();
  457. if (_DtGetDisplayResolution(style.display, style.screenNum) == 1)
  458. low_res = True;
  459. /* Set up DialogBoxDialog button labels */
  460. button_string[0] = CMPSTR((String) _DtOkString);
  461. button_string[1] = CMPSTR((String) _DtCancelString);
  462. button_string[2] = CMPSTR((String) _DtHelpString);
  463. /* Create toplevel DialogBox */
  464. /* saveRestore - Note that save.poscnt has been initialized elsewhere. */
  465. /* save.posArgs may contain information from restoreScreen().*/
  466. XtSetArg(save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS);
  467. save.poscnt++;
  468. XtSetArg(save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string);
  469. save.poscnt++;
  470. XtSetArg (save.posArgs[save.poscnt], XmNdefaultPosition, False);
  471. save.poscnt++;
  472. style.screenDialog =
  473. __DtCreateDialogBoxDialog(shell, "ScreenDialog", save.posArgs, save.poscnt);
  474. XmStringFree(button_string[0]);
  475. XmStringFree(button_string[1]);
  476. XmStringFree(button_string[2]);
  477. widget_list1[0] = _DtDialogBoxGetButton(style.screenDialog,2);
  478. n=0;
  479. XtSetArg(args[n], XmNautoUnmanage, False); n++;
  480. XtSetArg(args[n], XmNcancelButton, widget_list1[0]); n++;
  481. XtSetValues (style.screenDialog, args, n);
  482. /* Set the title */
  483. n=0;
  484. XtSetArg(args[n], XmNtitle, ((char *)GETMESSAGE(12, 1, "Style Manager - Screen"))); n++;
  485. XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
  486. XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
  487. XtSetValues (XtParent(style.screenDialog), args, n);
  488. /* Create the main form */
  489. n = 0;
  490. XtSetArg(args[n], XmNallowOverlap, False); n++;
  491. XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
  492. form=XmCreateForm(style.screenDialog, "Form", args, n);
  493. /* Create the visual */
  494. n = 0;
  495. XtSetArg(args[n], XmNfillMode, XmFILL_SELF); n++;
  496. XtSetArg(args[n], XmNbehavior, XmICON_LABEL); n++;
  497. XtSetArg(args[n], XmNpixmapForeground, style.secBSCol); n++;
  498. XtSetArg(args[n], XmNpixmapBackground, style.secTSCol); n++;
  499. XtSetArg(args[n], XmNstring, NULL); n++;
  500. XtSetArg(args[n], XmNshadowThickness, 0); n++;
  501. XtSetArg(args[n], XmNimageName, SCREEN_ICON); n++;
  502. XtSetArg(args[n], XmNtraversalOn, False); n++;
  503. widget_list1[list1_count++] =
  504. screen.pictLabel= _DtCreateIcon(form, "screenLabelPixmap", args, n);
  505. /* Create the default button */
  506. n = 0;
  507. XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
  508. XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
  509. string = CMPSTR(((char *)GETMESSAGE(12, 3, "Default")));
  510. XtSetArg(args[n], XmNlabelString, string); n++;
  511. XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
  512. widget_list1[list1_count++] =
  513. screen.systemDefault= XmCreatePushButtonGadget(form, "systemDefault", args, n);
  514. XmStringFree(string);
  515. /* Create the screen lock title box */
  516. n = 0;
  517. if (style.smState.smLockOnTimeoutStatus)
  518. string = CMPSTR(((char *)GETMESSAGE(12, 8, "Screen Lock")));
  519. else
  520. string = CMPSTR(((char *)GETMESSAGE(12, 18, "Front Panel Lock")));
  521. XtSetArg(args[n], XmNtitleString, string); n++;
  522. widget_list1[list1_count++] =
  523. screen.lockFrame= _DtCreateTitleBox(form, "lockFrame", args, n);
  524. XmStringFree(string);
  525. /* Create a form for the screen lock widgets */
  526. n = 0;
  527. XtSetArg(args[n], XmNallowOverlap, False); n++;
  528. XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
  529. screen.lockForm= XmCreateForm(screen.lockFrame, "lockForm", args, n);
  530. /* Create the screen saver title box */
  531. n = 0;
  532. if (style.smState.smLockOnTimeoutStatus)
  533. string = CMPSTR(((char *)GETMESSAGE(12, 4, "Screen Saver")));
  534. else
  535. string = CMPSTR(((char *)GETMESSAGE(12, 15, "Auto Screen Blanking")));
  536. XtSetArg(args[n], XmNtitleString, string); n++;
  537. widget_list1[list1_count++] =
  538. screen.saverFrame= _DtCreateTitleBox(form, "saverFrame", args, n);
  539. XmStringFree(string);
  540. /* Create a form for the screen saver widgets */
  541. n = 0;
  542. XtSetArg(args[n], XmNallowOverlap, False); n++;
  543. XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
  544. screen.saverForm= XmCreateForm(screen.saverFrame, "saverForm", args, n);
  545. /* Create the cycle time labels and slider */
  546. n = 0;
  547. if (style.smState.smLockOnTimeoutStatus)
  548. string = CMPSTR(((char *)GETMESSAGE(12, 6, "Time Per Saver")));
  549. else
  550. string = CMPSTR(((char *)GETMESSAGE(12, 20, "Time Per Background")));
  551. XtSetArg(args[n], XmNlabelString, string); n++;
  552. /* only if saver extensions are present */
  553. if (style.smState.smLockOnTimeoutStatus)
  554. screen.cycleTimeLabel = XmCreateLabelGadget(screen.saverForm,"cycleTimeLabel", args, n);
  555. else
  556. screen.cycleTimeLabel = XmCreateLabelGadget(screen.lockForm,"cycleTimeLabel", args, n);
  557. XmStringFree(string);
  558. n = 0;
  559. XtSetArg(args[n], XmNminimum, CYCLETIME_MIN); n++;
  560. XtSetArg(args[n], XmNmaximum, TIMEOUT_MAX); n++;
  561. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  562. XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
  563. XtSetArg(args[n], XmNshowValue, True); n++;
  564. XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
  565. if (style.smState.smLockOnTimeoutStatus)
  566. screen.cycleTimeScale= XmCreateScale(screen.saverForm,"cycleTimeScale", args, n);
  567. else
  568. screen.cycleTimeScale= XmCreateScale(screen.lockForm,"cycleTimeScale", args, n);
  569. n = 0;
  570. string = CMPSTR(((char *)GETMESSAGE(12, 7, "minutes")));
  571. XtSetArg(args[n], XmNlabelString, string); n++;
  572. if (style.smState.smLockOnTimeoutStatus)
  573. screen.cycleMinutesLabel= XmCreateLabelGadget(screen.saverForm,"cycleMinutes", args, n);
  574. else
  575. screen.cycleMinutesLabel= XmCreateLabelGadget(screen.lockForm,"cycleMinutes", args, n);
  576. XmStringFree(string);
  577. /* Create the screen saver on/off radio buttons and label */
  578. n = 0;
  579. if (style.smState.smLockOnTimeoutStatus)
  580. string = CMPSTR(((char *)GETMESSAGE(12, 12, "Screen Saver:")));
  581. else
  582. string = CMPSTR(((char *)GETMESSAGE(12, 16, "Screen Blanker:")));
  583. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  584. XtSetArg(args[n], XmNlabelString, string); n++;
  585. screen.saverLabel= XmCreateLabelGadget(screen.saverForm, "saverLabel", args, n);
  586. XmStringFree(string);
  587. n = 0;
  588. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  589. screen.saverRadioBox= XmCreateRadioBox(screen.saverForm, "saverRadioBox", args, n);
  590. n = 0;
  591. string = CMPSTR(((char *)GETMESSAGE(12, 10, "On")));
  592. XtSetArg(args[n], XmNlabelString, string); n++;
  593. screen.saverOn= XmCreateToggleButtonGadget(screen.saverRadioBox, "saverOn", args, n);
  594. XmStringFree(string);
  595. n = 0;
  596. string = CMPSTR(((char *)GETMESSAGE(12, 11, "Off")));
  597. XtSetArg(args[n], XmNlabelString, string); n++;
  598. screen.saverOff= XmCreateToggleButtonGadget(screen.saverRadioBox, "saverOff", args, n);
  599. XmStringFree(string);
  600. /* Create the screen saver list */
  601. n = 0;
  602. XtSetArg (args[n], XmNautomaticSelection, True); n++;
  603. XtSetArg (args[n], XmNselectionPolicy, XmMULTIPLE_SELECT); n++;
  604. XtSetArg (args[n], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); n++;
  605. if (low_res) {
  606. XtSetArg (args[n], XmNheight, 100); n++; }
  607. else {
  608. XtSetArg (args[n], XmNheight, SAVER_HEIGHT); n++; }
  609. XtSetArg (args[n], XmNhighlightColor, 0); n++;
  610. /* choose the parent of saverList depending on the presence of saver extensions */
  611. if (style.smState.smLockOnTimeoutStatus)
  612. screen.saverList = XmCreateScrolledList (screen.saverForm, "saversList", args, n);
  613. else
  614. screen.saverList = XmCreateScrolledList (screen.lockForm, "saversList", args, n);
  615. /* use the environment variable DTSCREENSAVERLIST to get the list of */
  616. /* available screen saver actions, load them into the scrolled list*/
  617. savers.saversList = getenv ("DTSCREENSAVERLIST");
  618. /* if DTSCREENSAVER is not set, set saver count to zero */
  619. if (savers.saversList == NULL) {
  620. savers.saverCount = 0;
  621. savers.selsaverCount=0;
  622. } else {
  623. savers.saverActionNames = build_saverList(savers.saversList, &savers.saverCount);
  624. savers.saverActionDesc = build_saverDesc(savers.saverActionNames, savers.saverCount);
  625. /* convert to XmString */
  626. listStrings = MakeListStrings(savers.saverActionDesc);
  627. XmListAddItems (screen.saverList, listStrings, savers.saverCount, 0);
  628. XtAddCallback (screen.saverList, XmNmultipleSelectionCallback,
  629. ListCB, (XtPointer)NULL);
  630. FreeListStrings (listStrings, savers.saverCount);
  631. /* check the state to see which item(s) should be selected, if none are */
  632. /* selected or if none in the selected list match the available list then */
  633. /* set the selection to the last position by default. This should be blank */
  634. /* if the DTSCREENSAVERLIST environment variable is set to default */
  635. savers.selsaverActionNames =
  636. build_selsaverList(style.smSaver.saverList, &savers.selsaverCount);
  637. /* since savers.selsaverCount may be changed below, we save */
  638. /* number of originally selected savers in order to accurately free the */
  639. /* savers.selsaverActionNames array below. */
  640. old_selsaverCount = savers.selsaverCount;
  641. if (savers.selsaverCount) {
  642. savers.selPositions = (int *) XtMalloc(sizeof(int) * savers.selsaverCount);
  643. for (n=0; n<savers.selsaverCount; n++) {
  644. /* determine if this selected saver matches one in valid saver list */
  645. for (m=0; (m < savers.saverCount) &&
  646. ((sel_found = strcmp(savers.selsaverActionNames[n],
  647. savers.saverActionNames[m])) != 0); m++) {}
  648. if (sel_found == 0) {
  649. XmListSelectPos (screen.saverList, m+1, False);
  650. savers.selPositions[n]=m+1;
  651. sel_matched = True;
  652. } else {
  653. /* This selected saver isn't valid, need to get rid of it.
  654. Do this by shifting each selected saver in the array
  655. back one position, i.e. n = n+1, n+1 = n+2, ....
  656. This overwrites the nth element and leaves the empty
  657. space at the end of the array. */
  658. for (i=n; i < (savers.selsaverCount - 1); i++)
  659. savers.selsaverActionNames[i] = savers.selsaverActionNames[i+1];
  660. /* reduce # of selected savers */
  661. savers.selsaverCount--;
  662. /* reset selected saver array position counter back one position for
  663. next loop test */
  664. n--;
  665. } /* if (sel_found == 0) */
  666. } /* for n<savers.selsaverCount */
  667. } /* if (savers.selsaverCount) */
  668. /* if there are still savers selected that match valid saver names */
  669. if (savers.selsaverCount) {
  670. /* set current saver to first selection */
  671. savers.current_saver = savers.saverActionNames[savers.selPositions[0] - 1];
  672. savers.current_saverDesc = savers.saverActionDesc[savers.selPositions[0] - 1];
  673. savers.current_position = savers.selPositions[0];
  674. } else {
  675. /* highlight last saver */
  676. XmListSelectPos (screen.saverList, savers.saverCount, False);
  677. /* set current saver to last one */
  678. savers.current_saver = savers.saverActionNames[savers.saverCount - 1];
  679. savers.current_saverDesc = savers.saverActionDesc[savers.saverCount - 1];
  680. savers.selPositions = (int *) XtMalloc(sizeof(int));
  681. savers.selPositions[0] = savers.saverCount;
  682. savers.selsaverCount = 1;
  683. savers.current_position = 1;
  684. }
  685. /* save the selected positions for later use */
  686. savers.origSelPositions = (int *) XtMalloc(sizeof(int) * savers.selsaverCount);
  687. for (i=0; i<savers.selsaverCount; i++)
  688. savers.origSelPositions[i] = savers.selPositions[i];
  689. savers.orig_selsaverCount = savers.selsaverCount;
  690. savers.previous_selsaverCount = savers.selsaverCount;
  691. free_saverList(savers.selsaverActionNames, old_selsaverCount);
  692. }
  693. /* Create frame for the saver area */
  694. n = 0;
  695. XtSetArg (args[n], XmNshadowType, XmSHADOW_IN); n++;
  696. XtSetArg (args[n], XmNshadowThickness, savers.shadow); n++;
  697. XtSetArg (args[n], XmNhighlightThickness, 0); n++;
  698. XtSetArg (args[n], XmNtraversalOn, False); n++;
  699. /* depending on the presence of saver extensions choose the parent of saverAreaFrame */
  700. if (style.smState.smLockOnTimeoutStatus)
  701. screen.saverAreaFrame = XmCreateFrame(screen.saverForm, "saverAreaFrame", args, n);
  702. else
  703. screen.saverAreaFrame = XmCreateFrame(screen.lockForm, "saverAreaFrame", args, n);
  704. /* Create saver area for the screen savers */
  705. n = 0;
  706. XtSetArg (args[n], XmNtraversalOn, False); n++;
  707. if (low_res) {
  708. XtSetArg (args[n], XmNwidth, 180); n++; }
  709. else {
  710. XtSetArg (args[n], XmNwidth, SAVER_WIDTH); n++; }
  711. screen.saverArea = XmCreateDrawingArea (screen.saverAreaFrame, "saverArea", args, n);
  712. /* get the initial secondary color pixel value for dtstyle for later use */
  713. XtVaGetValues(screen.saverArea, XmNbackground, &scratch, NULL);
  714. savers.bg = (Pixel)scratch;
  715. /* label for the previewed saver */
  716. n = 0;
  717. if (savers.saverCount)
  718. string = XmStringCreateLocalized (savers.current_saverDesc);
  719. else
  720. string = XmStringCreateLocalized (" ");
  721. XtSetArg(args[n], XmNlabelString, string); n++;
  722. if (style.smState.smLockOnTimeoutStatus)
  723. screen.prevLabel = XmCreateLabelGadget(screen.saverForm,"prevLabel", args, n);
  724. else
  725. screen.prevLabel = XmCreateLabelGadget(screen.lockForm,"prevLabel", args, n);
  726. XmStringFree(string);
  727. /* Create the screen saver labels and slider */
  728. n = 0;
  729. if (style.smState.smLockOnTimeoutStatus)
  730. string = CMPSTR(((char *)GETMESSAGE(12, 5, "Start Saver")));
  731. else
  732. string = CMPSTR(((char *)GETMESSAGE(12, 17, "Start Blanker")));
  733. XtSetArg(args[n], XmNlabelString, string); n++;
  734. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  735. screen.timeOutLabel= XmCreateLabelGadget(screen.saverForm,"timeOutLabel", args, n);
  736. XmStringFree(string);
  737. n = 0;
  738. XtSetArg(args[n], XmNminimum, TIMEOUT_MIN); n++;
  739. XtSetArg(args[n], XmNmaximum, TIMEOUT_MAX); n++;
  740. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  741. XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
  742. XtSetArg(args[n], XmNshowValue, True); n++;
  743. XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
  744. screen.timeOutScale= XmCreateScale(screen.saverForm,"timeOutScale", args, n);
  745. n = 0;
  746. string = CMPSTR(((char *)GETMESSAGE(12, 7, "minutes")));
  747. XtSetArg(args[n], XmNlabelString, string); n++;
  748. screen.saverMinutesLabel= XmCreateLabelGadget(screen.saverForm,"saverMinutes", args, n);
  749. XmStringFree(string);
  750. /* Create the screen lock on/off radio buttons and label */
  751. /* mapped only when saver extensions are present */
  752. n = 0;
  753. string = CMPSTR(((char *)GETMESSAGE(12, 13, "Screen Lock:")));
  754. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  755. XtSetArg(args[n], XmNlabelString, string); n++;
  756. screen.lockLabel= XmCreateLabelGadget(screen.lockForm, "lockLabel", args, n);
  757. XmStringFree(string);
  758. n = 0;
  759. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  760. screen.lockRadioBox= XmCreateRadioBox(screen.lockForm, "lockRadioBox", args, n);
  761. n = 0;
  762. string = CMPSTR(((char *)GETMESSAGE(12, 10, "On")));
  763. XtSetArg(args[n], XmNlabelString, string); n++;
  764. XtSetArg(args[n], XmNset, style.smState.smCoverScreen ? True : False); n++;
  765. screen.lockOn= XmCreateToggleButtonGadget(screen.lockRadioBox, "lockOn", args, n);
  766. XmStringFree(string);
  767. n = 0;
  768. string = CMPSTR(((char *)GETMESSAGE(12, 11, "Off")));
  769. XtSetArg(args[n], XmNlabelString, string); n++;
  770. XtSetArg(args[n], XmNset, style.smState.smCoverScreen ? False : True); n++;
  771. screen.lockOff= XmCreateToggleButtonGadget(screen.lockRadioBox, "lockOff", args, n);
  772. XmStringFree(string);
  773. /* Create the screen lock labels and slider */
  774. /* mapped only when saver extensions are present */
  775. n = 0;
  776. string = CMPSTR(((char *)GETMESSAGE(12, 14, "Start Lock")));
  777. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  778. XtSetArg(args[n], XmNlabelString, string); n++;
  779. screen.lockOutLabel= XmCreateLabelGadget(screen.lockForm,"lockOutLabel", args, n);
  780. XmStringFree(string);
  781. n = 0;
  782. XtSetArg(args[n], XmNminimum, TIMEOUT_MIN); n++;
  783. XtSetArg(args[n], XmNmaximum, TIMEOUT_MAX); n++;
  784. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  785. XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
  786. XtSetArg(args[n], XmNshowValue, True); n++;
  787. XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
  788. screen.lockOutScale= XmCreateScale(screen.lockForm,"lockOutScale", args, n);
  789. n = 0;
  790. string = CMPSTR(((char *)GETMESSAGE(12, 7, "minutes")));
  791. XtSetArg(args[n], XmNlabelString, string); n++;
  792. screen.lockMinutesLabel= XmCreateLabelGadget(screen.lockForm,"lockMinutes", args, n);
  793. XmStringFree(string);
  794. /* Create the radio buttons for lock savers */
  795. /* mapped only when saver extensions are not present */
  796. n = 0;
  797. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  798. XtSetArg(args[n], XmNspacing, 25); n++;
  799. screen.lockingRadioBox= XmCreateRadioBox(screen.lockForm, "lockingRadioBox", args, n);
  800. n = 0;
  801. string = CMPSTR(((char *)GETMESSAGE(12, 21, "Use Backgrounds For Lock")));
  802. XtSetArg(args[n], XmNlabelString, string); n++;
  803. screen.useSaversOn= XmCreateToggleButtonGadget(screen.lockingRadioBox, "useSaversOn", args, n);
  804. XmStringFree(string);
  805. n = 0;
  806. string = CMPSTR(((char *)GETMESSAGE(12, 22, "Transparent Lock")));
  807. XtSetArg(args[n], XmNlabelString, string); n++;
  808. screen.useSaversOff= XmCreateToggleButtonGadget(screen.lockingRadioBox, "useSaversOff", args, n);
  809. XmStringFree(string);
  810. /* add callbacks */
  811. /* Configure dialog based on the presence of screen saver extensions */
  812. if (!style.smState.smLockOnTimeoutStatus)
  813. {
  814. XtAddCallback(style.screenDialog, XmNmapCallback, no_svr_ext_formLayoutCB, NULL);
  815. XtAddCallback(style.screenDialog, XmNmapCallback, no_svr_ext_DtmapCB_screenDialog, shell);
  816. XtAddCallback(screen.systemDefault, XmNactivateCallback, no_svr_ext_systemDefaultCB, NULL);
  817. XtAddCallback(screen.timeOutScale, XmNvalueChangedCallback,
  818. no_svr_ext_timeOutvalueChangedCB, NULL);
  819. XtAddCallback(screen.saverOn, XmNvalueChangedCallback,
  820. no_svr_ext_saverToggleCB, NULL);
  821. XtAddCallback(screen.saverOff, XmNvalueChangedCallback,
  822. no_svr_ext_saverToggleCB, NULL);
  823. XtAddCallback(screen.useSaversOn, XmNvalueChangedCallback,
  824. saversToggleCB, NULL);
  825. XtAddCallback(screen.useSaversOff, XmNvalueChangedCallback,
  826. saversToggleCB, NULL);
  827. XtAddCallback(style.screenDialog, XmNcallback, no_svr_ext_ButtonCB, NULL);
  828. }
  829. else
  830. {
  831. XtAddCallback(style.screenDialog, XmNmapCallback, formLayoutCB, NULL);
  832. XtAddCallback(style.screenDialog, XmNmapCallback, _DtmapCB_screenDialog, shell);
  833. XtAddCallback(screen.systemDefault, XmNactivateCallback, systemDefaultCB, NULL);
  834. XtAddCallback(screen.timeOutScale, XmNvalueChangedCallback,
  835. timeOutvalueChangedCB, NULL);
  836. XtAddCallback(screen.lockOutScale, XmNvalueChangedCallback,
  837. timeOutvalueChangedCB, NULL);
  838. XtAddCallback(screen.saverOn, XmNvalueChangedCallback,
  839. saverToggleCB, NULL);
  840. XtAddCallback(screen.saverOff, XmNvalueChangedCallback,
  841. saverToggleCB, NULL);
  842. XtAddCallback(screen.lockOn, XmNvalueChangedCallback,
  843. lockToggleCB, NULL);
  844. XtAddCallback(screen.lockOff, XmNvalueChangedCallback,
  845. lockToggleCB, NULL);
  846. XtAddCallback(style.screenDialog, XmNcallback, ButtonCB, NULL);
  847. }
  848. XtAddCallback(style.screenDialog, XmNunmapCallback, UnmapCB, shell);
  849. XtAddCallback(style.screenDialog, XmNhelpCallback,
  850. (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_SCREEN_DIALOG);
  851. /* calculate the max label width for labels */
  852. if ((LabelWidth = XtWidth(screen.saverLabel)) > MaxLabelWidth)
  853. MaxLabelWidth = LabelWidth;
  854. if ((LabelWidth = XtWidth(screen.timeOutLabel)) > MaxLabelWidth)
  855. MaxLabelWidth = LabelWidth;
  856. if ((LabelWidth = XtWidth(screen.cycleTimeLabel)) > MaxLabelWidth)
  857. MaxLabelWidth = LabelWidth;
  858. if (style.smState.smLockOnTimeoutStatus)
  859. {
  860. if ((LabelWidth = XtWidth(screen.lockLabel)) > MaxLabelWidth)
  861. MaxLabelWidth = LabelWidth;
  862. if ((LabelWidth = XtWidth(screen.lockOutLabel)) > MaxLabelWidth)
  863. MaxLabelWidth = LabelWidth;
  864. }
  865. XtVaSetValues(screen.saverLabel, XmNwidth, MaxLabelWidth, NULL);
  866. XtVaSetValues(screen.timeOutLabel, XmNwidth, MaxLabelWidth, NULL);
  867. XtVaSetValues(screen.cycleTimeLabel, XmNwidth, MaxLabelWidth, NULL);
  868. if (style.smState.smLockOnTimeoutStatus)
  869. {
  870. XtVaSetValues(screen.lockLabel, XmNwidth, MaxLabelWidth, NULL);
  871. XtVaSetValues(screen.lockOutLabel, XmNwidth, MaxLabelWidth, NULL);
  872. }
  873. /* manage widgets */
  874. XtManageChildren(widget_list1,list1_count);
  875. XtManageChild(form);
  876. XtManageChild(screen.saverForm);
  877. XtManageChild(screen.cycleTimeLabel);
  878. XtManageChild(screen.cycleTimeScale);
  879. XtManageChild(screen.saverLabel);
  880. XtManageChild(screen.prevLabel);
  881. XtManageChild(screen.saverRadioBox);
  882. XtManageChild(screen.saverOn);
  883. XtManageChild(screen.saverOff);
  884. XtManageChild(screen.timeOutLabel);
  885. XtManageChild(screen.timeOutScale);
  886. XtManageChild(screen.saverMinutesLabel);
  887. XtManageChild(screen.saverList);
  888. XtManageChild(screen.saverAreaFrame);
  889. XtManageChild(screen.saverArea);
  890. XtManageChild(screen.cycleMinutesLabel);
  891. XtManageChild(screen.saverList);
  892. XtManageChild(screen.lockForm);
  893. /* manage the lock label, scale and minutes label only if */
  894. /* saver extensions are present */
  895. if (style.smState.smLockOnTimeoutStatus)
  896. {
  897. XtManageChild(screen.lockLabel);
  898. XtManageChild(screen.lockRadioBox);
  899. XtManageChild(screen.lockOn);
  900. XtManageChild(screen.lockOff);
  901. XtManageChild(screen.lockOutLabel);
  902. XtManageChild(screen.lockOutScale);
  903. XtManageChild(screen.lockMinutesLabel);
  904. }
  905. else
  906. {
  907. XtManageChild(screen.lockingRadioBox);
  908. XtManageChild(screen.useSaversOn);
  909. XtManageChild(screen.useSaversOff);
  910. }
  911. XtAddEventHandler(style.shell, StructureNotifyMask, False, IconHandler, NULL);
  912. return(style.screenDialog);
  913. }
  914. /*+++++++++++++++++++++++++++++++++++++++*/
  915. /* formLayoutCB */
  916. /*+++++++++++++++++++++++++++++++++++++++*/
  917. static void
  918. formLayoutCB(
  919. Widget w,
  920. XtPointer client_data,
  921. XtPointer call_data )
  922. {
  923. int n;
  924. Arg args[MAX_ARGS];
  925. Dimension ScaleHeight;
  926. Dimension LabelHeight;
  927. Dimension RadioHeight;
  928. Dimension RadioOffset, ScaleOffset;
  929. /* calculate width and height information */
  930. ScaleHeight = XtHeight(screen.timeOutScale);
  931. LabelHeight = XtHeight(screen.timeOutLabel);
  932. RadioHeight = XtHeight(screen.saverRadioBox);
  933. RadioOffset = ((Dimension) (RadioHeight - LabelHeight) / 2) - 2;
  934. ScaleOffset = 0;
  935. /* do form attachments */
  936. /* Picture Label */
  937. n=0;
  938. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  939. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  940. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  941. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  942. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  943. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  944. XtSetValues (screen.pictLabel, args, n);
  945. /* system Default */
  946. n=0;
  947. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  948. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  949. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  950. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  951. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  952. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  953. XtSetValues (screen.systemDefault, args, n);
  954. /* lock titlebox */
  955. n=0;
  956. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  957. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  958. XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
  959. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  960. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  961. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  962. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  963. XtSetValues (screen.lockFrame, args, n);
  964. /* lock label */
  965. n=0;
  966. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  967. XtSetArg (args[n], XmNtopOffset, style.verticalSpacing); n++;
  968. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  969. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  970. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  971. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  972. XtSetValues (screen.lockLabel, args, n);
  973. /* lock Radiobox */
  974. n=0;
  975. XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  976. XtSetArg(args[n], XmNtopWidget, screen.lockLabel); n++;
  977. XtSetArg(args[n], XmNtopOffset, -RadioOffset); n++;
  978. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  979. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  980. XtSetArg(args[n], XmNleftWidget, screen.lockLabel); n++;
  981. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  982. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  983. XtSetValues (screen.lockRadioBox, args, n);
  984. /* lockOut Label */
  985. n=0;
  986. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  987. XtSetArg(args[n], XmNtopWidget, screen.lockLabel); n++;
  988. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing + ScaleHeight - LabelHeight); n++;
  989. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  990. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  991. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  992. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  993. XtSetValues (screen.lockOutLabel, args, n);
  994. /* lockOut Scale */
  995. n=0;
  996. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  997. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  998. XtSetArg(args[n], XmNbottomWidget, screen.lockOutLabel);n++;
  999. XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++;
  1000. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1001. XtSetArg(args[n], XmNleftWidget, screen.lockOutLabel);n++;
  1002. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1003. XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1004. XtSetArg(args[n], XmNrightWidget, screen.lockMinutesLabel);n++;
  1005. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1006. XtSetValues (screen.lockOutScale, args, n);
  1007. /* Minutes label */
  1008. n=0;
  1009. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1010. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1011. XtSetArg(args[n], XmNbottomWidget, screen.lockOutLabel);n++;
  1012. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1013. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1014. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1015. XtSetValues (screen.lockMinutesLabel, args, n);
  1016. /* saver titlebox */
  1017. n=0;
  1018. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1019. XtSetArg(args[n], XmNtopWidget, screen.pictLabel); n++;
  1020. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1021. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1022. XtSetArg(args[n], XmNbottomWidget, screen.lockFrame); n++;
  1023. XtSetArg(args[n], XmNbottomOffset, 2*style.verticalSpacing); n++;
  1024. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1025. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1026. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1027. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1028. XtSetValues (screen.saverFrame, args, n);
  1029. /* cycleTime Label */
  1030. n=0;
  1031. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1032. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1033. XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
  1034. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1035. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1036. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1037. XtSetValues (screen.cycleTimeLabel, args, n);
  1038. /* cycleTime Scale */
  1039. n=0;
  1040. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1041. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1042. XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++;
  1043. XtSetArg(args[n], XmNbottomOffset, ScaleOffset);n++;
  1044. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1045. XtSetArg(args[n], XmNleftWidget, screen.cycleTimeLabel);n++;
  1046. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1047. XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1048. XtSetArg(args[n], XmNrightWidget, screen.cycleMinutesLabel);n++;
  1049. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1050. XtSetValues (screen.cycleTimeScale, args, n);
  1051. /* Minutes label */
  1052. n=0;
  1053. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1054. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1055. XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++;
  1056. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1057. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1058. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1059. XtSetValues (screen.cycleMinutesLabel, args, n);
  1060. /* TimeOut Label */
  1061. n=0;
  1062. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1063. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1064. XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++;
  1065. XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing + ScaleHeight - LabelHeight); n++;
  1066. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1067. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1068. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1069. XtSetValues (screen.timeOutLabel, args, n);
  1070. /* Minutes label */
  1071. n=0;
  1072. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1073. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1074. XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++;
  1075. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1076. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1077. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1078. XtSetValues (screen.saverMinutesLabel, args, n);
  1079. /* TimeOut Scale */
  1080. n=0;
  1081. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1082. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1083. XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++;
  1084. XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++;
  1085. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1086. XtSetArg(args[n], XmNleftWidget, screen.timeOutLabel);n++;
  1087. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1088. XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1089. XtSetArg(args[n], XmNrightWidget, screen.saverMinutesLabel);n++;
  1090. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1091. XtSetValues (screen.timeOutScale, args, n);
  1092. /* saver label */
  1093. n=0;
  1094. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1095. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1096. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1097. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1098. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1099. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1100. XtSetValues (screen.saverLabel, args, n);
  1101. /* saver Radiobox */
  1102. n=0;
  1103. XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1104. XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++;
  1105. XtSetArg(args[n], XmNtopOffset, -RadioOffset); n++;
  1106. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1107. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1108. XtSetArg(args[n], XmNleftWidget, screen.saverLabel); n++;
  1109. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1110. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1111. XtSetValues (screen.saverRadioBox, args, n);
  1112. /* preview label */
  1113. n=0;
  1114. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1115. XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++;
  1116. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1117. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1118. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1119. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1120. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1121. XtSetValues (screen.prevLabel, args, n);
  1122. /* scrolled list */
  1123. n = 0;
  1124. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1125. XtSetArg (args[n], XmNtopWidget, screen.prevLabel); n++;
  1126. XtSetArg (args[n], XmNtopOffset, style.verticalSpacing/2); n++;
  1127. XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1128. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1129. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1130. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1131. XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel); n++;
  1132. XtSetArg(args[n], XmNbottomOffset, 5*style.verticalSpacing); n++;
  1133. XtSetValues (XtParent(screen.saverList), args, n);
  1134. /* saverArea */
  1135. n=0;
  1136. XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1137. XtSetArg(args[n], XmNtopWidget, XtParent(screen.saverList)); n++;
  1138. XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1139. XtSetArg(args[n], XmNleftWidget, XtParent(screen.saverList)); n++;
  1140. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1141. XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1142. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1143. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1144. XtSetArg(args[n], XmNbottomWidget, XtParent(screen.saverList)); n++;
  1145. XtSetValues (screen.saverAreaFrame, args, n);
  1146. XtRemoveCallback(style.screenDialog, XmNmapCallback, formLayoutCB, NULL);
  1147. }
  1148. /*+++++++++++++++++++++++++++++++++++++++*/
  1149. /* no_svr_ext_formLayoutCB */
  1150. /*+++++++++++++++++++++++++++++++++++++++*/
  1151. static void
  1152. no_svr_ext_formLayoutCB(
  1153. Widget w,
  1154. XtPointer client_data,
  1155. XtPointer call_data )
  1156. {
  1157. int n;
  1158. Arg args[MAX_ARGS];
  1159. Dimension ScaleHeight;
  1160. Dimension LabelHeight;
  1161. Dimension RadioHeight;
  1162. Dimension RadioOffset, ScaleOffset;
  1163. /* calculate width and height information */
  1164. ScaleHeight = XtHeight(XtParent(screen.timeOutScale));
  1165. LabelHeight = XtHeight(screen.timeOutLabel);
  1166. RadioHeight = XtHeight(screen.saverRadioBox);
  1167. RadioOffset = ((Dimension) (RadioHeight - LabelHeight) / 2) - 2;
  1168. ScaleOffset = 0;
  1169. /* do form attachments */
  1170. /* Picture Label */
  1171. n=0;
  1172. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1173. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1174. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1175. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1176. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1177. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1178. XtSetValues (screen.pictLabel, args, n);
  1179. /* system Default */
  1180. n=0;
  1181. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1182. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1183. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1184. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1185. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1186. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1187. XtSetValues (screen.systemDefault, args, n);
  1188. /* saver titlebox */
  1189. n=0;
  1190. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1191. XtSetArg(args[n], XmNtopWidget, screen.pictLabel); n++;
  1192. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1193. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1194. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1195. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1196. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1197. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1198. XtSetValues (screen.saverFrame, args, n);
  1199. /* saver label */
  1200. n=0;
  1201. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1202. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1203. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1204. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1205. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1206. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1207. XtSetValues (screen.saverLabel, args, n);
  1208. /* saver Radiobox */
  1209. n=0;
  1210. XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1211. XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++;
  1212. XtSetArg(args[n], XmNtopOffset, -RadioOffset); n++;
  1213. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1214. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1215. XtSetArg(args[n], XmNleftWidget, screen.saverLabel); n++;
  1216. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1217. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1218. XtSetValues (screen.saverRadioBox, args, n);
  1219. /* TimeOut Label */
  1220. n=0;
  1221. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1222. XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++;
  1223. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing + ScaleHeight - LabelHeight); n++;
  1224. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1225. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1226. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1227. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1228. XtSetValues (screen.timeOutLabel, args, n);
  1229. /* TimeOut Scale */
  1230. n=0;
  1231. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1232. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1233. XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++;
  1234. XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++;
  1235. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1236. XtSetArg(args[n], XmNleftWidget, screen.timeOutLabel);n++;
  1237. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1238. XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1239. XtSetArg(args[n], XmNrightWidget, screen.saverMinutesLabel);n++;
  1240. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1241. XtSetValues (screen.timeOutScale, args, n);
  1242. /* Minutes label */
  1243. n=0;
  1244. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1245. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1246. XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++;
  1247. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1248. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1249. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1250. XtSetValues (screen.saverMinutesLabel, args, n);
  1251. /* lock titlebox */
  1252. n=0;
  1253. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1254. XtSetArg(args[n], XmNtopWidget, screen.saverFrame); n++;
  1255. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1256. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1257. XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
  1258. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1259. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1260. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1261. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1262. XtSetValues (screen.lockFrame, args, n);
  1263. /* locking radiobox */
  1264. n=0;
  1265. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1266. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1267. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  1268. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1269. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1270. XtSetValues (screen.lockingRadioBox, args, n);
  1271. /* preview label */
  1272. n=0;
  1273. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1274. XtSetArg(args[n], XmNtopWidget, screen.lockingRadioBox); n++;
  1275. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  1276. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1277. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1278. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1279. XtSetValues (screen.prevLabel, args, n);
  1280. /* cycleTime Label */
  1281. n=0;
  1282. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1283. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1284. XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
  1285. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1286. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1287. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1288. XtSetValues (screen.cycleTimeLabel, args, n);
  1289. /* cycleTime Scale */
  1290. n=0;
  1291. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1292. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1293. XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++;
  1294. XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++;
  1295. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1296. XtSetArg(args[n], XmNleftWidget, screen.cycleTimeLabel);n++;
  1297. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1298. XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  1299. XtSetArg(args[n], XmNrightWidget, screen.cycleMinutesLabel);n++;
  1300. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1301. XtSetValues (screen.cycleTimeScale, args, n);
  1302. /* Minutes label */
  1303. n=0;
  1304. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  1305. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1306. XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++;
  1307. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  1308. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1309. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1310. XtSetValues (screen.cycleMinutesLabel, args, n);
  1311. /* scrolled list */
  1312. n = 0;
  1313. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1314. XtSetArg (args[n], XmNtopWidget, screen.prevLabel); n++;
  1315. XtSetArg (args[n], XmNtopOffset, style.verticalSpacing); n++;
  1316. XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  1317. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1318. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1319. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1320. XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel); n++;
  1321. XtSetArg(args[n], XmNbottomOffset, 5*style.verticalSpacing); n++;
  1322. XtSetValues (XtParent(screen.saverList), args, n);
  1323. /* saverArea */
  1324. n=0;
  1325. XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1326. XtSetArg(args[n], XmNtopWidget, XtParent(screen.saverList)); n++;
  1327. XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1328. XtSetArg(args[n], XmNleftWidget, XtParent(screen.saverList)); n++;
  1329. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  1330. XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1331. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  1332. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1333. XtSetArg(args[n], XmNbottomWidget, XtParent(screen.saverList)); n++;
  1334. XtSetValues (screen.saverAreaFrame, args, n);
  1335. XtRemoveCallback(style.screenDialog, XmNmapCallback, no_svr_ext_formLayoutCB, NULL);
  1336. }
  1337. /*+++++++++++++++++++++++++++++++++++++++*/
  1338. /* _DtmapCB_screenDialog */
  1339. /*+++++++++++++++++++++++++++++++++++++++*/
  1340. static void
  1341. _DtmapCB_screenDialog(
  1342. Widget w,
  1343. XtPointer client_data,
  1344. XtPointer call_data )
  1345. {
  1346. static int first_time = 1;
  1347. int n;
  1348. Arg args[MAX_ARGS];
  1349. XmString string;
  1350. Boolean lock_on, saver_on;
  1351. if (first_time)
  1352. {
  1353. DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
  1354. if (!save.restoreFlag)
  1355. putDialog ((Widget)client_data, w);
  1356. /* Retrieve the value for the saver slider from xrdb */
  1357. screen.saverTimeout_xrdb = atoi((char *)style.xrdb.timeoutScale);
  1358. if (screen.saverTimeout_xrdb < 1)
  1359. screen.saverTimeout_xrdb = 10;
  1360. /* Retrieve the value for the lock slider from xrdb */
  1361. screen.lockTimeout_xrdb = atoi((char *)style.xrdb.lockoutScale);
  1362. if (screen.lockTimeout_xrdb < 1)
  1363. screen.lockTimeout_xrdb = 30;
  1364. /* initialize the value of savertimeout and locktimeout and cycle time to the */
  1365. /* initial state or to the values retrieved from xrdb if the corresponding*/
  1366. /* initial state is zero */
  1367. if (style.smState.smSaverTimeout)
  1368. screen.saverTimeout = style.smState.smSaverTimeout / 60;
  1369. else
  1370. screen.saverTimeout = screen.saverTimeout_xrdb;
  1371. if (style.smState.smLockTimeout)
  1372. screen.lockTimeout = style.smState.smLockTimeout / 60;
  1373. else
  1374. screen.lockTimeout = screen.lockTimeout_xrdb;
  1375. if (style.smState.smCycleTimeout)
  1376. screen.cycleTimeout = style.smState.smCycleTimeout / 60;
  1377. else
  1378. screen.cycleTimeout = 0;
  1379. /* set the value of the scales */
  1380. XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL);
  1381. XtVaSetValues(screen.lockOutScale, XmNvalue, screen.lockTimeout, NULL);
  1382. XtVaSetValues(screen.cycleTimeScale, XmNvalue, screen.cycleTimeout , NULL);
  1383. /* set the value of the saver toggles */
  1384. XmToggleButtonGadgetSetState(screen.saverOn,
  1385. style.smState.smSaverTimeout ? True : False, False);
  1386. XmToggleButtonGadgetSetState(screen.saverOff,
  1387. !style.smState.smSaverTimeout ? True : False, False );
  1388. XmToggleButtonGadgetSetState(screen.lockOn,
  1389. style.smState.smLockTimeout ? True : False, False);
  1390. XmToggleButtonGadgetSetState(screen.lockOff,
  1391. !style.smState.smLockTimeout ? True : False, False);
  1392. /* make saver widgets insensitive if screen saver is off */
  1393. /* also blank out the preview label widget */
  1394. if (XmToggleButtonGadgetGetState(screen.saverOff))
  1395. {
  1396. XtSetSensitive(screen.saverList, False);
  1397. XtSetSensitive(screen.saverArea, False);
  1398. XtSetSensitive(screen.timeOutLabel, False);
  1399. XtSetSensitive(screen.timeOutScale, False);
  1400. XtSetSensitive(screen.saverMinutesLabel, False);
  1401. XtSetSensitive(screen.cycleTimeLabel, False);
  1402. XtSetSensitive(screen.cycleTimeScale, False);
  1403. XtSetSensitive(screen.cycleMinutesLabel, False);
  1404. XtUnmanageChild(screen.prevLabel);
  1405. }
  1406. /* make saver widgets sensitive if screen saver is on */
  1407. /* also manage the preview label widget */
  1408. if (XmToggleButtonGadgetGetState(screen.saverOn))
  1409. {
  1410. XtSetSensitive(screen.saverList, True);
  1411. XtSetSensitive(screen.saverArea, True);
  1412. XtSetSensitive(screen.timeOutLabel, True);
  1413. XtSetSensitive(screen.timeOutScale, True);
  1414. XtSetSensitive(screen.saverMinutesLabel, True);
  1415. XtManageChild(screen.prevLabel);
  1416. /* make cycletime scale sensitive if selected savers are more than 1 */
  1417. if (savers.selsaverCount > 1)
  1418. {
  1419. XtSetSensitive(screen.cycleTimeLabel, True);
  1420. XtSetSensitive(screen.cycleTimeScale, True);
  1421. XtSetSensitive(screen.cycleMinutesLabel, True);
  1422. }
  1423. else
  1424. {
  1425. XtSetSensitive(screen.cycleTimeLabel, False);
  1426. XtSetSensitive(screen.cycleTimeScale, False);
  1427. XtSetSensitive(screen.cycleMinutesLabel, False);
  1428. }
  1429. }
  1430. /* make lock widgets insensitive if lock screen is off */
  1431. if (XmToggleButtonGadgetGetState(screen.lockOff))
  1432. {
  1433. XtSetSensitive(screen.lockOutLabel, False);
  1434. XtSetSensitive(screen.lockOutScale, False);
  1435. XtSetSensitive(screen.lockMinutesLabel, False);
  1436. }
  1437. /* make lock widgets sensitive if lock screen is on */
  1438. if (XmToggleButtonGadgetGetState(screen.lockOn))
  1439. {
  1440. XtSetSensitive(screen.lockOutLabel, True);
  1441. XtSetSensitive(screen.lockOutScale, True);
  1442. XtSetSensitive(screen.lockMinutesLabel, True);
  1443. }
  1444. if (!style.smState.smSaverTimeout)
  1445. screen.origTimeout = screen.newTimeout = style.smState.smLockTimeout;
  1446. else
  1447. if (!style.smState.smLockTimeout)
  1448. screen.origTimeout = screen.newTimeout = style.smState.smSaverTimeout;
  1449. else
  1450. screen.origTimeout =
  1451. screen.newTimeout =
  1452. MIN(style.smState.smSaverTimeout, style.smState.smLockTimeout);
  1453. first_time = 0;
  1454. }
  1455. /* check the saver values from X - need to do this everytime dialog is mapped because */
  1456. /* the user may have changed settings thru X while style manager has been running */
  1457. /* if the value of the timeout retrieved from X is not equal to the new timeout set in the */
  1458. /* style manager interface, then set both lock time and saver time scales to value retrieved from */
  1459. /* X, otherwise leave them alone */
  1460. XGetScreenSaver(style.display, &screen.xTimeout, &screen.interval,
  1461. &screen.blanking, &screen.exposures);
  1462. screen.new_blanking = DontPreferBlanking;
  1463. if (screen.xTimeout < 0)
  1464. screen.xTimeout = 0;
  1465. else
  1466. if ((screen.xTimeout < 60) && (screen.xTimeout > 1))
  1467. screen.xTimeout = 60;
  1468. else
  1469. if (screen.xTimeout > TIMEOUT_MAX * 60)
  1470. screen.xTimeout = TIMEOUT_MAX * 60;
  1471. if (screen.xTimeout < 0)
  1472. screen.xTimeout = 0;
  1473. else
  1474. if ((screen.xTimeout < 60) && (screen.xTimeout > 1))
  1475. screen.xTimeout = 60;
  1476. else
  1477. if (screen.xTimeout > TIMEOUT_MAX * 60)
  1478. screen.xTimeout = TIMEOUT_MAX * 60;
  1479. screen.timeMismatch = False;
  1480. if (screen.xTimeout != screen.newTimeout)
  1481. {
  1482. screen.timeMismatch = True;
  1483. screen.newTimeout = screen.xTimeout;
  1484. if (screen.xTimeout)
  1485. {
  1486. screen.saverTimeout = screen.xTimeout / 60;
  1487. screen.lockTimeout = screen.xTimeout / 60;
  1488. }
  1489. else
  1490. {
  1491. screen.saverTimeout = screen.saverTimeout_xrdb;
  1492. screen.lockTimeout = screen.lockTimeout_xrdb;
  1493. }
  1494. /* set the value of the saver widgets */
  1495. XmToggleButtonGadgetSetState(screen.saverOn, screen.xTimeout ? True : False, False);
  1496. XmToggleButtonGadgetSetState(screen.saverOff, !screen.xTimeout ? True : False, False);
  1497. XmToggleButtonGadgetSetState(screen.lockOn, screen.xTimeout ? True : False, False);
  1498. XmToggleButtonGadgetSetState(screen.lockOff, !screen.xTimeout ? True : False, False);
  1499. /* set the value of the scales */
  1500. XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL);
  1501. XtVaSetValues(screen.lockOutScale, XmNvalue, screen.lockTimeout_xrdb, NULL);
  1502. /* make saver widgets insensitive if screen saver is off */
  1503. /* also blankout the preview label widget */
  1504. if (XmToggleButtonGadgetGetState(screen.saverOff))
  1505. {
  1506. XtSetSensitive(screen.saverList, False);
  1507. XtSetSensitive(screen.saverArea, False);
  1508. XtSetSensitive(screen.timeOutLabel, False);
  1509. XtSetSensitive(screen.timeOutScale, False);
  1510. XtSetSensitive(screen.saverMinutesLabel, False);
  1511. XtSetSensitive(screen.cycleTimeLabel, False);
  1512. XtSetSensitive(screen.cycleTimeScale, False);
  1513. XtSetSensitive(screen.cycleMinutesLabel, False);
  1514. XtUnmanageChild(screen.prevLabel);
  1515. }
  1516. /* make saver widgets sensitive if screen saver is on */
  1517. /* also manage the preview label widget */
  1518. if (XmToggleButtonGadgetGetState(screen.saverOn))
  1519. {
  1520. XtSetSensitive(screen.saverList, True);
  1521. XtSetSensitive(screen.saverArea, True);
  1522. XtSetSensitive(screen.timeOutLabel, True);
  1523. XtSetSensitive(screen.timeOutScale, True);
  1524. XtSetSensitive(screen.saverMinutesLabel, True);
  1525. XtManageChild(screen.prevLabel);
  1526. /* make cycletime scale sensitive if selected savers are more than 1 */
  1527. if (savers.selsaverCount > 1)
  1528. {
  1529. XtSetSensitive(screen.cycleTimeLabel, True);
  1530. XtSetSensitive(screen.cycleTimeScale, True);
  1531. XtSetSensitive(screen.cycleMinutesLabel, True);
  1532. }
  1533. else
  1534. {
  1535. XtSetSensitive(screen.cycleTimeLabel, False);
  1536. XtSetSensitive(screen.cycleTimeScale, False);
  1537. XtSetSensitive(screen.cycleMinutesLabel, False);
  1538. }
  1539. }
  1540. /* make lock widgets insensitive if lock screen is off */
  1541. if (XmToggleButtonGadgetGetState(screen.lockOff))
  1542. {
  1543. XtSetSensitive(screen.lockOutLabel, False);
  1544. XtSetSensitive(screen.lockOutScale, False);
  1545. XtSetSensitive(screen.lockMinutesLabel, False);
  1546. }
  1547. /* make lock widgets sensitive if lock screen is on */
  1548. if (XmToggleButtonGadgetGetState(screen.lockOn))
  1549. {
  1550. XtSetSensitive(screen.lockOutLabel, True);
  1551. XtSetSensitive(screen.lockOutScale, True);
  1552. XtSetSensitive(screen.lockMinutesLabel, True);
  1553. }
  1554. }
  1555. /* run the current screen saver only if screen saver is turned on and a valid saver exists*/
  1556. if (XmToggleButtonGadgetGetState(screen.saverOn) && savers.saverCount && !savers.saverstate)
  1557. {
  1558. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  1559. savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1,
  1560. savers.current_saver, style.screenDialog);
  1561. string = XmStringCreateLocalized (savers.current_saverDesc);
  1562. XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL);
  1563. XmStringFree(string);
  1564. }
  1565. }
  1566. /*+++++++++++++++++++++++++++++++++++++++*/
  1567. /* no_svr_ext_DtmapCB_screenDialog */
  1568. /*+++++++++++++++++++++++++++++++++++++++*/
  1569. static void
  1570. no_svr_ext_DtmapCB_screenDialog(
  1571. Widget w,
  1572. XtPointer client_data,
  1573. XtPointer call_data )
  1574. {
  1575. static int first_time = 1;
  1576. int n;
  1577. Arg args[MAX_ARGS];
  1578. XmString string;
  1579. int mintime;
  1580. if (first_time)
  1581. {
  1582. DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
  1583. if (!save.restoreFlag)
  1584. putDialog ((Widget)client_data, w);
  1585. /* Retrieve the value for the saver slider from xrdb */
  1586. screen.saverTimeout_xrdb = atoi((char *)style.xrdb.timeoutScale);
  1587. if (screen.saverTimeout_xrdb < 1)
  1588. screen.saverTimeout_xrdb = 10;
  1589. if (style.smState.smCycleTimeout)
  1590. screen.cycleTimeout = style.smState.smCycleTimeout / 60;
  1591. else
  1592. screen.cycleTimeout = 0;
  1593. /* set the value of the cycle time scale */
  1594. XtVaSetValues(screen.cycleTimeScale, XmNvalue, screen.cycleTimeout , NULL);
  1595. /* set the initial condition for the locking RadioBoxes */
  1596. XmToggleButtonGadgetSetState(screen.useSaversOn,
  1597. style.smState.smSaverTimeout ? True : False, False);
  1598. XmToggleButtonGadgetSetState(screen.useSaversOff,
  1599. style.smState.smSaverTimeout ? False : True, False);
  1600. if (style.smState.smSaverTimeout)
  1601. {
  1602. XtSetSensitive(screen.saverList, True);
  1603. XtSetSensitive(screen.saverArea, True);
  1604. if (savers.selsaverCount > 1)
  1605. {
  1606. XtSetSensitive(screen.cycleTimeLabel, True);
  1607. XtSetSensitive(screen.cycleTimeScale, True);
  1608. XtSetSensitive(screen.cycleMinutesLabel, True);
  1609. }
  1610. else
  1611. {
  1612. XtSetSensitive(screen.cycleTimeLabel, False);
  1613. XtSetSensitive(screen.cycleTimeScale, False);
  1614. XtSetSensitive(screen.cycleMinutesLabel, False);
  1615. }
  1616. XtManageChild(screen.prevLabel);
  1617. SmNewSaverTime(60);
  1618. }
  1619. else
  1620. {
  1621. XtSetSensitive(screen.saverList, False);
  1622. XtSetSensitive(screen.saverArea, False);
  1623. XtSetSensitive(screen.cycleTimeLabel, False);
  1624. XtSetSensitive(screen.cycleTimeScale, False);
  1625. XtSetSensitive(screen.cycleMinutesLabel, False);
  1626. XtUnmanageChild(screen.prevLabel);
  1627. SmNewSaverTime(0);
  1628. }
  1629. screen.newTimeout = screen.origTimeout = 0;
  1630. first_time = 0;
  1631. }
  1632. /* check the saver values from X - need to do this everytime dialog is mapped because */
  1633. /* the user may have changed settings thru X while style manager has been running */
  1634. /* if the value of the timeout retrieved from X is not equal to the new timeout set in the */
  1635. /* style manager interface, then set both lock time and saver time scales to value retrieved from */
  1636. /* X, otherwise leave them alone */
  1637. XGetScreenSaver(style.display, &screen.xTimeout, &screen.interval,
  1638. &screen.blanking, &screen.exposures);
  1639. screen.new_blanking = PreferBlanking;
  1640. if (screen.xTimeout < 0)
  1641. screen.xTimeout = 0;
  1642. else
  1643. if ((screen.xTimeout < 60) && (screen.xTimeout > 1))
  1644. screen.xTimeout = 60;
  1645. else
  1646. if (screen.xTimeout > TIMEOUT_MAX * 60)
  1647. screen.xTimeout = TIMEOUT_MAX * 60;
  1648. if (screen.xTimeout != screen.newTimeout)
  1649. {
  1650. screen.origTimeout = screen.newTimeout = screen.xTimeout;
  1651. screen.saverTimeout = screen.xTimeout / 60;
  1652. }
  1653. /* set the value of the saver widgets */
  1654. XmToggleButtonGadgetSetState(screen.saverOn, screen.newTimeout ? True : False, False);
  1655. XmToggleButtonGadgetSetState(screen.saverOff, !screen.newTimeout ? True : False, False);
  1656. if (!screen.saverTimeout)
  1657. screen.saverTimeout = screen.saverTimeout_xrdb;
  1658. XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL);
  1659. /* make saver widgets insensitive if screen saver is off */
  1660. if (XmToggleButtonGadgetGetState(screen.saverOff))
  1661. {
  1662. XtSetSensitive(screen.timeOutLabel, False);
  1663. XtSetSensitive(screen.timeOutScale, False);
  1664. XtSetSensitive(screen.saverMinutesLabel, False);
  1665. }
  1666. /* make saver widgets sensitive if screen saver is on */
  1667. if (XmToggleButtonGadgetGetState(screen.saverOn))
  1668. {
  1669. XtSetSensitive(screen.timeOutLabel, True);
  1670. XtSetSensitive(screen.timeOutScale, True);
  1671. XtSetSensitive(screen.saverMinutesLabel, True);
  1672. }
  1673. /* run the current screen saver only if the useSaversOn toggle is enabled and valid saver exist*/
  1674. if (XmToggleButtonGadgetGetState(screen.useSaversOn) && savers.saverCount && !savers.saverstate)
  1675. {
  1676. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  1677. savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1,
  1678. savers.current_saver, style.screenDialog);
  1679. string = XmStringCreateLocalized (savers.current_saverDesc);
  1680. XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL);
  1681. XmStringFree(string);
  1682. }
  1683. }
  1684. /*****************************************/
  1685. /* timeOutvalueChangedCB */
  1686. /* set the timeout to be the minimum of */
  1687. /* the lock scale and timeout scale */
  1688. /*****************************************/
  1689. static void
  1690. timeOutvalueChangedCB(
  1691. Widget w,
  1692. XtPointer client_data,
  1693. XtPointer call_data )
  1694. {
  1695. int n;
  1696. Arg args[MAX_ARGS];
  1697. n=0;
  1698. XtSetArg(args[n], XmNvalue, &screen.saverTimeout); n++;
  1699. XtGetValues(screen.timeOutScale, args, n);
  1700. n=0;
  1701. XtSetArg(args[n], XmNvalue, &screen.lockTimeout); n++;
  1702. XtGetValues(screen.lockOutScale, args, n);
  1703. /* set newTimeout to the min value of lock scale and saver scale */
  1704. /* unless either screen saver or lock is off */
  1705. if (!XmToggleButtonGadgetGetState(screen.lockOn))
  1706. screen.newTimeout = screen.saverTimeout * 60;
  1707. else
  1708. if (!XmToggleButtonGadgetGetState(screen.saverOn))
  1709. screen.newTimeout = screen.lockTimeout * 60;
  1710. else
  1711. screen.newTimeout = MIN(screen.saverTimeout, screen.lockTimeout) * 60;
  1712. /* register new timeout with X */
  1713. XSetScreenSaver(style.display, screen.newTimeout,
  1714. screen.interval, screen.new_blanking, screen.exposures);
  1715. screen.systemDefaultFlag = False;
  1716. }
  1717. /*****************************************/
  1718. /* no_svr_ext_timeOutvalueChangedCB */
  1719. /* set the timeout to be the minimum of */
  1720. /* the lock scale and timeout scale */
  1721. /*****************************************/
  1722. static void
  1723. no_svr_ext_timeOutvalueChangedCB(
  1724. Widget w,
  1725. XtPointer client_data,
  1726. XtPointer call_data )
  1727. {
  1728. int n;
  1729. Arg args[MAX_ARGS];
  1730. n=0;
  1731. XtSetArg(args[n], XmNvalue, &screen.saverTimeout); n++;
  1732. XtGetValues(screen.timeOutScale, args, n);
  1733. /* set newTimeout to the value of saver scale */
  1734. screen.newTimeout = screen.saverTimeout * 60;
  1735. /* register new timeout with X */
  1736. XSetScreenSaver(style.display, screen.newTimeout,
  1737. screen.interval, screen.new_blanking, screen.exposures);
  1738. screen.systemDefaultFlag = False;
  1739. }
  1740. /*+++++++++++++++++++++++++++++++++++++++*/
  1741. /* saverToggleCB */
  1742. /*+++++++++++++++++++++++++++++++++++++++*/
  1743. static void
  1744. saverToggleCB(
  1745. Widget w,
  1746. XtPointer client_data,
  1747. XtPointer call_data )
  1748. {
  1749. int n;
  1750. Arg args[MAX_ARGS];
  1751. Boolean set;
  1752. XmString string;
  1753. XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data;
  1754. set = (Boolean) cb->set;
  1755. if (w == screen.saverOff && !set )
  1756. {
  1757. return;
  1758. }
  1759. if (w == screen.saverOff && set)
  1760. {
  1761. /* Terminate the screen saver that is currently running */
  1762. if (savers.saverstate)
  1763. {
  1764. _DtSaverStop(style.display, savers.saverstate);
  1765. savers.saverstate = NULL;
  1766. XSync(style.display, False);
  1767. XClearWindow(style.display, XtWindow(screen.saverArea));
  1768. }
  1769. XtSetSensitive(screen.saverList, False);
  1770. XtSetSensitive(screen.saverArea, False);
  1771. XtSetSensitive(screen.timeOutLabel, False);
  1772. XtSetSensitive(screen.timeOutScale, False);
  1773. XtSetSensitive(screen.saverMinutesLabel, False);
  1774. XtSetSensitive(screen.cycleTimeLabel, False);
  1775. XtSetSensitive(screen.cycleTimeScale, False);
  1776. XtSetSensitive(screen.cycleMinutesLabel, False);
  1777. /* do not display preview string */
  1778. XtUnmanageChild(screen.prevLabel);
  1779. /* set the background color of the saver window to the */
  1780. /* secondary color ID */
  1781. XSync(style.display, False);
  1782. XtVaSetValues(screen.saverArea, XmNbackground, savers.bg, NULL);
  1783. XClearWindow(style.display, XtWindow(screen.saverArea));
  1784. /* set the new timeout for the X server - note that since */
  1785. /* screen saver is disabled, the new timeout is now the value of the */
  1786. /* lock slider or zero if lock is disabled */
  1787. if (XmToggleButtonGadgetGetState(screen.lockOn))
  1788. screen.newTimeout = screen.lockTimeout * 60;
  1789. else
  1790. screen.newTimeout = 0;
  1791. /* let the session manger know not to run any savers */
  1792. SmNewSaverTime(0);
  1793. }
  1794. if (w == screen.saverOn && !set)
  1795. {
  1796. return;
  1797. }
  1798. if (w == screen.saverOn && set)
  1799. {
  1800. XtSetSensitive(screen.saverList, True);
  1801. XtSetSensitive(screen.saverArea, True);
  1802. XtSetSensitive(screen.timeOutLabel, True);
  1803. XtSetSensitive(screen.timeOutScale, True);
  1804. XtSetSensitive(screen.saverMinutesLabel , True);
  1805. if (savers.selsaverCount > 1)
  1806. {
  1807. XtSetSensitive(screen.cycleTimeLabel, True);
  1808. XtSetSensitive(screen.cycleTimeScale, True);
  1809. XtSetSensitive(screen.cycleMinutesLabel, True );
  1810. }
  1811. else
  1812. {
  1813. XtSetSensitive(screen.cycleTimeLabel, False);
  1814. XtSetSensitive(screen.cycleTimeScale, False);
  1815. XtSetSensitive(screen.cycleMinutesLabel, False);
  1816. }
  1817. if (savers.saverCount)
  1818. {
  1819. /* display the preview label */
  1820. XtManageChild(screen.prevLabel);
  1821. /* Restart the screen saver that is is currently selected */
  1822. if (!savers.saverstate)
  1823. {
  1824. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  1825. savers.saverstate = _DtSaverStart(style.display,
  1826. &screen.saverArea, 1, savers.current_saver,
  1827. style.screenDialog);
  1828. }
  1829. /* set the new timeout for the X server - note that since */
  1830. /* screen saver is enabled, the new timeout is now the value of the */
  1831. /* saver slider or the minimum of the timeout sliders */
  1832. }
  1833. if (!XmToggleButtonGadgetGetState(screen.lockOn))
  1834. screen.newTimeout = screen.saverTimeout * 60;
  1835. else
  1836. screen.newTimeout = MIN(screen.saverTimeout, screen.lockTimeout) * 60;
  1837. /* let the session manger know to run savers */
  1838. SmNewSaverTime(screen.newTimeout);
  1839. }
  1840. XSetScreenSaver(style.display, screen.newTimeout,
  1841. screen.interval, screen.new_blanking, screen.exposures);
  1842. screen.systemDefaultFlag = False;
  1843. }
  1844. /*+++++++++++++++++++++++++++++++++++++++*/
  1845. /* no_svr_ext_saverToggleCB */
  1846. /*+++++++++++++++++++++++++++++++++++++++*/
  1847. static void
  1848. no_svr_ext_saverToggleCB(
  1849. Widget w,
  1850. XtPointer client_data,
  1851. XtPointer call_data )
  1852. {
  1853. int n;
  1854. Arg args[MAX_ARGS];
  1855. Boolean set;
  1856. XmString string;
  1857. XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data;
  1858. set = (Boolean) cb->set;
  1859. if (w == screen.saverOff && !set )
  1860. {
  1861. return;
  1862. }
  1863. if (w == screen.saverOff && set)
  1864. {
  1865. XtSetSensitive(screen.timeOutLabel, False);
  1866. XtSetSensitive(screen.timeOutScale, False);
  1867. XtSetSensitive(screen.saverMinutesLabel, False);
  1868. /* set the new timeout for the X server - note that since */
  1869. /* screen saver is disabled, the new timeout is now zero */
  1870. screen.newTimeout = 0;
  1871. }
  1872. if (w == screen.saverOn && !set)
  1873. {
  1874. return;
  1875. }
  1876. if (w == screen.saverOn && set)
  1877. {
  1878. XtSetSensitive(screen.timeOutLabel, True);
  1879. XtSetSensitive(screen.timeOutScale, True);
  1880. XtSetSensitive(screen.saverMinutesLabel , True);
  1881. /* register the new timeout with the X server - note that since */
  1882. /* screen saver is enabled, the new timeout is now the value of the */
  1883. /* saver slider */
  1884. screen.newTimeout = screen.saverTimeout * 60;
  1885. }
  1886. XSetScreenSaver(style.display, screen.newTimeout,
  1887. screen.interval, screen.new_blanking, screen.exposures);
  1888. screen.systemDefaultFlag = False;
  1889. }
  1890. /*+++++++++++++++++++++++++++++++++++++++*/
  1891. /* lock ToggleCB */
  1892. /*+++++++++++++++++++++++++++++++++++++++*/
  1893. static void
  1894. lockToggleCB(
  1895. Widget w,
  1896. XtPointer client_data,
  1897. XtPointer call_data )
  1898. {
  1899. int n;
  1900. Arg args[MAX_ARGS];
  1901. Boolean set;
  1902. XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data;
  1903. set = (Boolean) cb->set;
  1904. if (w == screen.lockOff && !set )
  1905. {
  1906. return;
  1907. }
  1908. if (w == screen.lockOff && set)
  1909. {
  1910. XtSetSensitive(screen.lockOutLabel, False);
  1911. XtSetSensitive(screen.lockOutScale, False);
  1912. XtSetSensitive(screen.lockMinutesLabel, False);
  1913. /* register the new timeout with the X server - note that since */
  1914. /* lock is disabled, the new timeout is now the value of the */
  1915. /* saver slider or zero if saver is disabled */
  1916. if (XmToggleButtonGadgetGetState(screen.saverOn))
  1917. screen.newTimeout = screen.saverTimeout * 60;
  1918. else
  1919. screen.newTimeout = 0;
  1920. XSetScreenSaver(style.display, screen.newTimeout,
  1921. screen.interval, screen.new_blanking, screen.exposures);
  1922. }
  1923. if (w == screen.lockOn && !set)
  1924. {
  1925. return;
  1926. }
  1927. if (w == screen.lockOn && set)
  1928. {
  1929. XtSetSensitive(screen.lockOutLabel, True);
  1930. XtSetSensitive(screen.lockOutScale, True);
  1931. XtSetSensitive(screen.lockMinutesLabel, True);
  1932. /* register the new timeout with the X server - note that since */
  1933. /* lock is disabled, the new timeout is now the value of the */
  1934. /* lock slider or the minimum of the two timeout sliders */
  1935. if (!XmToggleButtonGadgetGetState(screen.saverOn))
  1936. screen.newTimeout = screen.lockTimeout * 60;
  1937. else
  1938. screen.newTimeout = MIN(screen.saverTimeout, screen.lockTimeout) * 60;
  1939. XSetScreenSaver(style.display, screen.newTimeout,
  1940. screen.interval, screen.new_blanking, screen.exposures);
  1941. }
  1942. screen.systemDefaultFlag = False;
  1943. }
  1944. /*+++++++++++++++++++++++++++++++++++++++*/
  1945. /* saversToggleCB */
  1946. /*+++++++++++++++++++++++++++++++++++++++*/
  1947. static void
  1948. saversToggleCB(
  1949. Widget w,
  1950. XtPointer client_data,
  1951. XtPointer call_data )
  1952. {
  1953. int n;
  1954. Arg args[MAX_ARGS];
  1955. Boolean set;
  1956. XmString string;
  1957. XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data;
  1958. set = (Boolean) cb->set;
  1959. if (w == screen.useSaversOff && !set )
  1960. {
  1961. return;
  1962. }
  1963. if (w == screen.useSaversOff && set)
  1964. {
  1965. /* Terminate the screen saver that is currently running */
  1966. if (savers.saverstate)
  1967. {
  1968. _DtSaverStop(style.display, savers.saverstate);
  1969. savers.saverstate = NULL;
  1970. XSync(style.display, False);
  1971. XClearWindow(style.display, XtWindow(screen.saverArea));
  1972. }
  1973. XtSetSensitive(screen.saverList, False);
  1974. XtSetSensitive(screen.saverArea, False);
  1975. XtSetSensitive(screen.cycleTimeLabel, False);
  1976. XtSetSensitive(screen.cycleTimeScale, False);
  1977. XtSetSensitive(screen.cycleMinutesLabel, False);
  1978. /* do not display preview string */
  1979. XtUnmanageChild(screen.prevLabel);
  1980. /* set the background color of the saver window to the */
  1981. /* secondary color ID */
  1982. XSync(style.display, False);
  1983. XtVaSetValues(screen.saverArea, XmNbackground, savers.bg, NULL);
  1984. XClearWindow(style.display, XtWindow(screen.saverArea));
  1985. /* let the session manger know not to run any savers */
  1986. SmNewSaverTime(0);
  1987. }
  1988. if (w == screen.useSaversOn && !set)
  1989. {
  1990. return;
  1991. }
  1992. if (w == screen.useSaversOn && set)
  1993. {
  1994. XtSetSensitive(screen.saverList, True);
  1995. XtSetSensitive(screen.saverArea, True);
  1996. if (savers.selsaverCount > 1)
  1997. {
  1998. XtSetSensitive(screen.cycleTimeLabel, True);
  1999. XtSetSensitive(screen.cycleTimeScale, True);
  2000. XtSetSensitive(screen.cycleMinutesLabel, True);
  2001. }
  2002. if (savers.saverCount)
  2003. {
  2004. /* display the preview label */
  2005. XtManageChild(screen.prevLabel);
  2006. /* Restart the screen saver that is is currently selected */
  2007. if (!savers.saverstate)
  2008. {
  2009. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  2010. savers.saverstate = _DtSaverStart(style.display,
  2011. &screen.saverArea, 1, savers.current_saver, style.screenDialog);
  2012. }
  2013. }
  2014. /* let the session manger know to run the savers */
  2015. SmNewSaverTime(screen.saverTimeout*60);
  2016. }
  2017. }
  2018. /*+++++++++++++++++++++++++++++++++++++++*/
  2019. /* systemDefaultCB */
  2020. /*+++++++++++++++++++++++++++++++++++++++*/
  2021. static void
  2022. systemDefaultCB(
  2023. Widget w,
  2024. XtPointer client_data,
  2025. XtPointer call_data )
  2026. {
  2027. int n;
  2028. Arg args[MAX_ARGS];
  2029. screen.saverTimeout = SAVER_DEFAULT;
  2030. n=0;
  2031. XtSetArg(args[n], XmNvalue, screen.saverTimeout); n++;
  2032. XtSetValues(screen.timeOutScale, args, n);
  2033. screen.lockTimeout = LOCK_DEFAULT;
  2034. n=0;
  2035. XtSetArg(args[n], XmNvalue, screen.lockTimeout); n++;
  2036. XtSetValues(screen.lockOutScale, args, n);
  2037. XmToggleButtonGadgetSetState(screen.lockOff, True, True);
  2038. screen.cycleTimeout = CYCLE_DEFAULT;
  2039. n=0;
  2040. XtSetArg(args[n], XmNvalue, screen.cycleTimeout); n++;
  2041. XtSetValues(screen.cycleTimeScale, args, n);
  2042. XmToggleButtonGadgetSetState(screen.saverOn, True, True);
  2043. screen.newTimeout = MIN(SAVER_DEFAULT, LOCK_DEFAULT) * 60;
  2044. /* register new timeout with X */
  2045. XSetScreenSaver(style.display, screen.newTimeout,
  2046. screen.interval, screen.new_blanking, screen.exposures);
  2047. screen.systemDefaultFlag = True;
  2048. }
  2049. /*+++++++++++++++++++++++++++++++++++++++*/
  2050. /* no_svr_ext_systemDefaultCB */
  2051. /*+++++++++++++++++++++++++++++++++++++++*/
  2052. static void
  2053. no_svr_ext_systemDefaultCB(
  2054. Widget w,
  2055. XtPointer client_data,
  2056. XtPointer call_data )
  2057. {
  2058. int n;
  2059. Arg args[MAX_ARGS];
  2060. screen.saverTimeout = SAVER_DEFAULT;
  2061. n=0;
  2062. XtSetArg(args[n], XmNvalue, screen.saverTimeout); n++;
  2063. XtSetValues(screen.timeOutScale, args, n);
  2064. screen.cycleTimeout = CYCLE_DEFAULT;
  2065. n=0;
  2066. XtSetArg(args[n], XmNvalue, screen.cycleTimeout); n++;
  2067. XtSetValues(screen.cycleTimeScale, args, n);
  2068. XmToggleButtonGadgetSetState(screen.saverOn, True, True);
  2069. XmToggleButtonGadgetSetState(screen.useSaversOn, True, True);
  2070. screen.newTimeout = SAVER_DEFAULT * 60;
  2071. /* register new timeout with X */
  2072. XSetScreenSaver(style.display, screen.newTimeout,
  2073. screen.interval, screen.new_blanking, screen.exposures);
  2074. screen.systemDefaultFlag = True;
  2075. }
  2076. /*+++++++++++++++++++++++++++++++++++++++*/
  2077. /* ButtonCB */
  2078. /* callback for PushButtons in DialogBox */
  2079. /*+++++++++++++++++++++++++++++++++++++++*/
  2080. static void
  2081. ButtonCB(
  2082. Widget w,
  2083. XtPointer client_data,
  2084. XtPointer call_data )
  2085. {
  2086. int i, n, m;
  2087. Arg args[MAX_ARGS];
  2088. Boolean sel_matched = False;
  2089. Boolean lockset;
  2090. Boolean saverset;
  2091. Boolean flag;
  2092. static char screenres[48];
  2093. int mintime;
  2094. XtArgVal scratch;
  2095. DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
  2096. switch (cb->button_position)
  2097. {
  2098. case OK_BUTTON:
  2099. XtUnmanageChild (w);
  2100. /* terminate the saver that is currently running */
  2101. if (savers.saverstate)
  2102. {
  2103. _DtSaverStop(style.display, savers.saverstate);
  2104. savers.saverstate = NULL;
  2105. }
  2106. /* write saver timeout resource to xrdb to save scale value */
  2107. /* when screen saver is turned off */
  2108. saverset = XmToggleButtonGadgetGetState(screen.saverOn);
  2109. if (!saverset)
  2110. {
  2111. sprintf (screenres, "Dtstyle*timeoutScale: %d\n", screen.saverTimeout);
  2112. _DtAddToResource (style.display, screenres);
  2113. }
  2114. /* write lock timeout resource to xrdb to save scale value */
  2115. /* when lock is turned off */
  2116. lockset = XmToggleButtonGadgetGetState(screen.lockOn);
  2117. if (!lockset)
  2118. {
  2119. sprintf (screenres, "Dtstyle*lockoutScale: %d\n", screen.lockTimeout);
  2120. _DtAddToResource (style.display, screenres);
  2121. }
  2122. /* if sendSettings is true send message to Session Manager */
  2123. if(style.smState.smSendSettings)
  2124. {
  2125. if(screen.systemDefaultFlag)
  2126. {
  2127. SmDefaultScreenSettings();
  2128. }
  2129. else
  2130. {
  2131. SmNewScreenSettings(saverset||lockset ? screen.newTimeout : 0,
  2132. screen.new_blanking,
  2133. screen.interval,
  2134. screen.exposures);
  2135. }
  2136. }
  2137. if (savers.saverCount)
  2138. {
  2139. savers.selsaverActionNames = (char **) XtMalloc(sizeof(char *) *
  2140. savers.selsaverCount);
  2141. for (i=0; i<savers.selsaverCount; i++)
  2142. {
  2143. char *tmp = savers.saverActionNames[savers.selPositions[i] - 1];
  2144. savers.selsaverActionNames[i] = (char *) XtMalloc(strlen(tmp) + 1);
  2145. strcpy(savers.selsaverActionNames[i], tmp);
  2146. }
  2147. if (savers.selsaversList != NULL)
  2148. XtFree((char*) savers.selsaversList);
  2149. savers.selsaversList = build_selectedList(savers.selsaverActionNames,
  2150. savers.selsaverCount);
  2151. }
  2152. else
  2153. savers.selsaversList = NULL;
  2154. /* save the selected positions for later use */
  2155. savers.orig_selsaverCount = savers.selsaverCount;
  2156. if (savers.origSelPositions != NULL)
  2157. XtFree((char *) savers.origSelPositions);
  2158. savers.origSelPositions = (int *) XtMalloc(sizeof(int) * savers.orig_selsaverCount);
  2159. for (i=0; i<savers.orig_selsaverCount; i++)
  2160. savers.origSelPositions[i] = savers.selPositions[i];
  2161. /* free the allocated selected savers */
  2162. free_saverList(savers.selsaverActionNames, savers.selsaverCount);
  2163. savers.selsaverActionNames = NULL;
  2164. XtVaGetValues(screen.cycleTimeScale, XmNvalue, &scratch, NULL);
  2165. screen.cycleTimeout = scratch;
  2166. /* send new saver time, lock time and time per saver to SM if they have changed, */
  2167. /* flag value indicates which value has changed */
  2168. SmNewSaverSettings(saverset ? screen.saverTimeout*60 : 0,
  2169. lockset ? screen.lockTimeout*60 : 0,
  2170. screen.cycleTimeout*60,
  2171. savers.selsaversList);
  2172. style.smState.smSaverTimeout = saverset ? screen.saverTimeout*60 : 0;
  2173. style.smState.smLockTimeout = lockset ? screen.lockTimeout*60 : 0;
  2174. style.smState.smCycleTimeout = screen.cycleTimeout*60;
  2175. style.smSaver.saverList = savers.selsaversList;
  2176. screen.origTimeout = screen.newTimeout;
  2177. XSetScreenSaver(style.display, style.smState.smSaverTimeout,
  2178. style.smState.smCycleTimeout,
  2179. screen.new_blanking,
  2180. screen.exposures);
  2181. break;
  2182. case CANCEL_BUTTON:
  2183. XtUnmanageChild(w);
  2184. /* initialize the value of savertimeout and locktimeout and cycle time to the */
  2185. /* current state or to the values retrieved from xrdb if the corresponding */
  2186. /* initial state is zero */
  2187. if (style.smState.smSaverTimeout)
  2188. screen.saverTimeout = style.smState.smSaverTimeout / 60;
  2189. else
  2190. screen.saverTimeout = screen.saverTimeout_xrdb;
  2191. if (style.smState.smLockTimeout)
  2192. screen.lockTimeout = style.smState.smLockTimeout / 60;
  2193. else
  2194. screen.lockTimeout = screen.lockTimeout_xrdb;
  2195. if (style.smState.smCycleTimeout)
  2196. screen.cycleTimeout = style.smState.smCycleTimeout / 60;
  2197. else
  2198. screen.cycleTimeout = 0;
  2199. /* reset the value of the scales */
  2200. XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL);
  2201. XtVaSetValues(screen.lockOutScale, XmNvalue, screen.lockTimeout, NULL);
  2202. XtVaSetValues(screen.cycleTimeScale, XmNvalue, screen.cycleTimeout , NULL);
  2203. /* reset the value of the saver toggles */
  2204. XmToggleButtonGadgetSetState(screen.saverOn, style.smState.smSaverTimeout ? True : False, True);
  2205. XmToggleButtonGadgetSetState(screen.saverOff, !style.smState.smSaverTimeout ? True : False, True);
  2206. XmToggleButtonGadgetSetState(screen.lockOn, style.smState.smLockTimeout ? True : False, True);
  2207. XmToggleButtonGadgetSetState(screen.lockOff, !style.smState.smLockTimeout ? True : False, True);
  2208. /* reset the X timeout */
  2209. screen.newTimeout = screen.origTimeout;
  2210. XSetScreenSaver(style.display, screen.origTimeout, screen.interval,
  2211. screen.blanking, screen.exposures);
  2212. /* if timeMismatch is true, set the timeout to xTimeout so that the next time */
  2213. /* the interface is mapped the correct timeouts show up */
  2214. if (screen.timeMismatch)
  2215. XSetScreenSaver(style.display, screen.xTimeout, screen.interval,
  2216. screen.blanking,screen.exposures);
  2217. if (savers.saverCount)
  2218. {
  2219. /* reset the list selection back to the current state */
  2220. /* first deselect all items */
  2221. XmListDeselectAllItems(screen.saverList);
  2222. for (i=0; i<savers.orig_selsaverCount; i++)
  2223. XmListSelectPos(screen.saverList, savers.origSelPositions[i], False);
  2224. /* set the current saver to be the first saver in the selected list */
  2225. savers.current_saver = savers.saverActionNames[savers.origSelPositions[0] - 1];
  2226. savers.current_saverDesc = savers.saverActionDesc[savers.origSelPositions[0] - 1];
  2227. savers.current_position = savers.origSelPositions[0];
  2228. }
  2229. /* Need to make sure the savers.selPositions array reflects the accurate
  2230. current selections. If the user invokes the Screen dialog, then cancels,
  2231. then reinvokes and OKs without making any changes to the selections, the
  2232. savers.selPositions array is assumed to contain the accurate selections.
  2233. Unless we reset it here to the origSelPositions, it may be inaccurate.
  2234. */
  2235. XtFree((char *) savers.selPositions);
  2236. savers.selPositions = (int *) XtMalloc(sizeof(int) * savers.orig_selsaverCount);
  2237. for (i=0; i<savers.orig_selsaverCount; i++)
  2238. savers.selPositions[i] = savers.origSelPositions[i];
  2239. savers.selsaverCount = savers.orig_selsaverCount;
  2240. break;
  2241. break;
  2242. case HELP_BUTTON:
  2243. XtCallCallbacks(style.screenDialog, XmNhelpCallback, (XtPointer)NULL);
  2244. break;
  2245. default:
  2246. break;
  2247. }
  2248. }
  2249. /*+++++++++++++++++++++++++++++++++++++++*/
  2250. /* no_svr_ext_ButtonCB */
  2251. /* callback for PushButtons in DialogBox */
  2252. /*+++++++++++++++++++++++++++++++++++++++*/
  2253. static void
  2254. no_svr_ext_ButtonCB(
  2255. Widget w,
  2256. XtPointer client_data,
  2257. XtPointer call_data )
  2258. {
  2259. int i, n, m;
  2260. Arg args[MAX_ARGS];
  2261. Boolean sel_matched = False;
  2262. Boolean saverset;
  2263. Boolean flag;
  2264. static char screenres[48];
  2265. int mintime;
  2266. XtArgVal scratch;
  2267. DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
  2268. switch (cb->button_position)
  2269. {
  2270. case OK_BUTTON:
  2271. XtUnmanageChild (w);
  2272. /* terminate the saver that is currently running */
  2273. if (savers.saverstate)
  2274. {
  2275. _DtSaverStop(style.display, savers.saverstate);
  2276. savers.saverstate = NULL;
  2277. }
  2278. /* write saver timeout resource to xrdb to save scale value */
  2279. /* when screen saver is turned off */
  2280. saverset = XmToggleButtonGadgetGetState(screen.saverOn);
  2281. if (!saverset)
  2282. {
  2283. sprintf (screenres, "Dtstyle*timeoutScale: %d\n", screen.saverTimeout);
  2284. _DtAddToResource (style.display, screenres);
  2285. }
  2286. /* if sendSettings is true send message to Session Manager */
  2287. if(style.smState.smSendSettings)
  2288. {
  2289. if(screen.systemDefaultFlag)
  2290. {
  2291. SmDefaultScreenSettings();
  2292. }
  2293. else
  2294. {
  2295. SmNewScreenSettings(saverset ? screen.newTimeout : 0,
  2296. screen.new_blanking,
  2297. screen.interval,
  2298. screen.exposures);
  2299. }
  2300. }
  2301. if (savers.saverCount)
  2302. {
  2303. savers.selsaverActionNames = (char **) XtMalloc(sizeof(char *) *
  2304. savers.selsaverCount);
  2305. for (i=0; i<savers.selsaverCount; i++)
  2306. {
  2307. char *tmp = savers.saverActionNames[savers.selPositions[i] - 1];
  2308. savers.selsaverActionNames[i] = (char *) XtMalloc(strlen(tmp) + 1);
  2309. strcpy(savers.selsaverActionNames[i], tmp);
  2310. }
  2311. if (savers.selsaversList != NULL)
  2312. XtFree((char*) savers.selsaversList);
  2313. savers.selsaversList = build_selectedList(savers.selsaverActionNames,
  2314. savers.selsaverCount);
  2315. }
  2316. else
  2317. savers.selsaversList = NULL;
  2318. /* save the selected positions for later use */
  2319. savers.orig_selsaverCount = savers.selsaverCount;
  2320. if (savers.origSelPositions != NULL)
  2321. XtFree((char *) savers.origSelPositions);
  2322. savers.origSelPositions = (int *) XtMalloc(sizeof(int) * savers.orig_selsaverCount);
  2323. for (i=0; i<savers.orig_selsaverCount; i++)
  2324. savers.origSelPositions[i] = savers.selPositions[i];
  2325. /* free the allocated selected savers */
  2326. free_saverList(savers.selsaverActionNames, savers.selsaverCount);
  2327. savers.selsaverActionNames = NULL;
  2328. XtVaGetValues(screen.cycleTimeScale, XmNvalue, &scratch, NULL);
  2329. screen.cycleTimeout = scratch;
  2330. /* send new saver time, lock time and time per saver to SM if they have changed, */
  2331. /* flag value indicates which value has changed */
  2332. /* send zero to the session manger if no savers selected */
  2333. if(!XmToggleButtonGadgetGetState(screen.useSaversOn))
  2334. saverset = False;
  2335. else
  2336. saverset = True;
  2337. SmNewSaverSettings(saverset ? screen.saverTimeout*60 : 0,
  2338. style.smState.smLockTimeout,
  2339. screen.cycleTimeout*60,
  2340. savers.selsaversList);
  2341. style.smState.smSaverTimeout = saverset ? screen.saverTimeout*60 : 0;
  2342. style.smState.smCycleTimeout = screen.cycleTimeout*60;
  2343. style.smSaver.saverList = savers.selsaversList;
  2344. screen.origTimeout = screen.newTimeout;
  2345. XSetScreenSaver(style.display, style.smState.smSaverTimeout,
  2346. style.smState.smCycleTimeout,
  2347. screen.new_blanking,
  2348. screen.exposures);
  2349. break;
  2350. case CANCEL_BUTTON:
  2351. XtUnmanageChild(w);
  2352. /* initialize the value of savertimeout and cycle time to the */
  2353. /* original value */
  2354. if (screen.origTimeout)
  2355. screen.saverTimeout = screen.origTimeout / 60;
  2356. else
  2357. screen.saverTimeout = screen.saverTimeout_xrdb;
  2358. if (style.smState.smCycleTimeout)
  2359. screen.cycleTimeout = style.smState.smCycleTimeout / 60;
  2360. else
  2361. screen.cycleTimeout = 0;
  2362. /* reset the value of the scales */
  2363. XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL);
  2364. XtVaSetValues(screen.cycleTimeScale, XmNvalue, screen.cycleTimeout , NULL);
  2365. /* reset the value of the saver toggles */
  2366. XmToggleButtonGadgetSetState(screen.saverOn, screen.origTimeout ? True : False, True);
  2367. XmToggleButtonGadgetSetState(screen.saverOff, !screen.origTimeout ? True : False, True);
  2368. /* reset the value of the locking radio box toggles */
  2369. if (style.smState.smSaverTimeout)
  2370. {
  2371. XmToggleButtonGadgetSetState(screen.useSaversOn, True, False);
  2372. XmToggleButtonGadgetSetState(screen.useSaversOff, False, False);
  2373. XtSetSensitive(screen.saverList, True);
  2374. XtSetSensitive(screen.saverArea, True);
  2375. if (savers.selsaverCount > 1)
  2376. {
  2377. XtSetSensitive(screen.cycleTimeLabel, True);
  2378. XtSetSensitive(screen.cycleTimeScale, True);
  2379. XtSetSensitive(screen.cycleMinutesLabel, True);
  2380. }
  2381. if (savers.saverCount)
  2382. /* display the preview label */
  2383. XtManageChild(screen.prevLabel);
  2384. /* let the session manger know to run the savers */
  2385. SmNewSaverTime(screen.saverTimeout*60);
  2386. }
  2387. else
  2388. {
  2389. XmToggleButtonGadgetSetState(screen.useSaversOff, True, False);
  2390. XmToggleButtonGadgetSetState(screen.useSaversOn, False, False);
  2391. XtSetSensitive(screen.saverList, False);
  2392. XtSetSensitive(screen.saverArea, False);
  2393. XtSetSensitive(screen.cycleTimeLabel, False);
  2394. XtSetSensitive(screen.cycleTimeScale, False);
  2395. XtSetSensitive(screen.cycleMinutesLabel, False);
  2396. /* do not display preview string */
  2397. XtUnmanageChild(screen.prevLabel);
  2398. /* set the background color of the saver window to the */
  2399. /* secondary color ID */
  2400. XSync(style.display, False);
  2401. XtVaSetValues(screen.saverArea, XmNbackground, savers.bg, NULL);
  2402. XClearWindow(style.display, XtWindow(screen.saverArea));
  2403. /* let the session manger know not to run any savers */
  2404. SmNewSaverTime(0);
  2405. }
  2406. /* reset the X timeout */
  2407. screen.newTimeout = screen.origTimeout;
  2408. XSetScreenSaver(style.display, screen.origTimeout, screen.interval,
  2409. screen.blanking,screen.exposures);
  2410. if (savers.saverCount)
  2411. {
  2412. /* reset the list selection back to the current state */
  2413. /* first deselect all items */
  2414. XmListDeselectAllItems(screen.saverList);
  2415. for (i=0; i<savers.orig_selsaverCount; i++)
  2416. XmListSelectPos(screen.saverList, savers.origSelPositions[i], False);
  2417. /* set the current saver to be the first saver in the selected list */
  2418. savers.current_saver = savers.saverActionNames[savers.origSelPositions[0] - 1];
  2419. savers.current_saverDesc = savers.saverActionDesc[savers.origSelPositions[0] - 1];
  2420. savers.current_position = savers.origSelPositions[0];
  2421. }
  2422. /* Need to make sure the savers.selPositions array reflects the accurate
  2423. current selections. If the user invokes the Screen dialog, then cancels,
  2424. then reinvokes and OKs without making any changes to the selections, the
  2425. savers.selPositions array is assumed to contain the accurate selections.
  2426. Unless we reset it here to the origSelPositions, it may be inaccurate.
  2427. */
  2428. XtFree((char *) savers.selPositions);
  2429. if (savers.orig_selsaverCount > 0) {
  2430. savers.selPositions =
  2431. (int *) XtMalloc(sizeof(int) * savers.orig_selsaverCount);
  2432. for (i=0; i<savers.orig_selsaverCount; i++)
  2433. savers.selPositions[i] = savers.origSelPositions[i];
  2434. }
  2435. savers.selsaverCount = savers.orig_selsaverCount;
  2436. break;
  2437. case HELP_BUTTON:
  2438. XtCallCallbacks(style.screenDialog, XmNhelpCallback, (XtPointer)NULL);
  2439. break;
  2440. default:
  2441. break;
  2442. }
  2443. }
  2444. /************************************************************************/
  2445. /* restoreScreen() */
  2446. /* restore any state information saved with saveScreen. */
  2447. /* This is called from restoreSession with the application */
  2448. /* shell and the special xrm database retrieved for restore. */
  2449. /************************************************************************/
  2450. void
  2451. restoreScreen(
  2452. Widget shell,
  2453. XrmDatabase db )
  2454. {
  2455. XrmName xrm_name[5];
  2456. XrmRepresentation rep_type;
  2457. XrmValue value;
  2458. xrm_name [0] = XrmStringToQuark ("Screen");
  2459. xrm_name [2] = 0;
  2460. /* get x position */
  2461. xrm_name [1] = XrmStringToQuark ("x");
  2462. if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
  2463. XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
  2464. save.restoreFlag = True;
  2465. }
  2466. /* get y position */
  2467. xrm_name [1] = XrmStringToQuark ("y");
  2468. if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
  2469. XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
  2470. }
  2471. xrm_name [1] = XrmStringToQuark ("ismapped");
  2472. XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
  2473. /* Are we supposed to be mapped? */
  2474. if (strcmp(value.addr, "True") == 0)
  2475. popup_screenBB(shell);
  2476. }
  2477. /*******************************************************************************/
  2478. /* saveScreen() */
  2479. /* This routine will write out to the passed file descriptor any state */
  2480. /* information this dialog needs. It is called from saveSessionCB with the */
  2481. /* file already opened. */
  2482. /* All information is saved in xrm format. There is no restriction */
  2483. /* on what can be saved. It doesn't have to be defined or be part of any */
  2484. /* widget or Xt definition. Just name and save it here and recover it in */
  2485. /* restoreBackdrop. The suggested minimum is whether you are mapped, and your */
  2486. /* location. */
  2487. /*******************************************************************************/
  2488. void
  2489. saveScreen(
  2490. int fd )
  2491. {
  2492. Position x,y;
  2493. char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
  2494. XmVendorShellExtObject vendorExt;
  2495. XmWidgetExtData extData;
  2496. if (style.screenDialog != NULL)
  2497. {
  2498. if (XtIsManaged(style.screenDialog))
  2499. sprintf(bufr, "*Screen.ismapped: True\n");
  2500. else
  2501. sprintf(bufr, "*Screen.ismapped: False\n");
  2502. /* Get and write out the geometry info for our Window */
  2503. x = XtX(XtParent(style.screenDialog));
  2504. y = XtY(XtParent(style.screenDialog));
  2505. /* Modify x & y to take into account window mgr frames */
  2506. /* This is pretty bogus, but I don't know a better way to do it. */
  2507. extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
  2508. vendorExt = (XmVendorShellExtObject)extData->widget;
  2509. x -= vendorExt->vendor.xOffset;
  2510. y -= vendorExt->vendor.yOffset;
  2511. sprintf(bufr, "%s*Screen.x: %d\n", bufr, x);
  2512. sprintf(bufr, "%s*Screen.y: %d\n", bufr, y);
  2513. if(-1 == write (fd, bufr, strlen(bufr))) {
  2514. perror(strerror(errno));
  2515. }
  2516. }
  2517. }
  2518. /************************************************************************/
  2519. /* MakeListStrings() */
  2520. /* Make XmStrings from the saver names, to pass into list. */
  2521. /************************************************************************/
  2522. static XmString *
  2523. MakeListStrings( char ** list )
  2524. {
  2525. int i;
  2526. XmString *xmList;
  2527. xmList = (XmString *) XtMalloc(savers.saverCount * sizeof(XmString));
  2528. for (i = 0; i < savers.saverCount; i++)
  2529. {
  2530. xmList[i] = XmStringCreateLocalized (list[i]);
  2531. }
  2532. return (xmList);
  2533. }
  2534. /************************************************************************/
  2535. /* FreeListStrings() */
  2536. /************************************************************************/
  2537. static void
  2538. FreeListStrings(XmString *xmlist,
  2539. int count)
  2540. {
  2541. int i;
  2542. for (i = 0; i < count; i++)
  2543. {
  2544. if (xmlist[i])
  2545. XmStringFree(xmlist[i]);
  2546. }
  2547. XtFree ((char *)xmlist);
  2548. }
  2549. /************************************************************************/
  2550. /* ListCB() */
  2551. /* Get the lastly selected Screen saver client running in the preview */
  2552. /* area. For a multiple selection by dragging, the last item in the */
  2553. /* selection is the client that is previewed. */
  2554. /************************************************************************/
  2555. static void
  2556. ListCB(
  2557. Widget w,
  2558. XtPointer client_data,
  2559. XtPointer call_data )
  2560. {
  2561. XmListCallbackStruct *cb = (XmListCallbackStruct *)call_data;
  2562. int i;
  2563. Boolean runsaver = False;
  2564. XmString string;
  2565. /* If no items are left in the selection (i.e. the last selected item */
  2566. /* was deselected) then force the previously selected item to remain */
  2567. /* selected */
  2568. if (cb->selected_item_count == 0)
  2569. {
  2570. XmListSelectPos(screen.saverList, cb->item_position, False);
  2571. savers.selsaverCount = 1;
  2572. if (savers.selPositions != NULL)
  2573. XtFree ((char *) savers.selPositions);
  2574. savers.selPositions = (int *) XtMalloc(sizeof(int));
  2575. savers.selPositions[0] = cb->item_position;
  2576. savers.current_saver = savers.saverActionNames[savers.selPositions[0] - 1];
  2577. savers.current_saverDesc = savers.saverActionDesc[savers.selPositions[0] - 1];
  2578. return;
  2579. }
  2580. /* make a copy of the selected item positions for later use */
  2581. if (savers.selPositions != NULL)
  2582. XtFree ((char *) savers.selPositions);
  2583. savers.selPositions = (int *) XtMalloc(sizeof(int) * cb->selected_item_count);
  2584. for (i=0; i< cb->selected_item_count; i++)
  2585. {
  2586. savers.selPositions[i] = cb->selected_item_positions[i];
  2587. }
  2588. savers.selsaverCount = cb->selected_item_count;
  2589. if (savers.selsaverCount < 2)
  2590. {
  2591. XtSetSensitive(screen.cycleTimeScale, False);
  2592. XtSetSensitive(screen.cycleTimeLabel, False);
  2593. XtSetSensitive(screen.cycleMinutesLabel, False);
  2594. }
  2595. else
  2596. if (savers.previous_selsaverCount < 2)
  2597. {
  2598. XtSetSensitive(screen.cycleTimeScale, True);
  2599. XtSetSensitive(screen.cycleTimeLabel, True);
  2600. XtSetSensitive(screen.cycleMinutesLabel, True);
  2601. }
  2602. savers.previous_selsaverCount = savers.selsaverCount;
  2603. /* Find out if the item is selected or deselected. When an item */
  2604. /* is deselected item_position is set to the deselected item which has */
  2605. /* the keyboard focus. However, the deselected screen saver must not be */
  2606. /* previewed. Therfore before a screen saver is started, its position must */
  2607. /* exist in the selected_item_positions array. If not then just return without */
  2608. /* altering the current (previewed) saver unless the deselected saver was the */
  2609. /* current saver. In that case kill the current saver and preview the last */
  2610. /* item from the selected list. */
  2611. for (i=0; i<cb->selected_item_count; i++)
  2612. {
  2613. if(cb->selected_item_positions[i] == cb->item_position)
  2614. runsaver=True;
  2615. }
  2616. if (!runsaver)
  2617. {
  2618. i = cb->selected_item_positions[(cb->selected_item_count-1)];
  2619. if (savers.current_position == cb->item_position)
  2620. {
  2621. if (savers.saverstate)
  2622. {
  2623. /* Terminate the screen saver that is currently running */
  2624. _DtSaverStop(style.display, savers.saverstate);
  2625. XSync(style.display, False);
  2626. savers.saverstate = NULL;
  2627. }
  2628. savers.current_saver = savers.saverActionNames[i-1];
  2629. savers.current_saverDesc = savers.saverActionDesc[i-1];
  2630. savers.current_position = i;
  2631. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  2632. savers.saverstate = _DtSaverStart(style.display, &screen.saverArea,
  2633. 1, savers.current_saver, style.screenDialog);
  2634. string = XmStringCreateLocalized (savers.current_saverDesc);
  2635. XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL);
  2636. XmStringFree(string);
  2637. }
  2638. return;
  2639. }
  2640. /* The item position returned is the selcted item */
  2641. /* Start screen saver. _DtSaverStop() must be called to terminate the */
  2642. /* screen saver. */
  2643. if (savers.saverstate)
  2644. {
  2645. /* Terminate the screen saver that is currently running */
  2646. _DtSaverStop(style.display, savers.saverstate);
  2647. XSync(style.display, False);
  2648. savers.saverstate = NULL;
  2649. }
  2650. XSync(style.display, False);
  2651. XClearWindow(style.display, XtWindow(screen.saverArea));
  2652. XSync(style.display, False);
  2653. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  2654. savers.current_position = cb->item_position;
  2655. savers.current_saver = savers.saverActionNames[savers.current_position - 1];
  2656. savers.current_saverDesc = savers.saverActionDesc[savers.current_position - 1];
  2657. savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1,
  2658. savers.current_saver, style.screenDialog);
  2659. /* update the preview label with the current running saver */
  2660. XtVaSetValues(screen.prevLabel, XmNlabelString, cb->item, NULL);
  2661. }
  2662. /************************************************************************/
  2663. /* IconHandler() */
  2664. /* Kills the currently previewed saver when the user iconifies the */
  2665. /* style manager. An XtEventHandler. */
  2666. /************************************************************************/
  2667. static void
  2668. IconHandler(
  2669. Widget shell,
  2670. XtPointer client_data,
  2671. XEvent *event,
  2672. Boolean *dispatch)
  2673. {
  2674. XmString string;
  2675. if (event->type == UnmapNotify)
  2676. {
  2677. /* terminate the saver that is currently running */
  2678. if (savers.saverstate)
  2679. {
  2680. _DtSaverStop(style.display, savers.saverstate);
  2681. savers.saverstate = NULL;
  2682. }
  2683. }
  2684. /* run the current screen saver only if the useSaversOn/saverOn toggle is enabled
  2685. and valid saver exist and one is not already running*/
  2686. else if (savers.saverCount && event->type == 19 && !savers.saverstate)
  2687. if (style.smState.smLockOnTimeoutStatus)
  2688. {
  2689. if (XmToggleButtonGadgetGetState(screen.saverOn) && savers.saverCount)
  2690. {
  2691. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  2692. savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1,
  2693. savers.current_saver, style.screenDialog);
  2694. string = XmStringCreateLocalized (savers.current_saverDesc);
  2695. XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL);
  2696. XmStringFree(string);
  2697. }
  2698. }
  2699. else
  2700. {
  2701. if (XmToggleButtonGadgetGetState(screen.useSaversOn) && savers.saverCount)
  2702. {
  2703. XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL);
  2704. savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1,
  2705. savers.current_saver, style.screenDialog);
  2706. string = XmStringCreateLocalized (savers.current_saverDesc);
  2707. XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL);
  2708. XmStringFree(string);
  2709. }
  2710. }
  2711. }
  2712. /************************************************************************/
  2713. /* UnmapCB() */
  2714. /* Kills the currently previewed saver when the user iconifies the */
  2715. /* style manager or unmaps the screen dialog. */
  2716. /************************************************************************/
  2717. static void
  2718. UnmapCB(
  2719. Widget w,
  2720. XtPointer client_data,
  2721. XtPointer call_data )
  2722. {
  2723. /* terminate the saver that is currently running */
  2724. if (savers.saverstate)
  2725. {
  2726. _DtSaverStop(style.display, savers.saverstate);
  2727. savers.saverstate = NULL;
  2728. }
  2729. }