summaryrefslogtreecommitdiff
path: root/lua/file_browser.lua
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2025-02-24 00:46:49 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2025-02-24 00:46:49 +0000
commit7c13df34578ca95f28a209f427f91d3b498b456a (patch)
tree4ae178ec3464427ee06ac89c0414b360b44b5318 /lua/file_browser.lua
parentb97c7974ea0bd9d4b0add639c699a07750a76a27 (diff)
parent476a515cd123409d44afffdb725dd5c69b91cb70 (diff)
downloadtangara-fw-7c13df34578ca95f28a209f427f91d3b498b456a.tar.gz
Merge pull request 'Add icons to the file browser' (#277) from slord/tangara-fw:file-browser-icons into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/277
Diffstat (limited to 'lua/file_browser.lua')
-rw-r--r--lua/file_browser.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/lua/file_browser.lua b/lua/file_browser.lua
index 6289828f..944a692e 100644
--- a/lua/file_browser.lua
+++ b/lua/file_browser.lua
@@ -13,6 +13,8 @@ local theme = require("theme")
local screen = require("screen")
local filesystem = require("filesystem")
local playlist_iterator = require("playlist_iterator")
+local img = require("images")
+
return screen:new {
create_ui = function(self)
@@ -58,8 +60,21 @@ return screen:new {
}
end
+ local get_icon_func = function(item)
+ if item:is_directory() then
+ return img.file_directory
+ elseif playlist_iterator:is_playlist(item) then
+ return img.file_playlist
+ elseif playback.is_playable(item:filepath()) then
+ return img.file_music
+ else
+ return img.unknown
+ end
+ end
+
widgets.InfiniteList(self.root, self.iterator, {
focus_first_item = true,
+ get_icon = get_icon_func,
callback = function(item)
return function()
local is_dir = item:is_directory()