1 /* xscreensaver, Copyright (c) 2006-2012 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 NSDictionary *defaultOptions;
57 const XrmOptionDescRec *opts;
58 id xml_root, xml_parsing;
61 UITextField *active_text_field;
62 NSMutableArray *controls;
63 NSMutableArray *pref_ctls; // UIControl objects, with index = c.tag
64 NSMutableArray *pref_keys; // ...and their corresponding resources
65 # ifdef USE_PICKER_VIEW
66 NSMutableArray *picker_values;
72 - (id)initWithXMLFile: (NSString *) xml_file
73 options: (const XrmOptionDescRec *) opts
74 controller: (NSUserDefaultsController *) prefs
75 defaults: (NSDictionary *) defs;