Ignore:
Timestamp:
Nov 15, 2010, 12:25:18 AM (11 years ago)
Author:
livings124
Message:

#3742 entering a blocklist URL should register while typing (and support undo) - boo for glue code replacing bindings!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PrefsController.m

    r11417 r11421  
    216216   
    217217    //set blocklist
     218    NSString * blocklistURL = [fDefaults stringForKey: @"BlocklistURL"];
     219    if (blocklistURL)
     220        [fBlocklistURLField setStringValue: blocklistURL];
     221   
     222    [self updateBlocklistButton];
    218223    [self updateBlocklistFields];
     224   
    219225    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateBlocklistFields)
    220226        name: @"BlocklistUpdated" object: nil];
     227   
     228    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateBlocklistURLField)
     229        name: NSControlTextDidChangeNotification object: fBlocklistURLField];
    221230   
    222231    //set rpc port
     
    481490   
    482491    [[BlocklistScheduler scheduler] updateSchedule];
    483 }
    484 
    485 - (void) setBlocklistURL: (id) sender
    486 {
    487     tr_blocklistSetURL(fHandle, [[fDefaults stringForKey: @"BlocklistURL"] UTF8String]);
     492   
     493    [self updateBlocklistButton];
    488494}
    489495
     
    542548}
    543549
     550- (void) updateBlocklistURLField
     551{
     552    NSString * blocklistString = [fBlocklistURLField stringValue];
     553   
     554    [fDefaults setObject: blocklistString forKey: @"BlocklistURL"];
     555    tr_blocklistSetURL(fHandle, [blocklistString UTF8String]);
     556   
     557    [self updateBlocklistButton];
     558}
     559
     560- (void) updateBlocklistButton
     561{
     562    NSString * blocklistString = [fDefaults objectForKey: @"BlocklistURL"];
     563    const BOOL enable = (blocklistString && ![blocklistString isEqualToString: @""])
     564                            && [fDefaults boolForKey: @"BlocklistNew"];
     565    [fBlocklistButton setEnabled: enable];
     566}
     567
    544568- (void) setAutoStartDownloads: (id) sender
    545569{
     
    11601184        //speed limit schedule times and day handled by bindings
    11611185       
     1186        [fBlocklistURLField setStringValue: blocklistURL];
     1187        [self updateBlocklistButton];
    11621188        [self updateBlocklistFields];
    11631189       
Note: See TracChangeset for help on using the changeset viewer.