aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Yakushev <yakushev.alex@gmail.com>2011-09-10 15:54:54 +0300
committerAlexander Yakushev <yakushev.alex@gmail.com>2011-09-10 15:54:54 +0300
commit85b51b55c75844f8712b7f00cabe3039b213430f (patch)
tree445eef471f287ffb99fc36c095536170c06f85aa
parent3132ea635414d25a5fb3e90be6cd71f920535849 (diff)
downloadawesompd-85b51b55c75844f8712b7f00cabe3039b213430f.tar.gz
awesompd-85b51b55c75844f8712b7f00cabe3039b213430f.tar.bz2
Added "Clear playlist" item to the playback menu
-rw-r--r--awesompd.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/awesompd.lua b/awesompd.lua
index cf47a2b..10b5442 100644
--- a/awesompd.lua
+++ b/awesompd.lua
@@ -1,7 +1,7 @@
---------------------------------------------------------------------------
-- @author Alexander Yakushev <yakushev.alex@gmail.com>
-- @copyright 2010-2011 Alexander Yakushev
--- @release v1.0.4
+-- @release v1.0.5
---------------------------------------------------------------------------
require('utf8')
@@ -281,6 +281,14 @@ function awesompd:command_replace_playlist(name)
end
end
+function awesompd:command_clear_playlist()
+ return function()
+ self:command("clear", self.update_track)
+ self.recreate_list = true
+ end
+end
+
+
-- /// End of mpc command functions ///
-- /// Menu generation functions ///
@@ -345,7 +353,7 @@ function awesompd:menu_playback()
self:command_toggle(),
self.ICONS.PLAY_PAUSE })
if self.connected and self.status ~= "Stopped" then
- if self.list_array[self.current_number-1] then
+ if self.list_array and self.list_array[self.current_number-1] then
table.insert(new_menu,
{ "Prev: " ..
awesompd.protect_string(jamendo.replace_link(
@@ -353,7 +361,7 @@ function awesompd:menu_playback()
true),
self:command_prev_track(), self.ICONS.PREV })
end
- if self.current_number ~= table.getn(self.list_array) then
+ if self.list_array and self.current_number ~= table.getn(self.list_array) then
table.insert(new_menu,
{ "Next: " ..
awesompd.protect_string(jamendo.replace_link(
@@ -362,6 +370,8 @@ function awesompd:menu_playback()
self:command_next_track(), self.ICONS.NEXT })
end
table.insert(new_menu, { "Stop", self:command_stop(), self.ICONS.STOP })
+ table.insert(new_menu, { "", nil })
+ table.insert(new_menu, { "Clear playlist", self:command_clear_playlist() })
end
self.recreate_playback = false
playback_menu = new_menu