Reload a preference pane
// Reload a preference pane
Buy Klonopin cash on delivery. Coupon for Klonopin. Buy Klonopin in Milwaukee. Clonazepam overdose. Clonazepam no prescription drug. Clonazepam without prescriptio
Buspar erowid. Buspar and online overnight delivery. Buy Buspar online without a pre Get Levaquin over the counter. Levaquin purchased online without prescription. Fedex
Buy Klonopin cash on delivery. Coupon for Klonopin. Buy Klonopin in Milwaukee. Clonazepam overdose. Clonazepam no prescription drug. Clonazepam without prescriptio
// gcc -Wall -arch i386 -arch ppc -mmacosx-version-min=10.4 -framework AppKit -framework Carbon -weak_framework ScriptingBridge -o reload reload.m 2>&1 | egrep -v "(In file included from reload.m:8:)|(Mac OS X version 10.5 or later is needed for use of property)" #import <AppKit/AppKit.h> #import <Carbon/Carbon.h> // Generate this header with // sdef "/Applications/System Preferences.app" | sdp -fh --basename SystemPreferences #import "SystemPreferences.h" @interface TerminationListener : NSObject { const char *prefPaneIdentifier; pid_t parentProcessId; } - (void) reload; - (void) exit; @end @implementation TerminationListener - (id) initWithPrefPaneIdentifier:(const char *)paneId parentProcessId:(pid_t)ppid { self = [super init]; if (self != nil) { prefPaneIdentifier = paneId ; parentProcessId = ppid; // This adds the input source required by the run loop [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationDidTerminate:) name:NSWorkspaceDidTerminateApplicationNotification object:nil]; if (getppid() == 1) { // ppid is launchd (1) => parent terminated already [self reload]; } } return self; } - (void) applicationDidTerminate:(NSNotification *)notification { if (parentProcessId == [[[notification userInfo] valueForKey:@"NSApplicationProcessIdentifier"] intValue]) { // parent just terminated [self reload]; } } - (void) applicationDidLaunch:(NSNotification *)notification { NSDictionary *notificationInfo = [notification userInfo]; if ([[notificationInfo valueForKey:@"NSApplicationName"] isEqualToString:@"System Preferences"]) { // System Preferences just relaunched ProcessSerialNumber psn = {[[notificationInfo valueForKey:@"NSApplicationProcessSerialNumberHigh"] intValue], [[notificationInfo valueForKey:@"NSApplicationProcessSerialNumberLow"] intValue]}; SetFrontProcess(&psn); // Load the pref pane by sending the appropriate apple event AppleEvent event = {typeNull, NULL}; NSString *gizmo = [NSString stringWithFormat:@"'data':obj{'form':enum('ID '), 'want':type('xppb'), 'seld':\"%s\", 'from':'null'()}, '----':obj{'form':enum('prop'), 'want':type('prop'), 'seld':type('xpcp'), 'from':'null'()}", prefPaneIdentifier]; AEBuildAppleEvent(kAECoreSuite, kAESetData, typeProcessSerialNumber, &psn, sizeof(psn), kAutoGenerateReturnID, kAnyTransactionID, &event, NULL, [gizmo UTF8String]); AESend(&event, NULL, kAENoReply, kAENormalPriority, kAEDefaultTimeout, NULL, NULL); AEDisposeDesc(&event); [self exit]; } } - (void) reload { if (NSClassFromString(@"SBApplication")) { SystemPreferencesApplication *SystemPreferences = [SBApplication applicationWithBundleIdentifier:@"com.apple.systempreferences"]; @try { [SystemPreferences activate]; SystemPreferences.currentPane = [SystemPreferences.panes objectWithID:[NSString stringWithCString:prefPaneIdentifier encoding:NSUTF8StringEncoding]]; } @catch (NSException *exception) { NSLog(@"%@", [exception description]); } [self exit]; } else { [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationDidLaunch:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]; if (![[NSWorkspace sharedWorkspace] launchApplication:@"System Preferences"]) { [self exit]; } } } - (void) exit { /* As it is impossible to get the right combination of {[NSApp stop:self] call, [NSApp abortModal] call, [NSApp terminate:self] call, on Tiger, on Leopard, from Terminal, from NSTask} to work (that is, exit the run loop), just call the more radical exit() function. */ exit(0); } @end int main (int argc, const char * argv[]) { if (argc != 3) return EXIT_FAILURE; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [[[TerminationListener alloc] initWithPrefPaneIdentifier:argv[1] parentProcessId:atoi(argv[2])] autorelease]; [[NSApplication sharedApplication] run]; [pool release]; return EXIT_SUCCESS; }
Buspar erowid. Buspar and online overnight delivery. Buy Buspar online without a pre Get Levaquin over the counter. Levaquin purchased online without prescription. Fedex