~ubuntu-branches/ubuntu/saucy/xdaliclock/saucy-proposed

« back to all changes in this revision

Viewing changes to OSX/DaliClockSaverView.m

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry
  • Date: 2013-07-16 10:01:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130716100114-zgaclt1rkj4y71g3
Tags: 2.38-1
* New upstream release.
* debian/control:
  + Added VCS-* fields.
  + Updated to Standards-Version 3.9.4
* debian/rules:
  + Rewrote to use dh.
* Added debian/docs file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* xdaliclock - a melting digital clock
2
 
 * Copyright (c) 1991-2009 Jamie Zawinski <jwz@jwz.org>
 
2
 * Copyright (c) 1991-2013 Jamie Zawinski <jwz@jwz.org>
3
3
 *
4
4
 * Permission to use, copy, modify, distribute, and sell this software and its
5
5
 * documentation for any purpose is hereby granted without fee, provided that
36
36
  NSAssert1 (nsb, @"no bundle for class %@", [self class]);
37
37
  NSString *name = [nsb bundleIdentifier];
38
38
  NSUserDefaults *defs = [ScreenSaverDefaults defaultsForModuleWithName:name];
39
 
  NSUserDefaultsController *controller =
40
 
    [[[NSUserDefaultsController alloc] initWithDefaults:defs
41
 
                                         initialValues:nil]
42
 
      retain];  // never freed
43
39
 
44
 
  /* Tell the DaliClockView class to initialize its preferences.
 
40
  /* Tell the DaliClockView class to initialize its default preferences.
45
41
     This can't just happen in [DaliClockView:initialize], because
46
 
     we have to ensure that DaliClockView is using the same
47
 
     NSUserDefaultsController object that we are using here.
 
42
     it has to happen before the NSUserDefaultsController is created.
48
43
   */
49
 
  [DaliClockView initializeDefaults:controller];
50
 
 
 
44
  [DaliClockView registerDefaults:defs];
51
45
 
52
46
  /* Now that the DaliClockView class has initialized its preferences,
53
47
     set the defaults for those preferences handled by DaliClockSaverView
64
58
   */
65
59
  NSString *key = @"initialBackgroundColor";
66
60
  NSColor *defbg = [NSUnarchiver unarchiveObjectWithData:
67
 
                                   [[controller defaults] objectForKey:key]];
 
61
                                   [defs objectForKey:key]];
68
62
  defbg = [defbg colorWithAlphaComponent:0.95];
69
 
  NSDictionary* defaults = [NSDictionary dictionaryWithObjectsAndKeys:
 
63
  NSDictionary* extras = [NSDictionary dictionaryWithObjectsAndKeys:
70
64
    [NSArchiver archivedDataWithRootObject:defbg], key,
71
65
    nil];
72
 
 
73
66
  NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:100];
74
 
  [dict addEntriesFromDictionary: [controller initialValues]];
75
 
  [dict addEntriesFromDictionary:defaults];
76
 
  [controller setInitialValues:dict];
77
 
  [[controller defaults] registerDefaults:dict];
 
67
  [dict addEntriesFromDictionary:[defs dictionaryRepresentation]];
 
68
  [dict addEntriesFromDictionary:extras];
 
69
  [defs registerDefaults:dict];
 
70
 
 
71
  NSUserDefaultsController *controller =
 
72
    [[[NSUserDefaultsController alloc] initWithDefaults:defs
 
73
                                         initialValues:nil]
 
74
      retain];  // never freed
 
75
 
 
76
  [DaliClockView setUserDefaultsController: controller];
78
77
}
79
78
 
80
79
 
99
98
}
100
99
 
101
100
 
 
101
// Kludge so that this is runnable by xscreensaver's SaverTester.app
 
102
- (id) initWithFrame:(NSRect)f saverName:(NSString *)s isPreview:(BOOL)p
 
103
{
 
104
  return [self initWithFrame:f isPreview:p];
 
105
}
 
106
 
 
107
 
102
108
- (void) startAnimation
103
109
{
104
110
  [super startAnimation];
167
173
- (IBAction)okClick:(id)sender
168
174
{
169
175
  [[NSApplication sharedApplication] endSheet:configSheet];
170
 
  // [[[[clockView class] userDefaultsController] defaults] synchronize];
 
176
  // Without this, preferences are not persistent in the screen saver.
 
177
  [[[[clockView class] userDefaultsController] defaults] synchronize];
171
178
}
172
179
 
173
180
/* The About button in the preferences sheet.