[vlc-devel] [PATCH 1/3] macOS: Move bookmark time calculation to helper method
Marvin Scholz
epirat07 at gmail.com
Fri May 19 17:50:22 CEST 2017
---
modules/gui/macosx/VLCBookmarksWindowController.m | 24 +++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/modules/gui/macosx/VLCBookmarksWindowController.m b/modules/gui/macosx/VLCBookmarksWindowController.m
index 1570cb6932..a1c22fd63c 100644
--- a/modules/gui/macosx/VLCBookmarksWindowController.m
+++ b/modules/gui/macosx/VLCBookmarksWindowController.m
@@ -176,11 +176,7 @@ - (IBAction)edit:(id)sender
}
[_editNameTextField setStringValue: toNSStr(pp_bookmarks[row]->psz_name)];
- mtime_t total = pp_bookmarks[row]->i_time_offset;
- unsigned hour = ( total / ( CLOCK_FREQ * 3600 ) );
- unsigned min = ( total % ( CLOCK_FREQ * 3600 ) ) / ( CLOCK_FREQ * 60 );
- float sec = ( total % ( CLOCK_FREQ * 60 ) ) / ( CLOCK_FREQ * 1. );
- [_editTimeTextField setStringValue: [NSString stringWithFormat:@"%02d:%02d:%06.3f", hour, min, sec]];
+ [_editTimeTextField setStringValue:[self timeStringForBookmark:pp_bookmarks[row]]];
/* Just keep the pointer value to check if it
* changes. Note, we don't need to keep a reference to the object.
@@ -340,6 +336,18 @@ - (IBAction)remove:(id)sender
[_dataTable reloadData];
}
+- (NSString *)timeStringForBookmark:(seekpoint_t *)bookmark
+{
+ assert(bookmark != NULL);
+
+ mtime_t total = bookmark->i_time_offset;
+ unsigned hour = ( total / ( CLOCK_FREQ * 3600 ) );
+ unsigned min = ( total % ( CLOCK_FREQ * 3600 ) ) / ( CLOCK_FREQ * 60 );
+ float sec = ( total % ( CLOCK_FREQ * 60 ) ) / ( CLOCK_FREQ * 1. );
+
+ return [NSString stringWithFormat:@"%02d:%02d:%06.3f", hour, min, sec];
+}
+
/*****************************************************************************
* data source methods
*****************************************************************************/
@@ -386,11 +394,7 @@ - (id)tableView:(NSTableView *)theDataTable objectValueForTableColumn: (NSTableC
if ([identifier isEqualToString: @"description"])
ret = toNSStr(pp_bookmarks[row]->psz_name);
else if ([identifier isEqualToString: @"time_offset"]) {
- int total = pp_bookmarks[row]->i_time_offset/ 1000000;
- int hour = total / (60*60);
- int min = (total - hour*60*60) / 60;
- int sec = total - hour*60*60 - min*60;
- ret = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, min, sec];
+ ret = [self timeStringForBookmark:pp_bookmarks[row]];
}
// Clear the bookmark list
--
2.11.0 (Apple Git-81)
More information about the vlc-devel
mailing list