[vlc-commits] macosx: fixed updateTitle as suggested by j-b and made sure to the represented filename correctly , if applicable
Felix Paul Kühne
git at videolan.org
Mon Jul 25 15:13:17 CEST 2011
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Jul 25 15:13:12 2011 +0200| [ac898417639ff746e427a753c2caf9427c740209] | committer: Felix Paul Kühne
macosx: fixed updateTitle as suggested by j-b and made sure to the represented filename correctly, if applicable
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac898417639ff746e427a753c2caf9427c740209
---
modules/gui/macosx/MainWindow.m | 48 ++++++++++++++++++++++++++++++++++-----
modules/gui/macosx/intf.m | 2 +-
2 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index e9dbe5c..2a53012 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -32,6 +32,8 @@
#import "controls.h" // TODO: remove me
#import <vlc_playlist.h>
#import <vlc_aout_intf.h>
+#import <vlc_url.h>
+#import <vlc_strings.h>
@implementation VLCMainWindow
static VLCMainWindow *_o_sharedInstance = nil;
@@ -453,19 +455,53 @@ static VLCMainWindow *_o_sharedInstance = nil;
if( p_input )
{
NSString *aString;
- input_item_t * p_item = input_GetItem( p_input );
- char * name = input_item_GetNowPlaying( p_item );
+ char *format = var_InheritString( VLCIntf, "input-title-format" );
+ char *formated = str_format_meta( p_input, format );
+ free( format );
+ aString = [NSString stringWithUTF8String:formated];
+ free( formated );
- if( !name )
- name = input_item_GetName( p_item );
+ char *uri = input_item_GetURI( input_GetItem( p_input ) );
- aString = [NSString stringWithUTF8String:name];
+ if ([aString isEqualToString:@""])
+ {
+
+ char *file = uri ? strrchr( uri, '/' ) : NULL;
+ if( file != NULL )
+ {
+ decode_URI( ++file );
+ aString = [NSString stringWithUTF8String:file];
+ }
+ else
+ aString = [NSString stringWithUTF8String:uri];
+ }
- free(name);
+ NSMutableString *o_mrl = [NSMutableString stringWithUTF8String: decode_URI(uri)];
+ 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
+ {
+ /* it's from the network or somewhere else,
+ * we clear the previous path */
+ [self setRepresentedFilename: @""];
+ }
[self setTitle: aString];
[[[[VLCMain sharedInstance] controls] fspanel] setStreamTitle: aString];
}
+ else
+ {
+ [self setTitle: _NS("VLC media player")];
+ [self setRepresentedFilename: @""];
+ }
}
- (void)updateWindow
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 64576f5..b1615c1 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -243,7 +243,6 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
break;
case INPUT_EVENT_TITLE:
case INPUT_EVENT_CHAPTER:
- [[VLCMain sharedInstance] updateTitle];
break;
case INPUT_EVENT_CACHE:
[[VLCMain sharedInstance] updateMainWindow];
@@ -262,6 +261,7 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
break;
case INPUT_EVENT_ITEM_META:
case INPUT_EVENT_ITEM_INFO:
+ [[VLCMain sharedInstance] updateTitle];
[[VLCMain sharedInstance] updateInfoandMetaPanel];
break;
case INPUT_EVENT_BOOKMARK:
More information about the vlc-commits
mailing list