069637400b03534ee473067ea092aab1291693cb
[xscreensaver] / OSX / PrefsReader.h
1 /* xscreensaver, Copyright (c) 2006-2012 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  */
11
12 /* This implements the substrate of the xscreensaver preferences code:
13    It does this by writing defaults to, and reading values from, the
14    NSUserDefaultsController (and ScreenSaverDefaults/NSUserDefaults)
15    and thereby reading the preferences that may have been edited by
16    the UI (XScreenSaverConfigSheet).
17  */
18
19 #ifdef USE_IPHONE
20 # import <Foundation/Foundation.h>
21 # import <UIKit/UIKit.h>
22 # define NSUserDefaultsController NSUserDefaults
23 #else
24 # import <Cocoa/Cocoa.h>
25 #endif
26
27
28 #import "jwxyz.h"
29
30 @interface PrefsReader : NSObject
31 {
32   NSString *saver_name;
33   NSUserDefaultsController *userDefaultsController;
34   NSUserDefaults *userDefaults;  // this is actually a 'ScreenSaverDefaults'
35   NSDictionary *defaultOptions;  // Hardcoded defaults before any changes.
36 }
37
38 - (id) initWithName: (NSString *) name
39             xrmKeys: (const XrmOptionDescRec *) opts
40            defaults: (const char * const *) defs;
41
42 - (NSUserDefaultsController *) userDefaultsController;
43 - (NSDictionary *) defaultOptions;
44
45 - (char *) getStringResource:  (const char *) name;
46 - (double) getFloatResource:   (const char *) name;
47 - (int)    getIntegerResource: (const char *) name;
48 - (BOOL)   getBooleanResource: (const char *) name;
49
50 @end