2013-10-18 20:38:07 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
2014-11-28 13:10:37 +00:00
|
|
|
local T = require("ffi/util").template
|
2013-10-18 20:38:07 +00:00
|
|
|
local _ = require("gettext")
|
2013-04-16 17:11:28 +00:00
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
local ReaderHyphenation = InputContainer:new{
|
2014-03-13 13:52:43 +00:00
|
|
|
hyph_menu_title = _("Hyphenation"),
|
|
|
|
hyph_table = nil,
|
2013-04-16 17:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ReaderHyphenation:init()
|
2014-03-13 13:52:43 +00:00
|
|
|
self.hyph_table = {}
|
|
|
|
self.hyph_alg = cre.getSelectedHyphDict()
|
|
|
|
for k,v in ipairs(cre.getHyphDictList()) do
|
|
|
|
table.insert(self.hyph_table, {
|
|
|
|
text = v,
|
|
|
|
callback = function()
|
|
|
|
self.hyph_alg = v
|
|
|
|
UIManager:show(InfoMessage:new{
|
2014-11-28 13:10:37 +00:00
|
|
|
text = T( _("Changed hyphenation to %1."), v),
|
2014-03-13 13:52:43 +00:00
|
|
|
})
|
2014-11-15 11:22:47 +00:00
|
|
|
self.ui.document:setHyphDictionary(v)
|
2014-07-16 12:55:26 +00:00
|
|
|
self.ui.toc:onUpdateToc()
|
2014-11-15 15:23:27 +00:00
|
|
|
end,
|
|
|
|
checked_func = function()
|
|
|
|
return v == self.hyph_alg
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
self.ui.menu:registerToMainMenu(self)
|
2013-04-16 17:11:28 +00:00
|
|
|
end
|
|
|
|
|
2014-01-22 14:02:42 +00:00
|
|
|
function ReaderHyphenation:onReadSettings(config)
|
2014-03-13 13:52:43 +00:00
|
|
|
local hyph_alg = config:readSetting("hyph_alg")
|
|
|
|
if hyph_alg then
|
2014-11-15 11:22:47 +00:00
|
|
|
self.ui.document:setHyphDictionary(hyph_alg)
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
|
|
|
self.hyph_alg = cre.getSelectedHyphDict()
|
2014-01-22 14:02:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderHyphenation:onSaveSettings()
|
|
|
|
self.ui.doc_settings:saveSetting("hyph_alg", self.hyph_alg)
|
|
|
|
end
|
|
|
|
|
2013-04-16 17:11:28 +00:00
|
|
|
function ReaderHyphenation:addToMainMenu(tab_item_table)
|
2014-03-13 13:52:43 +00:00
|
|
|
-- insert table to main reader menu
|
|
|
|
table.insert(tab_item_table.typeset, {
|
|
|
|
text = self.hyph_menu_title,
|
|
|
|
sub_item_table = self.hyph_table,
|
|
|
|
})
|
2013-04-16 17:11:28 +00:00
|
|
|
end
|
2013-10-18 20:38:07 +00:00
|
|
|
|
|
|
|
return ReaderHyphenation
|