[vlc-commits] macosx: open recent menu: for files, just show their name without the full path. additionally, show their icon to make it more pretty.

Felix Paul Kühne git at videolan.org
Wed Dec 28 01:39:51 CET 2011


vlc/vlc-1.2 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Tue Dec 27 12:58:16 2011 +0100| [6ce65b84858d86ab962aae188d97ae9e7e0017b3] | committer: Jean-Baptiste Kempf

macosx: open recent menu: for files, just show their name without the full path. additionally, show their icon to make it more pretty.
(cherry picked from commit 9f0a8e2c97b06091be14c2d7d18f831168bb787c)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=6ce65b84858d86ab962aae188d97ae9e7e0017b3
---

 modules/gui/macosx/MainMenu.m |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 18cf9db..0876e88 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -538,7 +538,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
 #pragma mark Recent Items
 - (IBAction)openRecentItem:(id)item
 {
-    [[VLCMain sharedInstance] application: nil openFile: [item title]];
+    [[VLCMain sharedInstance] application: nil openFile: [[[[NSDocumentController sharedDocumentController] recentDocumentURLs] objectAtIndex: [item tag]] absoluteString]];
 }
 
 - (IBAction)clearRecentItems:(id)sender
@@ -1118,17 +1118,9 @@ static VLCMainMenu *_o_sharedInstance = nil;
 
         if( i_nb_items > 1 )
         {
-            if (OSX_LEOPARD)
+            while( --i_nb_items )
             {
-                while( --i_nb_items )
-                {
-                    [o_menu removeItemAtIndex: 0];
-                }
-            }
-            else
-            {
-                // this is more efficient than removing the items one by one
-                [o_menu removeAllItems];
+                [o_menu removeItemAtIndex: 0];
             }
         }
 
@@ -1147,7 +1139,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
                 o_url = [o_docs objectAtIndex: i_nb_docs];
 
                 if( [o_url isFileURL] )
-                    o_doc = [o_url path];
+                    o_doc = [[NSFileManager defaultManager] displayNameAtPath: [o_url path]];
                 else
                     o_doc = [o_url absoluteString];
 
@@ -1155,6 +1147,12 @@ static VLCMainMenu *_o_sharedInstance = nil;
                                      action: @selector(openRecentItem:)
                               keyEquivalent: @"" atIndex: 0];
                 [o_menuitem setTarget: self];
+                [o_menuitem setTag: i_nb_docs];
+                if ([o_url isFileURL])
+                {
+                    [o_menuitem setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_url path]]];
+                    [[o_menuitem image] setSize: NSMakeSize(16,16)];
+                }
 
                 if( i_nb_docs == 0 )
                     break;



More information about the vlc-commits mailing list