1 /* xscreensaver, Copyright (c) 2006-2013 Jamie Zawinski <jwz@jwz.org>
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
12 /* XScreenSaver uses XML files to describe the user interface for configuring
13 the various screen savers. These files live in .../hacks/config/ and
14 say relatively high level things like: "there should be a checkbox
15 labelled "Leave Trails", and when it is checked, add the option '-trails'
16 to the command line when launching the program."
18 This code reads that XML and constructs a Cocoa interface from it.
19 The Cocoa controls are hooked up to NSUserDefaultsController to save
20 those settings into the MacOS preferences system. The Cocoa preferences
21 names are the same as the resource names specified in the screenhack's
22 'options' array (we use that array to map the command line switches
23 specified in the XML to the resource names to use).
27 # import <Foundation/Foundation.h>
28 # import <UIKit/UIKit.h>
29 # define NSView UIView
30 # define NSUserDefaultsController NSUserDefaults
32 # import <Cocoa/Cocoa.h>
37 #import <Foundation/NSXMLParser.h>
39 #undef USE_PICKER_VIEW
41 @interface XScreenSaverConfigSheet :
43 UITableViewController <NSXMLParserDelegate,
45 # ifdef USE_PICKER_VIEW
46 , UIPickerViewDelegate
47 , UIPickerViewDataSource
51 NSWindow <NSXMLParserDelegate>
55 NSUserDefaultsController *userDefaultsController;
56 NSUserDefaultsController *globalDefaultsController;
57 NSDictionary *defaultOptions;
58 const XrmOptionDescRec *opts;
59 id xml_root, xml_parsing;
62 UITextField *active_text_field;
63 NSMutableArray *controls;
64 NSMutableArray *pref_ctls; // UIControl objects, with index = c.tag
65 NSMutableArray *pref_keys; // ...and their corresponding resources
66 # ifdef USE_PICKER_VIEW
67 NSMutableArray *picker_values;
73 - (id)initWithXML: (NSData *) xml_data
74 options: (const XrmOptionDescRec *) opts
75 controller: (NSUserDefaultsController *) prefs
76 globalController: (NSUserDefaultsController *) globalPrefs
77 defaults: (NSDictionary *) defs;