[vlc-commits] macosx: simplified the way we set the window's title

Felix Paul Kühne git at videolan.org
Sun Aug 14 22:59:44 CEST 2011


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Aug 14 17:29:10 2011 +0200| [b7fbd8c6637712001a141cc553873a18a226c956] | committer: Felix Paul Kühne

macosx: simplified the way we set the window's title

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

 modules/gui/macosx/MainWindow.m |   38 +++++++++++---------------------------
 1 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index f3cf733..ab8d5d1 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -657,35 +657,19 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
         char *uri = input_item_GetURI( input_GetItem( p_input ) );
 
-        if ([aString isEqualToString:@""])
-        {
-
-            char *file = uri ? strrchr( uri, '/' ) : NULL;
-            if( file != NULL )
-            {
-                decode_URI( ++file );
-                aString = [NSString stringWithUTF8String:file];
-            }
-            else
-                aString = [NSString stringWithUTF8String:uri];
-        }
-
-        NSMutableString *o_mrl = [NSMutableString stringWithUTF8String: decode_URI(uri)];
+        NSURL * o_url = [NSURL URLWithString: [NSString stringWithUTF8String: uri]];
+        if ([o_url isFileURL])
+            [self setRepresentedURL: o_url];
+        else
+            [self setRepresentedURL: [NSURL URLWithString:@""]];
         free( uri );
-        NSRange prefix_range = [o_mrl rangeOfString: @"file:"];
-        if( prefix_range.location != NSNotFound )
-            [o_mrl deleteCharactersInRange: prefix_range];
 
-        if( [o_mrl characterAtIndex:0] == '/' )
-        {
-            /* it's a local file */
-            [self setRepresentedFilename: o_mrl];
-        }
-        else
+        if ([aString isEqualToString:@""])
         {
-            /* it's from the network or somewhere else,
-             * we clear the previous path */
-            [self setRepresentedFilename: @""];
+            if ([o_url isFileURL])
+                aString = [[NSFileManager defaultManager] displayNameAtPath: [o_url path]];
+            else
+                aString = [o_url absoluteString];
         }
 
         [self setTitle: aString];
@@ -694,7 +678,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
     else
     {
         [self setTitle: _NS("VLC media player")];
-        [self setRepresentedFilename: @""];
+        [self setRepresentedURL: [NSURL URLWithString: @""]];
     }
     [o_pool release];
 }



More information about the vlc-commits mailing list