mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 13:17:55 -05:00
Hookup Preferences window to tmProperties
Presently the new file type is not setup to use tmProperties as the way this is specified (in tmProperties) needs special-casing. Will likely change that.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#import <OakAppKit/NSMenu Additions.h>
|
||||
#import <OakFoundation/NSString Additions.h>
|
||||
#import <OakFoundation/OakStringListTransformer.h>
|
||||
#import <settings/settings.h>
|
||||
#import <bundles/bundles.h>
|
||||
#import <ns/ns.h>
|
||||
#import <text/ctype.h>
|
||||
@@ -15,13 +16,16 @@
|
||||
{
|
||||
[OakStringListTransformer createTransformerWithName:@"OakLineEndingsTransformer" andObjectsArray:@[ @"\n", @"\r", @"\r\n" ]];
|
||||
|
||||
self.defaultsProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
kUserDefaultsDisableSessionRestoreKey, @"disableSessionRestore",
|
||||
kUserDefaultsDisableNewDocumentAtStartupKey, @"disableDocumentAtStartup",
|
||||
kUserDefaultsDisableNewDocumentAtReactivationKey, @"disableDocumentAtReactivation",
|
||||
kUserDefaultsEncodingKey, @"encoding",
|
||||
kUserDefaultsLineEndingsKey, @"lineEndings",
|
||||
nil];
|
||||
self.defaultsProperties = @{
|
||||
@"disableSessionRestore" : kUserDefaultsDisableSessionRestoreKey,
|
||||
@"disableDocumentAtStartup" : kUserDefaultsDisableNewDocumentAtStartupKey,
|
||||
@"disableDocumentAtReactivation" : kUserDefaultsDisableNewDocumentAtReactivationKey,
|
||||
};
|
||||
|
||||
self.tmProperties = @{
|
||||
@"encoding" : [NSString stringWithCxxString:kSettingsEncodingKey],
|
||||
@"lineEndings" : [NSString stringWithCxxString:kSettingsLineEndingsKey],
|
||||
};
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -57,13 +61,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
encodingPopUp.encoding = [[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsEncodingKey];
|
||||
[encodingPopUp addObserver:self forKeyPath:@"encoding" options:NSKeyValueObservingOptionInitial context:NULL];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
|
||||
{
|
||||
if([keyPath isEqualToString:@"encoding"] && object == encodingPopUp)
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[object valueForKey:keyPath] forKey:kUserDefaultsEncodingKey];
|
||||
[self bind:@"encoding" toObject:encodingPopUp withKeyPath:@"encoding" options:nil];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -15,9 +15,6 @@ PUBLIC extern NSString* const kUserDefaultsDisableNewDocumentAtStartupKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsDisableNewDocumentAtReactivationKey;
|
||||
|
||||
PUBLIC extern NSString* const kUserDefaultsNewDocumentTypeKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsEncodingKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsUseBOMKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsLineEndingsKey;
|
||||
|
||||
// ============
|
||||
// = Projects =
|
||||
@@ -26,9 +23,6 @@ PUBLIC extern NSString* const kUserDefaultsLineEndingsKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsFoldersOnTopKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsShowFileExtensionsKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsInitialFileBrowserURLKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsExcludePatternKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsIncludePatternKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsBinaryPatternKey;
|
||||
|
||||
// ===========
|
||||
// = Bundles =
|
||||
@@ -71,7 +65,6 @@ PUBLIC extern NSString* const kUserDefaultsLicenseOwnerKey;
|
||||
// = Appearance =
|
||||
// ==============
|
||||
|
||||
PUBLIC extern NSString* const kUserDefaultsWindowTitleKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsAntiAliasKey;
|
||||
PUBLIC extern NSString* const kUserDefaultsLineNumbersKey;
|
||||
|
||||
|
||||
@@ -26,20 +26,10 @@ static NSDictionary* default_environment ()
|
||||
|
||||
static NSDictionary* default_settings ()
|
||||
{
|
||||
NSString* excludeGlob = @"{*.{o,pyc},Icon\\r,CVS,_darcs,_MTN,\\{arch\\},blib,*~.nib}";
|
||||
NSString* includeGlob = @"{.tm_properties,.htaccess}";
|
||||
NSString* binaryGlob = @"*.{icns,ico,jpg,jpeg,m4v,nib,pdf,png,psd,pyc,rtf,tif,tiff,xib}";
|
||||
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"3130E4FA-B10E-11D9-9F75-000D93589AF6", kUserDefaultsNewDocumentTypeKey,
|
||||
@"UTF-8", kUserDefaultsEncodingKey,
|
||||
NO_obj, kUserDefaultsUseBOMKey,
|
||||
@"\n", kUserDefaultsLineEndingsKey,
|
||||
YES_obj, kUserDefaultsFoldersOnTopKey,
|
||||
NO_obj, kUserDefaultsShowFileExtensionsKey,
|
||||
excludeGlob, kUserDefaultsExcludePatternKey,
|
||||
includeGlob, kUserDefaultsIncludePatternKey,
|
||||
binaryGlob, kUserDefaultsBinaryPatternKey,
|
||||
default_environment(), kUserDefaultsEnvironmentVariablesKey,
|
||||
NO_obj, kUserDefaultsDisableBundleUpdatesKey,
|
||||
[NSDate distantPast], kUserDefaultsLastBundleUpdateCheckKey,
|
||||
@@ -47,7 +37,6 @@ static NSDictionary* default_settings ()
|
||||
kRMateServerListenLocalhost, kUserDefaultsRMateServerListenKey,
|
||||
@52698, kUserDefaultsRMateServerPortKey,
|
||||
NSFullUserName(), kUserDefaultsLicenseOwnerKey,
|
||||
@"$TM_DISPLAYNAME", kUserDefaultsWindowTitleKey,
|
||||
YES_obj, kUserDefaultsAntiAliasKey,
|
||||
YES_obj, kUserDefaultsLineNumbersKey,
|
||||
nil];
|
||||
@@ -73,9 +62,6 @@ NSString* const kUserDefaultsDisableNewDocumentAtStartupKey = @"disableNewD
|
||||
NSString* const kUserDefaultsDisableNewDocumentAtReactivationKey = @"disableNewDocumentAtReactivation";
|
||||
|
||||
NSString* const kUserDefaultsNewDocumentTypeKey = @"fileType";
|
||||
NSString* const kUserDefaultsEncodingKey = @"encoding";
|
||||
NSString* const kUserDefaultsUseBOMKey = @"useBOM"; // only when encoding = UTF-8
|
||||
NSString* const kUserDefaultsLineEndingsKey = @"lineEndings";
|
||||
|
||||
// ============
|
||||
// = Projects =
|
||||
@@ -84,9 +70,6 @@ NSString* const kUserDefaultsLineEndingsKey = @"lineEndings
|
||||
NSString* const kUserDefaultsFoldersOnTopKey = @"foldersOnTop";
|
||||
NSString* const kUserDefaultsShowFileExtensionsKey = @"showFileExtensions";
|
||||
NSString* const kUserDefaultsInitialFileBrowserURLKey = @"initialFileBrowserURL";
|
||||
NSString* const kUserDefaultsExcludePatternKey = @"excludePattern";
|
||||
NSString* const kUserDefaultsIncludePatternKey = @"includePattern";
|
||||
NSString* const kUserDefaultsBinaryPatternKey = @"binaryPattern";
|
||||
|
||||
// ===========
|
||||
// = Bundles =
|
||||
@@ -129,7 +112,6 @@ NSString* const kUserDefaultsLicenseOwnerKey = @"licenseOwnerName";
|
||||
// = Appearance =
|
||||
// ==============
|
||||
|
||||
NSString* const kUserDefaultsWindowTitleKey = @"windowTitle";
|
||||
NSString* const kUserDefaultsAntiAliasKey = @"antiAlias";
|
||||
NSString* const kUserDefaultsLineNumbersKey = @"lineNumbers";
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
NSString* label;
|
||||
NSImage* image;
|
||||
NSDictionary* defaultsProperties; // property → defaults key
|
||||
NSDictionary* tmProperties; // property → tmProperties key
|
||||
}
|
||||
@property (nonatomic, readonly) NSString* identifier;
|
||||
@property (nonatomic, readonly) NSString* toolbarItemLabel;
|
||||
@property (nonatomic, readonly) NSImage* toolbarItemImage;
|
||||
@property (nonatomic, retain) NSDictionary* defaultsProperties;
|
||||
@property (nonatomic, retain) NSDictionary* tmProperties;
|
||||
|
||||
- (id)initWithNibName:(NSString*)aNibName label:(NSString*)aLabel image:(NSImage*)anImage;
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#import "PreferencesPane.h"
|
||||
#import <OakFoundation/NSString Additions.h>
|
||||
#import <ns/ns.h>
|
||||
#import <settings/settings.h>
|
||||
|
||||
@interface PreferencesPane ()
|
||||
@property (nonatomic, readwrite) NSString* toolbarItemLabel;
|
||||
@@ -6,7 +9,7 @@
|
||||
@end
|
||||
|
||||
@implementation PreferencesPane
|
||||
@synthesize toolbarItemLabel = label, toolbarItemImage = image, defaultsProperties;
|
||||
@synthesize toolbarItemLabel = label, toolbarItemImage = image, defaultsProperties, tmProperties;
|
||||
|
||||
- (NSString*)identifier { return label; }
|
||||
|
||||
@@ -23,7 +26,15 @@
|
||||
- (void)setValue:(id)newValue forUndefinedKey:(NSString*)aKey
|
||||
{
|
||||
if(NSString* key = [defaultsProperties objectForKey:aKey])
|
||||
{
|
||||
return [[NSUserDefaults standardUserDefaults] setObject:newValue forKey:key];
|
||||
}
|
||||
else if(NSString* key = [tmProperties objectForKey:aKey])
|
||||
{
|
||||
if([newValue isKindOfClass:[NSString class]])
|
||||
return settings_t::set(to_s(key), to_s((NSString*)newValue));
|
||||
NSLog(@"%s wrong type for %@: ‘%@’", SELNAME(_cmd), aKey, newValue);
|
||||
}
|
||||
[super setValue:newValue forUndefinedKey:aKey];
|
||||
}
|
||||
|
||||
@@ -31,6 +42,8 @@
|
||||
{
|
||||
if(NSString* key = [defaultsProperties objectForKey:aKey])
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:key];
|
||||
else if(NSString* key = [tmProperties objectForKey:aKey])
|
||||
return [NSString stringWithCxxString:settings_t::raw_get(to_s(key))];
|
||||
return [super valueForUndefinedKey:aKey];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
#import "ProjectsPreferences.h"
|
||||
#import "Keys.h"
|
||||
#import <settings/settings.h>
|
||||
#import <OakAppKit/NSImage Additions.h>
|
||||
#import <OakFoundation/NSString Additions.h>
|
||||
|
||||
@implementation ProjectsPreferences
|
||||
- (id)init
|
||||
{
|
||||
if(self = [super initWithNibName:@"ProjectsPreferences" label:@"Projects" image:[NSImage imageNamed:@"Projects" inSameBundleAsClass:[self class]]])
|
||||
{
|
||||
self.defaultsProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
kUserDefaultsFoldersOnTopKey, @"foldersOnTop",
|
||||
kUserDefaultsShowFileExtensionsKey, @"showFileExtensions",
|
||||
kUserDefaultsExcludePatternKey, @"excludePattern",
|
||||
kUserDefaultsIncludePatternKey, @"includePattern",
|
||||
kUserDefaultsBinaryPatternKey, @"binaryPattern",
|
||||
nil];
|
||||
self.defaultsProperties = @{
|
||||
@"foldersOnTop" : kUserDefaultsFoldersOnTopKey,
|
||||
@"showFileExtensions" : kUserDefaultsShowFileExtensionsKey,
|
||||
};
|
||||
|
||||
self.tmProperties = @{
|
||||
@"excludePattern" : [NSString stringWithCxxString:kSettingsExcludeKey],
|
||||
@"includePattern" : [NSString stringWithCxxString:kSettingsIncludeKey],
|
||||
@"binaryPattern" : [NSString stringWithCxxString:kSettingsBinaryKey],
|
||||
};
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user