[vlc-commits] macosx: store counting mode of the time field (default is to count up)

Felix Paul Kühne git at videolan.org
Wed Jul 27 11:43:39 CEST 2011


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Wed Jul 27 11:43:30 2011 +0200| [58a23fb880f43cc05994e32d7b029b78827ca3b4] | committer: Felix Paul Kühne

macosx: store counting mode of the time field (default is to count up)

Fixes #3078

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

 modules/gui/macosx/MainWindow.h |    2 --
 modules/gui/macosx/MainWindow.m |   12 ++++--------
 modules/gui/macosx/misc.h       |    1 +
 modules/gui/macosx/misc.m       |   19 ++++++++++++++++++-
 4 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h
index 7295c08..6545081 100644
--- a/modules/gui/macosx/MainWindow.h
+++ b/modules/gui/macosx/MainWindow.h
@@ -59,7 +59,6 @@
 
     BOOL b_dark_interface;
     BOOL b_video_playback_enabled;
-    BOOL b_time_remaining;
     int i_lastShownVolume;
     BOOL b_mute;
     input_state_e cachedInputState;
@@ -94,7 +93,6 @@
 - (IBAction)repeat:(id)sender;
 - (IBAction)shuffle:(id)sender;
 - (IBAction)timeSliderAction:(id)sender;
-- (IBAction)timeFieldWasClicked:(id)sender;
 - (IBAction)volumeAction:(id)sender;
 - (IBAction)effects:(id)sender;
 - (IBAction)fullscreen:(id)sender;
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 92f38fc..dca06f7 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -29,6 +29,7 @@
 #import "CoreInteraction.h"
 #import "AudioEffects.h"
 #import "MainMenu.h"
+#import "misc.h"
 #import "controls.h" // TODO: remove me
 #import <vlc_playlist.h>
 #import <vlc_aout_intf.h>
@@ -415,7 +416,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
         var_Get( p_input, "time", &time );
 
         mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
-        if( b_time_remaining && dur != -1 )
+        if( [o_time_fld timeRemaining] && dur != -1 )
         {
             o_time = [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ((dur - time.i_time) / 1000000) )];
         }
@@ -429,12 +430,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [self drawFancyGradientEffectForTimeSlider];
 }
 
-- (IBAction)timeFieldWasClicked:(id)sender
-{
-    b_time_remaining = !b_time_remaining;
-    NSLog( @"b_time_remaining %i", b_time_remaining );
-}
-
 - (IBAction)volumeAction:(id)sender
 {
     if (sender == o_volume_sld)
@@ -477,7 +472,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
         var_Get( p_input, "time", &time );
 
         mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
-        if( b_time_remaining && dur != -1 )
+        if( [o_time_fld timeRemaining] && dur != -1 )
         {
             o_time = [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ((dur - time.i_time) / 1000000))];
         }
@@ -485,6 +480,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
             o_time = [NSString stringWithUTF8String: secstotimestr( psz_time, (time.i_time / 1000000) )];
 
         [o_time_fld setStringValue: o_time];
+        [o_time_fld setNeedsDisplay:YES];
 //        [[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time];
     }
     else
diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h
index a6defe5..b391840 100644
--- a/modules/gui/macosx/misc.h
+++ b/modules/gui/macosx/misc.h
@@ -146,4 +146,5 @@
 @interface VLCTimeField : NSTextField
 {
 }
+- (BOOL)timeRemaining;
 @end
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index 38caa1e..1df47a2 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -658,11 +658,28 @@ void _drawFrameInRect(NSRect frameRect)
  *****************************************************************************/
 
 @implementation VLCTimeField
++ (void)initialize{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+    NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"];
+
+    [defaults registerDefaults:appDefaults];
+}
+
 - (void)mouseDown: (NSEvent *)ourEvent
 {
     if( [ourEvent clickCount] > 1 )
         [[[VLCMain sharedInstance] controls] goToSpecificTime: nil];
     else
-        [[VLCMainWindow sharedInstance] timeFieldWasClicked: self];
+    {
+        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"])
+            [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"DisplayTimeAsTimeRemaining"];
+        else
+            [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"DisplayTimeAsTimeRemaining"];
+    }
+}
+
+- (BOOL)timeRemaining
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:@"DisplayTimeAsTimeRemaining"];
 }
 @end



More information about the vlc-commits mailing list