2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* Copyright (c) 1994 FUJITSU LIMITED */
24 /* All Rights Reserved */
27 * $XConsortium: PrefMgr.cc /main/5 1996/06/11 16:27:12 cde-hal $
29 * Copyright (c) 1992 HAL Computer Systems International, Ltd.
30 * All rights reserved. Unpublished -- rights reserved under
31 * the Copyright Laws of the United States. USE OF A COPYRIGHT
32 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
35 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
36 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
37 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
38 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
41 * RESTRICTED RIGHTS LEGEND
42 * Use, duplication, or disclosure by the Government is subject
43 * to the restrictions as set forth in subparagraph (c)(l)(ii)
44 * of the Rights in Technical Data and Computer Software clause
45 * at DFARS 252.227-7013.
47 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
53 #define C_UserPreference
56 #define C_WindowGeometryPref
70 LONG_LIVED_CC(PrefMgr,pref_mgr);
72 PrefMgr *PrefMgr::g_pref_mgr;
76 message_mgr().warning_dialog ("PrefMgr access detected.");
77 if (PrefMgr::g_pref_mgr == NULL)
78 PrefMgr::g_pref_mgr = new PrefMgr();
79 return (*PrefMgr::g_pref_mgr);
83 #if defined(__STDC__) || defined(hpux)
84 # define DEFSYM(S) PrefSymbol PrefMgr::S = (PrefSymbol) #S
86 # define DEFSYM(S) PrefSymbol PrefMgr::S = (PrefSymbol) "S"
89 DEFSYM (BrowseGeometry);
93 DEFSYM (MapAutoUpdate);
94 DEFSYM (NodeHistSize);
95 DEFSYM (SearchHistSize);
96 DEFSYM (MaxSearchHits);
97 DEFSYM (DefaultMarkBase);
98 DEFSYM (DisplayFirstHit);
99 DEFSYM (AutomaticHelp);
101 // preferences for Japanese hyphenation - 4/6/94 kamiya
102 DEFSYM (HyphenMethod);
103 DEFSYM (HyphenLevel);
109 delete f_last_preference;
115 if (f_pref_agent == NULL)
116 f_pref_agent = new PrefAgent();
118 f_pref_agent->display();
127 UserPreference::flush_preferences();
131 message_mgr().error_dialog ((char*)"Unable to save preferences.");
138 PrefMgr::get_int (const PrefSymbol sym)
140 if (f_last_symbol != sym)
143 delete f_last_preference;
144 f_last_preference = new IntegerPref (sym);
147 return (((IntegerPref *) f_last_preference)->value());
151 PrefMgr::set_int (const PrefSymbol sym, int value)
153 if (f_last_symbol != sym)
156 delete f_last_preference;
157 f_last_preference = new IntegerPref (sym);
160 ((IntegerPref *) f_last_preference)->value (value);
161 notify (INT_CHANGED);
166 PrefMgr::get_boolean (const PrefSymbol sym)
168 if (f_last_symbol != sym)
171 delete f_last_preference;
172 f_last_preference = new BooleanPref (sym);
175 return (((BooleanPref *) f_last_preference)->value());
179 PrefMgr::set_boolean (const PrefSymbol sym, bool value)
181 if (f_last_symbol != sym)
184 delete f_last_preference;
185 f_last_preference = new BooleanPref (sym);
188 ((BooleanPref *) f_last_preference)->value (value);
189 notify (BOOLEAN_CHANGED);
194 PrefMgr::get_string (const PrefSymbol sym)
196 if (f_last_symbol != sym)
199 delete f_last_preference;
200 f_last_preference = new StringPref (sym);
203 return (((StringPref *) f_last_preference)->value());
207 PrefMgr::set_string (const PrefSymbol sym, const char *value)
209 if (f_last_symbol != sym)
212 delete f_last_preference;
213 f_last_preference = new StringPref (sym);
216 ((StringPref *) f_last_preference)->value (value);
217 notify (STRING_CHANGED);
221 const WindowGeometry &
222 PrefMgr::get_geometry (const PrefSymbol sym)
224 if (f_last_symbol != sym)
227 delete f_last_preference;
228 f_last_preference = new WindowGeometryPref (sym);
231 return (((WindowGeometryPref *) f_last_preference)->value());
235 PrefMgr::set_geometry (const PrefSymbol sym, const WindowGeometry &value)
237 if (f_last_symbol != sym)
240 delete f_last_preference;
241 f_last_preference = new WindowGeometryPref (sym);
244 ((WindowGeometryPref *) f_last_preference)->value (value);
245 notify (GEOMETRY_CHANGED);