Ignore:
Timestamp:
Dec 11, 2011, 10:31:01 PM (10 years ago)
Author:
livings124
Message:

eliminate all warnings by switching NSOpenPanel/NSSavePanels to use completion handler blocks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/GroupsPrefsController.m

    r12943 r13108  
    195195    [panel setCanChooseDirectories: YES];
    196196    [panel setCanCreateDirectories: YES];
    197 
    198     [panel beginSheetForDirectory: nil file: nil types: nil
    199         modalForWindow: [fCustomLocationPopUp window] modalDelegate: self didEndSelector:
    200         @selector(customDownloadLocationSheetClosed:returnCode:contextInfo:) contextInfo: nil];
     197   
     198    [panel beginSheetModalForWindow: [fCustomLocationPopUp window] completionHandler: ^(NSInteger result) {
     199        const NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
     200        if (result == NSFileHandlingPanelOKButton)
     201        {
     202            NSString * path = [[[panel URLs] objectAtIndex: 0] path];
     203            [[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
     204            [[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
     205        }
     206        else
     207        {
     208            if (![[GroupsController groups] customDownloadLocationForIndex: index])
     209                [[GroupsController groups] setUsesCustomDownloadLocation: NO forIndex: index];
     210        }
     211       
     212        [self refreshCustomLocationWithSingleGroup];
     213       
     214        [fCustomLocationPopUp selectItemAtIndex: 0];
     215    }];
    201216}
    202217
     
    215230
    216231    [fCustomLocationPopUp setEnabled: ([fCustomLocationEnableCheck state] == NSOnState)];
    217 }
    218 
    219 - (void) customDownloadLocationSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
    220 {
    221     NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
    222     if (code == NSOKButton)
    223     {
    224         NSString * path = [[[openPanel URLs] objectAtIndex: 0] path];
    225         [[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
    226         [[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
    227     }
    228     else
    229     {
    230         if (![[GroupsController groups] customDownloadLocationForIndex: index])
    231             [[GroupsController groups] setUsesCustomDownloadLocation: NO forIndex: index];
    232     }
    233    
    234     [self refreshCustomLocationWithSingleGroup];
    235    
    236     [fCustomLocationPopUp selectItemAtIndex: 0];
    237232}
    238233
Note: See TracChangeset for help on using the changeset viewer.