Commit 1bf284b0 authored by Felix Paul Kühne's avatar Felix Paul Kühne

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

(cherry picked from commit 815b2ce8389f038c12552b26df59fea67a96ad43)
parent 152a99ea
...@@ -41,6 +41,7 @@ Mac OS X: ...@@ -41,6 +41,7 @@ Mac OS X:
* Keep Aspect Ratio when resizing is back * Keep Aspect Ratio when resizing is back
* Added controls to manipulate the Subtitles Duration to the Track * Added controls to manipulate the Subtitles Duration to the Track
Synchronization panel Synchronization panel
* Hidden items in the sidebar are being retained for the next launch now
* Fix crash when trying to open an Audio CD by drag & drop * Fix crash when trying to open an Audio CD by drag & drop
* Improve reliability when opening DVDs or BRs by drag & drop * Improve reliability when opening DVDs or BRs by drag & drop
* Fix crash on exit * Fix crash on exit
......
...@@ -21,16 +21,16 @@ ...@@ -21,16 +21,16 @@
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4850"/>
<integer value="2770"/> <integer value="2770"/>
<integer value="4596"/> <integer value="2730"/>
<integer value="1617"/> <integer value="915"/>
<integer value="29"/>
<integer value="4722"/> <integer value="4722"/>
<integer value="4948"/> <integer value="4948"/>
<integer value="915"/> <integer value="4596"/>
<integer value="2730"/> <integer value="4713"/>
<integer value="21"/> <integer value="29"/>
<integer value="4850"/>
<integer value="1617"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
...@@ -7405,22 +7405,6 @@ LCAuLi4</string> ...@@ -7405,22 +7405,6 @@ LCAuLi4</string>
</object> </object>
<int key="connectionID">4704</int> <int key="connectionID">4704</int>
</object> </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="IBConnectionRecord">
<object class="IBOutletConnection" key="connection"> <object class="IBOutletConnection" key="connection">
<string key="label">o_sidebar_view</string> <string key="label">o_sidebar_view</string>
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "CompatibilityFixes.h" #import "CompatibilityFixes.h"
#import "PXSourceList.h" #import "PXSourceList.h"
#import "PXSourceListDataSource.h"
#import <vlc_input.h> #import <vlc_input.h>
#import "misc.h" #import "misc.h"
#import "fspanel.h" #import "fspanel.h"
......
...@@ -442,13 +442,16 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -442,13 +442,16 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_sidebaritems addObject: internetItem]; [o_sidebaritems addObject: internetItem];
[o_sidebar_view reloadData]; [o_sidebar_view reloadData];
NSUInteger i_sidebaritem_count = [o_sidebaritems count]; [o_sidebar_view expandItem: libraryItem expandChildren: YES];
for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
[o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
[o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO]; [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
[o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex]; [o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex];
[o_sidebar_view registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]]; [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 ) if( b_dark_interface )
{ {
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidResizeNotification object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResizedOrMoved:) name: NSWindowDidResizeNotification object: nil];
...@@ -2307,6 +2310,31 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -2307,6 +2310,31 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
return NO; 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 @end
@implementation VLCDetachedVideoWindow @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