X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2FXScreenSaverConfigSheet.m;h=7220d2c214485bcad29d649166aceca9973b34d2;hb=2762a7d7cf8d83e68b8f635941f6609119d630ae;hp=1df862b2a33fb182ce63af45501f0774aa48d1db;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/OSX/XScreenSaverConfigSheet.m b/OSX/XScreenSaverConfigSheet.m index 1df862b2..7220d2c2 100644 --- a/OSX/XScreenSaverConfigSheet.m +++ b/OSX/XScreenSaverConfigSheet.m @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2006-2012 Jamie Zawinski +/* xscreensaver, Copyright (c) 2006-2013 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -383,7 +383,7 @@ static char *anchorize (const char *url); s.height = 999999; s = [text sizeWithFont: font constrainedToSize: s - lineBreakMode: UILineBreakModeWordWrap]; + lineBreakMode:NSLineBreakByWordWrapping]; // GAAAH. Add one more line, or the UIWebView is still scrollable! // The text is sized right, but it lets you scroll it up anyway. @@ -533,7 +533,12 @@ static void layout_group (NSView *group, BOOL horiz_p); if ([active_text_field canResignFirstResponder]) [active_text_field resignFirstResponder]; NSString *pref_key = [pref_keys objectAtIndex: [sender tag]]; - double v = [sender value]; + + // Hacky API. See comment in InvertedSlider.m. + double v = ([sender isKindOfClass: [InvertedSlider class]] + ? [(InvertedSlider *) sender transformedValue] + : [sender value]); + if (v == (int) v) [userDefaultsController setInteger:v forKey:pref_key]; else @@ -689,7 +694,11 @@ static void layout_group (NSView *group, BOOL horiz_p); if ([control isKindOfClass:[UISlider class]]) { sel = @selector(sliderAction:); - [(UISlider *) control setValue: dval]; + // Hacky API. See comment in InvertedSlider.m. + if ([control isKindOfClass:[InvertedSlider class]]) + [(InvertedSlider *) control setTransformedValue: dval]; + else + [(UISlider *) control setValue: dval]; } else if ([control isKindOfClass:[UISwitch class]]) { sel = @selector(switchAction:); [(UISwitch *) control setOn: ((int) dval != 0)]; @@ -1100,7 +1109,7 @@ hreffify (NSText *nstext) [lab setBackgroundColor:[UIColor clearColor]]; [lab setNumberOfLines:0]; // unlimited // [lab setLineBreakMode:UILineBreakModeWordWrap]; - [lab setLineBreakMode:UILineBreakModeHeadTruncation]; + [lab setLineBreakMode:NSLineBreakByTruncatingHead]; [lab setAutoresizingMask: (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; # endif // USE_IPHONE @@ -1303,7 +1312,7 @@ hreffify (NSText *nstext) [lab setFrame:rect]; [self placeChild:lab on:parent]; # else // USE_IPHONE - [lab setTextAlignment: UITextAlignmentRight]; + [lab setTextAlignment: NSTextAlignmentRight]; [self placeChild:lab on:parent right:(label ? YES : NO)]; # endif // USE_IPHONE @@ -1673,7 +1682,7 @@ set_menu_item_object (NSMenuItem *item, NSObject *obj) for (NSArray *item in items) { RadioButton *b = [[RadioButton alloc] initWithIndex:i items:items]; - [b setLineBreakMode:UILineBreakModeHeadTruncation]; + [b setLineBreakMode:NSLineBreakByTruncatingHead]; [b setFont:[NSFont boldSystemFontOfSize: FONT_SIZE]]; [self placeChild:b on:parent]; i++; @@ -1795,7 +1804,7 @@ set_menu_item_object (NSMenuItem *item, NSObject *obj) txt.font = [UIFont systemFontOfSize: FONT_SIZE]; txt.placeholder = @""; txt.borderStyle = UITextBorderStyleRoundedRect; - txt.textAlignment = UITextAlignmentRight; + txt.textAlignment = NSTextAlignmentRight; txt.keyboardType = UIKeyboardTypeDefault; // Full kbd txt.autocorrectionType = UITextAutocorrectionTypeNo; txt.autocapitalizationType = UITextAutocapitalizationTypeNone; @@ -3409,10 +3418,10 @@ wrap_with_buttons (NSWindow *window, NSView *panel) controls on itself that are hooked up to the appropriate preferences. The default size of the view is just big enough to hold them all. */ -- (id)initWithXMLFile: (NSString *) xml_file - options: (const XrmOptionDescRec *) _opts - controller: (NSUserDefaultsController *) _prefs - defaults: (NSDictionary *) _defs +- (id)initWithXML: (NSData *) xml_data + options: (const XrmOptionDescRec *) _opts + controller: (NSUserDefaultsController *) _prefs + defaults: (NSDictionary *) _defs { # ifndef USE_IPHONE self = [super init]; @@ -3428,40 +3437,16 @@ wrap_with_buttons (NSWindow *window, NSView *panel) userDefaultsController = _prefs; [userDefaultsController retain]; - NSURL *furl = [NSURL fileURLWithPath:xml_file]; - - if (!furl) { - NSAssert1 (0, @"can't URLify \"%@\"", xml_file); - return nil; - } - -#if 0 // -- the old way - NSError *err = nil; - NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] - initWithContentsOfURL:furl - options:(NSXMLNodePreserveWhitespace | - NSXMLNodePreserveCDATA) - error:&err]; - if (!xmlDoc || err) { - if (err) - NSAssert2 (0, @"XML Error: %@: %@", - xml_file, [err localizedDescription]); - return nil; - } - - traverse_tree (prefs, self, opts, [xmlDoc rootElement]); -#endif /* 0 */ - + NSXMLParser *xmlDoc = [[NSXMLParser alloc] initWithData:xml_data]; - NSXMLParser *xmlDoc = [[NSXMLParser alloc] initWithContentsOfURL:furl]; if (!xmlDoc) { - NSAssert1 (0, @"XML Error: %@", xml_file); + NSAssert1 (0, @"XML Error: %@", xml_data); return nil; } [xmlDoc setDelegate:self]; if (! [xmlDoc parse]) { NSError *err = [xmlDoc parserError]; - NSAssert2 (0, @"XML Error: %@: %@", xml_file, err); + NSAssert2 (0, @"XML Error: %@: %@", xml_data, err); return nil; }