Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrajca committed Feb 24, 2013
1 parent ffb14a5 commit 71b6dbd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
12 changes: 0 additions & 12 deletions Pixen Application/Tools/Patterns/PXPatternEditorController.h
Expand Up @@ -16,11 +16,6 @@
@property (nonatomic, weak) IBOutlet PXPatternEditorView *editorView;
@property (nonatomic, weak) IBOutlet NSTextField *promptField;

@property (nonatomic, copy) NSString *toolName;
@property (nonatomic, copy) NSString *patternFileName;

@property (nonatomic, unsafe_unretained) id delegate;

- (void)setPattern:(PXPattern *)pattern;

- (IBAction)newPattern:(id)sender;
Expand All @@ -31,10 +26,3 @@
- (void)removePattern:(PXPattern *)pattern;

@end


@interface NSObject(PXPatternEditorControllerDelegate)

- (void)patternEditor:(PXPatternEditorController *)ed finishedWithPattern:(PXPattern *)pattern;

@end
22 changes: 5 additions & 17 deletions Pixen Application/Tools/Patterns/PXPatternEditorController.m
Expand Up @@ -15,7 +15,6 @@
@implementation PXPatternEditorController

@synthesize patternsController, scrollView, editorView, promptField;
@synthesize toolName, patternFileName, delegate;

- (void)awakeFromNib
{
Expand All @@ -30,8 +29,6 @@ - (void)awakeFromNib

[scrollView setDocumentView:editorView];

[[self window] setTitle:[NSLocalizedString(@"Pattern Editor: ", @"Pattern Editor:") stringByAppendingString:toolName]];

[self reloadPatterns];
}

Expand Down Expand Up @@ -65,9 +62,6 @@ - (IBAction)newPattern:(id)sender
{
PXPattern *pattern = [_pattern copy];
[self addPattern:pattern];

if ([delegate respondsToSelector:@selector(patternEditor:finishedWithPattern:)])
[delegate patternEditor:self finishedWithPattern:pattern];
}

- (void)deleteSheetDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:contextInfo
Expand All @@ -87,24 +81,21 @@ - (id)init
selector:@selector(patternsChanged:)
name:PXPatternsChangedNotificationName
object:nil];

[self setPatternFileName:GetPixenPatternFile()];
}
return self;
}

- (void)patternView:(PXPatternEditorView *)pv changedPattern:(PXPattern *)pattern
{
[self setPattern:pattern];

if ([delegate respondsToSelector:@selector(patternEditor:finishedWithPattern:)])
[delegate patternEditor:self finishedWithPattern:pattern];
}

- (void)reloadPatterns
{
BOOL isDirectory;
BOOL isDirectory = NO;

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *patternFileName = GetPixenPatternFile();

if (![fileManager fileExistsAtPath:patternFileName isDirectory:&isDirectory] || isDirectory)
return;
Expand Down Expand Up @@ -146,9 +137,6 @@ - (void)patternItemWasDoubleClicked:(PXPatternItem *)item
{
PXPattern *pattern = [item representedObject];
[self setPattern:pattern];

if ([delegate respondsToSelector:@selector(patternEditor:finishedWithPattern:)])
[delegate patternEditor:self finishedWithPattern:pattern];
}

- (void)addPattern:(PXPattern *)pattern
Expand All @@ -160,7 +148,7 @@ - (void)addPattern:(PXPattern *)pattern
userInfo:nil];

[NSKeyedArchiver archiveRootObject:[patternsController arrangedObjects]
toFile:patternFileName];
toFile:GetPixenPatternFile()];
}

- (void)removePattern:(PXPattern *)pattern
Expand All @@ -172,7 +160,7 @@ - (void)removePattern:(PXPattern *)pattern
userInfo:nil];

[NSKeyedArchiver archiveRootObject:[patternsController arrangedObjects]
toFile:patternFileName];
toFile:GetPixenPatternFile()];
}

- (void)dealloc
Expand Down

0 comments on commit 71b6dbd

Please sign in to comment.