mamburu: Expandedness state of file drawer is now persisted over app restarts
parent
0ad3106355
commit
3f35b5e07f
|
@ -5,6 +5,7 @@
|
||||||
#import "NDHotKeyEvent.h"
|
#import "NDHotKeyEvent.h"
|
||||||
#import "NowPlayingBarController.h"
|
#import "NowPlayingBarController.h"
|
||||||
|
|
||||||
|
@class FileTreeViewController;
|
||||||
@class PlaybackController;
|
@class PlaybackController;
|
||||||
@class PlaylistController;
|
@class PlaylistController;
|
||||||
@class PlaylistView;
|
@class PlaylistView;
|
||||||
|
@ -46,6 +47,8 @@
|
||||||
|
|
||||||
IBOutlet NSWindowController *spotlightWindowController;
|
IBOutlet NSWindowController *spotlightWindowController;
|
||||||
|
|
||||||
|
IBOutlet FileTreeViewController *fileTreeViewController;
|
||||||
|
|
||||||
NDHotKeyEvent *playHotKey;
|
NDHotKeyEvent *playHotKey;
|
||||||
NDHotKeyEvent *prevHotKey;
|
NDHotKeyEvent *prevHotKey;
|
||||||
NDHotKeyEvent *nextHotKey;
|
NDHotKeyEvent *nextHotKey;
|
||||||
|
@ -57,6 +60,8 @@
|
||||||
BOOL remoteButtonHeld; /* true as long as the user holds the left,right,plus or minus on the remote control */
|
BOOL remoteButtonHeld; /* true as long as the user holds the left,right,plus or minus on the remote control */
|
||||||
|
|
||||||
NSOperationQueue *queue; // Since we are the app delegate, we take care of the op queue
|
NSOperationQueue *queue; // Since we are the app delegate, we take care of the op queue
|
||||||
|
|
||||||
|
NSMutableSet* expandedNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)openURL:(id)sender;
|
- (IBAction)openURL:(id)sender;
|
||||||
|
@ -91,4 +96,7 @@ OSStatus handleHotKey(EventHandlerCallRef nextHandler,EventRef theEvent,void *us
|
||||||
- (IBAction)decreaseFontSize:(id)sender;
|
- (IBAction)decreaseFontSize:(id)sender;
|
||||||
- (void)changeFontSize:(float)size;
|
- (void)changeFontSize:(float)size;
|
||||||
|
|
||||||
|
- (void)nodeExpanded:(NSNotification*)notification;
|
||||||
|
- (void)nodeCollapsed:(NSNotification*)notification;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#import "AppController.h"
|
#import "AppController.h"
|
||||||
|
#import "FileTreeViewController.h"
|
||||||
#import "PlaybackController.h"
|
#import "PlaybackController.h"
|
||||||
#import "PlaylistController.h"
|
#import "PlaylistController.h"
|
||||||
#import "PlaylistView.h"
|
#import "PlaylistView.h"
|
||||||
|
@ -10,6 +11,7 @@
|
||||||
#import "SpotlightWindowController.h"
|
#import "SpotlightWindowController.h"
|
||||||
#import "StringToURLTransformer.h"
|
#import "StringToURLTransformer.h"
|
||||||
#import "FontSizetoLineHeightTransformer.h"
|
#import "FontSizetoLineHeightTransformer.h"
|
||||||
|
#import "PathNode.h"
|
||||||
#import <CogAudio/Status.h>
|
#import <CogAudio/Status.h>
|
||||||
|
|
||||||
@implementation AppController
|
@implementation AppController
|
||||||
|
@ -47,6 +49,7 @@
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[queue release];
|
[queue release];
|
||||||
|
[expandedNodes release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +60,7 @@
|
||||||
[remote startListening: self];
|
[remote startListening: self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (void)applicationDidResignActive:(NSNotification *)motification
|
- (void)applicationDidResignActive:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
|
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"remoteOnlyOnActive"]) {
|
||||||
[remote stopListening: self];
|
[remote stopListening: self];
|
||||||
|
@ -274,6 +277,67 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterFullscreen) name:NSWindowDidEnterFullScreenNotification object:mainWindow];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterFullscreen) name:NSWindowDidEnterFullScreenNotification object:mainWindow];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitFullscreen) name:NSWindowDidExitFullScreenNotification object:mainWindow];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitFullscreen) name:NSWindowDidExitFullScreenNotification object:mainWindow];
|
||||||
|
|
||||||
|
// We need file tree view to restore its state here
|
||||||
|
// so attempt to access file tree view controller's root view
|
||||||
|
// to force it to read nib and create file tree view for us
|
||||||
|
//
|
||||||
|
// TODO: there probably is a more elegant way to do all this
|
||||||
|
// but i'm too stupid/tired to figure it out now
|
||||||
|
[fileTreeViewController view];
|
||||||
|
|
||||||
|
FileTreeOutlineView* outlineView = [fileTreeViewController outlineView];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nodeExpanded:) name:NSOutlineViewItemDidExpandNotification object:outlineView];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nodeCollapsed:) name:NSOutlineViewItemDidCollapseNotification object:outlineView];
|
||||||
|
|
||||||
|
NSArray *expandedNodesArray = [[NSUserDefaults standardUserDefaults] valueForKey:@"fileTreeViewExpandedNodes"];
|
||||||
|
|
||||||
|
if (expandedNodesArray)
|
||||||
|
{
|
||||||
|
expandedNodes = [[NSMutableSet alloc] initWithArray:expandedNodesArray];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expandedNodes = [[NSMutableSet alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSLog(@"Nodes to expand: %@", [expandedNodes description]);
|
||||||
|
|
||||||
|
NSLog(@"Num of rows: %ld", [outlineView numberOfRows]);
|
||||||
|
|
||||||
|
if (!outlineView)
|
||||||
|
{
|
||||||
|
NSLog(@"outlineView is NULL!");
|
||||||
|
}
|
||||||
|
|
||||||
|
[outlineView reloadData];
|
||||||
|
|
||||||
|
for (NSInteger i=0; i<[outlineView numberOfRows]; i++)
|
||||||
|
{
|
||||||
|
PathNode *pn = [outlineView itemAtRow:i];
|
||||||
|
NSString *str = [[pn URL] absoluteString];
|
||||||
|
|
||||||
|
if ([expandedNodes containsObject:str])
|
||||||
|
{
|
||||||
|
[outlineView expandItem:pn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)nodeExpanded:(NSNotification*)notification
|
||||||
|
{
|
||||||
|
PathNode* node = [[notification userInfo] objectForKey:@"NSObject"];
|
||||||
|
NSString* url = [[node URL] absoluteString];
|
||||||
|
|
||||||
|
[expandedNodes addObject:url];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)nodeCollapsed:(NSNotification*)notification
|
||||||
|
{
|
||||||
|
PathNode* node = [[notification userInfo] objectForKey:@"NSObject"];
|
||||||
|
NSString* url = [[node URL] absoluteString];
|
||||||
|
|
||||||
|
[expandedNodes removeObject:url];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
||||||
|
@ -314,6 +378,10 @@ increase/decrease as long as the user holds the left/right, plus/minus button */
|
||||||
|
|
||||||
NSError *error;
|
NSError *error;
|
||||||
[[NSFileManager defaultManager] removeItemAtPath:[folder stringByAppendingPathComponent:fileName] error:&error];
|
[[NSFileManager defaultManager] removeItemAtPath:[folder stringByAppendingPathComponent:fileName] error:&error];
|
||||||
|
|
||||||
|
NSLog(@"Saving expanded nodes: %@", [expandedNodes description]);
|
||||||
|
|
||||||
|
[[NSUserDefaults standardUserDefaults] setValue:[expandedNodes allObjects] forKey:@"fileTreeViewExpandedNodes"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
|
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -82,7 +82,7 @@
|
||||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||||
</tableHeaderCell>
|
</tableHeaderCell>
|
||||||
<imageCell key="dataCell" controlSize="small" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="139EAE20-7EF7-4D8B-B72A-E18459698F54" id="1801">
|
<imageCell key="dataCell" controlSize="small" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="9E1EC36B-776F-41F6-84BA-3BCF9937C65D" id="1801">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
</imageCell>
|
</imageCell>
|
||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
|
@ -1365,6 +1365,7 @@ Gw
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="currentEntryController" destination="1897" id="49h-Dv-ved"/>
|
<outlet property="currentEntryController" destination="1897" id="49h-Dv-ved"/>
|
||||||
<outlet property="fileButton" destination="1631" id="1661"/>
|
<outlet property="fileButton" destination="1631" id="1661"/>
|
||||||
|
<outlet property="fileTreeViewController" destination="2172" id="4Zw-gB-Lmo"/>
|
||||||
<outlet property="infoButton" destination="1627" id="1663"/>
|
<outlet property="infoButton" destination="1627" id="1663"/>
|
||||||
<outlet property="mainView" destination="2123" id="1rG-oa-1Yy"/>
|
<outlet property="mainView" destination="2123" id="1rG-oa-1Yy"/>
|
||||||
<outlet property="mainWindow" destination="21" id="359"/>
|
<outlet property="mainWindow" destination="21" id="359"/>
|
||||||
|
@ -1650,7 +1651,7 @@ Gw
|
||||||
<customObject id="2434" customClass="FeedbackController"/>
|
<customObject id="2434" customClass="FeedbackController"/>
|
||||||
</objects>
|
</objects>
|
||||||
<resources>
|
<resources>
|
||||||
<image name="139EAE20-7EF7-4D8B-B72A-E18459698F54" width="17" height="17">
|
<image name="9E1EC36B-776F-41F6-84BA-3BCF9937C65D" width="17" height="17">
|
||||||
<mutableData key="keyedArchiveRepresentation">
|
<mutableData key="keyedArchiveRepresentation">
|
||||||
YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QDwcI
|
YnBsaXN0MDDUAQIDBAUGRkdYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoK8QDwcI
|
||||||
ExQZHh8qKyw0NzpAQ1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5T
|
ExQZHh8qKyw0NzpAQ1UkbnVsbNUJCgsMDQ4PEBESVk5TU2l6ZVYkY2xhc3NcTlNJbWFnZUZsYWdzVk5T
|
||||||
|
|
|
@ -11,9 +11,13 @@
|
||||||
|
|
||||||
@class PlaylistLoader;
|
@class PlaylistLoader;
|
||||||
@class PlaybackController;
|
@class PlaybackController;
|
||||||
|
@class FileTreeOutlineView;
|
||||||
@interface FileTreeViewController : SideViewController {
|
@interface FileTreeViewController : SideViewController {
|
||||||
IBOutlet PlaylistLoader *playlistLoader;
|
IBOutlet PlaylistLoader *playlistLoader;
|
||||||
IBOutlet PlaybackController *playbackController;
|
IBOutlet PlaybackController *playbackController;
|
||||||
|
IBOutlet FileTreeOutlineView *fileTreeOutlineView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (FileTreeOutlineView*)outlineView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -32,4 +32,9 @@
|
||||||
[playbackController playPauseResume:id];
|
[playbackController playPauseResume:id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (FileTreeOutlineView*)outlineView
|
||||||
|
{
|
||||||
|
return fileTreeOutlineView;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue