mirror of
https://github.com/koreader/koreader
synced 2024-11-13 19:11:25 +00:00
fd51671478
*Especially* in the hello world plugin.
54 lines
1.4 KiB
Lua
54 lines
1.4 KiB
Lua
--[[--
|
|
This is a debug plugin to test Plugin functionality.
|
|
|
|
@module koplugin.HelloWorld
|
|
--]]--
|
|
|
|
-- This is a debug plugin, remove the following if block to enable it
|
|
if true then
|
|
return { disabled = true, }
|
|
end
|
|
|
|
local Dispatcher = require("dispatcher") -- luacheck:ignore
|
|
local InfoMessage = require("ui/widget/infomessage")
|
|
local UIManager = require("ui/uimanager")
|
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
|
local _ = require("gettext")
|
|
|
|
local Hello = WidgetContainer:new{
|
|
name = "hello",
|
|
is_doc_only = false,
|
|
}
|
|
|
|
function Hello:onDispatcherRegisterActions()
|
|
Dispatcher:registerAction("helloworld_action", {category="none", event="HelloWorld", title=_("Hello World"), filemanager=true,})
|
|
end
|
|
|
|
function Hello:init()
|
|
self:onDispatcherRegisterActions()
|
|
self.ui.menu:registerToMainMenu(self)
|
|
end
|
|
|
|
function Hello:addToMainMenu(menu_items)
|
|
menu_items.hello_world = {
|
|
text = _("Hello World"),
|
|
-- in which menu this should be appended
|
|
sorting_hint = "more_tools",
|
|
-- a callback when tapping
|
|
callback = function()
|
|
UIManager:show(InfoMessage:new{
|
|
text = _("Hello, plugin world"),
|
|
})
|
|
end,
|
|
}
|
|
end
|
|
|
|
function Hello:onHelloWorld()
|
|
local popup = InfoMessage:new{
|
|
text = _("Hello World"),
|
|
}
|
|
UIManager:show(popup)
|
|
end
|
|
|
|
return Hello
|