[vlc-commits] macosx/MainWindow: move getCurrentTimeAsString to StringUtility

Felix Paul Kühne git at videolan.org
Fri Aug 24 19:04:04 CEST 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Aug 24 19:02:07 2012 +0200| [0d86a46b0b51a42ca8bc0f2b7584ed03f889925d] | committer: Felix Paul Kühne

macosx/MainWindow: move getCurrentTimeAsString to StringUtility

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

 modules/gui/macosx/MainWindow.m    |   27 ++-------------------------
 modules/gui/macosx/StringUtility.h |    1 +
 modules/gui/macosx/StringUtility.m |   24 +++++++++++++++++++++++-
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 852525f..c0aa080 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -57,8 +57,6 @@
 - (void)makeSplitViewHidden;
 
 - (NSRect)customConstrainFrameRect: (NSRect)frameRect toScreen: (NSScreen*)screen;
-
-- (NSString *)getCurrentTimeAsString:(input_thread_t *)p_input;
 @end
 
 @implementation VLCMainWindow
@@ -1194,7 +1192,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
         var_Set( p_input, "position", pos );
         [o_time_sld setFloatValue: f_updated];
 
-        o_time = [self getCurrentTimeAsString: p_input];
+        o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[o_time_fld timeRemaining]];
         [o_time_fld setStringValue: o_time];
         [o_fspanel setStreamPos: f_updated andTime: o_time];
         vlc_object_release( p_input );
@@ -1516,27 +1514,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
     b_splitview_removed = NO;
 }
 
-- (NSString *)getCurrentTimeAsString:(input_thread_t *)p_input
-{
-    assert( p_input != nil );
-
-    vlc_value_t time;
-    char psz_time[MSTRTIME_MAX_SIZE];
-
-    var_Get( p_input, "time", &time );
-
-    mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
-    if( [o_time_fld timeRemaining] && dur > 0 )
-    {
-        mtime_t remaining = 0;
-        if( dur > time.i_time )
-            remaining = dur - time.i_time;
-        return [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ( remaining / 1000000 ) )];
-    }
-    else
-        return [NSString stringWithUTF8String: secstotimestr( psz_time, ( time.i_time / 1000000 ) )];
-}
-
 - (void)updateTimeSlider
 {
     input_thread_t * p_input;
@@ -1551,7 +1528,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
         f_updated = 10000. * pos.f_float;
         [o_time_sld setFloatValue: f_updated];
 
-        o_time = [self getCurrentTimeAsString: p_input];
+        o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[o_time_fld timeRemaining]];
 
         mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
         if (dur == -1) {
diff --git a/modules/gui/macosx/StringUtility.h b/modules/gui/macosx/StringUtility.h
index be6ef4f..57db73c 100644
--- a/modules/gui/macosx/StringUtility.h
+++ b/modules/gui/macosx/StringUtility.h
@@ -40,6 +40,7 @@
 - (char *)delocalizeString:(NSString *)psz;
 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
 - (NSString *)OSXStringKeyToString:(NSString *)theString;
+- (NSString *)getCurrentTimeAsString:(input_thread_t *)p_input negative:(BOOL)b_negative;
 
 - (NSString *)VLCKeyToString:(NSString *)theString;
 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
diff --git a/modules/gui/macosx/StringUtility.m b/modules/gui/macosx/StringUtility.m
index 71d978c..134b90e 100644
--- a/modules/gui/macosx/StringUtility.m
+++ b/modules/gui/macosx/StringUtility.m
@@ -24,9 +24,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#import <vlc_input.h>
+#import <vlc_keys.h>
 #import "StringUtility.h"
 #import "intf.h"
-#import <vlc_keys.h>
 
 @implementation VLCStringUtility
 
@@ -183,6 +184,27 @@ static VLCStringUtility *_o_sharedInstance = nil;
     return theString;
 }
 
+- (NSString *)getCurrentTimeAsString:(input_thread_t *)p_input negative:(BOOL)b_negative
+{
+    assert( p_input != nil );
+    
+    vlc_value_t time;
+    char psz_time[MSTRTIME_MAX_SIZE];
+    
+    var_Get( p_input, "time", &time );
+    
+    mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
+    if( b_negative && dur > 0 )
+    {
+        mtime_t remaining = 0;
+        if( dur > time.i_time )
+            remaining = dur - time.i_time;
+        return [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ( remaining / 1000000 ) )];
+    }
+    else
+        return [NSString stringWithUTF8String: secstotimestr( psz_time, ( time.i_time / 1000000 ) )];
+}
+
 #pragma mark -
 #pragma mark Key Shortcuts
 



More information about the vlc-commits mailing list