Drop non-singleton support for the file chooser

The main problem was restoring the data source in showWindow: since that would lose state such as selected item.
This commit is contained in:
Allan Odgaard
2013-10-27 18:48:39 +01:00
parent 25307478a1
commit e9d60ce7b7
3 changed files with 2 additions and 22 deletions

View File

@@ -251,7 +251,7 @@ static path::glob_list_t globs_for_path (std::string const& path)
_openDocumentsMap.clear();
_records.clear();
[super windowWillClose:aNotification];
self.items = @[ ];
}
- (void)updateWindowTitle

View File

@@ -22,6 +22,5 @@ PUBLIC @interface OakChooser : NSObject
@property (nonatomic) NSTextField* statusTextField;
@property (nonatomic) NSTextField* itemCountTextField;
- (void)windowWillClose:(NSNotification*)aNotification;
- (void)accept:(id)sender;
@end

View File

@@ -27,7 +27,6 @@ NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string
}
@interface OakChooser () <NSWindowDelegate, NSTableViewDataSource, NSTableViewDelegate>
@property (nonatomic) OakChooser* retainedSelf;
@end
@implementation OakChooser
@@ -99,8 +98,6 @@ NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string
_window.delegate = self;
_window.level = NSFloatingWindowLevel;
_window.releasedWhenClosed = NO;
_retainedSelf = self;
}
return self;
}
@@ -122,12 +119,6 @@ NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string
- (void)showWindow:(id)sender
{
_retainedSelf = self;
_tableView.target = self;
_tableView.dataSource = self;
_tableView.delegate = self;
[_window makeKeyAndOrderFront:self];
[_window makeFirstResponder:_searchField];
}
@@ -137,15 +128,6 @@ NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string
[_window performClose:self];
}
- (void)windowWillClose:(NSNotification*)aNotification
{
_tableView.target = nil;
_tableView.dataSource = nil;
_tableView.delegate = nil;
_retainedSelf = nil;
}
// ==============
// = Properties =
// ==============
@@ -190,8 +172,7 @@ NSMutableAttributedString* CreateAttributedStringWithMarkedUpRanges (std::string
[_window orderOut:self];
if(_action)
[NSApp sendAction:_action to:_target from:self];
[_window close]; // Should be last as it gives up retainedSelf
[_window close];
}
- (void)cancel:(id)sender