-(void) restoreNeutralConfig {
if(!neutralConfig)
return;
- if([configs indexOfObject:neutralConfig] < 0) {// deleted, keep what we have
- neutralConfig = NULL;
- return;
- }
[self activateConfig: neutralConfig forApplication: NULL];
}
currentConfig = config;
[removeButton setEnabled: ![config protect]];
[targetController load];
- [[[NSApplication sharedApplication] delegate] configChanged];
- [tableView selectRow: [configs indexOfObject: config] byExtendingSelection: NO];
+ [(ApplicationController *)[[NSApplication sharedApplication] delegate] configChanged];
+ [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[configs indexOfObject:config]] byExtendingSelection:NO];
}
-(IBAction) addPressed: (id)sender {
Config* newConfig = [[Config alloc] init];
[newConfig setName: @"untitled"];
[configs addObject: newConfig];
- [[[NSApplication sharedApplication] delegate] configsChanged];
+ [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged];
[tableView reloadData];
- [tableView selectRow: ([configs count]-1) byExtendingSelection: NO];
+ [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:configs.count - 1] byExtendingSelection:NO];
[tableView editColumn: 0 row:([configs count]-1) withEvent:nil select:YES];
}
-(IBAction) removePressed: (id)sender {
[entries removeObjectForKey: key];
}
}
- [[[NSApplication sharedApplication] delegate] configsChanged];
+ [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged];
[tableView reloadData];
}
-(void)tableViewSelectionDidChange:(NSNotification*) notify {
- [self activateConfig: (Config*)[configs objectAtIndex:[tableView selectedRow]] forApplication: NULL];
+ if (tableView.selectedRow < configs.count)
+ [self activateConfig: (Config*)[configs objectAtIndex:[tableView selectedRow]] forApplication: NULL];
}
-(id) tableView: (NSTableView*)view objectValueForTableColumn: (NSTableColumn*) column row: (int) index {
[(Config*)[configs objectAtIndex: index] setName: newName];
[targetController refreshConfigsPreservingSelection:YES];
[tableView reloadData];
- [[[NSApplication sharedApplication] delegate] configsChanged];
+ [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged];
}
-(int)numberOfRowsInTableView: (NSTableView*)table {
for(int i=0; i<[ary count]; i++) {
NSDictionary* dict = [[ary objectAtIndex:i] objectForKey:@"entries"];
for(id key in dict) {
- [[[newConfigs objectAtIndex:i] entries]
+ [[[newConfigs objectAtIndex:i] entries]
setObject: [Target unstringify: [dict objectForKey: key] withConfigList: newConfigs]
forKey: key];
}
configs = newConfigs;
[tableView reloadData];
currentConfig = NULL;
- [[[NSApplication sharedApplication] delegate] configsChanged];
+ [(ApplicationController *)[[NSApplication sharedApplication] delegate] configsChanged];
int index = [[envelope objectForKey: @"selectedIndex"] intValue];
- [self activateConfig: [configs objectAtIndex:index] forApplication: NULL];
+ if (index < configs.count)
+ [self activateConfig: [configs objectAtIndex:index] forApplication: NULL];
}
-(void) applicationSwitchedTo: (NSString*) name withPsn: (ProcessSerialNumber) psn {