File Browser will now remember it's width

This closes issue #5.
This commit is contained in:
Gerd Knops
2012-08-21 19:39:23 -05:00
committed by Allan Odgaard
parent f2dd19f2a3
commit 9d17d74b1b
4 changed files with 14 additions and 1 deletions

View File

@@ -359,6 +359,12 @@ NSString* const kUserDefaultsFileBrowserPlacementKey = @"fileBrowserPlacement";
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidResignActiveNotification:) name:NSApplicationDidResignActiveNotification object:NSApp];
}
+ (void)initialize
{
if(self == [DocumentController class])
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ kUserDefaultsFileBrowserWidthKey : @250 }];
}
+ (void)applicationDidBecomeActiveNotification:(NSNotification*)aNotification
{
for(NSWindow* window in [NSApp orderedWindows])
@@ -1408,7 +1414,7 @@ static std::string file_chooser_glob (std::string const& path)
fileBrowser = [OakFileBrowser new];
fileBrowser.delegate = self;
[fileBrowser setupViewWithSize:NSMakeSize(fileBrowserWidth ?: 250, 100) resizeIndicatorOnRight:!placeOnRight state:fileBrowserState];
[fileBrowser setupViewWithSize:NSMakeSize(fileBrowserWidth ?: [[NSUserDefaults standardUserDefaults] integerForKey:kUserDefaultsFileBrowserWidthKey], 100) resizeIndicatorOnRight:!placeOnRight state:fileBrowserState];
[self updateFileBrowserStatus:self];
}

View File

@@ -1,5 +1,7 @@
#import <oak/debug.h>
PUBLIC extern NSString* const kUserDefaultsFileBrowserWidthKey;
@class OakFileBrowser;
@class OakFileBrowserView;
@class OakHistoryController;

View File

@@ -30,6 +30,8 @@
#import <text/ctype.h>
#import <regexp/format_string.h>
NSString* const kUserDefaultsFileBrowserWidthKey = @"fileBrowserWidth";
OAK_DEBUG_VAR(FileBrowser_Controller);
@interface OakFileBrowser ()

View File

@@ -4,6 +4,7 @@
#import <OakAppKit/NSImage Additions.h>
#import <OakAppKit/OakStatusBar.h>
#import <OakAppKit/OakFileIconImage.h>
#import <OakFileBrowser/OakFileBrowser.h>
@interface OakFileBrowserView ()
- (void)setupViews;
@@ -94,6 +95,8 @@ OAK_DEBUG_VAR(FileBrowser_View);
{
headerView.frame = NSMakeRect(0, NSHeight(self.frame) - OakStatusBarHeight, NSWidth(self.frame), OakStatusBarHeight);
outlineView.enclosingScrollView.frame = NSMakeRect(0, 0, NSWidth(self.frame), NSHeight(self.frame) - NSHeight(headerView.frame));
[[NSUserDefaults standardUserDefaults] setInteger:NSWidth(self.frame) forKey:kUserDefaultsFileBrowserWidthKey];
}
- (BOOL)isOpaque