Changeset 1038 for trunk/macosx


Ignore:
Timestamp:
Oct 29, 2006, 5:05:27 PM (15 years ago)
Author:
livings124
Message:

bind sound popups and catch if auto speed limit times are the same

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r1037 r1038  
    13241324    BOOL shouldBeOn;
    13251325    int hour = [[NSCalendarDate calendarDate] hourOfDay];
    1326     if (onHour < offHour)
     1326   
     1327    if (onHour == offHour)
     1328        shouldBeOn = NO;
     1329    else if (onHour < offHour)
    13271330        shouldBeOn = hour >= onHour && hour < offHour;
    13281331    else
     
    13411344    NSCalendarDate * currentDate = [NSCalendarDate calendarDate];
    13421345    if ([currentDate minuteOfHour] == 0 && [currentDate secondOfMinute] < AUTO_SPEED_LIMIT_SECONDS
    1343             && [currentDate hourOfDay] == [fDefaults integerForKey: fSpeedLimitEnabled
    1344                                             ? @"SpeedLimitAutoOffHour" : @"SpeedLimitAutoOnHour"])
     1346        && [currentDate hourOfDay] == [fDefaults integerForKey: fSpeedLimitEnabled
     1347                                        ? @"SpeedLimitAutoOffHour" : @"SpeedLimitAutoOnHour"]
     1348        && (fSpeedLimitEnabled || [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]
     1349                                    != [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]))
    13451350    {
    13461351        [self toggleSpeedLimit: nil];
  • trunk/macosx/English.lproj/PrefsWindow.nib/info.nib

    r1037 r1038  
    1212                <string>294 434 563 290 0 0 1152 842 </string>
    1313                <key>41</key>
    14                 <string>138 348 563 317 0 0 1152 842 </string>
     14                <string>294 420 563 317 0 0 1152 842 </string>
    1515                <key>66</key>
    1616                <string>294 507 563 144 0 0 1152 842 </string>
  • trunk/macosx/PrefsController.h

    r1034 r1038  
    3939    IBOutlet NSPopUpButton  * fFolderPopUp, * fImportFolderPopUp,
    4040                            * fDownloadSoundPopUp, * fSeedingSoundPopUp;
     41   
     42    NSArray                 * fSounds;
    4143   
    4244    SUUpdater               * fUpdater;
  • trunk/macosx/PrefsController.m

    r1037 r1038  
    8080        //actually set bandwidth limits
    8181        [self applySpeedSettings: nil];
     82       
     83        //set play sound
     84        NSMutableArray * sounds = [NSMutableArray array];
     85        NSEnumerator * soundEnumerator,
     86                    * soundDirectoriesEnumerator = [[NSArray arrayWithObjects: @"System/Library/Sounds",
     87                            [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"], nil] objectEnumerator];
     88        NSString * soundPath, * sound;
     89       
     90        //get list of all sounds and sort alphabetically
     91        while ((soundPath = [soundDirectoriesEnumerator nextObject]))
     92            if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: soundPath])
     93                while ((sound = [soundEnumerator nextObject]))
     94                {
     95                    sound = [sound stringByDeletingPathExtension];
     96                    if ([NSSound soundNamed: sound])
     97                        [sounds addObject: sound];
     98                }
     99       
     100        fSounds = [[sounds sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] retain];
    82101    }
    83102    return self;
     
    88107    if (fNatStatusTimer)
    89108        [fNatStatusTimer invalidate];
     109    [fSounds release];
    90110   
    91111    [super dealloc];
     
    119139    fNatStatusTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self
    120140                        selector: @selector(updateNatStatus) userInfo: nil repeats: YES];
    121    
    122     //set play sound
    123     NSMutableArray * sounds = [NSMutableArray array];
    124     NSEnumerator * soundEnumerator,
    125                 * soundDirectoriesEnumerator = [[NSArray arrayWithObjects: @"System/Library/Sounds",
    126                         [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"], nil] objectEnumerator];
    127     NSString * soundPath, * sound;
    128    
    129     //get list of all sounds and sort alphabetically
    130     while ((soundPath = [soundDirectoriesEnumerator nextObject]))
    131         if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: soundPath])
    132             while ((sound = [soundEnumerator nextObject]))
    133             {
    134                 sound = [sound stringByDeletingPathExtension];
    135                 if ([NSSound soundNamed: sound])
    136                     [sounds addObject: sound];
    137             }
    138    
    139     [sounds sortUsingSelector: @selector(caseInsensitiveCompare:)];
    140    
    141     //set download sound
    142     [fDownloadSoundPopUp removeAllItems];
    143     [fDownloadSoundPopUp addItemsWithTitles: sounds];
    144    
    145     int downloadSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"DownloadSound"]];
    146     if (downloadSoundIndex >= 0)
    147         [fDownloadSoundPopUp selectItemAtIndex: downloadSoundIndex];
    148     else
    149         [fDefaults setObject: [fDownloadSoundPopUp titleOfSelectedItem] forKey: @"DownloadSound"];
    150    
    151     //set seeding sound
    152     [fSeedingSoundPopUp removeAllItems];
    153     [fSeedingSoundPopUp addItemsWithTitles: sounds];
    154    
    155     int seedingSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"SeedingSound"]];
    156     if (seedingSoundIndex >= 0)
    157         [fSeedingSoundPopUp selectItemAtIndex: seedingSoundIndex];
    158     else
    159         [fDefaults setObject: [fSeedingSoundPopUp titleOfSelectedItem] forKey: @"SeedingSound"];
    160141
    161142    //set update check
     
    359340    if ((sound = [NSSound soundNamed: soundName]))
    360341        [sound play];
    361 
    362     #warning use bindings
    363     if (sender == fDownloadSoundPopUp)
    364         [fDefaults setObject: soundName forKey: @"DownloadSound"];
    365     else if (sender == fSeedingSoundPopUp)
    366         [fDefaults setObject: soundName forKey: @"SeedingSound"];
    367     else;
    368342}
    369343
Note: See TracChangeset for help on using the changeset viewer.