[vlc-devel] [PATCH 1/2] macOS: Move bookmark time calculation to helper method

Marvin Scholz epirat07 at gmail.com
Tue May 16 21:13:53 CEST 2017


---
 modules/gui/macosx/VLCBookmarksWindowController.m | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/modules/gui/macosx/VLCBookmarksWindowController.m b/modules/gui/macosx/VLCBookmarksWindowController.m
index a5660dc9ef..1f2bf02cbd 100644
--- a/modules/gui/macosx/VLCBookmarksWindowController.m
+++ b/modules/gui/macosx/VLCBookmarksWindowController.m
@@ -340,6 +340,17 @@ - (IBAction)remove:(id)sender
     [_dataTable reloadData];
 }
 
+- (NSString *)timeStringForBookmark:(seekpoint_t *)bookmark
+{
+    assert(bookmark != NULL);
+
+    long long total = bookmark->i_time_offset/ 1000000;
+    long long hour = total / (60*60);
+    long long min = (total - hour*60*60) / 60;
+    long long sec = total - hour*60*60 - min*60;
+    return [NSString stringWithFormat:@"%02lld:%02lld:%02lld", hour, min, sec];
+}
+
 /*****************************************************************************
  * data source methods
  *****************************************************************************/
@@ -386,11 +397,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