|
|
|
@ -5,10 +5,10 @@ This is a registry for document providers
|
|
|
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
|
|
|
|
local OpenWithDialog = require("ui/widget/openwithdialog")
|
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
|
local gettext = require("gettext")
|
|
|
|
|
local logger = require("logger")
|
|
|
|
|
local lfs = require("libs/libkoreader-lfs")
|
|
|
|
|
local util = require("util")
|
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
local T = require("ffi/util").template
|
|
|
|
|
|
|
|
|
|
local DocumentRegistry = {
|
|
|
|
@ -148,14 +148,14 @@ function DocumentRegistry:setProvider(file, provider, all)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DocumentRegistry:showSetProviderButtons(file, filemanager_instance, ui, reader_ui)
|
|
|
|
|
local _, filename_pure = util.splitFilePathName(file)
|
|
|
|
|
local __, filename_pure = util.splitFilePathName(file)
|
|
|
|
|
local filename_suffix = util.getFileNameSuffix(file)
|
|
|
|
|
|
|
|
|
|
local buttons = {}
|
|
|
|
|
local radio_buttons = {}
|
|
|
|
|
local providers = self:getProviders(file)
|
|
|
|
|
|
|
|
|
|
for _, provider in ipairs(providers) do
|
|
|
|
|
for ___, provider in ipairs(providers) do
|
|
|
|
|
-- we have no need for extension, mimetype, weights, etc. here
|
|
|
|
|
provider = provider.provider
|
|
|
|
|
table.insert(radio_buttons, {
|
|
|
|
@ -169,13 +169,13 @@ function DocumentRegistry:showSetProviderButtons(file, filemanager_instance, ui
|
|
|
|
|
|
|
|
|
|
table.insert(buttons, {
|
|
|
|
|
{
|
|
|
|
|
text = gettext("Cancel"),
|
|
|
|
|
text = _("Cancel"),
|
|
|
|
|
callback = function()
|
|
|
|
|
UIManager:close(self.set_provider_dialog)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = gettext("Open"),
|
|
|
|
|
text = _("Open"),
|
|
|
|
|
is_enter_default = true,
|
|
|
|
|
callback = function()
|
|
|
|
|
local provider = self.set_provider_dialog.radio_button_table.checked_button.provider
|
|
|
|
@ -183,9 +183,9 @@ function DocumentRegistry:showSetProviderButtons(file, filemanager_instance, ui
|
|
|
|
|
-- always for this file
|
|
|
|
|
if self.set_provider_dialog._check_file_button.checked then
|
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
|
text = T(gettext("Always open '%2' with %1?"),
|
|
|
|
|
text = T(_("Always open '%2' with %1?"),
|
|
|
|
|
provider.provider_name, filename_pure),
|
|
|
|
|
ok_text = gettext("Always"),
|
|
|
|
|
ok_text = _("Always"),
|
|
|
|
|
ok_callback = function()
|
|
|
|
|
self:setProvider(file, provider, false)
|
|
|
|
|
|
|
|
|
@ -197,9 +197,9 @@ function DocumentRegistry:showSetProviderButtons(file, filemanager_instance, ui
|
|
|
|
|
-- always for all files of this file type
|
|
|
|
|
elseif self.set_provider_dialog._check_global_button.checked then
|
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
|
text = T(gettext("Always open %2 files with %1?"),
|
|
|
|
|
text = T(_("Always open %2 files with %1?"),
|
|
|
|
|
provider.provider_name, filename_suffix),
|
|
|
|
|
ok_text = gettext("Always"),
|
|
|
|
|
ok_text = _("Always"),
|
|
|
|
|
ok_callback = function()
|
|
|
|
|
self:setProvider(file, provider, true)
|
|
|
|
|
|
|
|
|
@ -219,7 +219,7 @@ function DocumentRegistry:showSetProviderButtons(file, filemanager_instance, ui
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
self.set_provider_dialog = OpenWithDialog:new{
|
|
|
|
|
title = T(gettext("Open %1 with:"), filename_pure),
|
|
|
|
|
title = T(_("Open %1 with:"), filename_pure),
|
|
|
|
|
radio_buttons = radio_buttons,
|
|
|
|
|
buttons = buttons,
|
|
|
|
|
}
|
|
|
|
|