]> gitweb.fluxo.info Git - awesompd.git/commitdiff
Reworked current playlist
authorAlexander Yakushev <yakushev.alex@gmail.com>
Thu, 4 Nov 2010 16:47:48 +0000 (18:47 +0200)
committerAlexander Yakushev <yakushev.alex@gmail.com>
Thu, 4 Nov 2010 16:47:48 +0000 (18:47 +0200)
Now it displays at maximum 15 tracks before and 15 tracks after the current track.

awesompd.lua

index 7d49bc0c60495afd70c09f42481b3e41c3de01b2..ac864a9ddd330c34567699e0e95a5242a24df556 100644 (file)
@@ -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