[vlc-commits] macosx: replace all 'key-action' calls with their proper counter-parts
Felix Paul Kühne
git at videolan.org
Thu Feb 7 19:15:55 CET 2013
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Feb 7 19:15:15 2013 +0100| [9929cc94ce61b48c666dcf1aa2b65c1e7de763c9] | committer: Felix Paul Kühne
macosx: replace all 'key-action' calls with their proper counter-parts
This excludes 'ACTIONID_POSITION' for which there doesn't seem to be a replacement.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9929cc94ce61b48c666dcf1aa2b65c1e7de763c9
---
modules/gui/macosx/CoreInteraction.m | 57 +++++++++++++++++++++++-----------
modules/gui/macosx/controls.m | 2 +-
modules/gui/macosx/intf.m | 6 ++--
modules/gui/macosx/misc.m | 32 +++++++++++--------
4 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index 5145205..e310ff6 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -1,7 +1,7 @@
/*****************************************************************************
* CoreInteraction.m: MacOS X interface module
*****************************************************************************
- * Copyright (C) 2011-2012 Felix Paul Kühne
+ * Copyright (C) 2011-2013 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
@@ -35,6 +35,10 @@
#import <vlc_strings.h>
#import <vlc_url.h>
+ at interface VLCMainWindow (Internal)
+- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value;
+ at end
+
@implementation VLCCoreInteraction
static VLCCoreInteraction *_o_sharedInstance = nil;
@@ -78,11 +82,12 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
{
input_thread_t * p_input;
p_input = pl_CurrentInput(VLCIntf);
+ playlist_t * p_playlist = pl_Get(VLCIntf);
+
if (p_input) {
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE);
+ playlist_Play(p_playlist);
vlc_object_release(p_input);
} else {
- playlist_t * p_playlist = pl_Get(VLCIntf);
bool empty;
PL_LOCK;
@@ -98,27 +103,27 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)pause
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_PAUSE);
+ playlist_Pause(pl_Get(VLCIntf));
}
- (void)stop
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_STOP);
+ playlist_Stop(pl_Get(VLCIntf));
}
- (void)faster
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_FASTER);
+ var_TriggerCallback(pl_Get(VLCIntf), "rate-faster");
}
- (void)slower
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_SLOWER);
+ var_TriggerCallback(pl_Get(VLCIntf), "rate-slower");
}
- (void)normalSpeed
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_RATE_NORMAL);
+ var_SetFloat(pl_Get(VLCIntf), "rate", 1.);
}
- (void)toggleRecord
@@ -180,12 +185,12 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)previous
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_PREV);
+ playlist_Prev(pl_Get(VLCIntf));
}
- (void)next
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_NEXT);
+ playlist_Next(pl_Get(VLCIntf));
}
- (int)durationOfCurrentPlaylistItem
@@ -288,44 +293,60 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
[self backwardShort];
}
+- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value
+{
+ input_thread_t *p_input = pl_CurrentInput(VLCIntf);
+ if (!p_input)
+ return;
+
+ int i_interval = var_InheritInteger( p_input, p_value );
+ if (i_interval > 0) {
+ mtime_t val = CLOCK_FREQ * i_interval;
+ if (!b_value)
+ val = val * -1;
+ var_SetTime( p_input, "time-offset", val );
+ }
+ vlc_object_release(p_input);
+}
+
- (void)forwardExtraShort
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_EXTRASHORT);
+ [self jumpWithValue:"extrashort-jump-size" forward:YES];
}
- (void)backwardExtraShort
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_EXTRASHORT);
+ [self jumpWithValue:"extrashort-jump-size" forward:NO];
}
- (void)forwardShort
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT);
+ [self jumpWithValue:"short-jump-size" forward:YES];
}
- (void)backwardShort
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT);
+ [self jumpWithValue:"short-jump-size" forward:NO];
}
- (void)forwardMedium
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_MEDIUM);
+ [self jumpWithValue:"medium-jump-size" forward:YES];
}
- (void)backwardMedium
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_MEDIUM);
+ [self jumpWithValue:"medium-jump-size" forward:NO];
}
- (void)forwardLong
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_LONG);
+ [self jumpWithValue:"long-jump-size" forward:YES];
}
- (void)backwardLong
{
- var_SetInteger(VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_LONG);
+ [self jumpWithValue:"long-jump-size" forward:NO];
}
- (void)shuffle
diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m
index c39067e..cc7195b 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -1,7 +1,7 @@
/*****************************************************************************
* controls.m: MacOS X interface module
*****************************************************************************
- * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * Copyright (C) 2002-2013 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl at nanocrew.net>
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index ea12ce1..4607a16 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1053,12 +1053,10 @@ static VLCMain *_o_sharedMainInstance = nil;
[[VLCCoreInteraction sharedInstance] backward];
break;
case kRemoteButtonVolume_Plus_Hold:
- if (p_intf)
- var_SetInteger(p_intf->p_libvlc, "key-action", ACTIONID_VOL_UP);
+ [[VLCCoreInteraction sharedInstance] volumeUp];
break;
case kRemoteButtonVolume_Minus_Hold:
- if (p_intf)
- var_SetInteger(p_intf->p_libvlc, "key-action", ACTIONID_VOL_DOWN);
+ [[VLCCoreInteraction sharedInstance] volumeDown];
break;
}
if (b_remote_button_hold) {
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index ab6cbb5..01c8e5e 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -1,7 +1,7 @@
/*****************************************************************************
* misc.m: code not specific to vlc
*****************************************************************************
- * Copyright (C) 2003-2012 VLC authors and VideoLAN
+ * Copyright (C) 2003-2013 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl at nanocrew.net>
@@ -397,6 +397,7 @@ void _drawFrameInRect(NSRect frameRect)
- (void)scrollWheel:(NSEvent *)o_event
{
intf_thread_t * p_intf = VLCIntf;
+ BOOL b_forward = NO;
CGFloat f_deltaY = [o_event deltaY];
CGFloat f_deltaX = [o_event deltaX];
@@ -410,17 +411,19 @@ void _drawFrameInRect(NSRect frameRect)
CGFloat f_abs;
int i_vlckey;
- if (f_delta > 0.0f) {
- i_vlckey = ACTIONID_JUMP_BACKWARD_EXTRASHORT;
+ if (f_delta > 0.0f)
f_abs = f_delta;
- }
else {
- i_vlckey = ACTIONID_JUMP_FORWARD_EXTRASHORT;
+ b_forward = YES;
f_abs = -f_delta;
}
- for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++)
- var_SetInteger( p_intf->p_libvlc, "key-action", i_vlckey );
+ for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) {
+ if (b_forward)
+ [[VLCCoreInteraction sharedInstance] forwardExtraShort];
+ else
+ [[VLCCoreInteraction sharedInstance] backwardExtraShort];
+ }
}
- (BOOL)acceptsFirstResponder
@@ -500,6 +503,7 @@ void _drawFrameInRect(NSRect frameRect)
- (void)scrollWheel:(NSEvent *)o_event
{
intf_thread_t * p_intf = VLCIntf;
+ BOOL b_up = NO;
CGFloat f_deltaY = [o_event deltaY];
CGFloat f_deltaX = [o_event deltaX];
@@ -513,17 +517,19 @@ void _drawFrameInRect(NSRect frameRect)
CGFloat f_abs;
int i_vlckey;
- if (f_delta > 0.0f) {
- i_vlckey = ACTIONID_VOL_DOWN;
+ if (f_delta > 0.0f)
f_abs = f_delta;
- }
else {
- i_vlckey = ACTIONID_VOL_UP;
+ b_up = YES;
f_abs = -f_delta;
}
- for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++)
- var_SetInteger(p_intf->p_libvlc, "key-action", i_vlckey);
+ for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++) {
+ if (b_up)
+ [[VLCCoreInteraction sharedInstance] volumeUp];
+ else
+ [[VLCCoreInteraction sharedInstance] volumeDown];
+ }
}
@end
More information about the vlc-commits
mailing list