Skip to content

Commit

Permalink
Replace tweak_buttons_func with an event instead (#11777)
Browse files Browse the repository at this point in the history
  • Loading branch information
nairyosangha committed May 16, 2024
1 parent db63db1 commit 126c01e
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 136 deletions.
11 changes: 5 additions & 6 deletions frontend/apps/reader/modules/readerdictionary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ function ReaderDictionary:addToMainMenu(menu_items)
end
end

function ReaderDictionary:onLookupWord(word, is_sane, boxes, highlight, link, tweak_buttons_func)
function ReaderDictionary:onLookupWord(word, is_sane, boxes, highlight, link)
logger.dbg("dict lookup word:", word, boxes)
-- escape quotes and other funny characters in word
word = self:cleanSelection(word, is_sane)
Expand All @@ -440,7 +440,7 @@ function ReaderDictionary:onLookupWord(word, is_sane, boxes, highlight, link, tw

-- Wrapped through Trapper, as we may be using Trapper:dismissablePopen() in it
Trapper:wrap(function()
self:stardictLookup(word, self.enabled_dict_names, not disable_fuzzy_search, boxes, link, tweak_buttons_func)
self:stardictLookup(word, self.enabled_dict_names, not disable_fuzzy_search, boxes, link)
end)
return true
end
Expand Down Expand Up @@ -932,7 +932,7 @@ function ReaderDictionary:startSdcv(word, dict_names, fuzzy_search)
return results
end

function ReaderDictionary:stardictLookup(word, dict_names, fuzzy_search, boxes, link, tweak_buttons_func)
function ReaderDictionary:stardictLookup(word, dict_names, fuzzy_search, boxes, link)
if word == "" then
return
end
Expand Down Expand Up @@ -992,16 +992,15 @@ function ReaderDictionary:stardictLookup(word, dict_names, fuzzy_search, boxes,
return
end

self:showDict(word, tidyMarkup(results), boxes, link, tweak_buttons_func)
self:showDict(word, tidyMarkup(results), boxes, link)
end

function ReaderDictionary:showDict(word, results, boxes, link, tweak_buttons_func)
function ReaderDictionary:showDict(word, results, boxes, link)
if results and results[1] then
logger.dbg("showing quick lookup window", #DictQuickLookup.window_list+1, ":", word, results)
self.dict_window = DictQuickLookup:new{
ui = self.ui,
highlight = self.highlight,
tweak_buttons_func = tweak_buttons_func,
dialog = self.dialog,
-- original lookup word
word = word,
Expand Down
4 changes: 2 additions & 2 deletions frontend/ui/widget/dictquicklookup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ function DictQuickLookup:init()
})
end
end
if self.tweak_buttons_func then
self:tweak_buttons_func(buttons)
if self.ui then
self.ui:handleEvent(Event:new("DictButtonsReady", self, buttons))
end
-- Bottom buttons get a bit less padding so their line separators
-- reach out from the content to the borders a bit more
Expand Down
Loading

0 comments on commit 126c01e

Please sign in to comment.