Dispatcher:removeAction()

Gestures: use sub_item_table_func to allow the menu to refresh on change
reviewable/pr8212/r1
yparitcher 3 years ago
parent f5dc7b4539
commit 1f8574cf7e

@ -36,6 +36,7 @@ local Notification = require("ui/widget/notification")
local ReaderZooming = require("apps/reader/modules/readerzooming") local ReaderZooming = require("apps/reader/modules/readerzooming")
local Screen = require("device").screen local Screen = require("device").screen
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local util = require("util")
local _ = require("gettext") local _ = require("gettext")
local C_ = _.pgettext local C_ = _.pgettext
local T = require("ffi/util").template local T = require("ffi/util").template
@ -440,6 +441,20 @@ function Dispatcher:registerAction(name, value)
return true return true
end end
--[[--
Removes settings at runtime.
@param name the key to use in the table
--]]--
function Dispatcher:removeAction(name)
local k = util.arrayContains(dispatcher_menu_order, name)
if k then
table.remove(dispatcher_menu_order, k)
settingsList[name] = nil
end
return true
end
-- Returns a display name for the item. -- Returns a display name for the item.
function Dispatcher:getNameFromItem(item, location, settings) function Dispatcher:getNameFromItem(item, location, settings)
if settingsList[item] == nil then if settingsList[item] == nil then
@ -631,7 +646,7 @@ arguments are:
3) the object (table) in which the settings table is found 3) the object (table) in which the settings table is found
4) the name of the settings table 4) the name of the settings table
example usage: example usage:
Dispatcher.addSubMenu(self, sub_items, self.data, "profile1") Dispatcher:addSubMenu(self, sub_items, self.data, "profile1")
--]]-- --]]--
function Dispatcher:addSubMenu(caller, menu, location, settings) function Dispatcher:addSubMenu(caller, menu, location, settings)
Dispatcher:init() Dispatcher:init()

@ -240,7 +240,7 @@ function Gestures:genSubItem(ges, separator, hold_callback)
return { return {
text_func = function() return self:gestureTitleFunc(ges) end, text_func = function() return self:gestureTitleFunc(ges) end,
enabled_func = enabled_func, enabled_func = enabled_func,
sub_item_table = self:genMenu(ges), sub_item_table_func = function() return self:genMenu(ges) end,
separator = separator, separator = separator,
hold_callback = hold_callback, hold_callback = hold_callback,
} }

Loading…
Cancel
Save