[vlc-commits] macosx: save the expanded/collapsed state of the sidebar items (close #6389 )
Felix Paul Kühne
git at videolan.org
Mon Apr 9 20:19:11 CEST 2012
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Apr 9 18:56:00 2012 +0200| [815b2ce8389f038c12552b26df59fea67a96ad43] | committer: Felix Paul Kühne
macosx: save the expanded/collapsed state of the sidebar items (close #6389)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=815b2ce8389f038c12552b26df59fea67a96ad43
---
.../macosx/Resources/English.lproj/MainMenu.xib | 30 ++++-------------
modules/gui/macosx/MainWindow.h | 1 +
modules/gui/macosx/MainWindow.m | 34 ++++++++++++++++++--
3 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/extras/package/macosx/Resources/English.lproj/MainMenu.xib b/extras/package/macosx/Resources/English.lproj/MainMenu.xib
index 11ee3ff..7b59dd3 100644
--- a/extras/package/macosx/Resources/English.lproj/MainMenu.xib
+++ b/extras/package/macosx/Resources/English.lproj/MainMenu.xib
@@ -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>
@@ -7407,22 +7407,6 @@ LCAuLi4</string>
</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>
<reference key="source" ref="498338108"/>
<reference key="destination" ref="1064884668"/>
diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h
index cbd7bae..e47efcb 100644
--- a/modules/gui/macosx/MainWindow.h
+++ b/modules/gui/macosx/MainWindow.h
@@ -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"
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index e83ebbd..5954990 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -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
More information about the vlc-commits
mailing list