diff options
author | Albert Bloomfield <abloomfield@gmail.com> | 2012-02-16 08:20:41 -0500 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-02-17 12:02:22 +0100 |
commit | 885ecf832703ecc28eeb2476451fea2e8e3fa43e (patch) | |
tree | 044595d7c6977afea3f31955321734d070320de1 /apps | |
parent | 39eec730b055a21d284c73095cbc42c4e4f56787 (diff) | |
download | rockbox-885ecf832703ecc28eeb2476451fea2e8e3fa43e.tar.gz rockbox-885ecf832703ecc28eeb2476451fea2e8e3fa43e.zip |
Add playlist wrappers for lua
adds wrappers for the functions playlist_sync, playlist_remove_all_tracks, and playlist_insert_track, playlist_insert_directory
playlist_{sync,remove_all_tracks} take no arguments
playlist_insert_{track,directory} only have one required argument (either the filename or directory name)
They take as optional arguments position, queue, and either sync or recurse
They all just pass NULL to work with the current playlist
also adds constants for:
PLAYLIST_PREPEND,
PLAYLIST_INSERT,
PLAYLIST_INSERT_LAST,
PLAYLIST_INSERT_FIRST,
PLAYLIST_INSERT_SHUFFLED,
PLAYLIST_REPLACE, and
PLAYLIST_INSERT_LAST_SHUFFLED
Change-Id: Ib7464cba50e7a250edf092e50668f11010f2b737
Reviewed-on: http://gerrit.rockbox.org/109
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 6a6be388d1..5aadfd2210 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -593,6 +593,59 @@ RB_WRAP(do_menu) | |||
593 | return 1; | 593 | return 1; |
594 | } | 594 | } |
595 | 595 | ||
596 | RB_WRAP(playlist_sync) | ||
597 | { | ||
598 | /* just pass NULL to work with the current playlist */ | ||
599 | rb->playlist_sync(NULL); | ||
600 | return 1; | ||
601 | } | ||
602 | |||
603 | RB_WRAP(playlist_remove_all_tracks) | ||
604 | { | ||
605 | /* just pass NULL to work with the current playlist */ | ||
606 | int result = rb->playlist_remove_all_tracks(NULL); | ||
607 | lua_pushinteger(L, result); | ||
608 | return 1; | ||
609 | } | ||
610 | |||
611 | RB_WRAP(playlist_insert_track) | ||
612 | { | ||
613 | const char *filename; | ||
614 | int position, queue, sync; | ||
615 | |||
616 | /* for now don't take a playlist_info pointer, but just pass NULL to use | ||
617 | the current playlist. If this changes later, all the other | ||
618 | parameters can be shifted back. */ | ||
619 | filename = luaL_checkstring(L, 1); /* only required parameter */ | ||
620 | position = luaL_optint(L, 2, PLAYLIST_INSERT); | ||
621 | queue = lua_toboolean(L, 3); /* default to false */ | ||
622 | sync = lua_toboolean(L, 4); /* default to false */ | ||
623 | |||
624 | int result = rb->playlist_insert_track(NULL, filename, position, | ||
625 | queue, sync); | ||
626 | |||
627 | lua_pushinteger(L, result); | ||
628 | return 1; | ||
629 | } | ||
630 | |||
631 | RB_WRAP(playlist_insert_directory) | ||
632 | { | ||
633 | const char* dirname; | ||
634 | int position, queue, recurse; | ||
635 | |||
636 | /* just like in playlist_insert_track, only works with current playlist. */ | ||
637 | dirname = luaL_checkstring(L, 1); /* only required parameter */ | ||
638 | position = luaL_optint(L, 2, PLAYLIST_INSERT); | ||
639 | queue = lua_toboolean(L, 3); /* default to false */ | ||
640 | recurse = lua_toboolean(L, 4); /* default to false */ | ||
641 | |||
642 | int result = rb->playlist_insert_directory(NULL, dirname, position, | ||
643 | queue, recurse); | ||
644 | |||
645 | lua_pushinteger(L, result); | ||
646 | return 1; | ||
647 | } | ||
648 | |||
596 | SIMPLE_VOID_WRAPPER(backlight_force_on); | 649 | SIMPLE_VOID_WRAPPER(backlight_force_on); |
597 | SIMPLE_VOID_WRAPPER(backlight_use_settings); | 650 | SIMPLE_VOID_WRAPPER(backlight_use_settings); |
598 | #ifdef HAVE_REMOTE_LCD | 651 | #ifdef HAVE_REMOTE_LCD |
@@ -672,6 +725,10 @@ static const luaL_Reg rocklib[] = | |||
672 | R(clear_viewport), | 725 | R(clear_viewport), |
673 | R(current_path), | 726 | R(current_path), |
674 | R(gui_syncyesno_run), | 727 | R(gui_syncyesno_run), |
728 | R(playlist_sync), | ||
729 | R(playlist_remove_all_tracks), | ||
730 | R(playlist_insert_track), | ||
731 | R(playlist_insert_directory), | ||
675 | R(do_menu), | 732 | R(do_menu), |
676 | 733 | ||
677 | /* Backlight helper */ | 734 | /* Backlight helper */ |
@@ -718,6 +775,14 @@ LUALIB_API int luaopen_rock(lua_State *L) | |||
718 | RB_CONSTANT(FONT_SYSFIXED); | 775 | RB_CONSTANT(FONT_SYSFIXED); |
719 | RB_CONSTANT(FONT_UI); | 776 | RB_CONSTANT(FONT_UI); |
720 | 777 | ||
778 | RB_CONSTANT(PLAYLIST_PREPEND); | ||
779 | RB_CONSTANT(PLAYLIST_INSERT); | ||
780 | RB_CONSTANT(PLAYLIST_INSERT_LAST); | ||
781 | RB_CONSTANT(PLAYLIST_INSERT_FIRST); | ||
782 | RB_CONSTANT(PLAYLIST_INSERT_SHUFFLED); | ||
783 | RB_CONSTANT(PLAYLIST_REPLACE); | ||
784 | RB_CONSTANT(PLAYLIST_INSERT_LAST_SHUFFLED); | ||
785 | |||
721 | #ifdef HAVE_TOUCHSCREEN | 786 | #ifdef HAVE_TOUCHSCREEN |
722 | RB_CONSTANT(TOUCHSCREEN_POINT); | 787 | RB_CONSTANT(TOUCHSCREEN_POINT); |
723 | RB_CONSTANT(TOUCHSCREEN_BUTTON); | 788 | RB_CONSTANT(TOUCHSCREEN_BUTTON); |