// // SolarSeek.m // SolarSeek // // Created by Joe Azure on 3/8/06. // #import "SolarSeekApp.h" @implementation SolarSeekApp // Handles the application initialization process + (void)initialize { // check for the SolarSeek prefs director. If it doesn't exist create it. NSString *dir = [@"~/Library/Application Support/SolarSeek" stringByExpandingTildeInPath]; if([[NSFileManager defaultManager] fileExistsAtPath:dir] == NO && [[NSFileManager defaultManager] createDirectoryAtPath:dir attributes:nil]==NO) { NSLog(@"Could not create %@. Errors will result",dir); } } -(id) init { if ((self = [super init])) { NSLog(@"init called."); } return self; } #pragma mark move to SolarSeekController.h -(IBAction)updateContent:(id)sender { int index = [sender selectedRow]; if (index < 0) return; id itemAtRow = [sender itemAtRow:index]; if (!itemAtRow) return; NSManagedObject *selectedItem = [itemAtRow observedObject]; NSString *objectType = [selectedItem valueForKeyPath:@"entity.name"]; NSView *desiredView = nil; if ([objectType compare:@"Room"] == 0) { // switch to room desiredView = roomChatContentView; if (desiredView == nil) { // argh, nib not loaded [NSBundle loadNibNamed:@"Rooms" owner:self]; [self performSelector:@selector(updateContent:) withObject:sender afterDelay:0.3f]; return; } } if ([objectType compare:@"SidebarItem"] == 0) { NSString *name = [selectedItem valueForKey:@"name"]; if ([name compare:@"Friends"] == 0) { desiredView = friendsContentView; if (desiredView == nil) { // argh, nib not loaded [NSBundle loadNibNamed:@"Friends" owner:self]; [self performSelector:@selector(updateContent:) withObject:sender afterDelay:0.3f]; return; } } } if (desiredView) [self switchToView:desiredView]; } -(void) switchToView:(NSView *)view { if (currentView == view) return; if ([[content subviews] count] == 0) { [content addSubview:view]; } else { NSView *lastView = [[content subviews] objectAtIndex:0]; [lastView removeFromSuperviewWithoutNeedingDisplay]; [content addSubview:view]; } currentView = view; } -(void) switchContentTo:(int) newContent { id newView = nil; id oldView = currentView; // if (newContent == DOWNLOAD_CONTENT) { // newView = downloadsContentView; // // TODO : check for the current display mode (table, outline, browse) and use the correct view // }; // // if (newContent == UPLOAD_CONTENT) { // newView = uploadsContentView; // } // if (selectedContent == UPLOAD_CONTENT) { // newContent = uploadsContentView; // } if (newView == nil) newView = firstTimeConnectContentView; if (newView == oldView) return; if ([[oldView subviews] count] == 0) { [oldView addSubview:newView]; } else { NSView *view = [[oldView subviews] objectAtIndex:0]; [view removeFromSuperviewWithoutNeedingDisplay]; [oldView addSubview:newView]; } NSLog(@"oldView = %@, %@", oldView, [oldView subviews]); } -(SoulSeek *) soulseek { if (!soulseek) { soulseek = [[SoulSeek alloc] init]; } return soulseek; } @end