-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a new module that adds the ability for FMN to store/restore the "autohide" status of the Dock. NOTE: Right now, the module does not have a corresponding user-interface component, so it is always enabled. darcs-hash:20060917211218-3181a-5465d085477f0761e92801068875debcc680be7c.gz
- Loading branch information
Showing
10 changed files
with
432 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.yourcompany.DockModule</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>NSPrincipalClass</key> | ||
<string>FMNDockModule</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// DockRestorable.h | ||
// FMN | ||
// | ||
// Created by David Noblet on 9/16/06. | ||
// Copyright 2006 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "FMNRestorable.h" | ||
|
||
@interface DockRestorable : NSObject<FMNRestorable> { | ||
//NSDictionary* dockPrefs; | ||
Boolean autohidePref; | ||
} | ||
|
||
- (id) initWithCurrent; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
// | ||
// DockRestorable.m | ||
// FMN | ||
// | ||
// Created by David Noblet on 9/16/06. | ||
// Copyright 2006 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "DockRestorable.h" | ||
|
||
#define DOCK CFSTR("com.apple.dock") | ||
#define USER kCFPreferencesCurrentUser | ||
#define HOST kCFPreferencesAnyHost | ||
#define AUTOHIDE CFSTR("autohide") | ||
|
||
@implementation DockRestorable | ||
|
||
/*- (void) logDockPrefs | ||
{ | ||
NSEnumerator *enumerator = [dockPrefs keyEnumerator]; | ||
id key; | ||
|
||
while ((key = [enumerator nextObject])) | ||
{ | ||
id value = [dockPrefs valueForKey: key]; | ||
NSLog(@"@@@@@@@@@@ Key: '%@'; Value: '%@' @@@@@@@@@@@@@", key, value); | ||
} | ||
}*/ | ||
|
||
+ (Boolean) getDockAutohide | ||
{ | ||
Boolean success; | ||
return CFPreferencesGetAppBooleanValue ( | ||
AUTOHIDE, | ||
DOCK, | ||
&success | ||
) && success; | ||
} | ||
|
||
- (id) initWithCurrent | ||
{ | ||
self = [super init]; | ||
if(!self) | ||
return nil; | ||
|
||
NSLog(@"Storing Dock Preferences"); | ||
|
||
CFPreferencesAppSynchronize(DOCK); | ||
|
||
/*NSArray* keys; | ||
keys = (NSArray*) CFPreferencesCopyKeyList ( | ||
DOCK, | ||
USER, | ||
HOST | ||
); | ||
|
||
dockPrefs = (NSDictionary*) CFPreferencesCopyMultiple ( | ||
(CFArrayRef) keys, | ||
DOCK, | ||
USER, | ||
HOST | ||
); | ||
[keys release];*/ | ||
|
||
autohidePref = [DockRestorable getDockAutohide]; | ||
|
||
NSLog(@"Storing Dock Autohide Preference: %d",autohidePref); | ||
|
||
//[self logDockPrefs]; | ||
|
||
return self; | ||
} | ||
|
||
- (void) restore | ||
{ | ||
NSLog(@"Restoring Dock Preferences"); | ||
/*[self logDockPrefs]; | ||
|
||
CFPreferencesSetMultiple ( | ||
(CFDictionaryRef) dockPrefs, | ||
nil, | ||
DOCK, | ||
USER, | ||
HOST | ||
);*/ | ||
|
||
NSLog(@"Restoring Dock Autohide Preference: %d",autohidePref); | ||
|
||
if([DockRestorable getDockAutohide] != autohidePref) | ||
{ | ||
CFPreferencesSetValue( | ||
AUTOHIDE, | ||
autohidePref ? kCFBooleanTrue : kCFBooleanFalse, | ||
DOCK, | ||
USER, | ||
HOST | ||
); | ||
|
||
CFPreferencesAppSynchronize(DOCK); | ||
|
||
/*CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter(); | ||
CFNotificationCenterPostNotification ( | ||
center, | ||
CFSTR("com.apple.dock.prefchanged"), | ||
DOCK, | ||
nil, true | ||
);*/ | ||
|
||
/* | ||
tell application "System Events" | ||
keystroke "d" using {command down, option down} | ||
end tell | ||
*/ | ||
|
||
NSString *s = [NSString stringWithFormat: | ||
@"tell application \"System Events\"\n" | ||
@"\tkeystroke \"d\" using {command down, option down}\n" | ||
@"end tell\n"]; | ||
NSAppleScript *scriptObj = [[NSAppleScript alloc] initWithSource:s]; | ||
if (scriptObj) | ||
{ | ||
NSDictionary *errInfo; | ||
NSAppleEventDescriptor *aed = [scriptObj executeAndReturnError:&errInfo]; | ||
[scriptObj release]; | ||
if (!aed) | ||
{ | ||
NSLog(@"Got Error in deleteLoginItem"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
- (int) priority | ||
{ | ||
// We want this to be restored before the window positions and sizes | ||
return kRestorableDefaultPriority+1; | ||
} | ||
|
||
- (void) dealloc | ||
{ | ||
/*if(dockPrefs) | ||
{ | ||
[dockPrefs release]; | ||
}*/ | ||
[super dealloc]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.