Commit 0d86a46b authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx/MainWindow: move getCurrentTimeAsString to StringUtility

parent f90f3bc8
......@@ -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) {
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment