[vlc-commits] macosx: add file size column to playlist table (close #9497)
Felix Paul Kühne
git at videolan.org
Sun Feb 2 22:49:59 CET 2014
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Feb 2 20:30:27 2014 +0100| [eecfe4310f9435cfd9300ba0fbc27465a758bcbe] | committer: Felix Paul Kühne
macosx: add file size column to playlist table (close #9497)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eecfe4310f9435cfd9300ba0fbc27465a758bcbe
---
modules/gui/macosx/MainMenu.m | 4 +++-
modules/gui/macosx/playlist.h | 1 +
modules/gui/macosx/playlist.m | 16 ++++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 0f4b0fa..301d0e7 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -76,11 +76,13 @@ static VLCMainMenu *_o_sharedInstance = nil;
_NS("Date"), DATE_COLUMN,
_NS("Language"), LANGUAGE_COLUMN,
_NS("URI"), URI_COLUMN,
+ _NS("File Size"), FILESIZE_COLUMN,
nil];
// this array also assigns tags (index) to type of menu item
o_ptc_menuorder = [[NSArray alloc] initWithObjects: TRACKNUM_COLUMN, TITLE_COLUMN,
ARTIST_COLUMN, DURATION_COLUMN, GENRE_COLUMN, ALBUM_COLUMN,
- DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN, nil];
+ DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN,
+ FILESIZE_COLUMN,nil];
}
return _o_sharedInstance;
diff --git a/modules/gui/macosx/playlist.h b/modules/gui/macosx/playlist.h
index 7ffc060..900ab49 100644
--- a/modules/gui/macosx/playlist.h
+++ b/modules/gui/macosx/playlist.h
@@ -36,6 +36,7 @@
#define DATE_COLUMN @"date"
#define LANGUAGE_COLUMN @"language"
#define URI_COLUMN @"uri"
+#define FILESIZE_COLUMN @"file-size"
/*****************************************************************************
* VLCPlaylistView interface
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index 270b238..d2b636c 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -363,6 +363,22 @@
free(psz_value);
}
}
+ else if ([o_identifier isEqualToString:FILESIZE_COLUMN]) {
+ psz_value = input_item_GetURI(p_item->p_input);
+ o_value = @"";
+ if (psz_value) {
+ NSURL *url = [NSURL URLWithString:[NSString stringWithUTF8String:psz_value]];
+ if ([url isFileURL]) {
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ if ([fileManager fileExistsAtPath:[url path]]) {
+ NSError *error;
+ NSDictionary *attributes = [fileManager attributesOfItemAtPath:[url path] error:&error];
+ o_value = [NSByteCountFormatter stringFromByteCount:[attributes fileSize] countStyle:NSByteCountFormatterCountStyleDecimal];
+ }
+ }
+ free(psz_value);
+ }
+ }
else if ([o_identifier isEqualToString:@"status"]) {
if (input_item_HasErrorWhenReading(p_item->p_input)) {
o_value = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertCautionIcon)];
More information about the vlc-commits
mailing list