Prefs.c 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109
  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. /* $XConsortium: Prefs.c /main/7 1996/10/23 17:04:25 mustafa $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. *
  27. * FILE: Prefs.c
  28. *
  29. * COMPONENT_NAME: Desktop File Manager (dtfile)
  30. *
  31. * Description: Source file for the change directory dialog.
  32. *
  33. * FUNCTIONS: ApplyCallback
  34. * Create
  35. * Destroy
  36. * DirectionToString
  37. * FreeValues
  38. * GetDefaultValues
  39. * GetPreferencesValues
  40. * GetResourceValues
  41. * GetValues
  42. * InstallChange
  43. * InstallClose
  44. * OkCallback
  45. * OrderToString
  46. * RandomToString
  47. * ResetCallback
  48. * SetValues
  49. * ShowTypeToString
  50. * StringToDirection
  51. * StringToOrder
  52. * StringToRandom
  53. * StringToShowType
  54. * StringToTreeFiles
  55. * StringToView
  56. * ToggleCallback
  57. * TreeFilesToString
  58. * ViewToString
  59. * WriteResourceValues
  60. *
  61. * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
  62. * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
  63. * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
  64. * (c) Copyright 1993, 1994, 1995 Novell, Inc.
  65. *
  66. ****************************************************************************
  67. ************************************<+>*************************************/
  68. #include <stdio.h>
  69. #include <stdlib.h>
  70. #include <limits.h>
  71. #include <Xm/XmP.h>
  72. #include <Xm/Xm.h>
  73. #include <Xm/DialogS.h>
  74. #include <Xm/MessageB.h>
  75. #include <Xm/BulletinB.h>
  76. #include <Xm/Form.h>
  77. #include <Xm/Frame.h>
  78. #include <Xm/LabelG.h>
  79. #include <Xm/PushBG.h>
  80. #include <Xm/ToggleBG.h>
  81. #include <Xm/SeparatoG.h>
  82. #include <Xm/VendorSEP.h>
  83. #include <Xm/MwmUtil.h>
  84. #include <Xm/Protocols.h>
  85. #include <Dt/TitleBox.h>
  86. #include <Dt/DtNlUtils.h>
  87. #include "Encaps.h"
  88. #include "SharedProcs.h"
  89. #include <X11/ShellP.h>
  90. #include <X11/Shell.h>
  91. #include <X11/Xatom.h>
  92. #include "FileMgr.h"
  93. #include "Desktop.h"
  94. #include "Main.h"
  95. #include "Prefs.h"
  96. #include "Help.h"
  97. /******** Static Function Declarations ********/
  98. static void Create(
  99. Display *display,
  100. Widget parent,
  101. Widget *return_widget,
  102. XtPointer *dialog) ;
  103. static void InstallChange(
  104. PreferencesRec *preferences_rec,
  105. XtCallbackProc callback,
  106. XtPointer client_data) ;
  107. static void InstallClose(
  108. PreferencesRec *preferences_rec,
  109. XtCallbackProc callback,
  110. XtPointer client_data) ;
  111. static void Destroy(
  112. PreferencesRec *preferences_rec) ;
  113. static XtPointer GetValues(
  114. PreferencesRec *preferences_rec) ;
  115. static XtPointer GetDefaultValues( void ) ;
  116. static XtPointer GetResourceValues(
  117. XrmDatabase data_base,
  118. char **name_list) ;
  119. static void SetValues(
  120. PreferencesRec *preferences_rec,
  121. PreferencesData *preferences_data) ;
  122. static void WriteResourceValues(
  123. DialogData *values,
  124. int fd,
  125. char **name_list) ;
  126. static void FreeValues(
  127. PreferencesData *preferences_data) ;
  128. static void ResetCallback(
  129. Widget w,
  130. XtPointer client_data,
  131. XtPointer call_data) ;
  132. static void ToggleCallback(
  133. Widget w,
  134. XtPointer client_data,
  135. XtPointer call_data) ;
  136. static void OkCallback(
  137. Widget w,
  138. PreferencesApply *apply_data,
  139. XtPointer call_data) ;
  140. static void ApplyCallback(
  141. Widget w,
  142. PreferencesApply *apply_data,
  143. XtPointer call_data) ;
  144. static void GetPreferencesValues(
  145. PreferencesRec *preferences_rec,
  146. PreferencesData *preferences_data) ;
  147. /******** End Static Function Declarations ********/
  148. static char * Order_by_file_type = "order_by_file_type";
  149. static char * Order_by_alphabetical = "order_by_alphabetical";
  150. static char * Order_by_date = "order_by_date";
  151. static char * Order_by_size = "order_by_size";
  152. static char * By_name = "by_name";
  153. static char * By_name_and_icon = "by_name_and_icon";
  154. static char * By_name_and_small_icon = "by_name_and_small_icon";
  155. static char * By_attributes = "by_attributes";
  156. static char * Direction_descending = "direction_descending";
  157. static char * Direction_ascending = "direction_ascending";
  158. static char * Single_directory = "single_directory";
  159. static char * DirectoryTree = "directory_tree";
  160. static char * Tree_files_never = "never";
  161. static char * Tree_files_choose = "choose";
  162. static char * Tree_files_always = "always";
  163. static char * PreferencesName = "Preferences";
  164. static char * Random_on = "random_on";
  165. static char * Random_off = "random_off";
  166. /* Resource definitions for the preferences dialog */
  167. static DialogResource resources[] =
  168. {
  169. { "showType", SHOW_TYPE, sizeof(unsigned char),
  170. XtOffset(PreferencesDataPtr, show_type),
  171. (XtPointer) SINGLE_DIRECTORY, ShowTypeToString },
  172. { "treeFiles", TREE_FILES, sizeof(unsigned char),
  173. XtOffset(PreferencesDataPtr, tree_files),
  174. (XtPointer) TREE_FILES_NEVER, TreeFilesToString },
  175. { "view_single", VIEW, sizeof(unsigned char),
  176. XtOffset(PreferencesDataPtr, view_single),
  177. (XtPointer) BY_NAME_AND_ICON, ViewToString },
  178. { "view_tree", VIEW, sizeof(unsigned char),
  179. XtOffset(PreferencesDataPtr, view_tree),
  180. (XtPointer) BY_NAME_AND_SMALL_ICON, ViewToString },
  181. { "order", ORDER, sizeof(unsigned char),
  182. XtOffset(PreferencesDataPtr, order),
  183. (XtPointer) ORDER_BY_ALPHABETICAL, OrderToString },
  184. { "direction", DIRECTION_RESRC, sizeof(unsigned char),
  185. XtOffset(PreferencesDataPtr, direction),
  186. (XtPointer) DIRECTION_ASCENDING, DirectionToString },
  187. { "positionEnabled", RANDOM, sizeof(unsigned char),
  188. XtOffset(PreferencesDataPtr, positionEnabled),
  189. (XtPointer) RANDOM_OFF, RandomToString },
  190. };
  191. /* Callback function definitions */
  192. /*
  193. * The Dialog Class structure.
  194. */
  195. static DialogClass preferencesClassRec =
  196. {
  197. resources,
  198. XtNumber(resources),
  199. Create,
  200. (DialogInstallChangeProc) InstallChange,
  201. (DialogInstallCloseProc) InstallClose,
  202. (DialogDestroyProc) Destroy,
  203. (DialogGetValuesProc) GetValues,
  204. GetDefaultValues,
  205. GetResourceValues,
  206. (DialogSetValuesProc) SetValues,
  207. WriteResourceValues,
  208. (DialogFreeValuesProc) FreeValues,
  209. (DialogMapWindowProc) _DtGenericMapWindow,
  210. NULL,
  211. };
  212. DialogClass * preferencesClass = (DialogClass *) &preferencesClassRec;
  213. int showType;
  214. /************************************************************************
  215. *
  216. * Create
  217. *
  218. ************************************************************************/
  219. static void
  220. Create(
  221. Display *display,
  222. Widget parent,
  223. Widget *return_widget,
  224. XtPointer *dialog )
  225. {
  226. PreferencesRec * preferences_rec;
  227. Widget shell;
  228. Widget form;
  229. Widget show_frame;
  230. Widget view_frame;
  231. Widget order_frame;
  232. Widget direction_frame;
  233. Widget group_form;
  234. Widget separator;
  235. Widget temp;
  236. Widget headers_frame;
  237. Widget position_frame;
  238. Widget titleWidget;
  239. XmString label_string;
  240. Arg args[15];
  241. Dimension offset, screenHeight;
  242. int n;
  243. char * tmpStr;
  244. /* Allocate the change directory dialog instance record. */
  245. preferences_rec = (PreferencesRec *) XtMalloc (sizeof (PreferencesRec));
  246. screenHeight = HeightOfScreen( XtScreen( parent ) );
  247. /* We are supporting 3 sizes. They are: 1200, 1024, 480
  248. For the sake of simplicity, process two of them.
  249. */
  250. if( screenHeight >= (Dimension) 1024 )
  251. offset = (Dimension)5;
  252. else
  253. offset = (Dimension)1;
  254. /* Create the shell, bulletin board and form used for the dialog. */
  255. n = 0;
  256. XtSetArg (args[n], XmNmwmFunctions, MWM_FUNC_MOVE
  257. | MWM_FUNC_CLOSE); ++n;
  258. XtSetArg (args[n], XmNmwmDecorations, MWM_DECOR_BORDER
  259. | MWM_DECOR_TITLE); ++n;
  260. XtSetArg (args[n], XmNallowShellResize, False); ++n;
  261. preferences_rec->shell = shell =
  262. XmCreateDialogShell (parent, "preferences", args, n);
  263. /* Set the useAsyncGeo on the shell */
  264. XtSetArg (args[0], XmNuseAsyncGeometry, True);
  265. XtSetValues (XtParent(shell), args, 1);
  266. n = 0;
  267. XtSetArg (args[n], XmNmarginWidth, 1); n++;
  268. XtSetArg (args[n], XmNmarginHeight, 1); n++;
  269. XtSetArg (args[n], XmNshadowThickness, 1); n++;
  270. XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
  271. XtSetArg (args[n], XmNautoUnmanage, False); n++;
  272. form = XmCreateForm (shell, "form", args, n);
  273. XtAddCallback(form, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  274. HELP_PREFERENCES_DIALOG_STR);
  275. /* Create the headers status line */
  276. label_string = XmStringCreateLocalized ((GETMESSAGE(23,23, "Headers")));
  277. n = 0;
  278. XtSetArg (args[n], XmNtitleString, label_string); n++;
  279. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  280. XtSetArg (args[n], XmNtopOffset, offset); n++;
  281. XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  282. XtSetArg (args[n], XmNrightOffset, offset); n++;
  283. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  284. XtSetArg (args[n], XmNleftOffset, offset); n++;
  285. XtSetArg (args[n], XmNmarginWidth, offset); n++;
  286. XtSetArg (args[n], XmNmarginHeight, offset); n++;
  287. headers_frame = _DtCreateTitleBox(form, "headers_frame", args, n);
  288. XtManageChild (headers_frame);
  289. XtAddCallback(headers_frame, XmNhelpCallback,
  290. (XtCallbackProc)HelpRequestCB,
  291. HELP_PREFERENCES_HEADERS_STR);
  292. XmStringFree(label_string);
  293. titleWidget = _DtTitleBoxGetTitleArea(headers_frame);
  294. XtSetArg (args[0], XmNtraversalOn, False);
  295. XtSetValues (titleWidget, args, 1);
  296. group_form = XmCreateForm (headers_frame, "group_form", args, 0);
  297. XtManageChild (group_form);
  298. label_string = XmStringCreateLocalized ((GETMESSAGE(23,24, "Iconic Path")));
  299. n = 0;
  300. XtSetArg (args[n], XmNlabelString, label_string); n++;
  301. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  302. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  303. preferences_rec->show_iconic_path = temp =
  304. XmCreateToggleButtonGadget (group_form, "show_iconic_path", args, n);
  305. XtManageChild (temp);
  306. XmStringFree (label_string);
  307. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  308. (XtPointer) preferences_rec);
  309. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  310. HELP_PREFERENCES_HEADERS_STR);
  311. label_string = XmStringCreateLocalized ((GETMESSAGE(23,36, "Text Path")));
  312. n = 0;
  313. XtSetArg (args[n], XmNlabelString, label_string); n++;
  314. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  315. XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  316. XtSetArg (args[n], XmNleftWidget, preferences_rec->show_iconic_path);n++;
  317. XtSetArg (args[n], XmNleftOffset, 10); n++;
  318. preferences_rec->show_current_dir = temp =
  319. XmCreateToggleButtonGadget (group_form, "show_current_dir", args, n);
  320. XtManageChild (temp);
  321. XmStringFree (label_string);
  322. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback, (XtPointer) preferences_rec);
  323. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  324. HELP_PREFERENCES_HEADERS_STR);
  325. label_string = XmStringCreateLocalized ((GETMESSAGE(23,37, "Message Line")));
  326. n = 0;
  327. XtSetArg (args[n], XmNlabelString, label_string); n++;
  328. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  329. XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  330. XtSetArg (args[n], XmNleftWidget, preferences_rec->show_current_dir);n++;
  331. XtSetArg (args[n], XmNleftOffset, 10); n++;
  332. preferences_rec->show_status_line = temp =
  333. XmCreateToggleButtonGadget (group_form, "show_status_line", args, n);
  334. XtManageChild (temp);
  335. XmStringFree (label_string);
  336. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback, (XtPointer) preferences_rec);
  337. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  338. HELP_PREFERENCES_HEADERS_STR);
  339. /* Create the positioning status line */
  340. label_string = XmStringCreateLocalized ((GETMESSAGE(23,18, "Placement")));
  341. n = 0;
  342. XtSetArg (args[n], XmNtitleString, label_string); n++;
  343. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  344. XtSetArg (args[n], XmNtopWidget, headers_frame); n++;
  345. XtSetArg (args[n], XmNtopOffset, offset); n++;
  346. XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  347. XtSetArg (args[n], XmNrightOffset, offset); n++;
  348. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  349. XtSetArg (args[n], XmNleftOffset, offset); n++;
  350. XtSetArg (args[n], XmNmarginWidth, offset); n++;
  351. XtSetArg (args[n], XmNmarginHeight, offset); n++;
  352. position_frame = _DtCreateTitleBox(form, "position_frame", args, n);
  353. XtManageChild (position_frame);
  354. XtAddCallback(position_frame, XmNhelpCallback,
  355. (XtCallbackProc)HelpRequestCB,
  356. HELP_PREFERENCES_PLACEMENT_STR);
  357. XmStringFree(label_string);
  358. titleWidget = _DtTitleBoxGetTitleArea(position_frame);
  359. XtSetArg (args[0], XmNtraversalOn, False);
  360. XtSetValues (titleWidget, args, 1);
  361. group_form = XmCreateForm (position_frame, "group_form", args, 0);
  362. XtManageChild (group_form);
  363. label_string = XmStringCreateLocalized ((GETMESSAGE(23,20, "As Placed")));
  364. n = 0;
  365. XtSetArg (args[n], XmNlabelString, label_string); n++;
  366. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  367. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  368. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  369. preferences_rec->random_on = temp =
  370. XmCreateToggleButtonGadget (group_form, "random_on", args, n);
  371. XtManageChild (temp);
  372. XmStringFree (label_string);
  373. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  374. (XtPointer) preferences_rec);
  375. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  376. HELP_PREFERENCES_PLACEMENT_STR);
  377. label_string = XmStringCreateLocalized ((GETMESSAGE(23,35, "Rows and Columns")));
  378. n = 0;
  379. XtSetArg (args[n], XmNlabelString, label_string); n++;
  380. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  381. XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  382. XtSetArg (args[n], XmNleftWidget, preferences_rec->random_on); n++;
  383. XtSetArg (args[n], XmNleftOffset, 10); n++;
  384. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  385. preferences_rec->random_off = temp =
  386. XmCreateToggleButtonGadget (group_form, "random_off", args, n);
  387. XtManageChild (temp);
  388. XmStringFree (label_string);
  389. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback, (XtPointer) preferences_rec);
  390. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  391. HELP_PREFERENCES_PLACEMENT_STR);
  392. /* Create the show container and widgets */
  393. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 7, "Show")));
  394. n = 0;
  395. XtSetArg (args[n], XmNtitleString, label_string); n++;
  396. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  397. XtSetArg (args[n], XmNtopWidget, position_frame); n++;
  398. XtSetArg (args[n], XmNtopOffset, offset); n++;
  399. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  400. XtSetArg (args[n], XmNleftOffset, offset); n++;
  401. XtSetArg (args[n], XmNmarginWidth, offset); n++;
  402. XtSetArg (args[n], XmNmarginHeight, offset); n++;
  403. show_frame = _DtCreateTitleBox (form, "show_frame", args, n);
  404. XtManageChild (show_frame);
  405. XmStringFree (label_string);
  406. XtAddCallback(show_frame, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  407. HELP_PREFERENCES_SHOW_STR);
  408. titleWidget = _DtTitleBoxGetTitleArea(show_frame);
  409. XtSetArg (args[0], XmNtraversalOn, False);
  410. XtSetValues (titleWidget, args, 1);
  411. group_form = XmCreateForm (show_frame, "show_form", args, 0);
  412. XtManageChild (group_form);
  413. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 8, "By Single Folder")));
  414. n = 0;
  415. XtSetArg (args[n], XmNlabelString, label_string); n++;
  416. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  417. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  418. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  419. preferences_rec->show_single = temp =
  420. XmCreateToggleButtonGadget (group_form, "by_single_directory", args, n);
  421. XtManageChild (temp);
  422. XmStringFree (label_string);
  423. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  424. (XtPointer) preferences_rec);
  425. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  426. HELP_PREFERENCES_SHOW_STR);
  427. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 9, "By Tree")));
  428. n = 0;
  429. XtSetArg (args[n], XmNlabelString, label_string); n++;
  430. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  431. XtSetArg (args[n], XmNtopWidget, temp); n++;
  432. XtSetArg (args[n], XmNtopOffset, offset); n++;
  433. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  434. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  435. preferences_rec->show_multiple = temp =
  436. XmCreateToggleButtonGadget (group_form, "by_directory_tree", args, n);
  437. XtManageChild (temp);
  438. XmStringFree (label_string);
  439. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  440. (XtPointer) preferences_rec);
  441. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  442. HELP_PREFERENCES_SHOW_STR);
  443. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 27, "Folders only")));
  444. n = 0;
  445. XtSetArg (args[n], XmNlabelString, label_string); n++;
  446. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  447. XtSetArg (args[n], XmNtopWidget, temp); n++;
  448. XtSetArg (args[n], XmNtopOffset, offset); n++;
  449. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  450. XtSetArg (args[n], XmNleftOffset, 25); n++;
  451. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  452. preferences_rec->tree_files_never = temp =
  453. XmCreateToggleButtonGadget (group_form, "tree_files_never", args, n);
  454. XtManageChild (temp);
  455. XmStringFree (label_string);
  456. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  457. (XtPointer) preferences_rec);
  458. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  459. HELP_PREFERENCES_SHOW_STR);
  460. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 28, "Folders, then Files")));
  461. n = 0;
  462. XtSetArg (args[n], XmNlabelString, label_string); n++;
  463. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  464. XtSetArg (args[n], XmNtopWidget, temp); n++;
  465. XtSetArg (args[n], XmNtopOffset, offset); n++;
  466. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  467. XtSetArg (args[n], XmNleftOffset, 25); n++;
  468. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  469. preferences_rec->tree_files_choose = temp =
  470. XmCreateToggleButtonGadget (group_form, "tree_files_choose", args, n);
  471. XtManageChild (temp);
  472. XmStringFree (label_string);
  473. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  474. (XtPointer) preferences_rec);
  475. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  476. HELP_PREFERENCES_SHOW_STR);
  477. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 29, "Folders and Files")));
  478. n = 0;
  479. XtSetArg (args[n], XmNlabelString, label_string); n++;
  480. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  481. XtSetArg (args[n], XmNtopWidget, temp); n++;
  482. XtSetArg (args[n], XmNtopOffset, offset); n++;
  483. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  484. XtSetArg (args[n], XmNleftOffset, 25); n++;
  485. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  486. preferences_rec->tree_files_always = temp =
  487. XmCreateToggleButtonGadget (group_form, "tree_files_always", args, n);
  488. XtManageChild (temp);
  489. XmStringFree (label_string);
  490. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  491. (XtPointer) preferences_rec);
  492. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  493. HELP_PREFERENCES_SHOW_STR);
  494. /* Create the view container and widgets */
  495. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23,31, "Representation")));
  496. n = 0;
  497. XtSetArg (args[n], XmNtitleString, label_string); n++;
  498. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  499. XtSetArg (args[n], XmNtopWidget, position_frame); n++;
  500. XtSetArg (args[n], XmNtopOffset, offset); n++;
  501. XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  502. XtSetArg (args[n], XmNleftOffset, 10); n++;
  503. XtSetArg (args[n], XmNleftWidget, show_frame); n++;
  504. XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  505. XtSetArg (args[n], XmNrightOffset, offset); n++;
  506. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  507. XtSetArg (args[n], XmNbottomWidget, show_frame); n++;
  508. XtSetArg (args[n], XmNmarginWidth, offset); n++;
  509. XtSetArg (args[n], XmNmarginHeight, offset); n++;
  510. view_frame = _DtCreateTitleBox(form, "view_frame", args, n);
  511. XtManageChild (view_frame);
  512. XmStringFree (label_string);
  513. XtAddCallback(view_frame, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  514. HELP_PREFERENCES_VIEW_STR);
  515. titleWidget = _DtTitleBoxGetTitleArea(view_frame);
  516. XtSetArg (args[0], XmNtraversalOn, False);
  517. XtSetValues (titleWidget, args, 1);
  518. group_form = XmCreateForm (view_frame, "view_form", args, 0);
  519. XtManageChild (group_form);
  520. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23,32, "By Name Only")));
  521. n = 0;
  522. XtSetArg (args[n], XmNlabelString, label_string); n++;
  523. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  524. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  525. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  526. preferences_rec->by_name = temp =
  527. XmCreateToggleButtonGadget (group_form, "by_name", args, n);
  528. XtManageChild (temp);
  529. XmStringFree (label_string);
  530. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  531. (XtPointer) preferences_rec);
  532. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  533. HELP_PREFERENCES_VIEW_STR);
  534. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23,33, "By Large Icons")));
  535. n = 0;
  536. XtSetArg (args[n], XmNlabelString, label_string); n++;
  537. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  538. XtSetArg (args[n], XmNtopWidget, temp); n++;
  539. XtSetArg (args[n], XmNtopOffset, offset); n++;
  540. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  541. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  542. preferences_rec->by_name_and_icon = temp =
  543. XmCreateToggleButtonGadget (group_form, "by_name_and_icon", args, n);
  544. XtManageChild (temp);
  545. XmStringFree (label_string);
  546. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  547. (XtPointer) preferences_rec);
  548. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  549. HELP_PREFERENCES_VIEW_STR);
  550. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23,34, "By Small Icons")));
  551. n = 0;
  552. XtSetArg (args[n], XmNlabelString, label_string); n++;
  553. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  554. XtSetArg (args[n], XmNtopWidget, temp); n++;
  555. XtSetArg (args[n], XmNtopOffset, offset); n++;
  556. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  557. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  558. preferences_rec->by_name_and_small_icon = temp =
  559. XmCreateToggleButtonGadget (group_form, "by_name_and_small_icon", args, n);
  560. XtManageChild (temp);
  561. XmStringFree (label_string);
  562. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  563. (XtPointer) preferences_rec);
  564. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  565. HELP_PREFERENCES_VIEW_STR);
  566. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23,6, "By Name, date, size ...")));
  567. n = 0;
  568. XtSetArg (args[n], XmNlabelString, label_string); n++;
  569. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  570. XtSetArg (args[n], XmNtopWidget, temp); n++;
  571. XtSetArg (args[n], XmNtopOffset, offset); n++;
  572. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  573. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  574. preferences_rec->by_attributes = temp =
  575. XmCreateToggleButtonGadget (group_form, "by_attributes", args, n);
  576. XtManageChild (temp);
  577. XmStringFree (label_string);
  578. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  579. (XtPointer) preferences_rec);
  580. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  581. HELP_PREFERENCES_VIEW_STR);
  582. /* Create the file order container and widgets */
  583. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 10, "Order")));
  584. n = 0;
  585. XtSetArg (args[n], XmNtitleString, label_string); n++;
  586. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  587. XtSetArg (args[n], XmNtopWidget, view_frame); n++;
  588. XtSetArg (args[n], XmNtopOffset, offset); n++;
  589. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  590. XtSetArg (args[n], XmNleftOffset, offset); n++;
  591. XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  592. XtSetArg (args[n], XmNrightWidget, show_frame); n++;
  593. XtSetArg (args[n], XmNmarginWidth, offset); n++;
  594. XtSetArg (args[n], XmNmarginHeight, offset); n++;
  595. order_frame = _DtCreateTitleBox (form, "order_frame", args, n);
  596. XtManageChild (order_frame);
  597. XmStringFree (label_string);
  598. XtAddCallback(order_frame, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  599. HELP_PREFERENCES_ORDER_STR);
  600. titleWidget = _DtTitleBoxGetTitleArea(order_frame);
  601. XtSetArg (args[0], XmNtraversalOn, False);
  602. XtSetValues (titleWidget, args, 1);
  603. group_form = XmCreateForm (order_frame, "order_form", args, 0);
  604. XtManageChild (group_form);
  605. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 12, "Alphabetically")));
  606. n = 0;
  607. XtSetArg (args[n], XmNlabelString, label_string); n++;
  608. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  609. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  610. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  611. preferences_rec->order_alphabetical = temp =
  612. XmCreateToggleButtonGadget (group_form, "alphabetically", args, n);
  613. XtManageChild (temp);
  614. XmStringFree (label_string);
  615. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  616. (XtPointer) preferences_rec);
  617. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  618. HELP_PREFERENCES_ORDER_STR);
  619. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 11, "By File Type")));
  620. n = 0;
  621. XtSetArg (args[n], XmNlabelString, label_string); n++;
  622. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  623. XtSetArg (args[n], XmNtopWidget, temp); n++;
  624. XtSetArg (args[n], XmNtopOffset, offset); n++;
  625. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  626. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  627. preferences_rec->order_file_type = temp =
  628. XmCreateToggleButtonGadget (group_form, "by_file_type", args, n);
  629. XtManageChild (temp);
  630. XmStringFree (label_string);
  631. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  632. (XtPointer) preferences_rec);
  633. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  634. HELP_PREFERENCES_ORDER_STR);
  635. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 13, "By Date")));
  636. n = 0;
  637. XtSetArg (args[n], XmNlabelString, label_string); n++;
  638. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  639. XtSetArg (args[n], XmNtopWidget, temp); n++;
  640. XtSetArg (args[n], XmNtopOffset, offset); n++;
  641. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  642. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  643. preferences_rec->order_date = temp =
  644. XmCreateToggleButtonGadget (group_form, "by_date", args, n);
  645. XtManageChild (temp);
  646. XmStringFree (label_string);
  647. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  648. (XtPointer) preferences_rec);
  649. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  650. HELP_PREFERENCES_ORDER_STR);
  651. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 14, "By Size")));
  652. n = 0;
  653. XtSetArg (args[n], XmNlabelString, label_string); n++;
  654. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  655. XtSetArg (args[n], XmNtopWidget, temp); n++;
  656. XtSetArg (args[n], XmNtopOffset, offset); n++;
  657. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  658. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  659. preferences_rec->order_size = temp =
  660. XmCreateToggleButtonGadget (group_form, "by_size", args, n);
  661. XtManageChild (temp);
  662. XmStringFree (label_string);
  663. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  664. (XtPointer) preferences_rec);
  665. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  666. HELP_PREFERENCES_ORDER_STR);
  667. /* Create the file direction container and widgets */
  668. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 15, "Direction")));
  669. n = 0;
  670. XtSetArg (args[n], XmNtitleString, label_string); n++;
  671. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  672. XtSetArg (args[n], XmNtopWidget, view_frame); n++;
  673. XtSetArg (args[n], XmNtopOffset, offset); n++;
  674. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  675. XtSetArg (args[n], XmNbottomWidget, order_frame); n++;
  676. XtSetArg (args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  677. XtSetArg (args[n], XmNleftWidget, view_frame); n++;
  678. XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  679. XtSetArg (args[n], XmNrightOffset, offset); n++;
  680. XtSetArg (args[n], XmNmarginWidth, offset); n++;
  681. XtSetArg (args[n], XmNmarginHeight, offset); n++;
  682. direction_frame = _DtCreateTitleBox (form, "direction_frame", args, n);
  683. XtManageChild (direction_frame);
  684. XmStringFree (label_string);
  685. XtAddCallback(direction_frame, XmNhelpCallback,
  686. (XtCallbackProc)HelpRequestCB,
  687. HELP_PREFERENCES_DIRECTION_STR);
  688. titleWidget = _DtTitleBoxGetTitleArea(direction_frame);
  689. XtSetArg (args[0], XmNtraversalOn, False);
  690. XtSetValues (titleWidget, args, 1);
  691. group_form = XmCreateForm (direction_frame, "direction_form", args, 0);
  692. XtManageChild (group_form);
  693. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 16, "Ascending")));
  694. n = 0;
  695. XtSetArg (args[n], XmNlabelString, label_string); n++;
  696. XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  697. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  698. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  699. preferences_rec->direction_ascending = temp =
  700. XmCreateToggleButtonGadget (group_form, "ascending", args, n);
  701. XtManageChild (temp);
  702. XmStringFree (label_string);
  703. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  704. (XtPointer) preferences_rec);
  705. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  706. HELP_PREFERENCES_DIRECTION_STR);
  707. label_string = XmStringCreateLocalized (((char *)GETMESSAGE(23, 17, "Descending")));
  708. n = 0;
  709. XtSetArg (args[n], XmNlabelString, label_string); n++;
  710. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  711. XtSetArg (args[n], XmNtopWidget, temp); n++;
  712. XtSetArg (args[n], XmNtopOffset, offset); n++;
  713. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  714. XtSetArg (args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  715. preferences_rec->direction_descending = temp =
  716. XmCreateToggleButtonGadget (group_form, "descending", args, n);
  717. XtManageChild (temp);
  718. XmStringFree (label_string);
  719. XtAddCallback (temp, XmNvalueChangedCallback, ToggleCallback,
  720. (XtPointer) preferences_rec);
  721. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  722. HELP_PREFERENCES_DIRECTION_STR);
  723. /* Create a separator between the buttons */
  724. n = 0;
  725. XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  726. XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  727. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  728. XtSetArg (args[n], XmNtopWidget, order_frame); n++;
  729. XtSetArg (args[n], XmNtopOffset, offset); n++;
  730. separator = XmCreateSeparatorGadget (form, "separator", args, n);
  731. XtManageChild (separator);
  732. /* Create the ok, apply, reset, cancel and help buttons */
  733. n = 0;
  734. XtSetArg (args[n], XmNlabelString, okXmString); n++;
  735. XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  736. XtSetArg (args[n], XmNleftPosition, 1); n++;
  737. XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  738. XtSetArg (args[n], XmNrightPosition, 19); n++;
  739. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  740. XtSetArg (args[n], XmNtopWidget, separator); n++;
  741. XtSetArg (args[n], XmNtopOffset, offset); n++;
  742. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  743. XtSetArg (args[n], XmNbottomOffset, offset); n++;
  744. XtSetArg (args[n], XmNmarginWidth, 4); n++;
  745. XtSetArg (args[n], XmNmarginHeight, 4); n++;
  746. preferences_rec->ok = temp =
  747. XmCreatePushButtonGadget (form, "ok", args, n);
  748. XtManageChild (temp);
  749. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  750. HELP_PREFERENCES_DIALOG_STR);
  751. n = 0;
  752. XtSetArg (args[n], XmNlabelString, applyXmString); n++;
  753. XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  754. XtSetArg (args[n], XmNleftPosition, 21); n++;
  755. XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  756. XtSetArg (args[n], XmNrightPosition, 39); n++;
  757. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  758. XtSetArg (args[n], XmNtopWidget, separator); n++;
  759. XtSetArg (args[n], XmNtopOffset, offset); n++;
  760. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  761. XtSetArg (args[n], XmNbottomOffset, offset); n++;
  762. XtSetArg (args[n], XmNmarginWidth, 4); n++;
  763. XtSetArg (args[n], XmNmarginHeight, 4); n++;
  764. preferences_rec->apply = temp =
  765. XmCreatePushButtonGadget (form, "apply", args, n);
  766. XtManageChild (temp);
  767. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  768. HELP_PREFERENCES_DIALOG_STR);
  769. label_string = XmStringCreateLocalized ((GETMESSAGE(23,30, "Defaults")));
  770. n = 0;
  771. XtSetArg (args[n], XmNlabelString, label_string); n++;
  772. XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  773. XtSetArg (args[n], XmNleftPosition, 41); n++;
  774. XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  775. XtSetArg (args[n], XmNrightPosition, 59); n++;
  776. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  777. XtSetArg (args[n], XmNtopWidget, separator); n++;
  778. XtSetArg (args[n], XmNtopOffset, offset); n++;
  779. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  780. XtSetArg (args[n], XmNbottomOffset, offset); n++;
  781. XtSetArg (args[n], XmNmarginWidth, 4); n++;
  782. XtSetArg (args[n], XmNmarginHeight, 4); n++;
  783. preferences_rec->reset = temp =
  784. XmCreatePushButtonGadget (form, "defaults", args, n);
  785. XmStringFree (label_string);
  786. XtManageChild (temp);
  787. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  788. HELP_PREFERENCES_DIALOG_STR);
  789. XtAddCallback (temp, XmNactivateCallback, ResetCallback,
  790. (XtPointer) preferences_rec);
  791. n = 0;
  792. XtSetArg (args[n], XmNlabelString, cancelXmString); n++;
  793. XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  794. XtSetArg (args[n], XmNleftPosition, 61); n++;
  795. XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  796. XtSetArg (args[n], XmNrightPosition, 79); n++;
  797. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  798. XtSetArg (args[n], XmNtopWidget, separator); n++;
  799. XtSetArg (args[n], XmNtopOffset, offset); n++;
  800. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  801. XtSetArg (args[n], XmNbottomOffset, offset); n++;
  802. XtSetArg (args[n], XmNmarginWidth, 4); n++;
  803. XtSetArg (args[n], XmNmarginHeight, 4); n++;
  804. preferences_rec->close = temp =
  805. XmCreatePushButtonGadget (form, "close", args, n);
  806. XtManageChild (temp);
  807. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  808. HELP_PREFERENCES_DIALOG_STR);
  809. n = 0;
  810. XtSetArg (args[n], XmNlabelString, helpXmString); n++;
  811. XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  812. XtSetArg (args[n], XmNleftPosition, 81); n++;
  813. XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  814. XtSetArg (args[n], XmNrightPosition, 99); n++;
  815. XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  816. XtSetArg (args[n], XmNtopWidget, separator); n++;
  817. XtSetArg (args[n], XmNtopOffset, offset); n++;
  818. XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  819. XtSetArg (args[n], XmNbottomOffset, offset); n++;
  820. XtSetArg (args[n], XmNmarginWidth, 4); n++;
  821. XtSetArg (args[n], XmNmarginHeight, 4); n++;
  822. preferences_rec->help = temp =
  823. XmCreatePushButtonGadget (form, "help", args, n);
  824. XtManageChild (temp);
  825. XtAddCallback(temp, XmNactivateCallback, (XtCallbackProc)HelpRequestCB,
  826. HELP_PREFERENCES_DIALOG_STR);
  827. XtAddCallback(temp, XmNhelpCallback, (XtCallbackProc)HelpRequestCB,
  828. HELP_PREFERENCES_DIALOG_STR);
  829. XtSetArg (args[0], XmNcancelButton, preferences_rec->close);
  830. XtSetArg (args[1], XmNdefaultButton, preferences_rec->ok);
  831. XtSetValues (form, args, 2);
  832. /* Set the return values for the dialog widget and dialog instance. */
  833. *return_widget = form;
  834. *dialog = (XtPointer) preferences_rec;
  835. }
  836. /************************************************************************
  837. *
  838. * InstallChange
  839. *
  840. ************************************************************************/
  841. static void
  842. InstallChange(
  843. PreferencesRec *preferences_rec,
  844. XtCallbackProc callback,
  845. XtPointer client_data )
  846. {
  847. PreferencesApply * apply_data;
  848. /* Setup the callback data to be sent to the Ok callback. */
  849. /* This contains the encapsulation callback to invoke upon */
  850. /* the data within the dialog being changed. */
  851. apply_data = (PreferencesApply *) XtMalloc (sizeof (PreferencesApply));
  852. apply_data->callback = callback;
  853. apply_data->client_data = client_data;
  854. apply_data->preferences_rec = (XtPointer) preferences_rec;
  855. preferences_rec->apply_data = apply_data;
  856. /* Add the callbacks for list item insertion. */
  857. XtAddCallback (preferences_rec->apply, XmNactivateCallback,
  858. (XtCallbackProc)ApplyCallback, (XtPointer) apply_data);
  859. XtAddCallback (preferences_rec->ok, XmNactivateCallback,
  860. (XtCallbackProc)OkCallback, (XtPointer) apply_data);
  861. }
  862. /************************************************************************
  863. *
  864. * InstallClose
  865. *
  866. ************************************************************************/
  867. static void
  868. InstallClose(
  869. PreferencesRec *preferences_rec,
  870. XtCallbackProc callback,
  871. XtPointer client_data )
  872. {
  873. Atom delete_window_atom;
  874. XtAddCallback (preferences_rec->close,
  875. XmNactivateCallback, callback, client_data);
  876. delete_window_atom = XmInternAtom (XtDisplay(preferences_rec->shell),
  877. "WM_DELETE_WINDOW", True);
  878. XmRemoveWMProtocols( preferences_rec->shell, &delete_window_atom, 1 );
  879. XmAddWMProtocolCallback( preferences_rec->shell, delete_window_atom,
  880. callback, (XtPointer) client_data );
  881. }
  882. /************************************************************************
  883. *
  884. * Destroy
  885. *
  886. ************************************************************************/
  887. static void
  888. Destroy(
  889. PreferencesRec *preferences_rec )
  890. {
  891. XtDestroyWidget (preferences_rec->shell);
  892. XtFree ((char *) preferences_rec->apply_data);
  893. XtFree ((char *) preferences_rec);
  894. }
  895. /************************************************************************
  896. *
  897. * GetValues
  898. *
  899. ************************************************************************/
  900. static XtPointer
  901. GetValues(
  902. PreferencesRec *preferences_rec )
  903. {
  904. PreferencesData * preferences_data;
  905. Arg args[4];
  906. /* Allocate and initialize the change dir dialog data. */
  907. preferences_data = (PreferencesData *) XtMalloc (sizeof (PreferencesData));
  908. preferences_data->displayed = True;
  909. XtSetArg (args[0], XmNx, &preferences_data->x);
  910. XtSetArg (args[1], XmNy, &preferences_data->y);
  911. XtSetArg (args[2], XmNwidth, &preferences_data->width);
  912. XtSetArg (args[3], XmNheight, &preferences_data->height);
  913. XtGetValues (preferences_rec->shell, args, 4);
  914. GetPreferencesValues (preferences_rec, preferences_data);
  915. return ((XtPointer) preferences_data);
  916. }
  917. /************************************************************************
  918. *
  919. * GetDefaultValues
  920. *
  921. ************************************************************************/
  922. static XtPointer
  923. GetDefaultValues( void )
  924. {
  925. PreferencesData * preferences_data;
  926. /* Allocate and initialize the default change dir dialog data. */
  927. preferences_data = (PreferencesData *) XtMalloc (sizeof (PreferencesData));
  928. preferences_data->displayed = False;
  929. preferences_data->x = 0;
  930. preferences_data->y = 0;
  931. preferences_data->height = 0;
  932. preferences_data->width = 0;
  933. preferences_data->show_type = SINGLE_DIRECTORY;
  934. preferences_data->tree_files = TREE_FILES_NEVER;
  935. preferences_data->view_single = BY_NAME_AND_ICON;
  936. preferences_data->view_tree = BY_NAME_AND_SMALL_ICON;
  937. preferences_data->order = ORDER_BY_ALPHABETICAL;
  938. preferences_data->direction = DIRECTION_ASCENDING;
  939. preferences_data->positionEnabled = RANDOM_OFF;
  940. return ((XtPointer) preferences_data);
  941. }
  942. /************************************************************************
  943. *
  944. * GetResourceValues
  945. *
  946. ************************************************************************/
  947. static XtPointer
  948. GetResourceValues(
  949. XrmDatabase data_base,
  950. char **name_list )
  951. {
  952. PreferencesData * preferences_data;
  953. /* Allocate and get the resources for change dir dialog data. */
  954. preferences_data = (PreferencesData *) XtMalloc (sizeof (PreferencesData));
  955. _DtDialogGetResources (data_base, name_list, PreferencesName,
  956. (char *)preferences_data, resources,
  957. preferencesClass->resource_count);
  958. return ((XtPointer) preferences_data);
  959. }
  960. /************************************************************************
  961. *
  962. * SetValues
  963. *
  964. ************************************************************************/
  965. static void
  966. SetValues(
  967. PreferencesRec *preferences_rec,
  968. PreferencesData *preferences_data )
  969. {
  970. Arg true_args[1];
  971. Arg false_args[1];
  972. unsigned char *viewP;
  973. XtSetArg (true_args[0], XmNset, True);
  974. XtSetArg (false_args[0], XmNset, False);
  975. if (preferences_data->show_type == SINGLE_DIRECTORY)
  976. {
  977. XtSetValues (preferences_rec->show_single, true_args, 1);
  978. XtSetValues (preferences_rec->show_multiple, false_args, 1);
  979. if( trashFileMgrData
  980. &&(PreferencesData *)trashFileMgrData->preferences->data ==
  981. preferences_data)
  982. XtSetSensitive (XtParent (preferences_rec->show_multiple), False);
  983. else
  984. XtSetSensitive (XtParent (preferences_rec->show_multiple), True);
  985. XtSetSensitive (preferences_rec->tree_files_never, False);
  986. XtSetSensitive (preferences_rec->tree_files_choose, False);
  987. XtSetSensitive (preferences_rec->tree_files_always, False);
  988. viewP = &preferences_data->view_single;
  989. if (*viewP == BY_ATTRIBUTES)
  990. XtSetSensitive (XtParent (preferences_rec->random_on), False);
  991. else
  992. XtSetSensitive (XtParent (preferences_rec->random_on), True);
  993. }
  994. else
  995. {
  996. XtSetValues (preferences_rec->show_single, false_args, 1);
  997. XtSetValues (preferences_rec->show_multiple, true_args, 1);
  998. XtSetSensitive (XtParent (preferences_rec->random_on), False);
  999. XtSetSensitive (preferences_rec->tree_files_never, True);
  1000. XtSetSensitive (preferences_rec->tree_files_choose, True);
  1001. XtSetSensitive (preferences_rec->tree_files_always, True);
  1002. viewP = &preferences_data->view_tree;
  1003. }
  1004. if (preferences_data->tree_files == TREE_FILES_NEVER)
  1005. {
  1006. XtSetValues (preferences_rec->tree_files_never, true_args, 1);
  1007. XtSetValues (preferences_rec->tree_files_choose, false_args, 1);
  1008. XtSetValues (preferences_rec->tree_files_always, false_args, 1);
  1009. }
  1010. else if (preferences_data->tree_files == TREE_FILES_CHOOSE)
  1011. {
  1012. XtSetValues (preferences_rec->tree_files_never, false_args, 1);
  1013. XtSetValues (preferences_rec->tree_files_choose, true_args, 1);
  1014. XtSetValues (preferences_rec->tree_files_always, false_args, 1);
  1015. }
  1016. else /* preferences_data->tree_files == TREE_FILES_ALWAYS */
  1017. {
  1018. XtSetValues (preferences_rec->tree_files_never, false_args, 1);
  1019. XtSetValues (preferences_rec->tree_files_choose, false_args, 1);
  1020. XtSetValues (preferences_rec->tree_files_always, true_args, 1);
  1021. }
  1022. preferences_rec->view_single = preferences_data->view_single;
  1023. preferences_rec->view_tree = preferences_data->view_tree;
  1024. if (*viewP == BY_NAME)
  1025. {
  1026. XtSetValues (preferences_rec->by_name, true_args, 1);
  1027. XtSetValues (preferences_rec->by_name_and_icon, false_args, 1);
  1028. XtSetValues (preferences_rec->by_name_and_small_icon, false_args, 1);
  1029. XtSetValues (preferences_rec->by_attributes, false_args, 1);
  1030. }
  1031. else if (*viewP == BY_NAME_AND_ICON)
  1032. {
  1033. XtSetValues (preferences_rec->by_name, false_args, 1);
  1034. XtSetValues (preferences_rec->by_name_and_icon, true_args, 1);
  1035. XtSetValues (preferences_rec->by_name_and_small_icon, false_args, 1);
  1036. XtSetValues (preferences_rec->by_attributes, false_args, 1);
  1037. }
  1038. else if (*viewP == BY_NAME_AND_SMALL_ICON)
  1039. {
  1040. XtSetValues (preferences_rec->by_name, false_args, 1);
  1041. XtSetValues (preferences_rec->by_name_and_icon, false_args, 1);
  1042. XtSetValues (preferences_rec->by_name_and_small_icon, true_args, 1);
  1043. XtSetValues (preferences_rec->by_attributes, false_args, 1);
  1044. }
  1045. else if (*viewP == BY_ATTRIBUTES)
  1046. {
  1047. XtSetValues (preferences_rec->by_name, false_args, 1);
  1048. XtSetValues (preferences_rec->by_name_and_icon, false_args, 1);
  1049. XtSetValues (preferences_rec->by_name_and_small_icon, false_args, 1);
  1050. XtSetValues (preferences_rec->by_attributes, true_args, 1);
  1051. }
  1052. if (preferences_data->order == ORDER_BY_FILE_TYPE)
  1053. {
  1054. XtSetValues (preferences_rec->order_file_type, true_args, 1);
  1055. XtSetValues (preferences_rec->order_alphabetical, false_args, 1);
  1056. XtSetValues (preferences_rec->order_date, false_args, 1);
  1057. XtSetValues (preferences_rec->order_size, false_args, 1);
  1058. }
  1059. else if (preferences_data->order == ORDER_BY_ALPHABETICAL)
  1060. {
  1061. XtSetValues (preferences_rec->order_file_type, false_args, 1);
  1062. XtSetValues (preferences_rec->order_alphabetical, true_args, 1);
  1063. XtSetValues (preferences_rec->order_date, false_args, 1);
  1064. XtSetValues (preferences_rec->order_size, false_args, 1);
  1065. }
  1066. else if (preferences_data->order == ORDER_BY_DATE)
  1067. {
  1068. XtSetValues (preferences_rec->order_file_type, false_args, 1);
  1069. XtSetValues (preferences_rec->order_alphabetical, false_args, 1);
  1070. XtSetValues (preferences_rec->order_date, true_args, 1);
  1071. XtSetValues (preferences_rec->order_size, false_args, 1);
  1072. }
  1073. else if (preferences_data->order == ORDER_BY_SIZE)
  1074. {
  1075. XtSetValues (preferences_rec->order_file_type, false_args, 1);
  1076. XtSetValues (preferences_rec->order_alphabetical, false_args, 1);
  1077. XtSetValues (preferences_rec->order_date, false_args, 1);
  1078. XtSetValues (preferences_rec->order_size, true_args, 1);
  1079. }
  1080. if (preferences_data->direction == DIRECTION_ASCENDING)
  1081. {
  1082. XtSetValues (preferences_rec->direction_ascending, true_args, 1);
  1083. XtSetValues (preferences_rec->direction_descending, false_args, 1);
  1084. }
  1085. if (preferences_data->direction == DIRECTION_DESCENDING)
  1086. {
  1087. XtSetValues (preferences_rec->direction_ascending, false_args, 1);
  1088. XtSetValues (preferences_rec->direction_descending, true_args, 1);
  1089. }
  1090. if (preferences_data->positionEnabled == RANDOM_ON)
  1091. {
  1092. XtSetValues (preferences_rec->random_on, true_args, 1);
  1093. XtSetValues (preferences_rec->random_off, false_args, 1);
  1094. }
  1095. if (preferences_data->positionEnabled == RANDOM_OFF)
  1096. {
  1097. XtSetValues (preferences_rec->random_off, true_args, 1);
  1098. XtSetValues (preferences_rec->random_on, false_args, 1);
  1099. }
  1100. if( trashFileMgrData
  1101. &&(PreferencesData *)trashFileMgrData->preferences->data ==
  1102. preferences_data )
  1103. {
  1104. XtSetSensitive( preferences_rec->show_iconic_path, False );
  1105. XtSetSensitive( preferences_rec->show_current_dir, False );
  1106. XtSetSensitive( preferences_rec->show_status_line, False );
  1107. XtSetSensitive( preferences_rec->random_on, False );
  1108. }
  1109. else if( showFilesystem )
  1110. {
  1111. XtSetSensitive( preferences_rec->show_iconic_path, True );
  1112. XtSetSensitive( preferences_rec->show_current_dir, True );
  1113. XtSetSensitive( preferences_rec->show_status_line, True );
  1114. XtSetSensitive( preferences_rec->random_on, True );
  1115. if (preferences_data->show_iconic_path)
  1116. XtSetValues (preferences_rec->show_iconic_path, true_args, 1);
  1117. else
  1118. XtSetValues (preferences_rec->show_iconic_path, false_args, 1);
  1119. if (preferences_data->show_current_dir)
  1120. XtSetValues (preferences_rec->show_current_dir, true_args, 1);
  1121. else
  1122. XtSetValues (preferences_rec->show_current_dir, false_args, 1);
  1123. if (preferences_data->show_status_line)
  1124. XtSetValues (preferences_rec->show_status_line, true_args, 1);
  1125. else
  1126. XtSetValues (preferences_rec->show_status_line, false_args, 1);
  1127. }
  1128. else
  1129. {
  1130. XtSetSensitive( preferences_rec->show_iconic_path, False );
  1131. XtSetSensitive( preferences_rec->show_current_dir, False );
  1132. XtSetSensitive( preferences_rec->show_status_line, False );
  1133. XtSetSensitive( preferences_rec->random_on, True );
  1134. }
  1135. }
  1136. /************************************************************************
  1137. *
  1138. * WriteResourceValues
  1139. *
  1140. ************************************************************************/
  1141. static void
  1142. WriteResourceValues(
  1143. DialogData *values,
  1144. int fd,
  1145. char **name_list )
  1146. {
  1147. PreferencesData * preferences_data = (PreferencesData *) values->data;
  1148. PreferencesRec * preferences_rec;
  1149. Arg args[2];
  1150. /* If the dialog is currently displayed, update the geometry */
  1151. /* fields to their current values. */
  1152. if (preferences_data->displayed == True)
  1153. {
  1154. _DtGenericUpdateWindowPosition(values);
  1155. preferences_rec = (PreferencesRec *) _DtGetDialogInstance (values);
  1156. }
  1157. _DtDialogPutResources (fd, name_list, PreferencesName, values->data,
  1158. resources, preferencesClass->resource_count);
  1159. }
  1160. /************************************************************************
  1161. *
  1162. * FreeValues
  1163. *
  1164. ************************************************************************/
  1165. static void
  1166. FreeValues(
  1167. PreferencesData *preferences_data )
  1168. {
  1169. XtFree ((char *) preferences_data);
  1170. }
  1171. /************************************************************************
  1172. *
  1173. * ResetCallback
  1174. *
  1175. ************************************************************************/
  1176. static void
  1177. ResetCallback(
  1178. Widget w,
  1179. XtPointer client_data,
  1180. XtPointer call_data )
  1181. {
  1182. PreferencesRec * preferences_rec = (PreferencesRec *) client_data;
  1183. DialogData * dialog_data;
  1184. PreferencesData * preferences_data;
  1185. dialog_data = _DtGetInstanceData ((XtPointer)preferences_rec);
  1186. preferences_data = (PreferencesData *) dialog_data->data;
  1187. preferences_data->show_type = SINGLE_DIRECTORY;
  1188. preferences_data->tree_files = TREE_FILES_NEVER;
  1189. preferences_data->view_single = BY_NAME_AND_ICON;
  1190. preferences_data->view_tree = BY_NAME_AND_SMALL_ICON;
  1191. preferences_data->order = ORDER_BY_ALPHABETICAL;
  1192. preferences_data->direction = DIRECTION_ASCENDING;
  1193. preferences_data->positionEnabled = RANDOM_OFF;
  1194. preferences_data->show_iconic_path = True;
  1195. preferences_data->show_current_dir = True;
  1196. preferences_data->show_status_line = True;
  1197. /* Get the current data for the dialog and redisplay. */
  1198. SetValues (preferences_rec, (PreferencesData *) dialog_data->data);
  1199. }
  1200. /************************************************************************
  1201. *
  1202. * ToggleCallback
  1203. * Handle the one of many processing for the toggles.
  1204. *
  1205. ************************************************************************/
  1206. static void
  1207. ToggleCallback(
  1208. Widget w,
  1209. XtPointer client_data,
  1210. XtPointer call_data )
  1211. {
  1212. PreferencesRec * preferences_rec;
  1213. DialogData * dialog_data;
  1214. PreferencesData * preferences_data;
  1215. Boolean set;
  1216. unsigned char *viewP;
  1217. Arg args[1];
  1218. Arg false_args[1];
  1219. Arg true_args[1];
  1220. int tmp_view;
  1221. preferences_rec = (PreferencesRec *) client_data;
  1222. dialog_data = _DtGetInstanceData ((XtPointer)preferences_rec);
  1223. preferences_data = (PreferencesData *) dialog_data->data;
  1224. XtSetArg (false_args[0], XmNset, False);
  1225. XtSetArg (true_args[0], XmNset, True);
  1226. XtSetArg (args[0], XmNset, &set);
  1227. XtGetValues (preferences_rec->show_multiple, args, 1);
  1228. if (set)
  1229. viewP = &preferences_rec->view_tree;
  1230. else
  1231. viewP = &preferences_rec->view_single;
  1232. if (w == preferences_rec->show_single)
  1233. {
  1234. XtSetValues (preferences_rec->show_multiple, false_args, 1);
  1235. XtSetValues (preferences_rec->show_single, true_args, 1);
  1236. XtSetSensitive (XtParent (preferences_rec->random_on), True);
  1237. XtSetSensitive (preferences_rec->tree_files_never, False);
  1238. XtSetSensitive (preferences_rec->tree_files_choose, False);
  1239. XtSetSensitive (preferences_rec->tree_files_always, False);
  1240. if (preferences_rec->view_single == BY_NAME)
  1241. w = preferences_rec->by_name;
  1242. else if (preferences_rec->view_single == BY_NAME_AND_ICON)
  1243. w = preferences_rec->by_name_and_icon;
  1244. else if (preferences_rec->view_single == BY_NAME_AND_SMALL_ICON)
  1245. w = preferences_rec->by_name_and_small_icon;
  1246. else
  1247. {
  1248. w = preferences_rec->by_attributes;
  1249. XtSetSensitive (XtParent (preferences_rec->random_on), False);
  1250. }
  1251. showType = SINGLE_DIRECTORY;
  1252. ToggleCallback (w, client_data, call_data);
  1253. }
  1254. else if (w == preferences_rec->show_multiple)
  1255. {
  1256. XtSetValues (preferences_rec->show_single, false_args, 1);
  1257. XtSetValues (preferences_rec->show_multiple, true_args, 1);
  1258. XtSetSensitive (XtParent (preferences_rec->random_on), False);
  1259. XtSetSensitive (preferences_rec->tree_files_never, True);
  1260. XtSetSensitive (preferences_rec->tree_files_choose, True);
  1261. XtSetSensitive (preferences_rec->tree_files_always, True);
  1262. if (preferences_rec->view_tree == BY_NAME)
  1263. w = preferences_rec->by_name;
  1264. else if (preferences_rec->view_tree == BY_NAME_AND_ICON)
  1265. w = preferences_rec->by_name_and_icon;
  1266. else if (preferences_rec->view_tree == BY_NAME_AND_SMALL_ICON)
  1267. w = preferences_rec->by_name_and_small_icon;
  1268. else
  1269. w = preferences_rec->by_attributes;
  1270. showType = MULTIPLE_DIRECTORY;
  1271. ToggleCallback (w, client_data, call_data);
  1272. }
  1273. else if (w == preferences_rec->tree_files_never)
  1274. {
  1275. XtSetValues (preferences_rec->tree_files_choose, false_args, 1);
  1276. XtSetValues (preferences_rec->tree_files_always, false_args, 1);
  1277. XtSetValues (preferences_rec->tree_files_never, true_args, 1);
  1278. }
  1279. else if (w == preferences_rec->tree_files_choose)
  1280. {
  1281. XtSetValues (preferences_rec->tree_files_never, false_args, 1);
  1282. XtSetValues (preferences_rec->tree_files_always, false_args, 1);
  1283. XtSetValues (preferences_rec->tree_files_choose, true_args, 1);
  1284. }
  1285. else if (w == preferences_rec->tree_files_always)
  1286. {
  1287. XtSetValues (preferences_rec->tree_files_never, false_args, 1);
  1288. XtSetValues (preferences_rec->tree_files_choose, false_args, 1);
  1289. XtSetValues (preferences_rec->tree_files_always, true_args, 1);
  1290. }
  1291. else if (w == preferences_rec->by_name)
  1292. {
  1293. if (showType == SINGLE_DIRECTORY)
  1294. XtSetSensitive (XtParent (preferences_rec->random_on), True);
  1295. XtSetValues (preferences_rec->by_name_and_icon, false_args, 1);
  1296. XtSetValues (preferences_rec->by_name_and_small_icon, false_args, 1);
  1297. XtSetValues (preferences_rec->by_attributes, false_args, 1);
  1298. XtSetValues (preferences_rec->by_name, true_args, 1);
  1299. *viewP = BY_NAME;
  1300. }
  1301. else if (w == preferences_rec->by_name_and_icon)
  1302. {
  1303. if (showType == SINGLE_DIRECTORY)
  1304. XtSetSensitive (XtParent (preferences_rec->random_on), True);
  1305. XtSetValues (preferences_rec->by_name, false_args, 1);
  1306. XtSetValues (preferences_rec->by_name_and_small_icon, false_args, 1);
  1307. XtSetValues (preferences_rec->by_attributes, false_args, 1);
  1308. XtSetValues (preferences_rec->by_name_and_icon, true_args, 1);
  1309. *viewP = BY_NAME_AND_ICON;
  1310. }
  1311. else if (w == preferences_rec->by_name_and_small_icon)
  1312. {
  1313. if (showType == SINGLE_DIRECTORY)
  1314. XtSetSensitive (XtParent (preferences_rec->random_on), True);
  1315. XtSetValues (preferences_rec->by_name, false_args, 1);
  1316. XtSetValues (preferences_rec->by_attributes, false_args, 1);
  1317. XtSetValues (preferences_rec->by_name_and_icon, false_args, 1);
  1318. XtSetValues (preferences_rec->by_name_and_small_icon, true_args, 1);
  1319. *viewP = BY_NAME_AND_SMALL_ICON;
  1320. }
  1321. else if (w == preferences_rec->by_attributes)
  1322. {
  1323. XtSetSensitive (XtParent (preferences_rec->random_on), False);
  1324. XtSetValues (preferences_rec->by_name, false_args, 1);
  1325. XtSetValues (preferences_rec->by_name_and_icon, false_args, 1);
  1326. XtSetValues (preferences_rec->by_name_and_small_icon, false_args, 1);
  1327. XtSetValues (preferences_rec->by_attributes, true_args, 1);
  1328. *viewP = BY_ATTRIBUTES;
  1329. }
  1330. else if (w == preferences_rec->order_file_type)
  1331. {
  1332. XtSetValues (preferences_rec->order_alphabetical, false_args, 1);
  1333. XtSetValues (preferences_rec->order_date, false_args, 1);
  1334. XtSetValues (preferences_rec->order_size, false_args, 1);
  1335. XtSetValues (preferences_rec->order_file_type, true_args, 1);
  1336. }
  1337. else if (w == preferences_rec->order_alphabetical)
  1338. {
  1339. XtSetValues (preferences_rec->order_file_type, false_args, 1);
  1340. XtSetValues (preferences_rec->order_date, false_args, 1);
  1341. XtSetValues (preferences_rec->order_size, false_args, 1);
  1342. XtSetValues (preferences_rec->order_alphabetical, true_args, 1);
  1343. }
  1344. else if (w == preferences_rec->order_date)
  1345. {
  1346. XtSetValues (preferences_rec->order_file_type, false_args, 1);
  1347. XtSetValues (preferences_rec->order_alphabetical, false_args, 1);
  1348. XtSetValues (preferences_rec->order_size, false_args, 1);
  1349. XtSetValues (preferences_rec->order_date, true_args, 1);
  1350. }
  1351. else if (w == preferences_rec->order_size)
  1352. {
  1353. XtSetValues (preferences_rec->order_file_type, false_args, 1);
  1354. XtSetValues (preferences_rec->order_alphabetical, false_args, 1);
  1355. XtSetValues (preferences_rec->order_date, false_args, 1);
  1356. XtSetValues (preferences_rec->order_size, true_args, 1);
  1357. }
  1358. else if (w == preferences_rec->direction_ascending)
  1359. {
  1360. XtSetValues (preferences_rec->direction_descending, false_args, 1);
  1361. XtSetValues (preferences_rec->direction_ascending, true_args, 1);
  1362. }
  1363. else if (w == preferences_rec->direction_descending)
  1364. {
  1365. XtSetValues (preferences_rec->direction_ascending, false_args, 1);
  1366. XtSetValues (preferences_rec->direction_descending, true_args, 1);
  1367. }
  1368. else if (w == preferences_rec->random_on)
  1369. {
  1370. XtSetValues (preferences_rec->random_off, false_args, 1);
  1371. XtSetValues (preferences_rec->random_on, true_args, 1);
  1372. }
  1373. else if (w == preferences_rec->random_off)
  1374. {
  1375. XtSetValues (preferences_rec->random_on, false_args, 1);
  1376. XtSetValues (preferences_rec->random_off, true_args, 1);
  1377. }
  1378. }
  1379. /************************************************************************
  1380. *
  1381. * OkCallback
  1382. * This is a callback function called when the (Ok) button
  1383. * is pressed. It saves the new preverences data itnernally and
  1384. * then calls the encapsulations callback function.
  1385. *
  1386. ************************************************************************/
  1387. static void
  1388. OkCallback(
  1389. Widget w,
  1390. PreferencesApply *apply_data,
  1391. XtPointer call_data )
  1392. {
  1393. PreferencesRec * preferences_rec;
  1394. DialogData * dialog_data;
  1395. ApplyCallback( w, apply_data, call_data);
  1396. preferences_rec = (PreferencesRec *) apply_data->preferences_rec;
  1397. dialog_data = _DtGetInstanceData ((XtPointer)preferences_rec);
  1398. XtCallCallbacks(preferences_rec->close, XmNactivateCallback,
  1399. (XtPointer)dialog_data);
  1400. }
  1401. /************************************************************************
  1402. *
  1403. * ApplyCallback
  1404. * This is a callback function called when the (Apply) button
  1405. * is pressed. It saves the new preverences data itnernally and
  1406. * then calls the encapsulations callback funtion.
  1407. *
  1408. ************************************************************************/
  1409. static void
  1410. ApplyCallback(
  1411. Widget w,
  1412. PreferencesApply *apply_data,
  1413. XtPointer call_data )
  1414. {
  1415. (*(apply_data->callback)) (w, apply_data->client_data, NULL);
  1416. }
  1417. /************************************************************************
  1418. *
  1419. * GetPreferencesValues
  1420. * Update the current preferences values within the data structure
  1421. * from the current toggle button values.
  1422. *
  1423. ************************************************************************/
  1424. static void
  1425. GetPreferencesValues(
  1426. PreferencesRec *preferences_rec,
  1427. PreferencesData *preferences_data )
  1428. {
  1429. Boolean set;
  1430. Arg args[2];
  1431. XtSetArg (args[0], XmNset, &set);
  1432. XtGetValues (preferences_rec->show_single, args, 1);
  1433. if (set) preferences_data->show_type = SINGLE_DIRECTORY;
  1434. XtGetValues (preferences_rec->show_multiple, args, 1);
  1435. if (set) preferences_data->show_type = MULTIPLE_DIRECTORY;
  1436. preferences_data->view_single = preferences_rec->view_single;
  1437. preferences_data->view_tree = preferences_rec->view_tree;
  1438. XtGetValues (preferences_rec->tree_files_never, args, 1);
  1439. if (set) preferences_data->tree_files = TREE_FILES_NEVER;
  1440. XtGetValues (preferences_rec->tree_files_choose, args, 1);
  1441. if (set) preferences_data->tree_files = TREE_FILES_CHOOSE;
  1442. XtGetValues (preferences_rec->tree_files_always, args, 1);
  1443. if (set) preferences_data->tree_files = TREE_FILES_ALWAYS;
  1444. XtGetValues (preferences_rec->order_file_type, args, 1);
  1445. if (set) preferences_data->order = ORDER_BY_FILE_TYPE;
  1446. XtGetValues (preferences_rec->order_alphabetical, args, 1);
  1447. if (set) preferences_data->order = ORDER_BY_ALPHABETICAL;
  1448. XtGetValues (preferences_rec->order_date, args, 1);
  1449. if (set) preferences_data->order = ORDER_BY_DATE;
  1450. XtGetValues (preferences_rec->order_size, args, 1);
  1451. if (set) preferences_data->order = ORDER_BY_SIZE;
  1452. XtGetValues (preferences_rec->direction_ascending, args, 1);
  1453. if (set) preferences_data->direction = DIRECTION_ASCENDING;
  1454. XtGetValues (preferences_rec->direction_descending, args, 1);
  1455. if (set) preferences_data->direction = DIRECTION_DESCENDING;
  1456. XtGetValues (preferences_rec->random_on, args, 1);
  1457. if (set) preferences_data->positionEnabled = RANDOM_ON;
  1458. XtGetValues (preferences_rec->random_off, args, 1);
  1459. if (set) preferences_data->positionEnabled = RANDOM_OFF;
  1460. XtGetValues (preferences_rec->show_iconic_path, args, 1);
  1461. preferences_data->show_iconic_path = set;
  1462. XtGetValues (preferences_rec->show_current_dir, args, 1);
  1463. preferences_data->show_current_dir = set;
  1464. XtGetValues (preferences_rec->show_status_line, args, 1);
  1465. preferences_data->show_status_line = set;
  1466. }
  1467. /************************************************************************
  1468. *
  1469. * ShowTypeToString
  1470. * Convert the show type to a string and write it out.
  1471. *
  1472. ***********************************************************************/
  1473. void
  1474. ShowTypeToString(
  1475. int fd,
  1476. unsigned char *value,
  1477. char *out_buf )
  1478. {
  1479. char * buf = NULL;
  1480. if (*value == SINGLE_DIRECTORY)
  1481. buf = Single_directory;
  1482. else if (*value == MULTIPLE_DIRECTORY)
  1483. buf = DirectoryTree;
  1484. _DtStringToString(fd, (char **)&buf, out_buf);
  1485. }
  1486. /************************************************************************
  1487. *
  1488. * StringToShowType
  1489. * Convert string to a show type.
  1490. *
  1491. ************************************************************************/
  1492. void
  1493. StringToShowType(
  1494. XrmValuePtr args,
  1495. Cardinal *num_args,
  1496. XrmValue *from_val,
  1497. XrmValue *to_val )
  1498. {
  1499. char * in_str = (char *)(from_val->addr);
  1500. static unsigned char i;
  1501. to_val->size = sizeof (unsigned char);
  1502. to_val->addr = (XtPointer) &i;
  1503. if (_DtStringsAreEquivalent (in_str, Single_directory))
  1504. i = SINGLE_DIRECTORY;
  1505. else if (_DtStringsAreEquivalent (in_str, DirectoryTree))
  1506. i = MULTIPLE_DIRECTORY;
  1507. else
  1508. {
  1509. to_val->size = 0;
  1510. to_val->addr = NULL;
  1511. XtStringConversionWarning ((char *)from_val->addr, SHOW_TYPE);
  1512. }
  1513. }
  1514. /************************************************************************
  1515. *
  1516. * TreeFilesToString
  1517. * Convert the tree-files option to a string and write it out.
  1518. *
  1519. ***********************************************************************/
  1520. void
  1521. TreeFilesToString(
  1522. int fd,
  1523. unsigned char *value,
  1524. char *out_buf )
  1525. {
  1526. char * buf = NULL;
  1527. if (*value == TREE_FILES_NEVER)
  1528. buf = Tree_files_never;
  1529. else if (*value == TREE_FILES_CHOOSE)
  1530. buf = Tree_files_choose;
  1531. else if (*value == TREE_FILES_ALWAYS)
  1532. buf = Tree_files_always;
  1533. _DtStringToString(fd, (char **)&buf, out_buf);
  1534. }
  1535. /************************************************************************
  1536. *
  1537. * StringToTreeFiles
  1538. * Convert string to a tree-files option.
  1539. *
  1540. ************************************************************************/
  1541. void
  1542. StringToTreeFiles(
  1543. XrmValuePtr args,
  1544. Cardinal *num_args,
  1545. XrmValue *from_val,
  1546. XrmValue *to_val )
  1547. {
  1548. char * in_str = (char *)(from_val->addr);
  1549. static unsigned char i;
  1550. to_val->size = sizeof (unsigned char);
  1551. to_val->addr = (XtPointer) &i;
  1552. if (_DtStringsAreEquivalent (in_str, Tree_files_never))
  1553. i = TREE_FILES_NEVER;
  1554. else if (_DtStringsAreEquivalent (in_str, Tree_files_choose))
  1555. i = TREE_FILES_CHOOSE;
  1556. else if (_DtStringsAreEquivalent (in_str, Tree_files_always))
  1557. i = TREE_FILES_ALWAYS;
  1558. else
  1559. {
  1560. to_val->size = 0;
  1561. to_val->addr = NULL;
  1562. XtStringConversionWarning ((char *)from_val->addr, TREE_FILES);
  1563. }
  1564. }
  1565. /************************************************************************
  1566. *
  1567. * ViewToString
  1568. * Convert the view mode to a string and write it out.
  1569. *
  1570. ***********************************************************************/
  1571. void
  1572. ViewToString(
  1573. int fd,
  1574. unsigned char *value,
  1575. char *out_buf )
  1576. {
  1577. char * buf = NULL;
  1578. if (*value == BY_NAME)
  1579. buf = By_name;
  1580. else if (*value == BY_NAME_AND_ICON)
  1581. buf = By_name_and_icon;
  1582. else if (*value == BY_NAME_AND_SMALL_ICON)
  1583. buf = By_name_and_small_icon;
  1584. else if (*value == BY_ATTRIBUTES)
  1585. buf = By_attributes;
  1586. _DtStringToString(fd, (char **)&buf, out_buf);
  1587. }
  1588. /************************************************************************
  1589. *
  1590. * StringToView
  1591. * Convert string to a viewing mode.
  1592. *
  1593. ************************************************************************/
  1594. void
  1595. StringToView(
  1596. XrmValuePtr args,
  1597. Cardinal *num_args,
  1598. XrmValue *from_val,
  1599. XrmValue *to_val )
  1600. {
  1601. char * in_str = (char *)(from_val->addr);
  1602. static unsigned char i;
  1603. to_val->size = sizeof (unsigned char);
  1604. to_val->addr = (XtPointer) &i;
  1605. if (_DtStringsAreEquivalent (in_str, By_name))
  1606. i = BY_NAME;
  1607. else if (_DtStringsAreEquivalent (in_str, By_name_and_icon))
  1608. i = BY_NAME_AND_ICON;
  1609. else if (_DtStringsAreEquivalent (in_str, By_name_and_small_icon))
  1610. i = BY_NAME_AND_SMALL_ICON;
  1611. else if (_DtStringsAreEquivalent (in_str, By_attributes))
  1612. i = BY_ATTRIBUTES;
  1613. else
  1614. {
  1615. to_val->size = 0;
  1616. to_val->addr = NULL;
  1617. XtStringConversionWarning ((char *)from_val->addr, VIEW);
  1618. }
  1619. }
  1620. /************************************************************************
  1621. *
  1622. * OrderToString
  1623. * Convert the viewing order to a string and write it out.
  1624. *
  1625. ***********************************************************************/
  1626. void
  1627. OrderToString(
  1628. int fd,
  1629. unsigned char *value,
  1630. char *out_buf )
  1631. {
  1632. char * buf = NULL;
  1633. if (*value == ORDER_BY_FILE_TYPE)
  1634. buf = Order_by_file_type;
  1635. else if (*value == ORDER_BY_ALPHABETICAL)
  1636. buf = Order_by_alphabetical;
  1637. else if (*value == ORDER_BY_DATE)
  1638. buf = Order_by_date;
  1639. else if (*value == ORDER_BY_SIZE)
  1640. buf = Order_by_size;
  1641. _DtStringToString(fd, (char **)&buf, out_buf);
  1642. }
  1643. /************************************************************************
  1644. *
  1645. * StringToOrder
  1646. * Convert string to a view order.
  1647. *
  1648. ************************************************************************/
  1649. void
  1650. StringToOrder(
  1651. XrmValuePtr args,
  1652. Cardinal *num_args,
  1653. XrmValue *from_val,
  1654. XrmValue *to_val )
  1655. {
  1656. char * in_str = (char *)(from_val->addr);
  1657. static unsigned char i;
  1658. to_val->size = sizeof (unsigned char);
  1659. to_val->addr = (XtPointer) &i;
  1660. if (_DtStringsAreEquivalent (in_str, Order_by_file_type))
  1661. i = ORDER_BY_FILE_TYPE;
  1662. else if (_DtStringsAreEquivalent (in_str, Order_by_alphabetical))
  1663. i = ORDER_BY_ALPHABETICAL;
  1664. else if (_DtStringsAreEquivalent (in_str, Order_by_date))
  1665. i = ORDER_BY_DATE;
  1666. else if (_DtStringsAreEquivalent (in_str, Order_by_size))
  1667. i = ORDER_BY_SIZE;
  1668. else
  1669. {
  1670. to_val->size = 0;
  1671. to_val->addr = NULL;
  1672. XtStringConversionWarning ((char *)from_val->addr, DIRECTION_RESRC);
  1673. }
  1674. }
  1675. /************************************************************************
  1676. *
  1677. * DirectionToString
  1678. * Convert the ordering direction to a string and write it out.
  1679. *
  1680. ***********************************************************************/
  1681. void
  1682. DirectionToString(
  1683. int fd,
  1684. unsigned char *value,
  1685. char *out_buf )
  1686. {
  1687. char * buf = NULL;
  1688. if (*value == DIRECTION_ASCENDING)
  1689. buf = Direction_ascending;
  1690. else if (*value == DIRECTION_DESCENDING)
  1691. buf = Direction_descending;
  1692. _DtStringToString(fd, (char **)&buf, out_buf);
  1693. }
  1694. /************************************************************************
  1695. *
  1696. * RandomToString
  1697. * Convert the random placement to a string and write it out.
  1698. *
  1699. ***********************************************************************/
  1700. void
  1701. RandomToString(
  1702. int fd,
  1703. unsigned char *value,
  1704. char *out_buf )
  1705. {
  1706. char * buf = NULL;
  1707. if (*value == RANDOM_ON)
  1708. buf = Random_on;
  1709. else if (*value == RANDOM_OFF)
  1710. buf = Random_off;
  1711. _DtStringToString(fd, (char **)&buf, out_buf);
  1712. }
  1713. /************************************************************************
  1714. *
  1715. * StringToDirection
  1716. * Convert string to a view ordering direction.
  1717. *
  1718. ************************************************************************/
  1719. void
  1720. StringToDirection(
  1721. XrmValuePtr args,
  1722. Cardinal *num_args,
  1723. XrmValue *from_val,
  1724. XrmValue *to_val )
  1725. {
  1726. char * in_str = (char *)(from_val->addr);
  1727. static unsigned char i;
  1728. to_val->size = sizeof (unsigned char);
  1729. to_val->addr = (XtPointer) &i;
  1730. if (_DtStringsAreEquivalent (in_str, Direction_ascending))
  1731. i = DIRECTION_ASCENDING;
  1732. else if (_DtStringsAreEquivalent (in_str, Direction_descending))
  1733. i = DIRECTION_DESCENDING;
  1734. else
  1735. {
  1736. to_val->size = 0;
  1737. to_val->addr = NULL;
  1738. XtStringConversionWarning ((char *)from_val->addr, DIRECTION_RESRC);
  1739. }
  1740. }
  1741. /************************************************************************
  1742. *
  1743. * StringToRandom
  1744. * Convert string to either random placement on or off
  1745. *
  1746. ************************************************************************/
  1747. void
  1748. StringToRandom(
  1749. XrmValuePtr args,
  1750. Cardinal *num_args,
  1751. XrmValue *from_val,
  1752. XrmValue *to_val )
  1753. {
  1754. char * in_str = (char *)(from_val->addr);
  1755. static unsigned char i;
  1756. to_val->size = sizeof (unsigned char);
  1757. to_val->addr = (XtPointer) &i;
  1758. if (_DtStringsAreEquivalent (in_str, Random_on))
  1759. i = RANDOM_ON;
  1760. else if (_DtStringsAreEquivalent (in_str, Random_off))
  1761. i = RANDOM_OFF;
  1762. else
  1763. {
  1764. to_val->size = 0;
  1765. to_val->addr = NULL;
  1766. XtStringConversionWarning ((char *)from_val->addr, RANDOM);
  1767. }
  1768. }