Changeset 735


Ignore:
Timestamp:
Aug 7, 2006, 2:28:31 AM (15 years ago)
Author:
livings124
Message:

User can now choose the sound that plays.

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r734 r735  
    901901    {
    902902        NSSound * sound;
    903         if ((sound = [NSSound soundNamed: @"Glass"]))
     903        if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"DownloadSound"]]))
    904904            [sound play];
    905905    }
     
    13481348    {
    13491349        NSSound * sound;
    1350         if ((sound = [NSSound soundNamed: @"Submarine"]))
     1350        if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"SeedingSound"]]))
    13511351            [sound play];
    13521352    }
  • trunk/macosx/Defaults.plist

    r734 r735  
    3535        <key>DownloadLimit</key>
    3636        <integer>100</integer>
     37        <key>DownloadSound</key>
     38        <string>Glass</string>
    3739        <key>Filter</key>
    3840        <string>None</string>
     
    6163        <key>SavePrivateTorrent</key>
    6264        <true/>
     65        <key>SeedingSound</key>
     66        <string>Submarine</string>
    6367        <key>ShowInspector</key>
    6468        <false/>
  • trunk/macosx/English.lproj/PrefsWindow.nib/classes.nib

    r734 r735  
    1919                setRatioCheck = id;
    2020                setShowMessage = id;
     21                setSound = id;
    2122                setSpeedLimit = id;
    2223                setStartSetting = id;
     
    3637                fDownloadCheck = NSButton;
    3738                fDownloadField = NSTextField;
     39                fDownloadSoundPopUp = NSPopUpButton;
    3840                fFolderPopUp = NSPopUpButton;
    3941                fGeneralView = NSView;
     
    4951                fRemoveCheck = NSButton;
    5052                fRemoveDownloadingCheck = NSButton;
     53                fSeedingSoundPopUp = NSPopUpButton;
    5154                fSpeedLimitDownloadField = NSTextField;
    5255                fSpeedLimitUploadField = NSTextField;
  • trunk/macosx/English.lproj/PrefsWindow.nib/info.nib

    r734 r735  
    1212                <string>139 281 538 290 0 0 1152 842 </string>
    1313                <key>41</key>
    14                 <string>115 371 538 378 0 0 1152 842 </string>
     14                <string>307 386 538 386 0 0 1152 842 </string>
    1515                <key>66</key>
    1616                <string>353 613 538 104 0 0 1152 842 </string>
  • trunk/macosx/PrefsController.h

    r734 r735  
    3434    IBOutlet NSView         * fGeneralView, * fTransfersView, * fBandwidthView, * fNetworkView;
    3535   
    36     IBOutlet NSPopUpButton  * fFolderPopUp, * fImportFolderPopUp;
     36    IBOutlet NSPopUpButton  * fFolderPopUp, * fImportFolderPopUp,
     37                            * fDownloadSoundPopUp, * fSeedingSoundPopUp;
    3738    IBOutlet NSButton       * fQuitCheck, * fRemoveCheck,
    3839                            * fQuitDownloadingCheck, * fRemoveDownloadingCheck,
     
    6768- (void) setBadge:          (id) sender;
    6869- (void) setPlaySound:      (id) sender;
     70- (void) setSound:          (id) sender;
    6971- (void) setUpdate:         (id) sender;
    7072- (void) checkUpdate;
  • trunk/macosx/PrefsController.m

    r734 r735  
    193193   
    194194    //set play sound
    195     [fPlayDownloadSoundCheck setState: [fDefaults boolForKey: @"PlayDownloadSound"]];
    196     [fPlaySeedingSoundCheck setState: [fDefaults boolForKey: @"PlaySeedingSound"]];
     195    NSMutableArray * sounds = [NSMutableArray array];
     196    NSEnumerator * soundEnumerator,
     197                * soundDirectoriesEnumerator = [[NSArray arrayWithObjects: @"System/Library/Sounds", @"Library/Sounds",
     198                        [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"], nil] objectEnumerator];
     199    NSString * soundPath, * sound;
     200   
     201    //get list of all sounds and sort alphabetically
     202    while ((soundPath = [soundDirectoriesEnumerator nextObject]))
     203        if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: soundPath])
     204            while ((sound = [soundEnumerator nextObject]))
     205            {
     206                sound = [sound stringByDeletingPathExtension];
     207                if ([NSSound soundNamed: sound])
     208                    [sounds addObject: sound];
     209            }
     210   
     211    [sounds sortUsingSelector: @selector(caseInsensitiveCompare:)];
     212   
     213    //set download sound
     214    [fDownloadSoundPopUp removeAllItems];
     215    [fDownloadSoundPopUp addItemsWithTitles: sounds];
     216   
     217    BOOL playDownloadSound = [fDefaults boolForKey: @"PlayDownloadSound"];
     218    [fPlayDownloadSoundCheck setState: playDownloadSound];
     219    [fDownloadSoundPopUp setEnabled: playDownloadSound];
     220   
     221    int downloadSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"DownloadSound"]];
     222    if (downloadSoundIndex >= 0)
     223        [fDownloadSoundPopUp selectItemAtIndex: downloadSoundIndex];
     224    else
     225        [fDefaults setObject: [fDownloadSoundPopUp titleOfSelectedItem] forKey: @"DownloadSound"];
     226   
     227    //set seeding sound
     228    [fSeedingSoundPopUp removeAllItems];
     229    [fSeedingSoundPopUp addItemsWithTitles: sounds];
     230   
     231    BOOL playSeedingSound = [fDefaults boolForKey: @"PlaySeedingSound"];
     232    [fPlaySeedingSoundCheck setState: playSeedingSound];
     233    [fSeedingSoundPopUp setEnabled: playSeedingSound];
     234   
     235    int seedingSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"SeedingSound"]];
     236    if (seedingSoundIndex >= 0)
     237        [fSeedingSoundPopUp selectItemAtIndex: seedingSoundIndex];
     238    else
     239        [fDefaults setObject: [fSeedingSoundPopUp titleOfSelectedItem] forKey: @"SeedingSound"];
    197240   
    198241    //set start setting
     
    517560- (void) setPlaySound: (id) sender
    518561{
     562    BOOL state = [sender state];
     563
    519564    if (sender == fPlayDownloadSoundCheck)
    520         [fDefaults setBool: [sender state] forKey: @"PlayDownloadSound"];
     565    {
     566        [fDownloadSoundPopUp setEnabled: state];
     567        [fDefaults setBool: state forKey: @"PlayDownloadSound"];
     568    }
    521569    else if (sender == fPlaySeedingSoundCheck)
    522         [fDefaults setBool: [sender state] forKey: @"PlaySeedingSound"];
     570    {
     571        [fSeedingSoundPopUp setEnabled: state];
     572        [fDefaults setBool: state forKey: @"PlaySeedingSound"];
     573    }
     574    else;
     575}
     576
     577- (void) setSound: (id) sender
     578{
     579    //play sound when selecting
     580    NSString * soundName = [sender titleOfSelectedItem];
     581    NSSound * sound;
     582    if ((sound = [NSSound soundNamed: soundName]))
     583        [sound play];
     584
     585    if (sender == fDownloadSoundPopUp)
     586        [fDefaults setObject: soundName forKey: @"DownloadSound"];
     587    else if (sender == fSeedingSoundPopUp)
     588        [fDefaults setObject: soundName forKey: @"SeedingSound"];
    523589    else;
    524590}
Note: See TracChangeset for help on using the changeset viewer.