Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > KOReader

Notices

Reply
 
Thread Tools Search this Thread
Old 01-31-2025, 09:28 AM   #1
sdothum
Enthusiast
sdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it is
 
Posts: 36
Karma: 2062
Join Date: Oct 2021
Device: Kobo Libra 2
Is there a way to patch a plugin?

Specifically the vocabbuilder.koplugin.

i want to close the dictionary lookup popup when a word is added to the Vocabulary Builder database.

i am assuming the close needs be added to VocabBuilder:onDictButtonsReady function.

Saves just one button press action on the dictionary lookup.. but curious if this can be achieved.

Last edited by sdothum; 02-02-2025 at 10:58 AM.
sdothum is offline   Reply With Quote
Old 01-31-2025, 11:13 AM   #2
hius07
Wizard
hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.
 
Posts: 1,179
Karma: 3592925
Join Date: Sep 2014
Location: Ukraine
Device: Kindle
Example of patching a plugin
https://github.com/koreader/koreader...ent-2393154113
hius07 is offline   Reply With Quote
Advert
Old 02-01-2025, 12:17 PM   #3
sdothum
Enthusiast
sdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it is
 
Posts: 36
Karma: 2062
Join Date: Oct 2021
Device: Kobo Libra 2
Thank you for the plugin patch example.

i've managed to override the VocabBuilder: onDictButtonsReady function but am stumped at what i was expecting to be the easiest part -- closing the DictQuickLookup window. More needs be done than simply calling DictQuickLookup: onClose() after the button tap.

Any ideas? before i create another thread post?

Last edited by sdothum; 02-11-2025 at 05:18 AM.
sdothum is offline   Reply With Quote
Old 02-02-2025, 12:23 PM   #4
sdothum
Enthusiast
sdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it is
 
Posts: 36
Karma: 2062
Join Date: Oct 2021
Device: Kobo Libra 2
Found the answer.. at least what appears to work. Instead of using DictQuickLookup:onClose..

UIManager:sendEvent(Event:new("Close"))
sdothum is offline   Reply With Quote
Old 02-02-2025, 01:19 PM   #5
Frenzie
Wizard
Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.
 
Posts: 1,751
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
It's probably more proper to do UIManager:close(the_widget_in_question)
Frenzie is offline   Reply With Quote
Advert
Old 02-03-2025, 06:42 AM   #6
sdothum
Enthusiast
sdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it is
 
Posts: 36
Karma: 2062
Join Date: Oct 2021
Device: Kobo Libra 2
Quote:
Originally Posted by Frenzie View Post
It's probably more proper to do UIManager:close(the_widget_in_question)
i thought about that but could not figure out how to specify the widget id of the QuickDictLookup widget.
sdothum is offline   Reply With Quote
Old 02-03-2025, 06:52 AM   #7
hius07
Wizard
hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.
 
Posts: 1,179
Karma: 3592925
Join Date: Sep 2014
Location: Ukraine
Device: Kindle
It is dict_popup.
hius07 is offline   Reply With Quote
Old 02-11-2025, 05:13 AM   #8
sdothum
Enthusiast
sdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it is
 
Posts: 36
Karma: 2062
Join Date: Oct 2021
Device: Kobo Libra 2
The UIManager:close(dict_popup) does close the widget..

BUT this action also appears to bypass the widget's DictQuickLookup: onClose() function -- at least, the scheduled highlight clear is not triggered after the widget is closed (i do patch that to lengthen its duration before clearing).

The UIManager:sendEvent() close appears to be a more graceful action in this regard, clearing the highlight afterwards.

Last edited by sdothum; 02-11-2025 at 05:20 AM.
sdothum is offline   Reply With Quote
Old 02-11-2025, 05:29 AM   #9
hius07
Wizard
hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.
 
Posts: 1,179
Karma: 3592925
Join Date: Sep 2014
Location: Ukraine
Device: Kindle
Code:
dict_popup:onClose()
hius07 is offline   Reply With Quote
Old 02-11-2025, 10:56 AM   #10
sdothum
Enthusiast
sdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it is
 
Posts: 36
Karma: 2062
Join Date: Oct 2021
Device: Kobo Libra 2
Thank you! Adding that direct call works.

A question:
- the UIManager:close() plus dict_popup: onClose() are two statements versus the single UIManager:sendEvent() statement -- with the proposed changes more widget explicit.

