All pastes #73798 Raw Edit

Diego Massanti

public text v1 · immutable
#73798 ·published 2006-06-28 08:52 UTC
rendered paste body
#import <AppKit/AppKit.h>
#import "appControl.h"
#import <DiscRecording/DiscRecording.h>
#import <DiscRecordingUI/DiscRecordingUI.h>
#import <Foundation/Foundation.h>
#import <Foundation/NSBundle.h>
#import <QuickTime/QuickTime.h>
#import <CoreServices/CoreServices.h>
@implementation appControl

- (NSArray*)createLayoutForBurn:(NSArray*)list
{
	unsigned i, count = [list count];
	NSMutableArray  *tracks = [NSMutableArray arrayWithCapacity:count];
	for (i=0; i<count; ++i)
	{
		NSString    *path = [list objectAtIndex:i];
		NSLog(path);
		
		// HERE I CREATE THE TRACK.
		DRTrack      *track = [DRTrack trackForAudioFile:path];
		NSLog(path);
		DRTrack		 *trackLog = [DRTrack trackForAudioFile:path];
		if (track == nil)
		{
			NSLog(@"An error occurred at track %d: %@", (i+1), path);
			[NSException raise:NSObjectNotAvailableException
						format:@"Source file for track %u was not found, or could not be imported!  Filename was %@",
				(i+1), path];
		}
		
		NSMutableDictionary	*trackProperties = [[track properties] mutableCopy];
		[track setProperties:trackProperties];
		
		[tracks addObject:track];
		NSLog([[trackLog properties] description]);
	}
	return tracks;
}




// Custom function "Critic Alert" for managing exceptions and alerts. Thanks my friend from brazil :)
static void criticAlert(NSString* message) {
	NSAlert* alrt = [NSAlert alertWithMessageText:@"Unexpected error..."
									defaultButton:@"Terminate" alternateButton:nil otherButton:nil informativeTextWithFormat:message];
	[alrt setAlertStyle:NSCriticalAlertStyle];
	[alrt runModal];
}


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
{
	//infoAlert(@"test");

	//NSLog(osVersion);
	
}

/*- (IBAction)burn:(id)sender
{	
	DRBurnSetupPanel*	bsp = [DRBurnSetupPanel setupPanel];
	//Here i create a layout image with layoutForImageFIle ** DOCUMENTATION FOR THIS ONLY IN THE RELEASE NOTES FOR XCODE 2.3!!! ** Damn Apple!
	NSString*			cueFile = [[NSBundle mainBundle] pathForResource:@"massanti" ofType:@"cue"];
	
	////////////////////-----------------------------///////////////////////////////
	DRBurn*				drb = [DRBurn layoutForImageFile:cueFile];
	
	
	[bsp setCanSelectTestBurn:YES];
	[bsp setDelegate:self];
	
	
	if ([bsp runSetupPanel] == NSOKButton)
	{
		
		DRBurnProgressPanel*	bpp = [DRBurnProgressPanel progressPanel];
		
		[bpp setDelegate:self];
		// HERE I MUST REMEMBER TO ADD THE IMAGE HANDLING ROUTINE. LATER
		@try 
		{
			
			[bpp beginProgressSheetForBurn:[bsp burnObject] layout:drb modalForWindow:[NSApp mainWindow]];
		}
		@catch (NSException *exception)
		{
			NSLog(@"main: Caught %@: %@", [exception name], [exception  reason]);
			NSString*	errorTxt = ([exception  reason]);
			criticAlert(errorTxt);
		}
	}
	
}*/


- (IBAction)burn:(id)sender
{	
	DRBurnSetupPanel*	bsp = [DRBurnSetupPanel setupPanel];
	[bsp setCanSelectTestBurn:YES];
	[bsp beginSetupSheetForWindow:[NSApp mainWindow]
		modalDelegate:self
		didEndSelector:@selector(burnSetupPanelDidEnd:returnCode:contextInfo:)
			contextInfo:nil];
	
	
}
- (void)burnSetupPanelDidEnd:(DRBurnSetupPanel*)panel returnCode:(int)returnCode contextInfo:(void*)contextInfo
{	
	[panel orderOut:self];
	NSArray*			trackList = [[NSBundle mainBundle] pathsForResourcesOfType:@"mp3" inDirectory:@""];
	NSArray*			drb = [self createLayoutForBurn:trackList];
		
	
	
	if (returnCode != NSOKButton) return;
	DRBurn				*burn = [panel burnObject];
	DRBurnProgressPanel*	bpp = [DRBurnProgressPanel progressPanel];
	[bpp setDelegate:self];
	[bpp setVerboseProgressStatus:YES];
	NSLog([[burn properties]description]); 
	[bpp beginProgressSheetForBurn:burn layout:drb modalForWindow:[NSApp mainWindow]];	
}


@end