1 /* WPrefs.c- main window and other basic stuff
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 extern Panel
*InitWindowHandling(WMScreen
*scr
, WMWindow
*win
);
30 extern Panel
*InitKeyboardSettings(WMScreen
*scr
, WMWindow
*win
);
32 extern Panel
*InitMouseSettings(WMScreen
*scr
, WMWindow
*win
);
34 extern Panel
*InitKeyboardShortcuts(WMScreen
*scr
, WMWindow
*win
);
36 extern Panel
*InitWorkspace(WMScreen
*scr
, WMWindow
*win
);
38 extern Panel
*InitFocus(WMScreen
*scr
, WMWindow
*win
);
40 extern Panel
*InitPreferences(WMScreen
*scr
, WMWindow
*win
);
42 extern Panel
*InitText(WMScreen
*scr
, WMWindow
*win
);
44 extern Panel
*InitConfigurations(WMScreen
*scr
, WMWindow
*win
);
46 extern Panel
*InitPaths(WMScreen
*scr
, WMWindow
*win
);
48 extern Panel
*InitMenu(WMScreen
*scr
, WMWindow
*win
);
50 extern Panel
*InitExpert(WMScreen
*scr
, WMWindow
*win
);
52 extern Panel
*InitMenuPreferences(WMScreen
*scr
, WMWindow
*win
);
54 extern Panel
*InitIcons(WMScreen
*scr
, WMWindow
*win
);
56 extern Panel
*InitThemes(WMScreen
*scr
, WMWindow
*win
);
58 extern Panel
*InitAppearance(WMScreen
*scr
, WMWindow
*win
);
62 #define MAX_SECTIONS 16
65 typedef struct _WPrefs
{
68 WMScrollView
*scrollV
;
70 WMButton
*sectionB
[MAX_SECTIONS
];
91 static _WPrefs WPrefs
;
93 /* system wide defaults dictionary. Read-only */
94 static proplist_t GlobalDB
= NULL
;
95 /* user defaults dictionary */
96 static proplist_t WindowMakerDB
= NULL
;
99 static Bool TIFFOK
= False
;
102 #define INITIALIZED_PANEL (1<<0)
107 static void loadConfigurations(WMScreen
*scr
, WMWindow
*mainw
);
109 static void savePanelData(Panel
*panel
);
111 static void prepareForClose();
114 quit(WMWidget
*w
, void *data
)
123 save(WMWidget
*w
, void *data
)
129 char *msg
= "Reconfigure";
133 /* puts("gathering data");*/
134 for (i
=0; i
<WPrefs
.sectionCount
; i
++) {
135 PanelRec
*rec
= WMGetHangedData(WPrefs
.sectionB
[i
]);
136 if ((rec
->callbacks
.flags
& INITIALIZED_PANEL
))
137 savePanelData((Panel
*)rec
);
139 /* puts("compressing data");*/
140 /* compare the user dictionary with the global and remove redundant data */
141 keyList
= PLGetAllDictionaryKeys(GlobalDB
);
142 /* puts(PLGetDescription(WindowMakerDB));*/
143 for (i
=0; i
<PLGetNumberOfElements(keyList
); i
++) {
144 key
= PLGetArrayElement(keyList
, i
);
146 /* We don't have this value anyway, so no problem.
147 * Probably a new option */
148 p1
= PLGetDictionaryEntry(WindowMakerDB
, key
);
151 /* The global doesn't have it, so no problem either. */
152 p2
= PLGetDictionaryEntry(GlobalDB
, key
);
155 /* If both values are the same, don't save. */
156 if (PLIsEqual(p1
, p2
))
157 PLRemoveDictionaryEntry(WindowMakerDB
, key
);
159 /* puts(PLGetDescription(WindowMakerDB));*/
161 /* puts("storing data");*/
163 PLSave(WindowMakerDB
, YES
);
166 memset(&ev
, 0, sizeof(XEvent
));
168 ev
.xclient
.type
= ClientMessage
;
169 ev
.xclient
.message_type
= XInternAtom(WMScreenDisplay(WMWidgetScreen(w
)),
170 "_WINDOWMAKER_COMMAND", False
);
171 ev
.xclient
.window
= DefaultRootWindow(WMScreenDisplay(WMWidgetScreen(w
)));
172 ev
.xclient
.format
= 8;
174 for (i
= 0; i
<= strlen(msg
); i
++) {
175 ev
.xclient
.data
.b
[i
] = msg
[i
];
177 XSendEvent(WMScreenDisplay(WMWidgetScreen(w
)),
178 DefaultRootWindow(WMScreenDisplay(WMWidgetScreen(w
))),
179 False
, SubstructureRedirectMask
, &ev
);
180 XFlush(WMScreenDisplay(WMWidgetScreen(w
)));
186 undo(WMWidget
*w
, void *data
)
188 PanelRec
*rec
= (PanelRec
*)WPrefs
.currentPanel
;
193 if (rec
->callbacks
.undoChanges
194 && (rec
->callbacks
.flags
& INITIALIZED_PANEL
)) {
195 (*rec
->callbacks
.undoChanges
)(WPrefs
.currentPanel
);
201 undoAll(WMWidget
*w
, void *data
)
205 for (i
=0; i
<WPrefs
.sectionCount
; i
++) {
206 PanelRec
*rec
= WMGetHangedData(WPrefs
.sectionB
[i
]);
208 if (rec
->callbacks
.undoChanges
209 && (rec
->callbacks
.flags
& INITIALIZED_PANEL
))
210 (*rec
->callbacks
.undoChanges
)((Panel
*)rec
);
221 for (i
=0; i
<WPrefs
.sectionCount
; i
++) {
222 PanelRec
*rec
= WMGetHangedData(WPrefs
.sectionB
[i
]);
224 if (rec
->callbacks
.prepareForClose
225 && (rec
->callbacks
.flags
& INITIALIZED_PANEL
))
226 (*rec
->callbacks
.prepareForClose
)((Panel
*)rec
);
232 toggleBalloons(WMWidget
*w
, void *data
)
234 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
237 flag
= WMGetButtonSelected(WPrefs
.balloonBtn
);
239 WMSetBalloonEnabled(WMWidgetScreen(WPrefs
.win
), flag
);
241 WMSetUDBoolForKey(udb
, flag
, "BalloonHelp");
246 createMainWindow(WMScreen
*scr
)
248 WMScroller
*scroller
;
252 WPrefs
.win
= WMCreateWindow(scr
, "wprefs");
253 WMResizeWidget(WPrefs
.win
, 520, 390);
254 WMSetWindowTitle(WPrefs
.win
, _("Window Maker Preferences"));
255 WMSetWindowCloseAction(WPrefs
.win
, quit
, NULL
);
256 WMSetWindowMaxSize(WPrefs
.win
, 520, 390);
257 WMSetWindowMinSize(WPrefs
.win
, 520, 390);
258 WMSetWindowMiniwindowTitle(WPrefs
.win
, "Preferences");
259 WMSetWindowMiniwindowImage(WPrefs
.win
, WMGetApplicationIconImage(scr
));
261 WPrefs
.scrollV
= WMCreateScrollView(WPrefs
.win
);
262 WMResizeWidget(WPrefs
.scrollV
, 500, 87);
263 WMMoveWidget(WPrefs
.scrollV
, 10, 10);
264 WMSetScrollViewRelief(WPrefs
.scrollV
, WRSunken
);
265 WMSetScrollViewHasHorizontalScroller(WPrefs
.scrollV
, True
);
266 WMSetScrollViewHasVerticalScroller(WPrefs
.scrollV
, False
);
267 scroller
= WMGetScrollViewHorizontalScroller(WPrefs
.scrollV
);
268 WMSetScrollerArrowsPosition(scroller
, WSANone
);
270 WPrefs
.buttonF
= WMCreateFrame(WPrefs
.win
);
271 WMSetFrameRelief(WPrefs
.buttonF
, WRFlat
);
273 WMSetScrollViewContentView(WPrefs
.scrollV
, WMWidgetView(WPrefs
.buttonF
));
275 WPrefs
.undosBtn
= WMCreateCommandButton(WPrefs
.win
);
276 WMResizeWidget(WPrefs
.undosBtn
, 90, 28);
277 WMMoveWidget(WPrefs
.undosBtn
, 135, 350);
278 WMSetButtonText(WPrefs
.undosBtn
, _("Revert Page"));
279 WMSetButtonAction(WPrefs
.undosBtn
, undo
, NULL
);
281 WPrefs
.undoBtn
= WMCreateCommandButton(WPrefs
.win
);
282 WMResizeWidget(WPrefs
.undoBtn
, 90, 28);
283 WMMoveWidget(WPrefs
.undoBtn
, 235, 350);
284 WMSetButtonText(WPrefs
.undoBtn
, _("Revert All"));
285 WMSetButtonAction(WPrefs
.undoBtn
, undoAll
, NULL
);
287 WPrefs
.saveBtn
= WMCreateCommandButton(WPrefs
.win
);
288 WMResizeWidget(WPrefs
.saveBtn
, 80, 28);
289 WMMoveWidget(WPrefs
.saveBtn
, 335, 350);
290 WMSetButtonText(WPrefs
.saveBtn
, _("Save"));
291 WMSetButtonAction(WPrefs
.saveBtn
, save
, NULL
);
293 WPrefs
.closeBtn
= WMCreateCommandButton(WPrefs
.win
);
294 WMResizeWidget(WPrefs
.closeBtn
, 80, 28);
295 WMMoveWidget(WPrefs
.closeBtn
, 425, 350);
296 WMSetButtonText(WPrefs
.closeBtn
, _("Close"));
297 WMSetButtonAction(WPrefs
.closeBtn
, quit
, NULL
);
300 WPrefs
.balloonBtn
= WMCreateSwitchButton(WPrefs
.win
);
301 WMResizeWidget(WPrefs
.balloonBtn
, 200, 28);
302 WMMoveWidget(WPrefs
.balloonBtn
, 15, 350);
303 WMSetButtonText(WPrefs
.balloonBtn
, _("Balloon Help"));
304 WMSetButtonAction(WPrefs
.balloonBtn
, toggleBalloons
, NULL
);
306 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
307 Bool flag
= WMGetUDBoolForKey(udb
, "BalloonHelp");
309 WMSetButtonSelected(WPrefs
.balloonBtn
, flag
);
310 WMSetBalloonEnabled(scr
, flag
);
314 WPrefs
.banner
= WMCreateFrame(WPrefs
.win
);
315 WMResizeWidget(WPrefs
.banner
, FRAME_WIDTH
, FRAME_HEIGHT
);
316 WMMoveWidget(WPrefs
.banner
, FRAME_LEFT
, FRAME_TOP
);
317 WMSetFrameRelief(WPrefs
.banner
, WRFlat
);
319 font
= WMCreateFont(scr
, "-*-times-bold-r-*-*-24-*-*-*-*-*-*-*,"
320 "-*-fixed-medium-r-normal-*-24-*");
322 font
= WMBoldSystemFontOfSize(scr
, 24);
323 WPrefs
.nameL
= WMCreateLabel(WPrefs
.banner
);
324 WMSetLabelTextAlignment(WPrefs
.nameL
, WACenter
);
325 WMResizeWidget(WPrefs
.nameL
, FRAME_WIDTH
-20, 30);
326 WMMoveWidget(WPrefs
.nameL
, 10, 25);
327 WMSetLabelFont(WPrefs
.nameL
, font
);
328 WMSetLabelText(WPrefs
.nameL
, _("Window Maker Preferences Utility"));
331 WPrefs
.versionL
= WMCreateLabel(WPrefs
.banner
);
332 WMResizeWidget(WPrefs
.versionL
, FRAME_WIDTH
-20, 20);
333 WMMoveWidget(WPrefs
.versionL
, 10, 65);
334 WMSetLabelTextAlignment(WPrefs
.versionL
, WACenter
);
335 sprintf(buffer
, _("Version %s for Window Maker %s or newer"), WVERSION
,
337 WMSetLabelText(WPrefs
.versionL
, buffer
);
339 WPrefs
.statusL
= WMCreateLabel(WPrefs
.banner
);
340 WMResizeWidget(WPrefs
.statusL
, FRAME_WIDTH
-20, 60);
341 WMMoveWidget(WPrefs
.statusL
, 10, 100);
342 WMSetLabelTextAlignment(WPrefs
.statusL
, WACenter
);
343 WMSetLabelText(WPrefs
.statusL
, _("Starting..."));
345 WPrefs
.creditsL
= WMCreateLabel(WPrefs
.banner
);
346 WMResizeWidget(WPrefs
.creditsL
, FRAME_WIDTH
-20, 60);
347 WMMoveWidget(WPrefs
.creditsL
, 10, FRAME_HEIGHT
-60);
348 WMSetLabelTextAlignment(WPrefs
.creditsL
, WACenter
);
349 WMSetLabelText(WPrefs
.creditsL
, _("Programming/Design: Alfredo K. Kojima\n"
350 "Artwork: Marco van Hylckama Vlieg\n"
351 "More Programming: James Thompson"));
354 WMMapSubwidgets(WPrefs
.win
);
356 WMUnmapWidget(WPrefs
.undosBtn
);
357 WMUnmapWidget(WPrefs
.undoBtn
);
358 WMUnmapWidget(WPrefs
.saveBtn
);
363 showPanel(Panel
*panel
)
365 PanelRec
*rec
= (PanelRec
*)panel
;
367 if (!(rec
->callbacks
.flags
& INITIALIZED_PANEL
)) {
368 (*rec
->callbacks
.createWidgets
)(panel
);
369 rec
->callbacks
.flags
|= INITIALIZED_PANEL
;
372 WMSetWindowTitle(WPrefs
.win
, rec
->sectionName
);
374 WMMapWidget(rec
->frame
);
380 hidePanel(Panel
*panel
)
382 PanelRec
*rec
= (PanelRec
*)panel
;
384 WMUnmapWidget(rec
->frame
);
389 savePanelData(Panel
*panel
)
391 PanelRec
*rec
= (PanelRec
*)panel
;
393 if (rec
->callbacks
.updateDomain
) {
394 (*rec
->callbacks
.updateDomain
)(panel
);
400 changeSection(WMWidget
*self
, void *data
)
403 WMDestroyWidget(WPrefs
.banner
);
404 WPrefs
.banner
= NULL
;
405 /* WMMapWidget(WPrefs.undosBtn);
406 WMMapWidget(WPrefs.undoBtn);
408 WMMapWidget(WPrefs
.saveBtn
);
413 if (WPrefs
.currentPanel
)
414 hidePanel(WPrefs
.currentPanel
);
415 WPrefs
.currentPanel
= data
;
423 LocateImage(char *name
)
426 char *tmp
= wmalloc(strlen(name
)+8);
429 sprintf(tmp
, "%s.tiff", name
);
430 path
= WMPathForResourceOfType(tmp
, "tiff");
432 sprintf(tmp
, "%s.xpm", name
);
433 path
= WMPathForResourceOfType(tmp
, "xpm");
437 wwarning(_("could not locate image file %s\n"), name
);
445 SetButtonAlphaImage(WMScreen
*scr
, WMButton
*bPtr
, char *file
)
451 iconPath
= LocateImage(file
);
458 icon
= WMCreateBlendedPixmapFromFile(scr
, iconPath
, &color
);
460 wwarning(_("could not load icon file %s"), iconPath
);
465 WMSetButtonImage(bPtr
, icon
);
468 WMReleasePixmap(icon
);
475 icon
= WMCreateBlendedPixmapFromFile(scr
, iconPath
, &color
);
477 wwarning(_("could not load icon file %s"), iconPath
);
482 WMSetButtonAltImage(bPtr
, icon
);
485 WMReleasePixmap(icon
);
493 AddSection(Panel
*panel
, char *iconFile
)
497 assert(WPrefs
.sectionCount
< MAX_SECTIONS
);
500 bPtr
= WMCreateCustomButton(WPrefs
.buttonF
, WBBStateLightMask
501 |WBBStateChangeMask
);
502 WMResizeWidget(bPtr
, 64, 64);
503 WMMoveWidget(bPtr
, WPrefs
.sectionCount
*64, 0);
504 WMSetButtonImagePosition(bPtr
, WIPImageOnly
);
505 WMSetButtonAction(bPtr
, changeSection
, panel
);
506 WMHangData(bPtr
, panel
);
508 WMSetBalloonTextForView(((PanelRec
*)panel
)->description
,
511 SetButtonAlphaImage(WMWidgetScreen(bPtr
), bPtr
, iconFile
);
515 WPrefs
.sectionB
[WPrefs
.sectionCount
] = bPtr
;
517 if (WPrefs
.sectionCount
> 0) {
518 WMGroupButtons(WPrefs
.sectionB
[0], bPtr
);
521 WPrefs
.sectionCount
++;
523 WMResizeWidget(WPrefs
.buttonF
, WPrefs
.sectionCount
*64, 64);
528 Initialize(WMScreen
*scr
)
536 list
= RSupportedFileFormats();
537 for (i
=0; list
[i
]!=NULL
; i
++) {
538 if (strcmp(list
[i
], "TIFF")==0) {
545 path
= WMPathForResourceOfType("WPrefs.tiff", NULL
);
547 path
= WMPathForResourceOfType("WPrefs.xpm", NULL
);
551 tmp
= RLoadImage(WMScreenRContext(scr
), path
, 0);
553 wwarning(_("could not load image file %s:%s"), path
,
554 RMessageForError(RErrorCode
));
556 icon
= WMCreatePixmapFromRImage(scr
, tmp
, 0);
559 WMSetApplicationIconImage(scr
, icon
);
560 WMReleasePixmap(icon
);
566 memset(&WPrefs
, 0, sizeof(_WPrefs
));
567 createMainWindow(scr
);
569 WMRealizeWidget(WPrefs
.win
);
570 WMMapWidget(WPrefs
.win
);
571 XFlush(WMScreenDisplay(scr
));
572 WMSetLabelText(WPrefs
.statusL
, _("Loading Window Maker configuration files..."));
573 XFlush(WMScreenDisplay(scr
));
574 loadConfigurations(scr
, WPrefs
.win
);
576 WMSetLabelText(WPrefs
.statusL
, _("Initializing configuration panels..."));
578 InitWindowHandling(scr
, WPrefs
.win
);
579 InitFocus(scr
, WPrefs
.win
);
580 InitMenuPreferences(scr
, WPrefs
.win
);
581 InitIcons(scr
, WPrefs
.win
);
582 InitPreferences(scr
, WPrefs
.win
);
584 InitPaths(scr
, WPrefs
.win
);
585 InitWorkspace(scr
, WPrefs
.win
);
586 InitConfigurations(scr
, WPrefs
.win
);
588 InitMenu(scr
, WPrefs
.win
);
590 #ifdef not_yet_fully_implemented
591 InitKeyboardSettings(scr
, WPrefs
.win
);
593 InitKeyboardShortcuts(scr
, WPrefs
.win
);
594 InitMouseSettings(scr
, WPrefs
.win
);
596 InitAppearance(scr
, WPrefs
.win
);
598 #ifdef not_yet_fully_implemented
599 InitText(scr
, WPrefs
.win
);
600 InitThemes(scr
, WPrefs
.win
);
602 InitExpert(scr
, WPrefs
.win
);
604 WMRealizeWidget(WPrefs
.scrollV
);
606 WMSetLabelText(WPrefs
.statusL
,
607 _("WPrefs is free software and is distributed WITHOUT ANY\n"
608 "WARRANTY under the terms of the GNU General Public License.\n"
609 "The icons in this program are licensed through the\n"
610 "OpenContent License."));
615 GetWindow(Panel
*panel
)
622 loadConfigurations(WMScreen
*scr
, WMWindow
*mainw
)
631 path
= wdefaultspathfordomain("WindowMaker");
633 db
= PLGetProplistWithPath(path
);
635 if (!PLIsDictionary(db
)) {
638 sprintf(mbuf
, _("Window Maker domain (%s) is corrupted!"), path
);
639 WMRunAlertPanel(scr
, mainw
, _("Error"), mbuf
, _("OK"), NULL
, NULL
);
642 sprintf(mbuf
, _("Could not load Window Maker domain (%s) from defaults database."),
644 WMRunAlertPanel(scr
, mainw
, _("Error"), mbuf
, _("OK"), NULL
, NULL
);
648 path
= getenv("WMAKER_BIN_NAME");
651 path
= wstrappend(path
, " --version");
653 file
= popen(path
, "r");
654 if (!file
|| !fgets(buffer
, 1023, file
)) {
655 wsyserror(_("could not extract version information from Window Maker"));
656 wfatal(_("Make sure wmaker is in your search path."));
658 WMRunAlertPanel(scr
, mainw
, _("Error"),
659 _("Could not extract version from Window Maker. Make sure it is correctly installed and is in your PATH environment variable."),
660 _("OK"), NULL
, NULL
);
666 if (sscanf(buffer
, "Window Maker %i.%i.%i",&v1
,&v2
,&v3
)!=3
667 && sscanf(buffer
, "WindowMaker %i.%i.%i",&v1
,&v2
,&v3
)!=3) {
668 WMRunAlertPanel(scr
, mainw
, _("Error"),
669 _("Could not extract version from Window Maker. "
670 "Make sure it is correctly installed and the path "
671 "where it installed is in the PATH environment "
672 "variable."), _("OK"), NULL
, NULL
);
675 if (v1
== 0 && (v2
< 18 || v3
< 0)) {
676 sprintf(mbuf
, _("WPrefs only supports Window Maker 0.18.0 or newer.\n"
677 "The version installed is %i.%i.%i\n"), v1
, v2
, v3
);
678 WMRunAlertPanel(scr
, mainw
, _("Error"), mbuf
, _("OK"), NULL
, NULL
);
682 if (v1
> 1 || (v1
== 1 && (v2
> 0))) {
683 sprintf(mbuf
, _("Window Maker %i.%i.%i, which is installed in your system, is not fully supported by this version of WPrefs."),
685 WMRunAlertPanel(scr
, mainw
, _("Warning"), mbuf
, _("OK"), NULL
, NULL
);
688 file
= popen("wmaker --global_defaults_path", "r");
689 if (!file
|| !fgets(buffer
, 1023, file
)) {
690 wsyserror(_("could not run \"wmaker --global_defaults_path\"."));
694 ptr
= strchr(buffer
, '\n');
697 strcat(buffer
, "/WindowMaker");
703 gdb
= PLGetProplistWithPath(buffer
);
705 if (!PLIsDictionary(gdb
)) {
708 sprintf(mbuf
, _("Window Maker domain (%s) is corrupted!"), buffer
);
709 WMRunAlertPanel(scr
, mainw
, _("Error"), mbuf
, _("OK"), NULL
, NULL
);
712 sprintf(mbuf
, _("Could not load global Window Maker domain (%s)."),
714 WMRunAlertPanel(scr
, mainw
, _("Error"), mbuf
, _("OK"), NULL
, NULL
);
718 db
= PLMakeDictionaryFromEntries(NULL
, NULL
, NULL
);
721 gdb
= PLMakeDictionaryFromEntries(NULL
, NULL
, NULL
);
731 GetObjectForKey(char *defaultName
)
733 proplist_t object
= NULL
;
734 proplist_t key
= PLMakeString(defaultName
);
736 object
= PLGetDictionaryEntry(WindowMakerDB
, key
);
738 object
= PLGetDictionaryEntry(GlobalDB
, key
);
747 SetObjectForKey(proplist_t object
, char *defaultName
)
749 proplist_t key
= PLMakeString(defaultName
);
751 PLInsertDictionaryEntry(WindowMakerDB
, key
, object
);
757 RemoveObjectForKey(char *defaultName
)
759 proplist_t key
= PLMakeString(defaultName
);
761 PLRemoveDictionaryEntry(WindowMakerDB
, key
);
768 GetStringForKey(char *defaultName
)
772 val
= GetObjectForKey(defaultName
);
777 if (!PLIsString(val
))
780 return PLGetString(val
);
786 GetArrayForKey(char *defaultName
)
790 val
= GetObjectForKey(defaultName
);
803 GetDictionaryForKey(char *defaultName
)
807 val
= GetObjectForKey(defaultName
);
812 if (!PLIsDictionary(val
))
820 GetIntegerForKey(char *defaultName
)
826 val
= GetObjectForKey(defaultName
);
831 if (!PLIsString(val
))
834 str
= PLGetString(val
);
838 if (sscanf(str
, "%i", &value
)!=1)
846 GetBoolForKey(char *defaultName
)
851 str
= GetStringForKey(defaultName
);
856 if (sscanf(str
, "%i", &value
)==1 && value
!=0)
859 if (strcasecmp(str
, "YES")==0)
862 if (strcasecmp(str
, "Y")==0)
870 SetIntegerForKey(int value
, char *defaultName
)
875 sprintf(buffer
, "%i", value
);
876 object
= PLMakeString(buffer
);
878 SetObjectForKey(object
, defaultName
);
885 SetStringForKey(char *value
, char *defaultName
)
889 object
= PLMakeString(value
);
891 SetObjectForKey(object
, defaultName
);
897 SetBoolForKey(Bool value
, char *defaultName
)
899 static proplist_t yes
= NULL
, no
= NULL
;
902 yes
= PLMakeString("YES");
903 no
= PLMakeString("NO");
906 SetObjectForKey(value
? yes
: no
, defaultName
);
911 SetSpeedForKey(int speed
, char *defaultName
)
936 SetStringForKey(str
, defaultName
);
941 GetSpeedForKey(char *defaultName
)
946 str
= GetStringForKey(defaultName
);
950 if (strcasecmp(str
, "ultraslow")==0)
952 else if (strcasecmp(str
, "slow")==0)
954 else if (strcasecmp(str
, "medium")==0)
956 else if (strcasecmp(str
, "fast")==0)
958 else if (strcasecmp(str
, "ultrafast")==0)
961 wwarning(_("bad speed value for option %s\n. Using default Medium"),