Is there a reason to discourage the sendEvent() usage (which has not presented any issues for this usecase)? i'm guessing the above is more immune to future coding changes or are there other possible semantic reasons?

Last edited by sdothum; 02-11-2025 at 11:07 AM.
sdothum is offline   Reply With Quote
Old 02-11-2025, 11:31 AM   #11
hius07
Wizard
hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.
 
Posts: 1,179
Karma: 3592925
Join Date: Sep 2014
Location: Ukraine
Device: Kindle
Direct calls are cheaper than events.
Events can be handled by many listeners, for example, renaming a book title and resetting some caches here and there.
hius07 is offline   Reply With Quote
Old 02-11-2025, 11:33 AM   #12
hius07
Wizard
hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.
 
Posts: 1,179
Karma: 3592925
Join Date: Sep 2014
Location: Ukraine
Device: Kindle
https://koreader.rocks/doc/topics/Events.md.html#
hius07 is offline   Reply With Quote
Old 06-20-2025, 01:06 PM   #13
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,969
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
A similar question if I may:

Is there a way to patch something in a plugin that's not in the main plugin object?

I'm trying to patch in a replacement for CalibreSearch.switchResults() in calibre.koplugin/search.lua.

I'm trying to replace the sort with one that does lower() before compare so lower case Calibre titles, tags, etc aren't after all the upper case ones.

(I suspect patching sort.natsort_cmp would be easier, but it's also used by other things.)
JimmXinu is offline   Reply With Quote
Old 06-20-2025, 01:29 PM   #14
hius07
Wizard
hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.hius07 ought to be getting tired of karma fortunes by now.
 
Posts: 1,179
Karma: 3592925
Join Date: Sep 2014
Location: Ukraine
Device: Kindle
CalibreSearch can be found as an upvalue in some of the main module methods.
Look for example at
https://github.com/koreader/koreader...ent-2871327027
hius07 is offline   Reply With Quote
Old 06-20-2025, 01:40 PM   #15
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 6,969
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
Quote:
Originally Posted by hius07 View Post
CalibreSearch can be found as an upvalue in some of the main module methods.
Look for example at
https://github.com/koreader/koreader...ent-2871327027
I got as far as userpatch.getUpValue() before, but apparently I misunderstand it.

I have:
Code:
local userpatch = require("userpatch")

userpatch.registerPatchPluginFunc("calibre", function(Calibre)

    local CalibreSearch, up_idx = userpatch.getUpValue(Calibre.onCalibreSearch, "CalibreSearch")

    print("\ncalibre patch CalibreSearch:")
    print(CalibreSearch)
    
end)
And calibre.koplugin/main.lua contains a reference to CalibreSearch:
Code:
function Calibre:onCalibreSearch()
    CalibreSearch:ShowSearch()
    return true
end
But I just get 'nil' printed in the crash.log.

ADDENDUM

Of all the Calibre methods that reference CalibreSearch, getSearchMenuTable is the only one that gives me that reference from getUpValue:
Code:
userpatch.registerPatchPluginFunc("calibre", function(Calibre)

    local CalibreSearch, up_idx = userpatch. getUpValue(Calibre.getSearchMenuTable, "CalibreSearch")

    print("\ncalibre patch CalibreSearch:")
    print(CalibreSearch)
    
end)
No idea why that one works and the others don't.

Last edited by JimmXinu; 06-20-2025 at 02:29 PM. Reason: Addendum
JimmXinu is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] LOI-Generator - edit] plugin to generate a List of Illustrations KevinH Plugins 1 01-19-2023 04:31 PM
Updating plugin fails because plugin file is in use by Calibre? ownedbycats Calibre 1 12-03-2022 08:34 PM
[Metadata Source Plugin] Empty Plugin? (Fake Identifier) mneimeyer Plugins 3 11-11-2019 08:07 PM
[Plugin] QuickPrefsEdit - Edit plugin prefs json files. slowsmile Plugins 3 07-25-2018 08:14 PM
Goodread Perception Expander plugin not shown on plugin list (kobo h2o) www KOReader 4 09-28-2017 10:34 AM


All times are GMT -4. The time now is 10:59 PM.


MobileRead.com is a privately owned, operated and funded community.