aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Yakushev <yakushev.alex@gmail.com>2010-11-04 18:47:48 +0200
committerAlexander Yakushev <yakushev.alex@gmail.com>2010-11-04 18:47:48 +0200
commitda3707e4c53331e1618a911a88a65ff467ef8594 (patch)
treed7f2240e6f47b64cc21cab273a43609854f1d56d
parenta62b2d4fddeca886cb5d059ab5f68bf867349bb4 (diff)
downloadawesompd-da3707e4c53331e1618a911a88a65ff467ef8594.tar.gz
awesompd-da3707e4c53331e1618a911a88a65ff467ef8594.tar.bz2
Reworked current playlist
Now it displays at maximum 15 tracks before and 15 tracks after the current track.
-rw-r--r--awesompd.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/awesompd.lua b/awesompd.lua
index 7d49bc0..ac864a9 100644
--- a/awesompd.lua
+++ b/awesompd.lua
@@ -293,12 +293,15 @@ function awesompd:get_list_menu()
if self.recreate_list then
local new_menu = {}
if self.list_array then
- for i = 1, table.getn(self.list_array) do
- new_menu[i] = { awesompd.protect_string(self.list_array[i]),
- self:command_play_specific(i),
- self.current_number == i and
- (self.status == "Playing" and self.ICONS.PLAY or self.ICONS.PAUSE)
- or nil}
+ local total_count = table.getn(self.list_array)
+ local start_num = (self.current_number - 15 > 0) and self.current_number - 15 or 1
+ local end_num = (self.current_number + 15 < total_count ) and self.current_number + 15 or total_count
+ for i = start_num, end_num do
+ table.insert(new_menu, { awesompd.protect_string(self.list_array[i]),
+ self:command_play_specific(i),
+ self.current_number == i and
+ (self.status == "Playing" and self.ICONS.PLAY or self.ICONS.PAUSE)
+ or nil} )
end
end
self.recreate_list = false
@@ -306,7 +309,7 @@ function awesompd:get_list_menu()
end
return self.list_menu
end
-
+
-- Returns the playlists menu. Menu consists of all files in the playlist folder.
function awesompd:get_playlists_menu()
if self.recreate_playlists then