//*****************************************************************************
//
//	PanelController.h.  
//
//		Preferences logic.
//
//			by	Felipe A. Rodriguez		
//
//	This code is supplied "as is" the author makes no warranty as to its 
//	suitability for any purpose.  This code is free and may be distributed 
//	in accordance with the terms of the:
//		
//			GNU GENERAL PUBLIC LICENSE
//			Version 2, June 1991
//			copyright (C) 1989, 1991 Free Software Foundation, Inc.
// 			675 Mass Ave, Cambridge, MA 02139, USA
//
//*****************************************************************************

#import "SoundPanelController.h"
#import "../Coordinator.h"


 

@implementation SoundPanelController

//*****************************************************************************
//
//		sent to us after nib objects are unarchived and init'd 
//
//*****************************************************************************
 
- awakeFromNib
{
int i = 0;

	if(strcmp(NXGetDefaultValue([NXApp appName], "sound"), "YES") == 0)		
		[[swMatrix findCellWithTag:i] setIntValue:1];

    return self;
}
//*****************************************************************************
//
//		returns the inspector panel we control
//
//*****************************************************************************

- inspectorPanel
{
    return [swMatrix window];
}
//*****************************************************************************
//
//		Target method of defaults db entries for our preferences
//		check switches based on the tag assigned in IB to each switch.
//
//*****************************************************************************

- switch:sender
{
//int tag = [sender selectedTag];
										// toggles entries YES/NO
	if(strcmp(NXGetDefaultValue([NXApp appName], "sound"),"NO") == 0)
		{														// sw set ON
 		if(!NXWriteDefault([NXApp appName], "sound", "YES"))
			[[NXApp delegate] showAlert:"ddbWriteError"];
		}
	else 														// sw set OFF
		{
		if(!NXWriteDefault([NXApp appName], "sound", "NO"))
			[[NXApp delegate] showAlert:"ddbWriteError"];
		}

    return self;
}

@end
