+#else // USE_IPHONE
+
+/* Create a dictionary of one-line descriptions of every saver,
+ for display on the UITableView.
+ */
+- (NSDictionary *)makeDescTable
+{
+ NSMutableDictionary *dict =
+ [NSMutableDictionary dictionaryWithCapacity:[saverNames count]];
+
+ for (NSString *saver in saverNames) {
+ NSString *desc = 0;
+ NSString *path = [saverDir stringByAppendingPathComponent:
+ [[saver lowercaseString]
+ stringByReplacingOccurrencesOfString:@" "
+ withString:@""]];
+ NSRange r;
+
+ path = [path stringByAppendingPathExtension:@"xml"];
+ desc = [NSString stringWithContentsOfFile:path
+ encoding:NSISOLatin1StringEncoding
+ error:nil];
+ if (! desc) goto FAIL;
+
+ r = [desc rangeOfString:@"<_description>"
+ options:NSCaseInsensitiveSearch];
+ if (r.length == 0) {
+ desc = 0;
+ goto FAIL;
+ }
+ desc = [desc substringFromIndex: r.location + r.length];
+ r = [desc rangeOfString:@"</_description>"
+ options:NSCaseInsensitiveSearch];
+ if (r.length > 0)
+ desc = [desc substringToIndex: r.location];
+
+ // Leading and trailing whitespace.
+ desc = [desc stringByTrimmingCharactersInSet:
+ [NSCharacterSet whitespaceAndNewlineCharacterSet]];
+
+ // Let's see if we can find a year on the last line.
+ r = [desc rangeOfString:@"\n" options:NSBackwardsSearch];
+ NSString *year = 0;
+ for (NSString *word in
+ [[desc substringFromIndex:r.location + r.length]
+ componentsSeparatedByCharactersInSet:
+ [NSCharacterSet characterSetWithCharactersInString:
+ @" \t\n-."]]) {
+ int n = [word doubleValue];
+ if (n > 1970 && n < 2100)
+ year = word;
+ }
+
+ // Delete everything after the first blank line.
+ r = [desc rangeOfString:@"\n\n" options:0];
+ if (r.length > 0)
+ desc = [desc substringToIndex: r.location];
+
+ // Truncate really long ones.
+ int max = 140;
+ if ([desc length] > max)
+ desc = [desc substringToIndex: max];
+
+ if (year)
+ desc = [year stringByAppendingString:
+ [@": " stringByAppendingString: desc]];
+
+ FAIL:
+ if (! desc) {
+ desc = @"Oops, this module appears to be incomplete.";
+ // NSLog(@"broken saver: %@", path);
+ }
+
+ [dict setObject:desc forKey:saver];
+ }
+
+ return dict;
+}
+
+
+- (UIViewController *) makeMenu
+{
+ listController = [[[SaverListController alloc]
+ initWithNames:saverNames
+ descriptions:[self makeDescTable]]
+ retain];
+ UIBarButtonItem *run = [[[UIBarButtonItem alloc]
+ initWithTitle:@"Run"
+ style: UIBarButtonItemStylePlain
+ target: self
+ action: @selector(loadSaverMenu:)]
+ autorelease];
+ UIBarButtonItem *about = [[[UIBarButtonItem alloc]
+ initWithTitle: @"About"
+ style: UIBarButtonItemStylePlain
+ target: self
+ action: @selector(aboutPanel:)]
+ autorelease];
+ UIBarButtonItem *pref = [[[UIBarButtonItem alloc]
+ initWithTitle:@"Settings"
+ style: UIBarButtonItemStylePlain
+ target: self
+ action: @selector(openPreferences:)]
+ autorelease];
+ NSArray *a = [NSArray arrayWithObjects: pref, about, nil];
+
+ [run setEnabled:NO];
+ [about setEnabled:YES];
+ [pref setEnabled:NO];
+ listController.navigationItem.leftBarButtonItem = run;
+ listController.navigationItem.rightBarButtonItems = a;
+
+ return listController;
+}
+
+#endif // USE_IPHONE
+
+