Index: trunk/ChameleonPrefPane/Sources/AdvancedSetupController.h =================================================================== --- trunk/ChameleonPrefPane/Sources/AdvancedSetupController.h (revision 42) +++ trunk/ChameleonPrefPane/Sources/AdvancedSetupController.h (revision 43) @@ -6,10 +6,11 @@ // #import +#import // TabView subpane controller definition -@interface AdvancedSetupController : NSObject { +@interface AdvancedSetupController : PreferencesControllerBase { IBOutlet NSButton* mKernel; IBOutlet NSTextField* mKernelText; IBOutlet NSButton* mDeviceRd; Index: trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm =================================================================== --- trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm (revision 42) +++ trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm (revision 43) @@ -47,11 +47,41 @@ static PartitionExtractor * partExtractor=NULL; static PropertyList * prop = NULL; static int currentRowSel = -1; +static ChameleonPrefPane *gInstance = NULL; + //-------------------------------------------------------------------------- @implementation ChameleonPrefPane ++ (ChameleonPrefPane *)instance +{ + return(gInstance); +} + //-------------------------------------------------------------------------- +- (id) init +{ + self = [super init]; + gInstance = self; + + // set the image to display the current file being played + mMacOSXImage = [self getImageResource: @"MacOSX" ofType: @"png"]; + mWindowsImage = [self getImageResource: @"Windows" ofType: @"png"]; + mLinuxImage = [self getImageResource: @"Linux" ofType: @"png"]; + mCDROMImage = [self getImageResource: @"CDROM" ofType: @"png"]; + mUnknownImage = [self getImageResource: @"Chameleon" ofType: @"tiff"]; + + + // Retrieve the com.chameleon.prefPane.plist config + return self; +} + +- (NSMutableDictionary*) getPreferencesFile +{ + return mOptionsDict; +} + +//-------------------------------------------------------------------------- /** * SFAuthorization delegates */ @@ -196,23 +226,7 @@ [oldGlobalPreferences release]; } -//-------------------------------------------------------------------------- -- (id) init -{ - self = [super init]; - // set the image to display the current file being played - mMacOSXImage = [self getImageResource: @"MacOSX" ofType: @"png"]; - mWindowsImage = [self getImageResource: @"Windows" ofType: @"png"]; - mLinuxImage = [self getImageResource: @"Linux" ofType: @"png"]; - mCDROMImage = [self getImageResource: @"CDROM" ofType: @"png"]; - mUnknownImage = [self getImageResource: @"Chameleon" ofType: @"tiff"]; - - - // Retrieve the com.chameleon.prefPane.plist config - return self; -} - //-------------------------------------------------------------------------- /** When called here, all outlets references are initialized */ - (void)awakeFromNib Index: trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.h =================================================================== --- trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.h (revision 0) +++ trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.h (revision 43) @@ -0,0 +1,18 @@ +// +// PreferencesControllerBase.h +// ChameleonPrefPane +// +// Created by Rekursor on 1/22/10. +// + +#import +#import + +// Define common expected behavior for all derived controllers +@interface PreferencesControllerBase : NSObject { + +} + +-(NSMutableDictionary*) getPreferencesDictionary; + +@end Index: trunk/ChameleonPrefPane/Sources/process.cpp =================================================================== --- trunk/ChameleonPrefPane/Sources/process.cpp (revision 42) +++ trunk/ChameleonPrefPane/Sources/process.cpp (revision 43) @@ -7,7 +7,10 @@ #include "process.h" #include +#include +#include + //---------------------------------------------------------------- // portable open process: FILE * ShellProcess::open(const char *cmd, const char *mode) { @@ -148,9 +151,19 @@ partInfo.fsType()!="Apple_Free" ) { - if (partInfo.label().size()==0) partInfo.label("Untitled"); - if(_hiddenParts.length()==0 || _hiddenParts.find(partInfo.toHdStr()) == std::string::npos) - _partList.push_back(partInfo); + std::string DiskLabel(label); + DiskLabel.erase( DiskLabel.find_last_not_of(" ") + 1); + std::string UnixPath = "/Volumes/" + DiskLabel + "/usr/bin/man"; + std::string WinPath = "/Volumes/" + DiskLabel + "/Windows/system.ini"; + + if (fileExists(UnixPath) || fileExists(WinPath)) + { //check if one of them exists + if (partInfo.label().size()==0) partInfo.label("Untitled"); + if(_hiddenParts.length()==0 || + _hiddenParts.find(partInfo.toHdStr()) == std::string::npos) + _partList.push_back(partInfo); + } + } } } Index: trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.h =================================================================== --- trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.h (revision 42) +++ trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.h (revision 43) @@ -9,9 +9,10 @@ #import #import + @interface ChameleonPrefPane : NSPreferencePane { -@public +@private // Objects corresponding to the interface mapping: IBOutlet NSTableView * mPartitionsTable; IBOutlet NSTableColumn * mPartitionImgColumn; @@ -40,23 +41,26 @@ int mPreferenceFileVersion; } ++ (ChameleonPrefPane*) instance; // return the current instance + +- (IBAction)onRestart: (id)sender; +- (IBAction)onShutdown: (id)sender; +- (IBAction)onSleep: (id)sender; +- (IBAction)onSwapHD: (id)sender; +- (IBAction)onUseFrozenParts: (id)sender; +- (IBAction)onInjectPartsToFreeze: (id)sender; + +- (NSMutableDictionary*) getPreferencesFile; + - (void)awakeFromNib; - (void)initBootConfig; - (id) getImageResource: (NSString *) str ofType: (NSString*) sType; - (void) loadPreferences; --(bool) savePreferences: (NSDictionary*) dict; +- (bool) savePreferences: (NSDictionary*) dict; -//- (void) mainViewDidLoad; - (void)tableViewSelectionDidChange:(NSNotification *)notification; - (void) selectDefaultPartition; -- (IBAction)onRestart: (id)sender; -- (IBAction)onShutdown: (id)sender; -- (IBAction)onSleep: (id)sender; -- (IBAction)onSwapHD: (id)sender; -- (IBAction)onUseFrozenParts: (id)sender; -- (IBAction)onInjectPartsToFreeze: (id)sender; - - (bool)isUnlocked; - (void) refreshLockStates; - (void) doSwapHD: (int) val save: (bool) doSave src: (int)isrc dst: (int) idst; Index: trunk/ChameleonPrefPane/Sources/process.h =================================================================== --- trunk/ChameleonPrefPane/Sources/process.h (revision 42) +++ trunk/ChameleonPrefPane/Sources/process.h (revision 43) @@ -16,6 +16,20 @@ const int MAX_HD = 10; //---------------------------------------------------------------- + +/** + * Check whether file exists: + */ +inline bool fileExists(const char * str) +{ + struct stat stFileInfo; + if((stat(str,&stFileInfo)) == 0) return true; + else return false; +} + +inline bool fileExists(std::string str) {return fileExists(str.c_str());} + +//---------------------------------------------------------------- class ShellProcess { public: Index: trunk/ChameleonPrefPane/Sources/PeripheralsController.h =================================================================== --- trunk/ChameleonPrefPane/Sources/PeripheralsController.h (revision 42) +++ trunk/ChameleonPrefPane/Sources/PeripheralsController.h (revision 43) @@ -6,10 +6,11 @@ // #import +#import // TabView subpane controller definition -@interface PeripheralsController : NSObject { +@interface PeripheralsController : PreferencesControllerBase { IBOutlet NSButton* mLegacyLogo; IBOutlet NSButton* mBootBanner; Index: trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.mm =================================================================== --- trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.mm (revision 0) +++ trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.mm (revision 43) @@ -0,0 +1,20 @@ +// +// PreferencesControllerBase.mm +// ChameleonPrefPane +// +// Created by Rekursor on 1/22/10. +// + +#import "PreferencesControllerBase.h" + + +@implementation PreferencesControllerBase + +-(NSMutableDictionary*) getPreferencesDictionary +{ + if ([ChameleonPrefPane instance]==nil) return nil; + + return [[ChameleonPrefPane instance] getPreferencesFile]; +} + +@end Index: trunk/ChameleonPrefPane/Sources/BootFlagsController.h =================================================================== --- trunk/ChameleonPrefPane/Sources/BootFlagsController.h (revision 42) +++ trunk/ChameleonPrefPane/Sources/BootFlagsController.h (revision 43) @@ -6,10 +6,10 @@ // #import +#import - // TabView subpane controller definition -@interface BootFlagsController : NSObject { +@interface BootFlagsController : PreferencesControllerBase { IBOutlet NSButton* mVerbose; IBOutlet NSButton* mSafeBoot; Index: trunk/ChameleonPrefPane/Sources/BootSetupController.h =================================================================== --- trunk/ChameleonPrefPane/Sources/BootSetupController.h (revision 42) +++ trunk/ChameleonPrefPane/Sources/BootSetupController.h (revision 43) @@ -6,10 +6,10 @@ // #import +#import - // TabView subpane controller definition -@interface BootSetupController : NSObject { +@interface BootSetupController : PreferencesControllerBase { // TODO move swap hds and freeze buttons to this class Index: trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj =================================================================== --- trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj (revision 42) +++ trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj (revision 43) @@ -21,6 +21,8 @@ 01993115110A0EB9003B056E /* AdvancedSetupController.h in Headers */ = {isa = PBXBuildFile; fileRef = 01993113110A0EB9003B056E /* AdvancedSetupController.h */; }; 01993116110A0EB9003B056E /* AdvancedSetupController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 01993114110A0EB9003B056E /* AdvancedSetupController.mm */; }; 01993199110A2C61003B056E /* string_util.h in Headers */ = {isa = PBXBuildFile; fileRef = 01993198110A2C61003B056E /* string_util.h */; }; + 019931DD110A37FA003B056E /* PreferencesControllerBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 019931DB110A37FA003B056E /* PreferencesControllerBase.h */; }; + 019931DE110A37FA003B056E /* PreferencesControllerBase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 019931DC110A37FA003B056E /* PreferencesControllerBase.mm */; }; 01A40F75110550F4002A74CD /* CHANGES in Resources */ = {isa = PBXBuildFile; fileRef = 01A40F74110550F4002A74CD /* CHANGES */; }; 01B0E8141108B85A00ACF21B /* ChameleonPrefPane.h in Headers */ = {isa = PBXBuildFile; fileRef = 01B0E80E1108B85A00ACF21B /* ChameleonPrefPane.h */; }; 01B0E8151108B85A00ACF21B /* ChameleonPrefPane.mm in Sources */ = {isa = PBXBuildFile; fileRef = 01B0E80F1108B85A00ACF21B /* ChameleonPrefPane.mm */; }; @@ -59,6 +61,8 @@ 01993113110A0EB9003B056E /* AdvancedSetupController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AdvancedSetupController.h; path = Sources/AdvancedSetupController.h; sourceTree = ""; }; 01993114110A0EB9003B056E /* AdvancedSetupController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AdvancedSetupController.mm; path = Sources/AdvancedSetupController.mm; sourceTree = ""; }; 01993198110A2C61003B056E /* string_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = string_util.h; path = Sources/string_util.h; sourceTree = SOURCE_ROOT; }; + 019931DB110A37FA003B056E /* PreferencesControllerBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PreferencesControllerBase.h; path = Sources/PreferencesControllerBase.h; sourceTree = ""; }; + 019931DC110A37FA003B056E /* PreferencesControllerBase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PreferencesControllerBase.mm; path = Sources/PreferencesControllerBase.mm; sourceTree = ""; }; 01A40F74110550F4002A74CD /* CHANGES */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGES; sourceTree = ""; }; 01B0E80E1108B85A00ACF21B /* ChameleonPrefPane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChameleonPrefPane.h; path = Sources/ChameleonPrefPane.h; sourceTree = ""; }; 01B0E80F1108B85A00ACF21B /* ChameleonPrefPane.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ChameleonPrefPane.mm; path = Sources/ChameleonPrefPane.mm; sourceTree = ""; }; @@ -146,6 +150,8 @@ 01993198110A2C61003B056E /* string_util.h */, 01B0E80E1108B85A00ACF21B /* ChameleonPrefPane.h */, 01B0E80F1108B85A00ACF21B /* ChameleonPrefPane.mm */, + 019931DB110A37FA003B056E /* PreferencesControllerBase.h */, + 019931DC110A37FA003B056E /* PreferencesControllerBase.mm */, 019930DF110A0CB4003B056E /* BootSetupController.h */, 019930E0110A0CB4003B056E /* BootSetupController.mm */, 019930E6110A0D80003B056E /* BootFlagsController.h */, @@ -220,6 +226,7 @@ 019930FE110A0E6F003B056E /* PeripheralsController.h in Headers */, 01993115110A0EB9003B056E /* AdvancedSetupController.h in Headers */, 01993199110A2C61003B056E /* string_util.h in Headers */, + 019931DD110A37FA003B056E /* PreferencesControllerBase.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -310,6 +317,7 @@ 019930E9110A0D80003B056E /* BootFlagsController.mm in Sources */, 019930FF110A0E6F003B056E /* PeripheralsController.mm in Sources */, 01993116110A0EB9003B056E /* AdvancedSetupController.mm in Sources */, + 019931DE110A37FA003B056E /* PreferencesControllerBase.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };