FileManager: show files with sidecar dir in bold (#2391)

docsettings : added hasSidecarDir() and made getSidecarDir() more robust
widget/menu : allow items to specify themselves to be displayed in bold
pull/2409/head
poire-z 8 years ago committed by Qingping Hou
parent efd6c7f556
commit 0aa19d72a0

@ -17,7 +17,21 @@ end
-- Sidecar directory is the file without _last_ suffix.
function DocSettings:getSidecarDir(doc_path)
return doc_path:match("(.*)%.")..".sdr"
local file_without_suffix = doc_path:match("(.*)%.")
if file_without_suffix then
return file_without_suffix..".sdr"
end
-- We shouldn't be called with anything but files with registered
-- extensions, but in case we are, return something useful
return doc_path..".sdr"
end
function DocSettings:hasSidecarDir(doc_path)
-- We may be called with items from FileManager, which may not be a document
if lfs.attributes(doc_path, "mode") == "directory" then
return false
end
return lfs.attributes(self:getSidecarDir(doc_path), "mode") == "directory"
end
function DocSettings:getHistoryPath(fullpath)

@ -3,6 +3,7 @@ local UIManager = require("ui/uimanager")
local Menu = require("ui/widget/menu")
local Screen = require("device").screen
local Device = require("device")
local DocSettings = require("docsettings")
local util = require("ffi/util")
local _ = require("gettext")
local ffi = require("ffi")
@ -128,9 +129,15 @@ function FileChooser:genItemTableFromPath(path)
else
sstr = string.format("%d B", file_size)
end
-- show files with a .sdr in bold
local bold = nil
if DocSettings:hasSidecarDir(full_path) then
bold = true
end
table.insert(item_table, {
text = file.name,
mandatory = sstr,
bold = bold,
path = full_path
})
end

@ -648,7 +648,7 @@ function Menu:updateItems(select_number)
state_size = self.state_size or {},
text = self.item_table[i].text,
mandatory = self.item_table[i].mandatory,
bold = self.item_table.current == i,
bold = self.item_table.current == i or self.item_table[i].bold == true,
face = self.cface,
dimen = self.item_dimen:new(),
shortcut = item_shortcut,

Loading…
Cancel
Save