[vlc-devel] [PATCH 20/22] lua: use vlc_actions_do

Rémi Denis-Courmont remi at remlab.net
Thu Aug 3 16:44:23 CEST 2017


Le 3 août 2017 16:10:53 GMT+03:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>From: Thomas Guillem <thomas at gllm.fr>
>
>---
> modules/lua/libs/misc.c      | 9 +++++++++
> share/lua/README.txt         | 1 +
> share/lua/modules/common.lua | 7 +++++--
> 3 files changed, 15 insertions(+), 2 deletions(-)
>
>diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c
>index a0472e82a2..36ca4137d7 100644
>--- a/modules/lua/libs/misc.c
>+++ b/modules/lua/libs/misc.c
>@@ -154,6 +154,14 @@ static int vlclua_action_id( lua_State *L )
>     return 1;
> }
> 
>+static int vlclua_action_do( lua_State *L )
>+{
>+    vlc_object_t *p_this = vlclua_get_this( L );
>+    int i_ret = vlc_actions_do( p_this, luaL_checkint( L, 1 ),
>+                                luaL_checkboolean( L, 2 ) );
>+    return vlclua_push_ret( L, i_ret );
>+}
>+
>/*****************************************************************************
>  *
>*****************************************************************************/
>@@ -163,6 +171,7 @@ static const luaL_Reg vlclua_misc_reg[] = {
>     { "license", vlclua_license },
> 
>     { "action_id", vlclua_action_id },
>+    { "action_do", vlclua_action_do },
> 
>     { "mdate", vlclua_mdate },
>     { "mwait", vlclua_mwait },
>diff --git a/share/lua/README.txt b/share/lua/README.txt
>index eb782ee030..2c2fabf0d1 100644
>--- a/share/lua/README.txt
>+++ b/share/lua/README.txt
>@@ -151,6 +151,7 @@ misc.copyright(): Get the VLC copyright statement.
> misc.license(): Get the VLC license.
> 
> misc.action_id( name ): get the id of the given action.
>+misc.action_do( id, notify ): execute the action identified by the id
> 
> misc.mdate(): Get the current date (in microseconds).
> misc.mwait(): Wait for the given date (in microseconds).
>diff --git a/share/lua/modules/common.lua
>b/share/lua/modules/common.lua
>index 8c49c713e5..4c13eeae34 100644
>--- a/share/lua/modules/common.lua
>+++ b/share/lua/modules/common.lua
>@@ -25,8 +25,11 @@ end
> function hotkey(arg)
>     local id = vlc.misc.action_id( arg )
>     if id ~= nil then
>-        vlc.var.set( vlc.object.libvlc(), "key-action", id )
>-        return true
>+        if vlc.misc.action_do( id, true ) == 0 then
>+            return true
>+        else
>+            return false
>+        end
>     else
>         return false
>     end
>-- 
>2.11.0
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

Broken by design API. The script has no way to express the context of the action.
-- 
Rémi Denis-Courmont
Typed on an inconvenient virtual keyboard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170803/8cc3cf61/attachment-0001.html>


More information about the vlc-devel mailing list