2017-07-01 10:11:44 +00:00
|
|
|
--[[--
|
|
|
|
This module contains miscellaneous helper functions for FileManager
|
|
|
|
]]
|
|
|
|
|
2023-02-07 02:46:09 +00:00
|
|
|
local BD = require("ui/bidi")
|
2017-07-01 10:11:44 +00:00
|
|
|
local Device = require("device")
|
2017-09-22 16:24:38 +00:00
|
|
|
local DocSettings = require("docsettings")
|
2023-10-03 06:24:29 +00:00
|
|
|
local Event = require("ui/event")
|
2023-02-07 02:46:09 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2023-02-17 21:06:55 +00:00
|
|
|
local ffiutil = require("ffi/util")
|
2023-11-05 05:24:18 +00:00
|
|
|
local lfs = require("libs/libkoreader-lfs")
|
2023-02-17 21:06:55 +00:00
|
|
|
local util = require("util")
|
2019-10-21 12:24:29 +00:00
|
|
|
local _ = require("gettext")
|
2023-02-17 21:06:55 +00:00
|
|
|
local T = ffiutil.template
|
2017-07-01 10:11:44 +00:00
|
|
|
|
|
|
|
local filemanagerutil = {}
|
|
|
|
|
|
|
|
function filemanagerutil.getDefaultDir()
|
2020-06-19 07:41:50 +00:00
|
|
|
return Device.home_dir or "."
|
2017-07-01 10:11:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function filemanagerutil.abbreviate(path)
|
2018-07-28 18:44:55 +00:00
|
|
|
if not path then return "" end
|
2019-10-21 12:24:29 +00:00
|
|
|
if G_reader_settings:nilOrTrue("shorten_home_dir") then
|
2017-07-01 10:11:44 +00:00
|
|
|
local home_dir = G_reader_settings:readSetting("home_dir") or filemanagerutil.getDefaultDir()
|
2022-11-14 01:20:26 +00:00
|
|
|
if path == home_dir or path == home_dir .. "/" then
|
2019-10-21 12:24:29 +00:00
|
|
|
return _("Home")
|
|
|
|
end
|
2017-07-01 10:11:44 +00:00
|
|
|
local len = home_dir:len()
|
|
|
|
local start = path:sub(1, len)
|
2019-11-19 20:06:03 +00:00
|
|
|
if start == home_dir and path:sub(len+1, len+1) == "/" then
|
2019-10-21 12:24:29 +00:00
|
|
|
return path:sub(len+2)
|
2017-07-01 10:11:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return path
|
|
|
|
end
|
|
|
|
|
2023-08-30 04:53:59 +00:00
|
|
|
function filemanagerutil.splitFileNameType(filepath)
|
|
|
|
local _, filename = util.splitFilePathName(filepath)
|
2023-03-31 09:59:11 +00:00
|
|
|
local filename_without_suffix, filetype = util.splitFileNameSuffix(filename)
|
|
|
|
filetype = filetype:lower()
|
|
|
|
if filetype == "zip" then
|
|
|
|
local filename_without_sub_suffix, sub_filetype = util.splitFileNameSuffix(filename_without_suffix)
|
|
|
|
sub_filetype = sub_filetype:lower()
|
|
|
|
local supported_sub_filetypes = { "fb2", "htm", "html", "log", "md", "rtf", "txt", }
|
2023-05-03 12:43:05 +00:00
|
|
|
if util.arrayContains(supported_sub_filetypes, sub_filetype) then
|
|
|
|
return filename_without_sub_suffix, sub_filetype .. ".zip"
|
2023-03-31 09:59:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return filename_without_suffix, filetype
|
|
|
|
end
|
|
|
|
|
2023-11-05 05:24:18 +00:00
|
|
|
function filemanagerutil.getRandomFile(dir, match_func)
|
|
|
|
if not dir:match("/$") then
|
|
|
|
dir = dir .. "/"
|
|
|
|
end
|
|
|
|
local files = {}
|
|
|
|
local ok, iter, dir_obj = pcall(lfs.dir, dir)
|
|
|
|
if ok then
|
|
|
|
for entry in iter, dir_obj do
|
|
|
|
local file = dir .. entry
|
|
|
|
if lfs.attributes(file, "mode") == "file" and match_func(file) then
|
|
|
|
table.insert(files, entry)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #files > 0 then
|
|
|
|
math.randomseed(os.time())
|
|
|
|
return dir .. files[math.random(#files)]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-07 18:29:53 +00:00
|
|
|
-- Purge doc settings except kept
|
|
|
|
function filemanagerutil.resetDocumentSettings(file)
|
|
|
|
local settings_to_keep = {
|
2024-05-03 06:08:57 +00:00
|
|
|
annotations = true,
|
|
|
|
annotations_paging = true,
|
|
|
|
annotations_rolling = true,
|
2021-11-07 18:29:53 +00:00
|
|
|
bookmarks = true,
|
2024-05-03 06:08:57 +00:00
|
|
|
bookmarks_paging = true,
|
|
|
|
bookmarks_rolling = true,
|
2022-02-10 10:08:51 +00:00
|
|
|
bookmarks_sorted_20220106 = true,
|
2021-11-07 18:29:53 +00:00
|
|
|
bookmarks_version = true,
|
|
|
|
cre_dom_version = true,
|
|
|
|
highlight = true,
|
2024-05-03 06:08:57 +00:00
|
|
|
highlight_paging = true,
|
|
|
|
highlight_rolling = true,
|
2021-11-07 18:29:53 +00:00
|
|
|
highlights_imported = true,
|
|
|
|
last_page = true,
|
|
|
|
last_xpointer = true,
|
|
|
|
}
|
2023-02-17 21:06:55 +00:00
|
|
|
local file_abs_path = ffiutil.realpath(file)
|
2021-11-07 18:29:53 +00:00
|
|
|
if file_abs_path then
|
|
|
|
local doc_settings = DocSettings:open(file_abs_path)
|
|
|
|
for k in pairs(doc_settings.data) do
|
|
|
|
if not settings_to_keep[k] then
|
|
|
|
doc_settings:delSetting(k)
|
|
|
|
end
|
|
|
|
end
|
2022-02-10 10:08:51 +00:00
|
|
|
doc_settings:makeTrue("docsettings_reset_done") -- for readertypeset block_rendering_mode
|
2023-02-07 02:46:09 +00:00
|
|
|
doc_settings:flush()
|
2021-11-07 18:29:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-02-17 21:06:55 +00:00
|
|
|
-- Get a document status ("new", "reading", "complete", or "abandoned")
|
2022-12-24 08:28:02 +00:00
|
|
|
function filemanagerutil.getStatus(file)
|
|
|
|
if DocSettings:hasSidecarFile(file) then
|
2023-02-17 21:06:55 +00:00
|
|
|
local summary = DocSettings:open(file):readSetting("summary")
|
|
|
|
if summary and summary.status and summary.status ~= "" then
|
|
|
|
return summary.status
|
2022-12-24 08:28:02 +00:00
|
|
|
end
|
2023-02-17 21:06:55 +00:00
|
|
|
return "reading"
|
2022-12-24 08:28:02 +00:00
|
|
|
end
|
2023-02-17 21:06:55 +00:00
|
|
|
return "new"
|
2022-12-24 08:28:02 +00:00
|
|
|
end
|
|
|
|
|
2023-02-17 21:06:55 +00:00
|
|
|
-- Set a document status ("reading", "complete", or "abandoned")
|
2024-02-07 08:35:52 +00:00
|
|
|
function filemanagerutil.setStatus(doc_settings_or_file, status)
|
2022-12-24 07:46:46 +00:00
|
|
|
-- In case the book doesn't have a sidecar file, this'll create it
|
2024-02-07 08:35:52 +00:00
|
|
|
local doc_settings
|
|
|
|
if type(doc_settings_or_file) == "table" then
|
|
|
|
doc_settings = doc_settings_or_file
|
|
|
|
else
|
|
|
|
doc_settings = DocSettings:open(doc_settings_or_file)
|
|
|
|
end
|
2023-09-29 04:44:10 +00:00
|
|
|
local summary = doc_settings:readSetting("summary", {})
|
2023-02-17 21:06:55 +00:00
|
|
|
summary.status = status
|
|
|
|
summary.modified = os.date("%Y-%m-%d", os.time())
|
|
|
|
doc_settings:flush()
|
2022-12-24 07:46:46 +00:00
|
|
|
end
|
|
|
|
|
2023-08-26 14:13:59 +00:00
|
|
|
function filemanagerutil.statusToString(status)
|
|
|
|
local status_to_text = {
|
|
|
|
new = _("Unread"),
|
|
|
|
reading = _("Reading"),
|
|
|
|
abandoned = _("On hold"),
|
|
|
|
complete = _("Finished"),
|
|
|
|
}
|
|
|
|
|
|
|
|
return status_to_text[status]
|
|
|
|
end
|
|
|
|
|
2023-02-06 04:42:54 +00:00
|
|
|
-- Generate all book status file dialog buttons in a row
|
2023-09-29 04:44:10 +00:00
|
|
|
function filemanagerutil.genStatusButtonsRow(doc_settings_or_file, caller_callback)
|
2024-01-17 07:58:21 +00:00
|
|
|
local file, summary, status
|
2024-02-07 08:35:52 +00:00
|
|
|
if type(doc_settings_or_file) == "table" then
|
2024-01-17 07:58:21 +00:00
|
|
|
file = doc_settings_or_file:readSetting("doc_path")
|
2024-02-07 08:35:52 +00:00
|
|
|
summary = doc_settings_or_file:readSetting("summary", {})
|
2023-09-29 04:44:10 +00:00
|
|
|
status = summary.status
|
|
|
|
else
|
2024-01-17 07:58:21 +00:00
|
|
|
file = doc_settings_or_file
|
|
|
|
summary = {}
|
|
|
|
status = filemanagerutil.getStatus(file)
|
2023-09-29 04:44:10 +00:00
|
|
|
end
|
2023-02-09 01:22:42 +00:00
|
|
|
local function genStatusButton(to_status)
|
2023-02-07 02:46:09 +00:00
|
|
|
return {
|
2023-08-26 14:13:59 +00:00
|
|
|
text = filemanagerutil.statusToString(to_status) .. (status == to_status and " ✓" or ""),
|
2023-02-09 01:22:42 +00:00
|
|
|
enabled = status ~= to_status,
|
2023-02-07 02:46:09 +00:00
|
|
|
callback = function()
|
2024-01-17 07:58:21 +00:00
|
|
|
summary.status = to_status
|
2024-02-07 08:35:52 +00:00
|
|
|
filemanagerutil.setStatus(doc_settings_or_file, to_status)
|
2024-01-17 07:58:21 +00:00
|
|
|
UIManager:broadcastEvent(Event:new("DocSettingsItemsChanged", file, { summary = summary })) -- for CoverBrowser
|
2023-02-07 02:46:09 +00:00
|
|
|
caller_callback()
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
end
|
2023-02-06 04:42:54 +00:00
|
|
|
return {
|
2023-02-09 03:55:13 +00:00
|
|
|
genStatusButton("reading"),
|
|
|
|
genStatusButton("abandoned"),
|
|
|
|
genStatusButton("complete"),
|
2023-02-07 02:46:09 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-02-17 21:06:55 +00:00
|
|
|
-- Generate "Reset" file dialog button
|
2024-02-07 08:35:52 +00:00
|
|
|
function filemanagerutil.genResetSettingsButton(doc_settings_or_file, caller_callback, button_disabled)
|
|
|
|
local doc_settings, file, has_sidecar_file
|
|
|
|
if type(doc_settings_or_file) == "table" then
|
|
|
|
doc_settings = doc_settings_or_file
|
|
|
|
file = doc_settings_or_file:readSetting("doc_path")
|
|
|
|
has_sidecar_file = true
|
|
|
|
else
|
|
|
|
file = ffiutil.realpath(doc_settings_or_file) or doc_settings_or_file
|
|
|
|
has_sidecar_file = DocSettings:hasSidecarFile(file)
|
|
|
|
end
|
2023-10-31 05:30:39 +00:00
|
|
|
local custom_cover_file = DocSettings:findCustomCoverFile(file)
|
2023-09-05 04:42:46 +00:00
|
|
|
local has_custom_cover_file = custom_cover_file and true or false
|
2023-10-31 05:30:39 +00:00
|
|
|
local custom_metadata_file = DocSettings:findCustomMetadataFile(file)
|
2023-09-05 04:42:46 +00:00
|
|
|
local has_custom_metadata_file = custom_metadata_file and true or false
|
2023-02-07 02:46:09 +00:00
|
|
|
return {
|
|
|
|
text = _("Reset"),
|
2023-09-05 04:42:46 +00:00
|
|
|
enabled = not button_disabled and (has_sidecar_file or has_custom_metadata_file or has_custom_cover_file),
|
2023-02-07 02:46:09 +00:00
|
|
|
callback = function()
|
2023-09-05 04:42:46 +00:00
|
|
|
local CheckButton = require("ui/widget/checkbutton")
|
2023-03-31 09:59:11 +00:00
|
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
2023-09-05 04:42:46 +00:00
|
|
|
local check_button_settings, check_button_cover, check_button_metadata
|
2023-03-31 09:59:11 +00:00
|
|
|
local confirmbox = ConfirmBox:new{
|
2023-02-17 21:06:55 +00:00
|
|
|
text = T(_("Reset this document?") .. "\n\n%1\n\n" ..
|
2023-09-06 06:41:10 +00:00
|
|
|
_("Information will be permanently lost."),
|
2023-02-07 02:46:09 +00:00
|
|
|
BD.filepath(file)),
|
|
|
|
ok_text = _("Reset"),
|
|
|
|
ok_callback = function()
|
2023-09-05 04:42:46 +00:00
|
|
|
local data_to_purge = {
|
|
|
|
doc_settings = check_button_settings.checked,
|
2023-10-31 05:30:39 +00:00
|
|
|
custom_cover_file = check_button_cover.checked and custom_cover_file,
|
|
|
|
custom_metadata_file = check_button_metadata.checked and custom_metadata_file,
|
2023-09-05 04:42:46 +00:00
|
|
|
}
|
2024-02-07 08:35:52 +00:00
|
|
|
(doc_settings or DocSettings:open(file)):purge(nil, data_to_purge)
|
2023-09-05 04:42:46 +00:00
|
|
|
if data_to_purge.custom_cover_file or data_to_purge.custom_metadata_file then
|
2023-10-03 06:24:29 +00:00
|
|
|
UIManager:broadcastEvent(Event:new("InvalidateMetadataCache", file))
|
2023-05-03 12:43:05 +00:00
|
|
|
end
|
2023-09-05 04:42:46 +00:00
|
|
|
if data_to_purge.doc_settings then
|
2024-01-17 07:58:21 +00:00
|
|
|
UIManager:broadcastEvent(Event:new("DocSettingsItemsChanged", file)) -- for CoverBrowser
|
2023-09-05 04:42:46 +00:00
|
|
|
require("readhistory"):fileSettingsPurged(file)
|
|
|
|
end
|
2023-02-07 02:46:09 +00:00
|
|
|
caller_callback()
|
|
|
|
end,
|
2023-03-31 09:59:11 +00:00
|
|
|
}
|
2023-09-05 04:42:46 +00:00
|
|
|
check_button_settings = CheckButton:new{
|
|
|
|
text = _("document settings, progress, bookmarks, highlights, notes"),
|
|
|
|
checked = has_sidecar_file,
|
|
|
|
enabled = has_sidecar_file,
|
|
|
|
parent = confirmbox,
|
|
|
|
}
|
|
|
|
confirmbox:addWidget(check_button_settings)
|
|
|
|
check_button_cover = CheckButton:new{
|
|
|
|
text = _("custom cover image"),
|
|
|
|
checked = has_custom_cover_file,
|
|
|
|
enabled = has_custom_cover_file,
|
|
|
|
parent = confirmbox,
|
|
|
|
}
|
|
|
|
confirmbox:addWidget(check_button_cover)
|
|
|
|
check_button_metadata = CheckButton:new{
|
|
|
|
text = _("custom book metadata"),
|
|
|
|
checked = has_custom_metadata_file,
|
|
|
|
enabled = has_custom_metadata_file,
|
|
|
|
parent = confirmbox,
|
|
|
|
}
|
|
|
|
confirmbox:addWidget(check_button_metadata)
|
2023-03-31 09:59:11 +00:00
|
|
|
UIManager:show(confirmbox)
|
2023-02-07 02:46:09 +00:00
|
|
|
end,
|
2023-02-06 04:42:54 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-06-08 05:27:52 +00:00
|
|
|
function filemanagerutil.genShowFolderButton(file, caller_callback, button_disabled)
|
|
|
|
return {
|
|
|
|
text = _("Show folder"),
|
|
|
|
enabled = not button_disabled,
|
|
|
|
callback = function()
|
|
|
|
caller_callback()
|
|
|
|
local ui = require("apps/filemanager/filemanager").instance
|
|
|
|
if ui then
|
|
|
|
local pathname = util.splitFilePathName(file)
|
|
|
|
ui.file_chooser:changeToPath(pathname, file)
|
|
|
|
else
|
|
|
|
ui = require("apps/reader/readerui").instance
|
|
|
|
ui:onClose()
|
|
|
|
ui:showFileManager(file)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2024-02-07 08:35:52 +00:00
|
|
|
function filemanagerutil.genBookInformationButton(file, book_props, caller_callback, button_disabled)
|
2023-03-26 18:11:19 +00:00
|
|
|
return {
|
|
|
|
text = _("Book information"),
|
|
|
|
enabled = not button_disabled,
|
|
|
|
callback = function()
|
2023-03-31 16:35:27 +00:00
|
|
|
caller_callback()
|
2024-01-26 21:01:45 +00:00
|
|
|
local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo")
|
2024-02-07 08:35:52 +00:00
|
|
|
FileManagerBookInfo:show(file, book_props and FileManagerBookInfo.extendProps(book_props))
|
2023-03-26 18:11:19 +00:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2024-02-07 08:35:52 +00:00
|
|
|
function filemanagerutil.genBookCoverButton(file, book_props, caller_callback, button_disabled)
|
|
|
|
local has_cover = book_props and book_props.has_cover
|
2023-03-26 18:11:19 +00:00
|
|
|
return {
|
2023-03-31 16:35:27 +00:00
|
|
|
text = _("Book cover"),
|
2024-02-07 08:35:52 +00:00
|
|
|
enabled = (not button_disabled and (not book_props or has_cover)) and true or false,
|
2023-03-26 18:11:19 +00:00
|
|
|
callback = function()
|
2023-03-31 16:35:27 +00:00
|
|
|
caller_callback()
|
2024-01-26 21:01:45 +00:00
|
|
|
local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo")
|
|
|
|
FileManagerBookInfo:onShowBookCover(file)
|
2023-03-26 18:11:19 +00:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2024-02-07 08:35:52 +00:00
|
|
|
function filemanagerutil.genBookDescriptionButton(file, book_props, caller_callback, button_disabled)
|
|
|
|
local description = book_props and book_props.description
|
2023-03-26 18:11:19 +00:00
|
|
|
return {
|
2023-03-31 16:35:27 +00:00
|
|
|
text = _("Book description"),
|
2024-01-26 21:01:45 +00:00
|
|
|
-- enabled for deleted books if description is kept in CoverBrowser bookinfo cache
|
2024-02-07 08:35:52 +00:00
|
|
|
enabled = (not (button_disabled or book_props) or description) and true or false,
|
2023-03-26 18:11:19 +00:00
|
|
|
callback = function()
|
2023-03-31 16:35:27 +00:00
|
|
|
caller_callback()
|
2024-01-26 21:01:45 +00:00
|
|
|
local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo")
|
|
|
|
FileManagerBookInfo:onShowBookDescription(description, file)
|
2023-03-26 18:11:19 +00:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-02-17 21:06:55 +00:00
|
|
|
-- Generate "Execute script" file dialog button
|
|
|
|
function filemanagerutil.genExecuteScriptButton(file, caller_callback)
|
2023-03-31 09:59:11 +00:00
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
2023-02-17 21:06:55 +00:00
|
|
|
return {
|
|
|
|
-- @translators This is the script's programming language (e.g., shell or python)
|
|
|
|
text = T(_("Execute %1 script"), util.getScriptType(file)),
|
|
|
|
callback = function()
|
|
|
|
caller_callback()
|
|
|
|
local script_is_running_msg = InfoMessage:new{
|
|
|
|
-- @translators %1 is the script's programming language (e.g., shell or python), %2 is the filename
|
|
|
|
text = T(_("Running %1 script %2…"), util.getScriptType(file), BD.filename(ffiutil.basename(file))),
|
|
|
|
}
|
|
|
|
UIManager:show(script_is_running_msg)
|
|
|
|
UIManager:scheduleIn(0.5, function()
|
|
|
|
local rv
|
|
|
|
if Device:isAndroid() then
|
|
|
|
Device:setIgnoreInput(true)
|
|
|
|
rv = os.execute("sh " .. ffiutil.realpath(file)) -- run by sh, because sdcard has no execute permissions
|
|
|
|
Device:setIgnoreInput(false)
|
|
|
|
else
|
|
|
|
rv = os.execute(ffiutil.realpath(file))
|
|
|
|
end
|
|
|
|
UIManager:close(script_is_running_msg)
|
|
|
|
if rv == 0 then
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("The script exited successfully."),
|
|
|
|
})
|
|
|
|
else
|
|
|
|
--- @note: Lua 5.1 returns the raw return value from the os's system call. Counteract this madness.
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = T(_("The script returned a non-zero status code: %1!"), bit.rshift(rv, 8)),
|
|
|
|
icon = "notice-warning",
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-12-16 08:36:57 +00:00
|
|
|
function filemanagerutil.showChooseDialog(title_header, caller_callback, current_path, default_path, file_filter)
|
|
|
|
local is_file = file_filter and true or false
|
|
|
|
local path = current_path or default_path
|
|
|
|
local dialog
|
|
|
|
local buttons = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = is_file and _("Choose file") or _("Choose folder"),
|
|
|
|
callback = function()
|
|
|
|
UIManager:close(dialog)
|
|
|
|
if path then
|
|
|
|
if is_file then
|
|
|
|
path = path:match("(.*/)")
|
|
|
|
end
|
|
|
|
if lfs.attributes(path, "mode") ~= "directory" then
|
|
|
|
path = G_reader_settings:readSetting("home_dir") or filemanagerutil.getDefaultDir()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local PathChooser = require("ui/widget/pathchooser")
|
|
|
|
local path_chooser = PathChooser:new{
|
|
|
|
select_directory = not is_file,
|
|
|
|
select_file = is_file,
|
|
|
|
show_files = is_file,
|
|
|
|
file_filter = file_filter,
|
|
|
|
path = path,
|
|
|
|
onConfirm = function(new_path)
|
|
|
|
caller_callback(new_path)
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
UIManager:show(path_chooser)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if default_path then
|
|
|
|
table.insert(buttons, {
|
|
|
|
{
|
|
|
|
text = _("Use default"),
|
|
|
|
enabled = path ~= default_path,
|
|
|
|
callback = function()
|
|
|
|
UIManager:close(dialog)
|
|
|
|
caller_callback(default_path)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
local title_value = path and (is_file and BD.filepath(path) or BD.dirpath(path))
|
|
|
|
or _("not set")
|
|
|
|
local ButtonDialog = require("ui/widget/buttondialog")
|
|
|
|
dialog = ButtonDialog:new{
|
|
|
|
title = title_header .. "\n\n" .. title_value .. "\n",
|
|
|
|
buttons = buttons,
|
|
|
|
}
|
|
|
|
UIManager:show(dialog)
|
|
|
|
end
|
|
|
|
|
2017-07-01 10:11:44 +00:00
|
|
|
return filemanagerutil
|