Commit 815b2ce8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: save the expanded/collapsed state of the sidebar items (close #6389)

parent 1bb938e4
......@@ -21,16 +21,16 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4850"/>
<integer value="2770"/>
<integer value="4596"/>
<integer value="1617"/>
<integer value="29"/>
<integer value="2730"/>
<integer value="915"/>
<integer value="4722"/>
<integer value="4948"/>
<integer value="915"/>
<integer value="2730"/>
<integer value="21"/>
<integer value="4596"/>
<integer value="4713"/>
<integer value="29"/>
<integer value="4850"/>
<integer value="1617"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -7405,22 +7405,6 @@ LCAuLi4</string>
</object>
<int key="connectionID">4704</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="1064884668"/>
<reference key="destination" ref="498338108"/>
</object>
<int key="connectionID">4719</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1064884668"/>
<reference key="destination" ref="498338108"/>
</object>
<int key="connectionID">4720</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_sidebar_view</string>
......
......@@ -27,6 +27,7 @@
#import <Cocoa/Cocoa.h>
#import "CompatibilityFixes.h"
#import "PXSourceList.h"
#import "PXSourceListDataSource.h"
#import <vlc_input.h>
#import "misc.h"
#import "fspanel.h"
......
......@@ -442,13 +442,16 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_sidebaritems addObject: internetItem];
[o_sidebar_view reloadData];
NSUInteger i_sidebaritem_count = [o_sidebaritems count];
for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
[o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
[o_sidebar_view expandItem: libraryItem expandChildren: YES];
[o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
[o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex];
[o_sidebar_view registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
[o_sidebar_view setAutosaveName:@"mainwindow-sidebar"];
[(PXSourceList *)o_sidebar_view setDataSource:self];
[o_sidebar_view setDelegate:self];
[o_sidebar_view setAutosaveExpandedItems:YES];
if( b_dark_interface )
{
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidResizeNotification object: nil];
......@@ -2307,6 +2310,31 @@ static VLCMainWindow *_o_sharedInstance = nil;
}
return NO;
}
- (id)sourceList:(PXSourceList *)aSourceList persistentObjectForItem:(id)item
{
return [item identifier];
}
- (id)sourceList:(PXSourceList *)aSourceList itemForPersistentObject:(id)object
{
/* the following code assumes for sakes of simplicity that only the top level
* items are allowed to have children */
NSArray * array = [NSArray arrayWithArray: o_sidebaritems]; // read-only arrays are noticebly faster
NSUInteger count = [array count];
if (count < 1)
return nil;
for (NSUInteger x = 0; x < count; x++)
{
id item = [array objectAtIndex: x]; // save one objc selector call
if ([[item identifier] isEqualToString:object])
return item;
}
return nil;
}
@end
@implementation VLCDetachedVideoWindow
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment