Commit e316b5a5 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fix and slightly optimize (on 10.6+) the open recent menu (fixes #5538)

parent 74f2f90a
......@@ -26,7 +26,7 @@
<integer value="2730"/>
<integer value="915"/>
<integer value="1617"/>
<integer value="235"/>
<integer value="569"/>
<integer value="4596"/>
<integer value="21"/>
</object>
......@@ -11439,7 +11439,7 @@ LCAuLi4</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{1004, 603}, {143, 23}}</string>
<string>{{684, 529}, {143, 23}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{385, 503}, {267, 233}}</string>
......@@ -11455,7 +11455,7 @@ LCAuLi4</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{388, 425}, {297, 243}}</string>
<string>{{387, 419}, {297, 243}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
......@@ -14787,6 +14787,7 @@ LCAuLi4</string>
<string>openDonate:</string>
<string>openForum:</string>
<string>openReadMe:</string>
<string>openRecentItem:</string>
<string>openWebsite:</string>
<string>resizeVideoWindow:</string>
<string>setPlaybackRate:</string>
......@@ -14836,6 +14837,7 @@ LCAuLi4</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
......@@ -14854,6 +14856,7 @@ LCAuLi4</string>
<string>openDonate:</string>
<string>openForum:</string>
<string>openReadMe:</string>
<string>openRecentItem:</string>
<string>openWebsite:</string>
<string>resizeVideoWindow:</string>
<string>setPlaybackRate:</string>
......@@ -14922,6 +14925,10 @@ LCAuLi4</string>
<string key="name">openReadMe:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">openRecentItem:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">openWebsite:</string>
<string key="candidateClassName">id</string>
......
......@@ -61,6 +61,10 @@ enum {
extern OSErr UpdateSystemActivity(UInt8 activity);
#define UsrActivity 1
#endif
@interface NSMenu (IntroducedInSnowLeopard)
- (void)removeAllItems;
@end
#endif
#pragma mark -
......
......@@ -199,7 +199,7 @@
- (void)setRateControlsEnabled:(BOOL)b_enabled;
- (IBAction)clearRecentItems:(id)sender;
- (void)openRecentItem:(id)item;
- (IBAction)openRecentItem:(id)item;
- (IBAction)intfOpenFile:(id)sender;
- (IBAction)intfOpenFileGeneric:(id)sender;
......
......@@ -538,15 +538,14 @@ static VLCMainMenu *_o_sharedInstance = nil;
#pragma mark -
#pragma mark Recent Items
- (void)openRecentItem:(id)item
- (IBAction)openRecentItem:(id)item
{
[[VLCMain sharedInstance] application: nil openFile: [item title]];
}
- (IBAction)clearRecentItems:(id)sender
{
[[NSDocumentController sharedDocumentController]
clearRecentDocuments: nil];
[[NSDocumentController sharedDocumentController] clearRecentDocuments: nil];
}
#pragma mark -
......@@ -1107,22 +1106,30 @@ static VLCMainMenu *_o_sharedInstance = nil;
{
NSMenu * o_menu = [o_mi_open_recent submenu];
int i_nb_items = [o_menu numberOfItems];
NSArray * o_docs = [[NSDocumentController sharedDocumentController]
recentDocumentURLs];
NSArray * o_docs = [[NSDocumentController sharedDocumentController] recentDocumentURLs];
UInt32 i_nb_docs = [o_docs count];
if( i_nb_items > 1 )
{
if (OSX_LEOPARD)
{
while( --i_nb_items )
{
[o_menu removeItemAtIndex: 0];
}
}
else
{
// this is more efficient than removing the items one by one
[o_menu removeAllItems];
}
}
if( i_nb_docs > 0 )
{
NSURL * o_url;
NSString * o_doc;
NSMenuItem *o_menuitem;
[o_menu insertItem: [NSMenuItem separatorItem] atIndex: 0];
......@@ -1137,9 +1144,10 @@ static VLCMainMenu *_o_sharedInstance = nil;
else
o_doc = [o_url absoluteString];
[o_menu insertItemWithTitle: o_doc
o_menuitem = [o_menu insertItemWithTitle: o_doc
action: @selector(openRecentItem:)
keyEquivalent: @"" atIndex: 0];
[o_menuitem setTarget: self];
if( i_nb_docs == 0 )
break;
......
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