Index: trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.h
===================================================================
--- trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.h (revision 11)
+++ trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.h (revision 12)
@@ -18,7 +18,9 @@
IBOutlet NSTableColumn * mFileSystemColumn;
IBOutlet NSTableColumn * mPartitionNameColumn;
IBOutlet NSTableColumn * mPartitionIDColumn;
- IBOutlet NSButton * mResetButton;
+ IBOutlet NSButton * mSleepButton;
+ IBOutlet NSButton * mShutDownButton;
+ IBOutlet NSButton * mRestartButton;
IBOutlet NSButton * mSwapHD01;
IBOutlet NSButton * mSwapHD02;
IBOutlet NSTextField* mStatusText;
@@ -45,6 +47,8 @@
- (void) selectDefaultPartition;
- (IBAction)onRestart: (id)sender;
+- (IBAction)onShutdown: (id)sender;
+- (IBAction)onSleep: (id)sender;
- (IBAction)onSwapHD: (id)sender;
- (BOOL)isUnlocked;
Index: trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm
===================================================================
--- trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm (revision 11)
+++ trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm (revision 12)
@@ -275,22 +275,37 @@
}
//--------------------------------------------------------------------------
+// following DieBuch recommendation : using applescript and system events (thanks!):
- (IBAction)onRestart: (id)sender
{
NSInteger n = NSRunAlertPanel(@"Restarting OS X",
- @"Are you sure you want to restart now ?",
- @"OK", @"Cancel", /*ThirdButtonHere:*/nil
- /*, args for a printf-style msg go here */);
+ @"Are you sure you want to restart your computer now ?",
+ @"OK", @"Cancel", nil);
if (n==1)
{
- AuthorizationRef auth = [self isUnlocked] ? [[authView authorization] authorizationRef] : NULL;
- // executePrivilegedCmd(auth,"/sbin/reboot");
- // following DieBuch recommendation (thanks!):
- executePrivilegedCmd(auth,"/usr/bin/osascript","-e 'tell application \"System Events\" to restart'");
+ AuthorizationRef auth = [[authView authorization] authorizationRef];
+ executePrivilegedCmd(auth,"/usr/bin/osascript","-e 'tell app \"System Events\" to restart'");
}
-
+
}
+- (IBAction)onShutdown: (id)sender
+{
+ NSInteger n = NSRunAlertPanel(@"Shutting Down OS X",
+ @"Are you sure you want to shut down your computer now ?",
+ @"OK", @"Cancel", /*ThirdButtonHere:*/nil
+ /*, args for a printf-style msg go here */);
+ if (n==1)
+ {
+ system("/usr/bin/osascript -e 'tell app \"System Events\" to shut down'");
+ }
+
+}
+- (IBAction)onSleep: (id)sender
+{
+ system("/usr/bin/osascript -e 'tell app \"System Events\" to sleep'");
+}
+
//--------------------------------------------------------------------------
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
Index: trunk/ChameleonPrefPane/English.lproj/Chameleon.xib
===================================================================
--- trunk/ChameleonPrefPane/English.lproj/Chameleon.xib (revision 11)
+++ trunk/ChameleonPrefPane/English.lproj/Chameleon.xib (revision 12)
@@ -12,7 +12,7 @@